Scripting v/s Programming languages : Which one to choose?

Scripting vs Programming languages

Introduction

Programming is defined as a process of creating a set of instructions that tells a computer how to perform a task. The main purpose of programming language is to find a sequence of instructions that will be executed by the processor, thereby solving the given problem. In today’s technology powered world, programmers are given many choices of languages that they can choose from. One example is either to choose a scripting language or compiled language.

In modern programming world, we have languages that falls into both categories. The main difference between an interpreted language and a compiled language is that compilation requires analysis and the generation of machine code only once, whereas in an interpreted language, interpreter may need to analyze and interpret the same program statements each time it meets them.

To start with let us take some examples:

  • Compiled Languages – C, C++, Java, ADA etc..
  • Interpreted Languages – Bash script, Perl, JavaScript, PHP etc…

Interested in learning scripting vs programming languages and which one to choose, here is the answer to it. Let us understand compiled and scripting languages in detail as a part of this blog post.

Programming / Compiled Language

When a program is written in a programming language, to automate a task or to perform a task, and if it is uses compiler for implementation, then the programming language is said to be compiled language.

A compiler is a software that translates the source code (written in a programming language) to machine code (the target language). They generally translate source code from a high level language to low level language, to create an executable file. In this process of translation the compiler will have different intermediate steps (Tokenization, Intermediate code generation, Linking, Generating loadable file etc…)

There are different types of compiler available. They are,

1. Cross-compiler :

If an executable code generated by the compiler is capable of running on other OS which is different from where    the compiler is running, is called cross-compiler.

2. Bootstrap compiler :

Bootstrapping or self-booting compiler is defined as a process of writing compiler in the programming language,  in which the program is to be compiled.

3. Decompiler :

Decompiler takes an executable file as input and produces source code/ file as output, which can be recompiled.

4. Source-to-source compiler :

When a compiler takes input as high level source code and outputs source code of another high level language,then it is said to be source-to-source compiler.

Let us understand the advantages and disadvantages of compiled languages.

Advantages

Speed :

When a code is written using programming language and compiled, the source code is converted into native specific code. Here, there is no requirement for further translation like script. This code can be run or executed more number of times with high speed, thus leading to high efficiency.

Type checking :

When a set of instructions is written and compiled, compiler is capable of performing type check, where syntax and semantics checks are done. This type checks helps programmer to rectify the errors before execution of program, which may lead to any runtime errors.

Hardware optimization :

Source code can be optimized for a specific hardware when written using compiled languages. If the user provides hardware details of a computer, compiler could create machine language code that makes the most efficient use of the specified hardware provided by the user. In our other blog on Embedded Systems and C programming we discussed the topic of optimization in detail. Such optimization programmer may not be able to achieve in case of scripting languages.

Disadvantages

Difficulty in Bug Fixing :

Bug fixing is tedious when compared to interpreted languages. For example, consider an application is compiled and executed. If any bugs are found, application should be stopped and bug fixing has to be done. Once it is fixed, code has to be re-compiled and executed again. If more bugs or errors are found, this process has to be repeated again and again.

Higher Compile time :

If the application is larger, more compile time is required to compile it. In an application development stage, in order to test functionality and troubleshoot the code written, it has to be compiled first. Programmers cannot perform any task or proceed further in coding which may affect the effectiveness, until compilation is over. Hence more compile time is required.

Hardware Specific :

More time is spent on maintaining a source code,  when it has to be run on several machines. Compiler translates source code into a specific machine language and due to that programs has to compiled for specific OS and architectures. Hence to run code on different hardware, more maintenance is required.

Scripting / Script Language

When a source code is not compiled and converted into machine code, instead executed directly by interpreting every single instruction one by one, it is called interpreted or scripting language. Scripts are generally interpreted.

An interpreter may parse the source code and execute or generate any intermediate representation and execute, or execute an already compiled machine code.

Advantages

Ease of updating :

Scripting languages run on the subset of programming language. Hence they have less access to the native abilities of a computer. Though scripting languages are slower and have less access, they are powerful programming tools. When computers were not so powerful and JavaScript was not famous, Java applets dominated more. However today, thanks to higher processing capability scripting languages have become faster and easy to develop.

Lesser LOC:

When any scripting language is used, less lines of code (LOC) or instructions can be written for an application when compared to code written in compiled languages. Scripting languages uses less memory when interpreted. It is because, at a time, only few lines of source code would occupy memory, whereas in a compiled language an executable file would occupy more memory space.

Easy debugging :

Interpreter interprets every single instruction and checks for error, be it a simple typing error, missing semicolon, brackets etc., and notifies and stops interpreting the next line of code until error is fixed. Hence debugging is becomes easy, rather than finding error from a fully compiled code.

Task Automation :

Automation of repetitive tasks are possible when we use scripting languages. We can write small scripts to automate a task and refine it later or use automation tools available. This is not available in compiled languages. This makes programming easy with scripts.

Disadvantages

Performance :

Performance of interpreted language is less when compared with compiled languages. It is because, every single instruction should pass an interpretation at run time. This makes the execution by interpreter less efficient. Also, interpreted languages are slower, because it requires more hash table lookups to access a variable/method call every time.

Need for interpreter :

Source codes written using scripted language, requires an interpreter to execute on a local machine. Thus, making sure of availability of an interpreter on a local machine every time by user is a disadvantage.

Executable code can be downloaded :

It is one of the major disadvantages of using script languages. An user can download the executable code from a remote server and it can be installed and run in a web browser’s machine using local browser interpreter available. This makes the machine prone to attacks without the knowledge of the use.

Conclusion

While developing a real project, choosing a suitable programming language plays a very important role. Depending on need and priority (ex: ease of use v/s security) choice need to be made by programmers whether to go with compiled or choose the interpreted one. Both compiled and interpreted languages have their own set of limitations and advantages.

Happy Learning!!!

About

Emertxe is India’s pioneer institute in Embedded Systems, Linux and IoT training, Since 2003. Our Embedded training vertical has generated huge pool of Industry ready embedded engineers. For freshers we offer placement oriented embedded course with attractive scholarships. For working professionals weekend options are available with embedded systems trainings and advanced workshops. Practical approach, applied learning, result oriented approach makes our trainings unique. Embedded systems course – For Freshers Embedded IoT Courses – For Freshers and Professionals Weekend embedded courses and workshops – For professionals Emertxe’s flagship training centre in Bangalore, offers one of the most exhaustive suites of Embedded systems and IoT technology courses available in India. Along with embedded systems, Emertxe offers training in specialized courses in Qt QML application programming, Qt for Embedded, Embedded android system development, Yocto for custom embedded Linux development, Advanced Linux device drivers courses, Software engineering courses as individual verticals. We offer short term and long term trainings in each technology areas, catering to various segments. We are here – To take you beyond!

View all posts by

One thought on “Scripting v/s Programming languages : Which one to choose?

Leave a Reply

Your email address will not be published. Required fields are marked *