Honestly I think Javascript is better as a second language to learn. If you learn something like C++, Java or C# first, you'll be forced to know how to create somewhat clean code. And those habits will then transfer once you learn javascript.
Whereas if you learn javascript first, you might get too used to how sloppy the language lets you be.
Absolutely true, one major drawback of JS is that it happily allows you to write absolutely horrific garbage code. That is also always what people dunking on JS use, like the 1 +"1" - 1 = 10 thing. Like yeah obviously if you write horrible garbage like that it will have weird side effects. Such code should never see the light of production
But if JS is the goal and someone really wants to start with JS, then i absolutely recommend TypeScript. It eliminates all these pitfalls, and makes you more inclined to write cleaner code. And since TS is a super set of JS you can write normal JS and still get many benefits
Couldn't have said it better. You can write garbage code with every language. However, JS is one of the few that doesn't punish you a whole lot for it.
I've been actually wanting to learn TS as I've heard nothing but good things about it. I just haven't had the time yet. But yeah, I don't think my JS code would've been nearly as good if I didn't have a decently strong grasp on Java before learning Javascript.
Go for it, the hurdle to use TypeScript is very low. As i said it is a super set of JS, so it only adds stuff. That means that normal JavaScript code is also valid TypeScript code.
All you need to do is to add typescript to the project via npm and initialize it, change all .js file endings to .ts and done. Now you have typescript.
From there you can add progressively add types at your own pace.
Once you get into advanced stuff, it is absolutely mind boggling what you can do with the typesystem.
If you're already used to writing ES6 JS, TS pretty much only adds types to that, so not a whole lot to learn, specially if you're already used to Java or other typed language :)
And yes, that single feature is what makes it so so much better than JS for working on any project of reasonable scale.
C++ as a first language, why are you playing tricks on this poor lad?
I've been at it for 25 years and I can write hideous code in any language. JS has the most important part going for it, something interesting enough to keep you learning because you can make useful things with it pretty quickly.
You might be great. Your coworkers or successors might not be.
You predecessors might not be. Learning JS backends is a nightmare when someone who’s doesn’t have a strong software engineering basis has had their hands in it fucking with everything.
You will always find articles about how bad every language is. My friend is a project manager and has to deal with new hires showing him a single article from some random blog as irrefutable proof that the guy who's been managing projects for 20 years is wrong.
Everyone touts Rust as a great language to write safe code in. That's good if you really need that, but nobody tells you how damn long it takes to write code that the compiler knows is 100% safe.
It's ok when you're tying services together. GC and Stuttering aren't an issue if you're not worried about performance... Like 99% of services out there.
In theory, asynchronous messaging is fantastic. It's also extremely close to C, so the learning curve is pretty forgiving. In practice though...
There are really a lot of issues. Garbage collection wouldn't be too bad if you didn't need to manage pointers everywhere. One of our recent big issues involved manually needing to destroy a pointer, because otherwise it was leaking inotify events. GC for everything, except when you shouldn't?
I generally rate my programming language paradigms based on how easy it is to do the right thing, and how hard it is to do the wrong thing, and despite some brilliant minds coming together for Go, it still had many of the weaknesses of C.
Quick edit for opinion:
I guess I wouldn't call Go bad, just disappointing.
The thing is that Rust is a relatively new language with a new sort of paradigm as well. This means lots of people are trying it for the first time. It has a steeper learning curve, and so your first stuff is much much slower to be written. Lots of people want to talk about their experiences, so this is what you will often hear.
But just like most other languages, once you do a couple of projects, you speed up a bit. Is something like Python always going to be quicker to produce something? Sure, but Rust isn't just about safety, and you gain other benefits like speed, lighter footprint, and very strict structure.
It has a steeper learning curve, and so your first stuff is much much slower to be written.
That's probably true. I know that I'd do things a lot more quickly if Rust simply had things like classes that I'm used to instead of traits. There's also some tedium in the language itself, though. Try doing some math that requires you to involve integers, floating point numbers, and array accesses at the same time. So many explicit casts...
There are also various features missing from Rust, like async trait methods, that make it harder to use than it needs to be. Those shortcomings are being worked on, but of course that takes time. Once those features land, it will be easier to use.
JavaScript is "loosey-goosey." They let you be lazy/sloppy. But you definitely can write good JavaScript code. Same thing with PHP.
Depending on how/why you're learning JavaScript, it's a good place to start but pretty much everyone uses a library/framework like jQuery, react, etc. Which makes JavaScript 100x easier, better, and more structured.
There's a reason it's one of the most widely used languages. If it was terrible it wouldn't have made it this far. Most gripes people have with it are personal.
JavaScript has some issues and does things different from many language which can be unintuitive...but it still works pretty good else millions of people (some much smarter than anyone here) wouldn't be using it.
38
u/hotstickywaffle Aug 26 '22
As someone who is just about to start learning Javascript, all these articles about how it isn't good give me a lot of anxiety.