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

328 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

Languages are generally all built on top of each other. For example, many Python libraries are all written in C/C++ and wrapped in Python, and the Python interpreter itself is written in C.

What may take someone 300 lines in C to properly do may take Python 2 lines, it doesn’t mean those 300 lines in C/C++ aren’t happening, because they are, it’s just not explicitly required for the developer to write it all out as it’s automatically handled by Python, or whatever language you’re doing.

Languages are created to fill a need. Anyone can create their own language, in school I worked with a PhD student who created their own visual programming language to control robot cars. python being interpreted and not compiled and being “beginner-friendly” is because that what they wanted to create to fill the need.

Anonymous 0 Comments

Computer languages are like human languages.

Basically anything you want to accomplish, you can do in nearly any language there is. Most of the difference comes down to who else speaks that language.

If you want to study Italian art, you *can* read about Italian painters in books written in Japanese. But you’ll *probably* find it easier to find books about Italian painters that are written in Italian.

If French is your first language, you’ll probably find Spanish easier than Mandarin. If Mandarin is your first language, it probably seems unfair to say Spanish is easier.

You should chose a language based on what the people you want to work with use.

Don’t listen to any argument that says some particular language is *inherently* better at something than another.

At best you can say one language is *better suited* to some task than another — and that will be because of the availability of sample code, reusable libraries, and industry experts that use that language.

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.

Anonymous 0 Comments

Here are some analogies:
Python might be your boss telling you what to work on next. It’ll be a pretty general list of things to do, and then you have to use your own intuition and thinking to figure out what he wants to do.

C might be like a lawyer drafting up a contract on exactly what you can and can’t do. They have to be much more detailed than the previous example because they have to be precise and very little can be assumed to be implied. They have to use legalese to write down exactly what they mean.

Everything in Python can be done in C, but it may waste a lot of time having an unnecessary amount of detail. If your boss spends hours each day drafting up in detail exactly what you should be doing, that is a huge waste of time.

Anonymous 0 Comments

Imagine 4 vehicles. A Ferrari, a Ford F150 pickup truck, a Toyota Sienna minivan, and a large Simi truck.

All of these are vehicles and share many things in common. All have doors, wheels, & engines. All of them could be used for the same tasks, but each one is better at some tasks and worse at others.

Doing a soccer drop off of your 10 year old and his 2 best friends? Well you could do it in the Semi or the Ferrari, but it’s likely that everyone would be much happier in the Sienna or the F150. Picking up a load of lumber at the hardware store? The F150 is your best bet but the Semi would work as long as it has the right trailer and the seats in the Sienna fold down real nice. But doing that task in the Ferrari is just a hard no.

Want to take a lap around a race track? All the vehicles “can” drive around that track but you’d likely get the best time in the Ferrari.

This is the case with programing languages. They all do basically the same tasks, but they are built in such a way that each one does different things better or worse than others. There’s no single “best” language any more than there’s a single “best” vehicle. There’s just different choices that have different pros and cons.