eli5: How are some programming languages better at different tasks than others?

334 viewsOtherTechnology

For example I am taking Python right now which is known to be “beginner-friendly” but then in highschool I took Java where we did a lot of content relating to classes and object oriented coding. But what makes the languages specialize in these fields specifically?

In: Technology

5 Answers

Anonymous 0 Comments

Same reason a wrench is better at some things than a hammer.

To get more specific with programming languages: there are always tradeoffs.

C gives you very precise control over what’s happening at the memory level, and strong typing (among other things) means the compiler can better predict what the code will do at runtime and heavily optimize it. This makes well-written optimized C blazing fast… but the low level control means you often have to write a lot more code to do the same thing, and it’s easy to make unexpected errors that crash your program.

Python, on the other hand, is made to be easy and fast for the programmer to write. It does a lot of work for you behind the scenes, making assumptions about what the programmer probably intends to do, thus saving you from having to code those things yourself (for example, Python does memory management automatically, including something known as “garbage collecting,” which Java also does). All this extra lifting the language does makes the programmer’s life easier, but adds extra steps during execution which makes the program run slower. Python gets around this by having a C and C++ API, allowing libraries that perform intensive computations to be written in a faster language, while the high level program logic (which rarely needs a high level of optimization) can be written in a language that’s faster and easier to write, prototype, and iterate on.

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