IT Technology

Difference Between Macros and Functions

Macros vs Functions

Summary: Difference Between Macros and Functions is that A macro is a series of statements that instructs a program how to complete a task. While Functions are sets of codes that are designed to accomplish a specific task.

Difference Between Macros and Functions

Macros

A macro is a series of statements that instructs a program how to complete a task. Macros allow users to automate routine, repetitive, or difficult tasks in application software such as word processing, spreadsheet, or database programs. That is, users can create simple programs within the software by writing macros. You usually create a macro in one of two ways: (1) record the macro or (2) write the macro.

If you want to automate a routine or repetitive task such as formatting or editing, you would record a macro. A macro recorder is similar to a movie camera because both record all actions until turned off. To record a macro, start the macro recorder in the software. Then, perform the steps to be part of the macro, such as clicks of the mouse or keystrokes.

Once the macro is recorded, you can run it anytime you want to perform that same sequence of actions. For example, if you always print three copies of certain documents, you could record the actions required to print three copies. To print three copies, you would run the macro called PrintThreeCopies. When you become familiar with programming techniques, you can write your own macros instead of recording them.

Functions

Functions are sets of codes that are designed to accomplish a specific task. Functions often “take in” data, process it, and “return” with a result. When function is once written, you can use it again and again. Or you can also call a function within another function. Many codes are combined into a single line of code to create functions. And many languages provide you some built-in functions.

Difference Between Functions and Macros

Function is compiled.

And Type Checking is enabled.

Code length does not increases.

Function has no side-effect.

Execution is slower.

Function check compile errors.

Macros are preprocessed.

Type Checking is not enabled.

Code Length increases.

Macro can lead to some side-effects.

Execution is faster.

It does not check compile errors.

Also Read:

Difference Between Low Level Language and High Level Language

Difference Between Procedural Language and Object Oriented Language

Difference Between Object Oriented Programming and Structured Programming

Difference Between Low Level Language and Assembly Language

Difference Between Compiler and Interpreter

Difference Between Control Structures and Control Statements

Difference Between www and Internet