What is the difference between a programming language and a scripting language?

Both are programming languages. A program is just a more or less complex script.

But what characterizes a script language is that it does not need to be compiled to be executed, it is said to be interpreted.

C, C++ for example are languages whose programs must be compiled, that is to say, transformed into machine language, for a given hardware and operating system (a C program compiled on a PC will not work on a Mac for example and if it is compiled for Windows, it will not work under Linux)

JAVA or all .NET languages for example, must also be compiled but in bytecode (an intermediate code, higher level than the machine language), and this bytecode is executed by a virtual machine which is in principle able to execute an application without its author having to worry about the hardware or software specificities of the system which executes it.

Php and JavaScript for example are interpreted languages. They don’t have to be compiled and almost don’t take into account the machine on which they are executed. The Php interpreter is the result of a compiled program written in C.

Essentially, the issues of these 3 technologies are to offer more or less granularity to the programmer. A program compiled in machine language gives precise access to the electronic elements of the hardware that executes it. This type of program generally runs faster, takes longer to set up and requires a great deal of rigor from the programmer. This type of application could in fact intervene in another running program, knowingly or by mistake, which could render the machine unstable or unusable. On the other hand, if you need to develop a driver for an electronic board or an application that runs without latency, in real time, a compiled language such as ASM, C or C++ will be indispensable.

Virtual machines that run JAVA or .NET don’t offer as much granularity, but they do protect the systems they run on, to some extent. And since this issue is taken care of by the virtual machine itself, developments in JAVA or .NET are faster to deploy.

The script is far from the machine. It orchestrates routines on an existing software infrastructure, simply and quickly.

Who can do more, can do less! You can create anything with a compiled language, even a web site! But it will take you more time, and time in programming is very long and therefore, very expensive.

You see that these different languages have different interests. But this is not so much related to their syntax as to their execution mode and the freedom they offer.

Categories IT

How does a programming language work?

We’ll have to do a little history. Sorry for the long answer.

In the beginning, there were the first computers

Monsters of several tens of tons, occupying several rooms. Programming these machines meant taking them apart and putting them back together again by changing the internal wiring.

The use of vacuum tubes

(the “lamps”) allowed to limit this rewiring (it was always necessary to rewire, but not the whole machine), and the appearance, then the miniaturization, of transistors, allowed, them, to reduce the size.

As the machines evolved, the need to rewire them completely disappeared.

But computers still had to be driven in binaries. To put it simply, the central computing unit (what we call the processor today) has a set of predefined instructions. Each instruction has a value expressed by a binary digit. Some instructions are followed by data, which are also represented by a binary digit. The program, in its most raw state, is the succession of these instructions.

We can program using Assembler

To put it simply, the assembler is a human readable representation of the processor instruction set. Each family of processors has its own assembler. In a nutshell: to each instruction corresponds a simple code word. Assemblers are therefore proto programming languages. It is a bit more readable than binary code, but not very practical to use. The level of abstraction is at its lowest, which does not facilitate algorithmic design.

The computer scientists of the time (one in particular, Grace Hopper

Although she was not the only one, she was a pioneer in this field) had the idea of writing their programs in a form of simplified English. This simplified English would have a vocabulary, syntax and grammar that would be programmatically identifiable, and which could be translated into assembly (and thus into binary code). It would therefore be called a programming language.

When one uses a programming language, one writes in a language that is easily understood by the programmer. This is called the “source code”. In this form, the program is incomprehensible to the processor, and cannot be executed as is. The programming language being programmatically understandable, the source code can however be understood by another program, the compiler (I will not dwell on the subtleties between compiled and interpreted languages). This compiler provides the translation from the source code to the binary code that is executed.

To summarize roughly, the programming language is a simplified language that allows to express algorithms, with more or less abstraction from the physical realities of the machine on which the program will be executed. The grammar of this language is programmatically recognizable, so that a program written in this language is readable by another program, the compiler. The compiler translates the program written in the programming language into binary code, which can be executed.

A programming language is just a language like any other, except that this time it is to talk to a machine.

Programming languages all have the same goal: to make a machine with a binary processor do something.

PHP, Java, C++, etc… The syntaxes change, the paradigms sometimes too, but in the end, it will be calculated by 0 and 1.

When we write code, we write “instructions” that the machine will execute.

All current machines (in 99.99999% of the cases, I don’t take into account Quantum Computers), have a processor (also called micro-processor) that will contain billions of transistors.

A transistor is an electronic element capable of doing basic operations (AND, NOR, OR, etc…), namely binary.

In the end, everything comes together, even if there is a great diversity of programming languages.

A programming language can be both very simple and very complicated. You can actually create your own!

I saw other interesting answers, I leave them the in-depth explanations.

Categories IT

Which programming language do you refuse to learn and why?

As a Linux/Unix expert with about 20 years of professional experience, I refuse to learn shell scripting languages at an advanced level.

Obviously, I know the basics. I can do loops, pipes, if/else conditions, cases and all that; I also know the ins and outs of the usual tools like grep, sed and awk. That’s enough to effectively do ad-hoc tasks in the command prompt. Most people watching me work like this would probably say that I am quite advanced in my use of the shell and associated tools.

In reality, I am not a very good bash/ksh/sh/other programmer, and that is by choice.

Once you stop doing little one-off command line manipulations (where the shell is a very effective tool) and start writing scripts that run consistently in production, you enter the realm of software development.

And from the perspective of software developers, the shell is a totally inadequate tool. In fact, it’s really nothing more than a glorified macro processor with a few control structures thrown in.

Once you start doing advanced programming with shell scripts, much of your code will have to deal with the shortcomings of the language instead of your real problem. It becomes especially bad if you have to deal with variable values (such as filenames) that contain spaces. Instead of dealing with this, many shell programmers choose to ignore the problem by telling everyone that spaces in filenames (or any other string) are not “the Unix way”. But think about it, what century are we living in?

Essential data structures such as associative arrays (or any array for that matter) were not available in the original Unix shell. Of course, they are available in modern variants like bash, but they were added on top of it and it shows. The syntactic clutter required to use them correctly can break your brain. Just to give an example, in ksh, if you have an array called “foo” and you want to pass it to a command called “bla” with proper handling of elements containing spaces, the syntax used is:

bla “$ {foo [@]}"

It’s intuitive, isn’t it? I’m sure you would have figured it out the first time if you were asking yourself “how do I pass an array to a command?”. Similarly, many other features will only be accessible if you memorize the specific combination of special characters you need to use them properly, instead of being able to call them with an obvious, memorable name.

I have seen many examples of shell scripts used inappropriately; scripts exceeding 1500 lines and costing my company money every day. Since they run critical production and fail over and over again, seasoned professionals have to spend hours inspecting the scripts to try to figure out what the code is trying to do and why it’s not going to work.

Besides all that, I manage to write shell scripts from time to time, but only very small ones. For anything that requires more than like 15 lines of code, I choose another language, like Python. Sometimes it’s much more verbose than an equivalent shell script, but it’s also much more readable (that really counts in software development), and it won’t make you fiddle around with “advanced concepts” such as spaces in strings. Python also provides an excellent library for accessing most system-level APIs without having to call external commands and figure out how to interpret their incomprehensible success or failure feedback.

Welcome to the 21st century.

Categories IT

What is the worst programming language?

What is the worst programming language?

C++. For a very simple reason. I’ve been using it for 25 years, I’ve taught it, I enjoy it and I’ve done my most significant projects with it. Yet even today, it is impossible for me, and it is impossible even for an expert, to write a large project without encountering a memory segmentation error.

That says it all.

To understand the ins and outs in more detail, a few explanations:

C++ is a weak typing language. Anything can be typed into anything. The specification is full of implicit transtyping rules inherited from C that make it possible to miss the type actually stored and manipulated under the hood when reading the code. More generally, the compiler offers no guarantee on the actual type of what is being manipulated because of all this permissiveness. It’s the same thing in Assembler, but at least that’s its role and it’s not a language disguised as a high level language.

Even with a thorough knowledge of pointers, reference semantics, and even with maximum use of the STL rather than your own manual memory allocation system, and even though you are aware of this trap, you will definitely make pointer invalidation errors, keeping a pointer to an STL entry and doing push_back on your vector for example. This is human. It follows intrinsically from this low-level/high-level potpourri. The compiler and the language specification do nothing for you. Each of these errors will eat up an average of one day of debugging (or more) and each time you will curse the absurdity of working on a language that silently leaves you with your nose in this kind of stupidity. There are only external tools like Valgrind to save you from these traps. Besides, it is impossible to do a proper project in C++ without using a memchecker.

I still feel that a significant part of the language specification escapes me even after 25 years, and for good reason. The C++ specification is plethoric and sprawling, and recent developments have only exacerbated this fact. There are 120 ways to do the same thing. Template metaprogramming. Variadic templates. Move constructors. Multiple inheritance. All these concepts take several years to understand and really master for a real benefit only on very specific types of projects but are unlikely to be profitable in the lifetime of an average programmer. They only add to the general insecurity that will lead you to low-level errors. Worse, to maximize your chances of writing usable and correct code, you are even better off sticking to a tagged subset of the specification, which is what people actually do in practice. You know there is a language definition problem when you have to rely on the programmer’s self-discipline to voluntarily ignore a whole part of the specification.

If the question was: is C++ useful? I would have answered yes, for specific projects that are close to the machine and the system, or that require very fast operations on irregular data structures, not vectorizable in a more advanced language. I continue to use it in these cases where the benefit of having a higher level layer on a low level base is well identified and makes it profitable despite its weaknesses.

But from a formal computer science point of view, and from the desirable characteristics of a language, rigor, parsimony, clarity of specification, verifiability, C++ is one of the worst languages out there, especially for undertaking a large general purpose project. It is a low-level optimization language that people have mistakenly hijacked for general-purpose projects because of some of its high-level language mimicking characteristics – and because it was the best choice at the time. Today there are many languages that do it better, just as fast or almost as fast, in fewer lines of code and with much less development time and cost.

Categories IT

What programming language should a beginner learn?

For beginners, the question is not so much about the programming language but about the tools that will allow you to solve a given problem and thus to do computer programming (i.e. ask a machine to execute a task in a certain way).

Logic is therefore very important. You have to be able to write by hand the essential steps that allow you to arrive at a given solution (we say write an algorithm in the scientific/computer jargon), for me, this is the most important part of the learning. Being able to break down a complex problem into small, easy-to-solve problems is the ultimate pleasure, especially when it works, you become like a little god (immortal in what you can do). So who are Guido van Rossum, Bjarne Stroustrup, James Gosling and Patrick Naughton in front of you? Simple people who understood what you know now (basics of computer programming).

Logic is like time, it gets out of hand, so be sure to practice regularly to keep your mind flexible.

Now that you are satisfied with your algorithm, you don’t need to repeat it on other problems with your neurons (it is tedious and boring).

The solution is to ask a computer to do it for you, which is where programming languages come in. Basically, they follow the same principles. Once you have learned the basics, you can easily choose a technology to your liking (you have to store around), inevitably you will find one/two that will steal your mind. For me, it’s the programming language python that has gained my interest. I like python because it’s beautiful, a bit like a good cup of coffee that you drink in the morning while watching the sun rise (the pleasure).

There is no language for beginners, but languages that allow you to develop tools that meet your expectations. Depending on your expectations, I recommend several groups of languages to get you started in development. The main reason is that programming languages are tools to meet needs. Here are my suggestions:

  • If you want to create websites, then there is html, css, javascript and php.
  • If you want to create software, then Python is a good choice (even if some people doubt it, but I don’t).
  • If you want to add a database, then there is MariaDB.
  • If you want to integrate software with website and database, then there is Java, HTML, CSS and MariaDB.
  • If you are working in a field where numerical analysis is intensive, then there is Julia and the languages of which Julia allows direct import of codes, Mathlab, Mapple and an infinity of languages. The importance in choosing a language is the presence of libraries that meet your needs.
  • If it is out of pure curiosity or you have no idea, then Python is a good choice.

Personally, I advise you to start with the easiest, and most requested. Web development. In order: html, css, javascript. From there, you can continue on “front-end”: Angular, vue, node, react, etc. or on “back-end”: PHP, C#, MySql, MS-SQL, etc.
I know that many people will tell you about other technologies (Python for example), but it will take you more time to be efficient and to pretend to pass job interviews, or to take on freelance projects.

There is often a misconception of computer learning by classifying difficult languages vs. easy languages, or beginner language and pro language. However all (high level) languages have similar principles and are fairly equivalent in performance, and often evolve by borrowing syntax and programming methods, and are accessible (as long as they are open and documented). Even if they have different learning difficulties there is no decisive advantage with one or the other.

From this point of view there is no one language that “must” be learned. However, in terms of motivation, learning a language that doesn’t have many libraries or api is quite boring. In this case we find in first place python, javascript, but also java (with android) (or swift for apple). But more than a language, you have to appropriate an ecosystem (ide api etc) and a “culture”, and many fashion effects can lead to a lack of pragmatism to become a dev.

The preliminary question is thus in which goal do you wish to learn programming? it is necessarily necessary to initially consider the opportunities which you have (or wish to have), to learn a language does not replace the practice of dev and the comprehension of the trade which is related to the dev, to learn the python does not have value in being, so much the applications can be vast and correspond to different trades, with the final the language which it is necessary to learn and that which “falls to you”.

Categories IT