What makes different programming languages “better” than others? Or more powerful? Why have different languages developed over time? Are they all based on the same thing?

1.24K views

What makes different programming languages “better” than others? Or more powerful? Why have different languages developed over time? Are they all based on the same thing?

In: 187

78 Answers

Anonymous 0 Comments

An example:

Some languages (none of the currenty widely used ones) don’t have loops or the concept of repetition but instead they have go-to-step-*x* commands. Others don’t have “goto” commands and others have both.

An exponentiation program without loops:

1. Ask user for $base.
2. Ask user for $exponent.
3. Set $result to 1.
4. If $exponent is 0 go to 8.
5. Subtract 1 from $exponent.
6. Multiply $result by $base.
7. Go to 4.
8. Display $result to user.

Equivalent program with *buildt-in* “language-level” loops:

– Ask user for $base.
– Ask user for $exponent.
– Set $result to 1.
– Do the following $exponent times:
– Multiply $result by $base
– Display $result to user.

Some language features that aren’t in *every* language include the ability to detect programmer errors before running, the ability to handle errors *while* running (Sometimes a language forbids you to do things that *could* be errors even if they aren’t. It has pros and cons.), the ability to use emojis as variable names, the ability to trade development effort for fine-grained control, the ability to use real (“decimal”) numbers as opposed to just integer numbers (JavaScript kind of *only* has real numbers), the ability to use very big numbers, the ability to define your own data types or control structures, automatic vs manual memory management. I could go on.

> Are they all based on the same thing?

Not *really*. You can think about algorithms in different ways and the languages reflect that. There are so called “programming language paradigms”. For example “functional programming” is inspired by mathematics, where a function always associates the same result to the same arguments and you can’t reassign variables. Other “procedural languages” just provide some convenient abstraction layers over giving the processor a series of commands “store this in here and then store that in there…”.

Similar languages can sometimes be translated into each other. Sometimes information is lost that way and sometimes the program get’s slower because of a translation.

In another sense they are equal as long as they are “turing complete”, which means that you can theoretically solve any mathematical problem with it. Or let’s say, you can create the same programs with them. Practically programs in some languages will be slower than others because it’s very difficult for the translation program to find an optimal machine-language equivalent.

You can invent your own programming language! You just have to describe very precisely what you want the processor to do and then create a translation program that translates your description into machine language or another programming language that already has a translator (“compiler”).

You are viewing 1 out of 78 answers, click here to view all answers.