Linguagens de script versus linguagens de programação: as principais diferenças

Scripting Languages ​​vs. Programming Languages: The Key Differences

What is the difference between Python and C++? Why is one so much more difficult than the other? Why do different languages ​​have different scopes and reaches?

Imagem em destaque

Take a random software developer and ask which language they are proficient in and they will probably say C#, Python or JavaScript. Keep searching and someone will mention PHP, Java, C++ or SQL (for some it's a language, for others it's not). Maybe you'll meet some strange developer who talks about Clojure or Ruby. Just by probabilities, it would be tempting to think that there are around a few dozen programming languages, perhaps even a hundred.

For some, it comes as a surprise to discover that there are, in fact, closer to 700 programming languages ​​in the wild. Now, to be fair, this includes stale, obsolete, obscure language, and jokes constructed out of boredom or to prove a point. But even if we filtered them out, we would still have many ways to write code.

In most cases, a language is created to solve a problem. For example, PHP started out as a set of tools created by a single developer to handle his personal web pages. Over time, the tools grew and eventually merged into the web development programming language that PHP is today. Python was designed as a successor to ABC that would focus on simplicity and readability. Java was designed from the ground up with object-oriented programming in mind. Search hard enough and you'll find that every language tells an interesting story.

You may have heard people classifying languages ​​into different groups, such as high-level or low-level, dynamic or static, and programming or scripting. This last case is the one I want to focus on today. Understanding the difference between scripts will give us important insights into the value of each of our projects.

What is a computer language?

Basically, a computer language is a set of rules that facilitate communication between humans and computers. It is a bridge that allows us to give instructions to the computer. There are different languages ​​for different purposes. For example, command languages ​​are used to control the computer's own tasks, such as starting programs, and query languages ​​are used to query databases and information systems.

Computers don't understand language like we do. If I yell at a CPU “What’s 2+2?” he can't understand me (and people will probably look at me funny). Below the user interface, information is being processed in terms of 0s and 1s, binary data. This is what we call machine code. In theory, a human being with enough effort and willpower could understand what those 0 and 1 mean, but for most of us, this is simply impossible.

Thus, just like a visitor from a different country who hires the services of a translator, we use computer languages ​​as a way of translating our intention into machine code. These languages ​​can be subdivided into levels depending on how close they are to their machine counterpart. For summary purposes, we will divide them into 2 levels:

  • Human language
  • High-level languages
  • Low-level languages
  • Machine code

The main example of a low-level language is Assembly, or asm, where each instruction is equivalent to 1 machine instruction. In other words, the engineer has absolute control over how information is handled. Although low-level languages ​​are unbeatable in terms of performance, writing code is often difficult and time-consuming.

High-level languages, on the other hand, tend to be closer to human language. Case in point, even non-programmers can read and get a rough idea of ​​what a piece of python code is trying to accomplish. Unfortunately, these languages ​​tend to be slow compared to their low-level brethren.

Programming versus scripting

Criterion Scripting languages Programming languages
Definition A type of programming language that automates tasks and controls other software A set of instructions used to create software applications and control computer behavior
Compilation Interpreted at runtime, no compilation required Usually compiled into machine code before runtime
Speed Slower due to runtime interpretation Faster because compiled code runs directly on the CPU
Easy to use Generally easier to learn and use, generally high level with simple syntax It can be low or high level, with varying degrees of complexity
Use cases Often used for web development, automation, word processing, etc. Used for a wide range of applications, from operating systems to games
Examples JavaScript, Python, Ruby C, C++, Java, Rust
Interactivity Often used to create interactive aspects on web pages May or may not have interactive features depending on the language and development environment
Files Organization Often used independently with one or a few files Large projects are typically organized into many files and directories
Access to system resources Typically limited access to system resources for security reasons Full access to system resources
Error checking Errors are typically checked at runtime Errors are typically checked during compilation
Learning curve Easier learning curve due to high-level abstractions and simplicity Steeper learning curve, especially for low-level languages
Integration Often used to join components and applications together or to automate interactions between systems Used to build independent applications or components that can be glued together using language scripts

When we talk about programming languages, we often refer to languages ​​used to build software from scratch – just to mention the most popular examples, we have C, C++, C#, Rust and Java. What they all have in common is that these languages ​​are compiled. In other words, after you finish writing your program, you translate it into machine code (or a similar low-level alternative) so that it can be executed immediately.

Scripting languages, on the other hand, are used to manipulate, customize, and automate installations of an existing system. For example, let's say I want to write a script (a set of computer instructions) that downloads data from the web and automatically saves it to my hard drive. I don't need to write new software to do this, just give instructions on what I already have.

Unlike compiled languages, scripting languages ​​are often interpreted. In other words, other software reads the code line by line during execution and translates it into machine code, returning an error if it finds a problem on a line.

Because scripting languages ​​are not designed for writing complete programs, they are slower and more energy-intensive than programming languages. The most popular languages ​​today are actually considered scripting languages ​​(like JavaScript or LUA). But wait, that doesn't make sense, right?

On the one hand, you can definitely write JavaScript code and compile it using the JS engine. What about Python? It is interpreted, but is considered by many people to be a programming language. So what happens?

To be honest, the difference between scripting languages ​​and programming languages ​​has become quite blurry over the last few decades. Most modern and popular languages ​​have enough to accomplish either task with relative ease. That being said, no sane person would think of developing an operating system or a video game engine in JavaScript.

When to use one or the other

Although high-level languages ​​can write programs, not every program should be written with one. Complex, performance-driven software development requires low-level solutions that focus on cost-effectiveness and efficiency. To be fair, most basic applications can be written and run in a language like Python without worrying about performance. Yes, it may be a thousand times slower than C++, but that's the difference between 0.01 seconds and 0.00001 seconds. Slower, yes, but we'll never notice it.

Now game engines, for example, need to perform millions of calculations per minute. Go watch any Pixar movie. Every character, every texture and every light was calculated by a computer – these are the cases where every millisecond counts. Likewise, operating systems that directly manage software need, by nature, to be compiled into machine code, something that interpreted languages ​​simply cannot do.

If you are creating something intended to manipulate an existing system, you will use a scripting language. If you intend to build software, you can use a high-level or low-level programming language. You could even use both, writing some parts in C or Assembly and letting Python take care of the rest.

High-level languages ​​and scripting languages ​​are easier to use, faster to debug, and easier to use — that's their main strength. Low-level languages ​​are powerhouses capable of doing much more, but require more knowledge.

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.