hzp
varishangout.com
Here's the secret: there is no perfect first programming language. Because what makes a successful language for the purpose of learning does not solely depend on the language.
Not only that, but learning how to code with the worst programming language isn't even that much of a problem: if you learned French you'll probably have an easier time to learn Spanish afterwards. It's the same with programming languages, skills transpose between (similar) languages!
What you want is to learn to code. You want to train your brain to learn to find a solution to a problem in small steps understandable by the computer.
Train your brain to be able re-arrange syntactic constructs to produce something meaningful that does exactly what you think it does.
And finally, train your brain to interpret errors, trace them back to what caused them and fixing them.
The first question you want to ask yourself is why do you want to 'learn to code'. And that is to manage your motivation. With anything related to learning, motivation and/or discipline is the most important! Because learning will always be a painful and frustrating experience at some point or the other. And if you burnout and abandon you failed. Some languages are more suitable than others for certain tasks. This also does not only depend on the language itself! Java and C# are hugely similar, but I think it's fair to say that to make video games C# might be better because of the huge (mostly free) ecosystem around the Unity Engine. Do you want to make websites? Well you won't be able to avoid JS (or a language that transpiles to JS). Is all you want to do is hack scripts together to automate some of the stuff you do on your computer yourself? You don't care about features and abstractions all you want is easy ways to interact with your OS, filesystem, other programs, etc.
The second question is how do you want to learn, how motivated and resilient do you think you are. Staying with the video games example, C++ is the most widely used language for that purpose in the industry. But C++ is also by far considered one of the hardest languages, and surprisingly a huge amount of people agree it might not be suited as a first language. There are various reasons for that:
sorry for my autistic sperging...
EDIT: I realize that this sounds extremely biased *against* c++. That was not my intent! If you're not scared of a high learning curve, and c++ is what will motivate you. Go for c++! The most important thing as a beginner is writing code, and stick through it until you feel comfortable.
Not only that, but learning how to code with the worst programming language isn't even that much of a problem: if you learned French you'll probably have an easier time to learn Spanish afterwards. It's the same with programming languages, skills transpose between (similar) languages!
What you want is to learn to code. You want to train your brain to learn to find a solution to a problem in small steps understandable by the computer.
Train your brain to be able re-arrange syntactic constructs to produce something meaningful that does exactly what you think it does.
And finally, train your brain to interpret errors, trace them back to what caused them and fixing them.
The first question you want to ask yourself is why do you want to 'learn to code'. And that is to manage your motivation. With anything related to learning, motivation and/or discipline is the most important! Because learning will always be a painful and frustrating experience at some point or the other. And if you burnout and abandon you failed. Some languages are more suitable than others for certain tasks. This also does not only depend on the language itself! Java and C# are hugely similar, but I think it's fair to say that to make video games C# might be better because of the huge (mostly free) ecosystem around the Unity Engine. Do you want to make websites? Well you won't be able to avoid JS (or a language that transpiles to JS). Is all you want to do is hack scripts together to automate some of the stuff you do on your computer yourself? You don't care about features and abstractions all you want is easy ways to interact with your OS, filesystem, other programs, etc.
The second question is how do you want to learn, how motivated and resilient do you think you are. Staying with the video games example, C++ is the most widely used language for that purpose in the industry. But C++ is also by far considered one of the hardest languages, and surprisingly a huge amount of people agree it might not be suited as a first language. There are various reasons for that:
- syntax: the language is very large (much larger than C). Now syntax usually doesn't matter, except for beginners (I'll explain later).
Ease of syntax is subjective, but small languages like C have a syntax that can be learned in less than an hour or so (I could teach you scheme's entire syntax in 45 seconds!) whereas C#, Java have a lot of keywords and a lot of grammar rules. C++ is both big and has lots of similar syntactic constructs which have completely unrelated semantics (there's this famous meme about initialization in c++) - errors: C++ compilers are famous for their unreadable errors, and errors are the most important thing for developers. It is quite literally your only feedback from the compiler/interpreter. Learning to read errors is a skill! With experience you're able to just glance at an error, then your code, and boom, in less than a second you found the mistake. This is also why syntax matters so much for beginners: they cannot read errors. Very often they feel overwhelmed and ignore them, and just try to fix random things until it works. I'm not mocking anyone here, this is a perfectly normal reaction. Compiler errors are no small thing, lots of research and developper's time is spent on them! In C++, due to templates, it's possible that the compiler spits something like 200 lines of errors just because of a small typo...
So languages with good error messages include C# and obviously rust.
python and ruby too but their dynamic nature means you'll have less errors while writing code and more while running your program, this is fine but makes your programming feedback loop slower. - semantics: some languages are garbage collected (memory is managed by the language's runtime system itself), that means there are a lot less things you might have to think about when writing code. C++ is not garbage collected, and you have to manage memory yourself. This means more things to learn to get things working, but also more problems to deal with. If you think that your program crashing with only the line 'segfault (core dumped)' is bad, wait until you have to debug a program that runs smoothly but silently corrupts your memory. Or your program is working as intended... it just doesn't read the input you gave it.
- semantics 2: there's more than memory management and syntax that makes a language "distinct". Another way to categorize languages is with their paradigms. As languages developed we've discovered and invented quite different ways to manage the complexity of code. One of them is to model everything as objects, another is to use functions as much as possible (functions as values), etc. On top of, but also orthogonal to, the main paradigm (if you can call it that) we have various features to deal with specific problems or subset of problems (examples include exceptions, HKTs, generics, lambdas, type level computations, multimethods, etc. etc.). This can make a language very easy and nice to use but also extremely complex and daunting to beginners.
GC & easy languages: python, ruby, scheme
GC & a little more complex because of OOP and generics and whatnot: C#
No GC: rust, C, C++ - ecosystem: like I said previously, it matters for what you want to do. If you are extremely motivated you might be able to learn X before Y and have a nice gentle learning curve. If you prefer to suffer a lot but get results right away you might prefer to learn the language best suited for your goal so you can work on what you want right away, even if that means having a harder time. Languages with a very large community also come with tons and tons of people who post about their problems and just as many who give beginner's help and write tutorials. This means that googling for things you don't understand is much easier. Another aspect of the ecosystem is the developer tools. Languages like C and C++ have very varied build tools, all kind of suck, now not only do you have to deal with learning to code, but also learning how to compile your code. You might want to pick a language which is known to be easy to use.
S-tier ecosystem: rust - everything just werks and is easy to use.
A-tier : python, ruby - they come with a package manager and you can just run the scripts. They also have a REPL (interactive interpreter) which makes it good to experiment small things.
B-tier : C# - you will be tied to visual studio/vscode most of the time, because that's just microsoft. But it comes with the advantage that almost everything related to project management is handled by it, including using external libraries (NuGet packages).
C-tier: transpilers - some languages compile to another language (mostly javascript), the pain comes from this added step, which sometimes restrict the way you can compile the generated code, it rarely "just works".
huge learning curve: c, c++ (avoid cmake if you can as a beginner, if you need a library just copy paste the code lol)
sorry for my autistic sperging...
EDIT: I realize that this sounds extremely biased *against* c++. That was not my intent! If you're not scared of a high learning curve, and c++ is what will motivate you. Go for c++! The most important thing as a beginner is writing code, and stick through it until you feel comfortable.
Last edited: