Why are there so many vehicles, like motorcycles and cars and pickup trucks and ambulances and semis?
Why are there so many musical instruments, like guitars and drums and trumpets and cellos?
Just like all vehicles get you from point A to point B, and all musical instruments play music, all programming languages let you program computers. But they’re all good for different things.
Very practically speaking, here’s one of the biggest differences.
Low-level programming languages tell the computer exactly what to do in excruciating detail. It’s tedious to program in these languages because you have to detail every single step, but if you’re clever you can make a program that’s very fast and efficient.
High-level programming languages let you write much less code to tell the computer what to do. You can give very broad, general-purpose instructions and it will figure out the details. However, it’s probably not going to do it the most efficient way, it can be quite wasteful.
High-level languages are great when your goal is to write a program as quickly as possible because it’s only going to be used a few times or only by a few people and it doesn’t need to be fast. Low-level languages are great when your program is very important and needs to be as efficient as possible.
And there are lots of options in-between.
And that’s just one difference. Just like with vehicles and musical instruments, there are lots of differences between programming languages.
Why does Baskin-Robbins carry 31 flavors of ice cream? People have preferences, and at the last time I checked, programmers are people. Some programmers specialize in specific languages, some specialize in specific subjects, like databases or caching or web front end, and know how to make those things work in a variety of languages. There’s also a great deal of overlap in most languages fundamental features. All languages feature variables and flow control, most support the concept of objects and functions, so translating a particular program from one language to another might not even be particularly complex, just a bit time consuming and fiddly.
If there was only one programming language ever written, then we would all be writing in assembler. Programs would likely be much more efficient, but have far fewer features, and cross-platform compatibility would be nearly impossible.
Programming languages are used to help programmers build software that perform certain tasks. There’s not been one language invented yet that performs the best at all tasks. It’s usually because the set of interesting tasks to solve have conflicting sets of desirable attributes.
For example, Python is great at ad-hoc programming without an overarching upfront design of how one might solve a task. It achieves this by being flexible and dynamic. By being flexible and dynamic, it gives up strictness and staticness, which are desirable attributes if your task requires more safety or performance. On the flip side, c++ is stricter and requires the programmer to handle more low-level planning, but this also allows c++ programs to have lower overhead and achieve better performance in many cases.
In an analogy, Python approach to telling someone how to drive to a restaurant is like “go north on I95, exit 56, then roughly a mile until you see the green awnings”. The C++ approach would be more like “drive 15MPH onto on-ramp, look left before merging into I95, accelerating to 60MPH over 3 seconds, drive 20 miles, then look up every ten seconds until you see exit 56, slow down to exit over the course of 10 seconds, take a right turn off exit ramp, drive 0.8 miles, start looking for 345 East Bubbly Road, signal to turn onto parking lot, etc”.
You can see how Python is generally less verbose and higher level, but C++ gives you (forces you to take) more control over exact plan. Python may get you to the wrong place, or may get you there more slowly. C++ requires more work to get right, but once you get it right there’s less chance of failure.
I’m a computer science student.
Most computer languages do certain tasks better than others. Take for example C++, which is used in 90-ish% of video games because it is very performant in comparison to other languages. Try to have it run the final fantasy 7 remake at 60fps with JavaScript.
Same thing for python, great for machine learning, data science, AI, big data, etc not many other languages can do what it does.
JavaScript has a firm hold on web development
I can keep on going but you get the idea
Programming languages are used to help programmers build software that perform certain tasks. There’s not been one language invented yet that performs the best at all tasks. It’s usually because the set of interesting tasks to solve have conflicting sets of desirable attributes.
For example, Python is great at ad-hoc programming without an overarching upfront design of how one might solve a task. It achieves this by being flexible and dynamic. By being flexible and dynamic, it gives up strictness and staticness, which are desirable attributes if your task requires more safety or performance. On the flip side, c++ is stricter and requires the programmer to handle more low-level planning, but this also allows c++ programs to have lower overhead and achieve better performance in many cases.
In an analogy, Python approach to telling someone how to drive to a restaurant is like “go north on I95, exit 56, then roughly a mile until you see the green awnings”. The C++ approach would be more like “drive 15MPH onto on-ramp, look left before merging into I95, accelerating to 60MPH over 3 seconds, drive 20 miles, then look up every ten seconds until you see exit 56, slow down to exit over the course of 10 seconds, take a right turn off exit ramp, drive 0.8 miles, start looking for 345 East Bubbly Road, signal to turn onto parking lot, etc”.
You can see how Python is generally less verbose and higher level, but C++ gives you (forces you to take) more control over exact plan. Python may get you to the wrong place, or may get you there more slowly. C++ requires more work to get right, but once you get it right there’s less chance of failure.
I’m a computer science student.
Most computer languages do certain tasks better than others. Take for example C++, which is used in 90-ish% of video games because it is very performant in comparison to other languages. Try to have it run the final fantasy 7 remake at 60fps with JavaScript.
Same thing for python, great for machine learning, data science, AI, big data, etc not many other languages can do what it does.
JavaScript has a firm hold on web development
I can keep on going but you get the idea
Because each one has a different purpose, or because some don’t fit a particular need so a new competing one is made, or because [making them is fun](https://toylang.com/).
Fun fact about lua, which might be bullshit but I like a good story:
When brazil was cut off due to sanctions, someone had to develop a new programming language without outside influence. When the sanctions were dropped, the world was finally introduced to lua properly.
So lua was developed in isolation from conventional wisdom, which is likely why it’s so odd.
Latest Answers