12

Aren't both just a set of instructions that get executed by some interpreter? (contrary to a full-fledged program, which runs (gets executed) at some computer system?

3 Answers 3

11

Basically the difference is just one of degree. A script tends to be a lot more formally defined, with a well-defined scripting language behind it, while a macro is usually something more simple and ad-hoc. Macros are frequently "recorded" by telling a program "watch everything that I do" and then performing the action, whereas scripts are generally entered as text in the scripting language.

2
  • 4
    Unless the OP is asking about macros such as C preprocessor macros or LISP macros. Dec 28, 2013 at 20:09
  • 1
    @Frustrated: Yeah, but from the context it doesn't look like that's what he's asking. Dec 28, 2013 at 21:00
7

Macros come in different flavors.

The original kind was macros in assembly language, where a group of instructions could be named and each time the name was used the instructions were substituted for the name.

C and C++ also have macros that work this way.

But as with most things in IT, why have one term or one meaning when we can make things more confusing? So some environments (starting with MS Word, I believe) introduced "macros" that were a recorded set of actions.

So there are two kinds of macro. The first gets substituted for the name and then compiled. The second is usually interpreted at runtime by the environment.

4

Macro

The common usage of macros is in software applications, and they originated as a tool to map user input to a different set of user output. The key aspect here is the changing of user input/output at the application level. Since user input tends to be related to keyboards, mouse and other devices. The output changed by the macro was often previously recorded by one of those devices. There are also macros that can be written by the user but the goal is often to yield a desired output.

Script

If macros are to application output, then scripts are to application automation. Scripts are often an application specific programming language that automate tasks for the user. The key here is the role of the user as a programmer, and the fact that users are not programmers. If you categorize scripting languages as those that don't compile, are parsed and easy to use then there are many languages that fit those requirements. I argue that scripting languages are the ones easiest for application users to automate the software with the least amount of programming knowledge. That is how they should be categorized as scripts. Anything that requires specialized knowledge outside the domain of the application is just programming tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.