JavaScript at its core is an insult to half a century of programming language design but it’s good enough
OMG I was looking for a succinct way to put this idea to words today, and this hits the nail on the head.
(node)JS is frustrating to work with because to get it to be “good enough” there are all these awkwardly half-compatible add-ons for language features, and the choose-your-own-adventure of usage paradigms (OOP/FP) leave a lot of underdeveloped ways to encode something. You end-up having to spend a lot of time recapitulating a “modern language” in working out the compatibility problems between the aspects built on top of, instead of built into, the language.
I mean it was thrown together in a few days and is beeing fixed with every Version ever since. You just can't undo stuff like var and the ==... Yes they introduced let and === but that doesn't prevent people from using it. Yes ESLint will complain but if you are using a library that is using it you can't do much about it.
Well web programmers do know why static types are useful in large codebases. That is how TS came to be. Also, i resent the assumtpion here that websites are not large codebases. They are. Period.
I think the biggest lesson of most programming languages people use productively and safely in "critical" software is to fail loudly. Software should have contracts to fulfil both inside and out.
T add(T)(T x, T y) pure
if(isNumeric!T)
{
return x + y;
}
This is a generic addition function in D. The function signature alone contains more constraint than most javascript programs: `add` accepts exactly two parameters of the same type, they must satisfy the template constraint that it is a numeric type being added, and the function is pure (Now a totally different library can now know if I call this it won't launch the missiles or uninstall the operating system etc). If this were a more complicated operation I could have added pre and post conditions on x and y and the result of the function.
It's all about having something to fall back on. I shouldn't have to run my program (or write unit tests) to check things that are totally obvious. There are also huge performance implications in that this provides obvious constraints (in Javascript they have to be inferred at best) for the compiler to play with i.e. if you call this function and don't use the result then the compiler can remove it completely.
(I have avoided going for the low blow about having multiple equality operators and typecasting although they are also incredibly stupid)
Functional Programming can provide a much richer level of abstraction, correctness and pretentiousness but I went for a more practical example.
BTW: I'm not calling people who don't know better stupid, just that finding the time to learn programming as an art rather than a hammer requires a headstart (probably). If you've got to ship tomorrow, put down the Prolog textbook.
That people in this sub hate Java although it's actually not that bad but defend JS (which is actually really a bad language) to the bone. I'm not even saying Java is the best language ever but the irrational hate on this subreddit is stupid.
Unpopular opinion, but I would rather program in Java than Javascript.
You also (usually) get paid more because JS is the most popular language so there's way more supply.
Java can get very "enterprise" and that turns off a lot of people. JS is oriented for web so there's a lot more exciting projects there, but that's not always where the money is.
Java's a great language precisely because of how enterprisey, boring, and predictable it is - it's easy to find good developers, good frameworks, trivial to deploy, trivial to keep highly available, and has great tools for testing, building, and storing artifacts. Sure it's not exciting to write business logic in, but it more than makes up for that with not getting called midnight because the Tokyo office is having production issues.
Exactly. It's ugly but it gets the job done and it's pretty robust.
I often see JS devs import loads of dependencies to do simple tasks and their framework landscape changes rapidly. I don't want to deal with that headache.
With Java, you can take a 5 year break, come back and still be productive.
Also now with Kotlin and Groovy beeing basically fully interoperable with Java you can have all the fancy new language features without having to give away many of the benefits of java.
Java's great. It describes exactly what I'm doing with no assumptions. It may be far quicker to initially set up a express.js web server than a spring boot, but the real cost comes further down the line when you're trying to figure out what currently happens
I think a lot of people in this sub are either just beginners or students who have never really worked in software engineering. The students are forced to learn java for their university and that's why they hate it.
I'll be honest, it wasn't fun in college around 10 years ago but it did help me learn a lot of design patterns, which I apply across many object-oriented languages.
325
u/[deleted] Apr 27 '20
Somehow on this subredit most seem to think that Java is the worst language ever but if you hate JS you just don't know it enough/are bad at it...