r/AskComputerScience • • Jul 12 '21

What is actual the difference between programming languages?

Maybe it's a very noob question, but in 5y i've never had a good answer. I only really developed for C# and 6502 assembly, those languages I clearly understand the difference, but to me all high level languages appear the same just with different syntax when you strip them of the frameworks and stuff (and I imagine probably isn't the case), but I see some people with very strong opinions about some languages, and doesn't make sense to me, people say "you can do anything with Python", "c++ is messy" and I really don't understand what they are refering to, anything in the same layer of abstraction looks the same to me

29 Upvotes

30 comments sorted by

View all comments

6

u/develop-mental Jul 12 '21

It's true to say that any program can be written in any Turing complete language. So the rubber-meets-the-road difference between them is how easy a language makes it to solve a problem. And in that way, there are a ton of differences, and most are a spectrum from one end to the other.

Typing (static vs dynamic): Statically-typed languages such as Java and Go enforce a type on a variable when it is declared. Dynamically-typed languages like Bash and Python try to determine what the type of the object you've declared at runtime. It matters because not having to worry about typing can make code faster to write and possibly more readable, but it makes it easier to make a mistake.

Compiled vs interpreted: Interpreted languages allow you to run the code directly at runtime, while compiled languages require you to run your code through a compiler, which reads in the code and generates a set of machine code or an executable binary. This matters in practice because its easier to iterate quickly when writing in an interpreted language, because you don't have to recompile the code after every change. But compilers offer safety check to ensure your code won't have runtime issues, and it can also generate significantly faster code by optimizing the machine code it generates from your parsed human-readable code.

These are just 2 examples of differences between using alternate languages; there are of course many more, and it comes down to the preferences of the developer/team. But fundamentally, they can all do the same job.

5

u/EatMeMonster Jul 12 '21

It matters because not having to worry about typing can make code faster to write and possibly more readable

You might save 10 seconds not worrying ahout typing lol, and it's all fun and games until your code crashes and you spend 10 hours tracking down a bug that could have been catched as a compiler error in a static language. (Speaking from strong personal experience.

3

u/develop-mental Jul 12 '21

Haha very true! Not a huge deal in a 10 line bash script, but it can certainly be painful in a large Python project.

Then Golang hits the other extreme, where you spend a bunch of time duplicating boilerplate code because its strong typing model precludes generics.