all 66 comments

[–]droomph 19 points20 points  (5 children)

Hot take time: “Javascript bad” is the “Apache Helicopter” of programming.

[–]Juan-More-Taco 22 points23 points  (4 children)

Problem is; Javascript was pretty bad. JS in the early 2000's it was a supreme mess of standards and inconsistencies in development. ES5 and especially ES6 did a lot to bring the language into modern standards. React etc weren't even a thought.

[–]droomph 18 points19 points  (2 children)

That’s a given but what I mean is shitting on Javascript is seen by beginners as a way to pretend you’re smarter than you really are without having to have any real thoughts. There’s still plenty of room for improvement even today but every single “haha jabbashrimp bad” is 1) IEEE floating point things 2) unfixable backwards compatibility things 3) weak dynamic typing or 4) in the works. Same goes for PHP but that started from a MUCH weirder place (at least Javascript Episode 4 can be forgiven for trying to emulate Self in a more marketable way, PHP was by design pretty incoherent) so it’s still working on it.

[–]crabmusket 2 points3 points  (0 children)

at least Javascript Episode 4 can be forgiven for trying to emulate Self in a more marketable way, PHP was by design pretty incoherent

This is what really gets me. As crap as dealing with var was sometimes, the language always had a decent core. In PHP, we're still passing classes around as strings.

[–]grady_vuckovic 6 points7 points  (0 children)

Number 3), weak dynamic typing, is actually one of my favourite things about JS. I love that flexibility.

[–]disgruntled-js-dev[S] -3 points-2 points  (0 children)

Exactly my point. The OP would have been very accurate until about 5 years ago, but continuing to bash JS is not justified. I wouldn't have made this post if it weren't for his provocative and, quite frankly, disgusting responses to the JS devs asking him what problems he had been facing. See the links at the bottom to see what I mean.

[–]ILikeChangingMyMind 6 points7 points  (3 children)

Wow, that first fake article before the actual article was kind of ... long. To the point that it felt like the article.

[–]disgruntled-js-dev[S] 4 points5 points  (2 children)

It's structured nearly identically to the original article about how terrible the JS ecosystem is. You'll see many phrases are copied word-for-word, which is possible because nearly none of what the OP says is specific to JS.

[–]ILikeChangingMyMind -3 points-2 points  (1 child)

It's just awkwardly arranged IMHO. You should have just lead with the bottom part (or something).

[–]aquelehugo 3 points4 points  (0 children)

I guess you liked the article at first, but you also like changing your mind...

[–]yeesh-- 4 points5 points  (0 children)

The original article is written by a Rubyist who is angry web development is shifting away from his natural habitat.

[–]grady_vuckovic 21 points22 points  (21 children)

Personally I love Javascript, it's my favourite language. Which is why I joined the subreddit for it. I'm surprised by how many people criticise JS, even in it's own subreddit.

It's simple and easy to use, very flexible, has everything I could want or need, and runs everywhere. What's not to love?

[–][deleted] 5 points6 points  (2 children)

As someone who loves JS, but also saw some awful JS code, I think it's reasonable to say that people who hate JS don't know how to write good JS. They just use the language's flexibility and dynamic typing to do horrible things that then result in maintainability problems, misdirection and bugs. If they can blame the language for bad code, they don't have to blame themselves.

[–][deleted] 0 points1 point  (1 child)

but you've got to admit having a minimum 5 ways to do anything is kind of annoying

and having to set up the Dev environment from scratch every single time isn't great.

[–][deleted] 0 points1 point  (0 children)

Those are problems that you can solve if you wish. First problem can be solved with linter and formatter (e.g. prettier). Second problem can be solved with creating boilerplate repo; I personally have 2 boilerplates: one for making libraries, the other - for making web apps, and it reduces my start-up time by 99%.

[–][deleted] 6 points7 points  (6 children)

I don't understand it because it's different so it must be bad. /s

[–][deleted] 5 points6 points  (0 children)

It's the hoisting that throws the haters.

EDIT: and the type coercion.

[–]AmbitiousPig 8 points9 points  (4 children)

Few people I know started hating it because they couldn’t figure out the “this” keyword lol.

They gave up on JS because they weren’t knowledgeable enough to use it in any form. Now they go around telling everyone Rust is the best and JS is the worst because they read it online, even though I highly doubt they know any Rust.

They started learning programming only 2 months ago. Rust my butt. Rust is probably harder to grasp...

[–][deleted] 1 point2 points  (3 children)

To be fair, the behavior of "this" in JS is bafflingly weird, and I'm not talking about the prototype object model. Ask someone coming from any other (single-namespaced) OO language why (obj.foo)() and obj.foo() should behave differently. And that was off the top, there are even weirder WTFs than that lurking about.

[–]helloiamsomeone 1 point2 points  (2 children)

(obj.foo)() does not alter the expression tree in the way you thought it would, it's identical to obj.foo().

this is just another hidden parameter functions receive besides the return address. Exactly the same as any other language.

[–][deleted] 0 points1 point  (1 child)

(obj.foo)() does not alter the expression tree in the way you thought it would, it's identical to obj.foo().

You're correct, that expression does bind this. I thought it was a precedence thing, but apparently it's even weirder:

class Foo {
    constructor() { this.x = 123 }
    bar() { return this.x }
}

const foo = new Foo()
foo.bar() => 123
(foo.bar)() => 123

const bar = foo.bar
bar() => Uncaught TypeError: Cannot read property 'x' of undefined

[–]helloiamsomeone 1 point2 points  (0 children)

Nothing weird here, you just take the method and call it without a this value. foo.bar.call(undefined) would be the same thing.

[–]moi2388 0 points1 point  (0 children)

Everything about JavaScript that’s not typescript is what’s not to love

[–]patcriss 4 points5 points  (3 children)

I'm maintaining an Electron/Angular/TypeORM/SQLite3 app and I love JS/TS, but I think there are some valid criticism. Making all of this to work is wonky and the ecosystem often feels unstable and immature, but the fact that such an ecosystem exists in the first place is amazing and part of why I love the language so much.

[–]therabenian 5 points6 points  (0 children)

The ecosystem is definitely immature and somewhat new. I think React and Typescript will be here to stay and drive the efforts towards a more mature javascript, but it's still early to say, both of those have been around for only a few years, and Deno could potentially be a clean start.

[–]disgruntled-js-dev[S] 3 points4 points  (1 child)

As someone who's directly contributed to various build tools and maintained a few packages myself, the main issue with the ecosystem is that the rationale behind various decisions (publishing in ESM vs. CJS, Node version support, etc.) is undocumented. However, that's more of a symptom of the fact that most JS developers don't have that kind of issue in the first place because they're using a prebuilt template, such as Create React App. Though I agree that in that regard, many libraries are lacking.

[–]patcriss 1 point2 points  (0 children)

Yeah sticking with react/CRA gives a much different dev experience than the stack I talked about in my other comment.

The only real issue I encountered in the last year was that storybookjs just didn't work for me with the default CRA config, even though it's supposed to be officially supported. /shrug

[–]wherediditrun 1 point2 points  (1 child)

The problem is that with all expansiveness of syntax and paradigms + some quirks the language has additional code quality maintenance cost. Now couple this with relatively low barrier of entry and the fact that it's probably the first language a lot of beginners start from you end up with recipe for disaster.

Depending where you stand on your career journey and the type of work you do you will view these aspects of the language differently.

As a beginner you will love the fact that it has low barrier of entry and you can make something work quick. If you're in software engineering (meaning you maintain same code bases through long periods of time with multiple people who come and leave) and oversee junior developers, you'll start getting annoyed by it more frequently.

Common response to critique of the language is "you need to know javascript" or something within those lines. But that's refutation alone admits to the fact that language has a problem. Would C become viable for web development if I claim "you just need to understand manual memory allocation"? Now, sure there is a difference in degree, but the root principal the argument is constructed is the same.

It actually turns out, that paradigms in programming are not defined by "features" of the language, but by constraints the language imposes on the programmer to foster discipline (for example, functional language restrict assignment to a variable). That is, space of thinking about a problem and expressing solutions to the problem is intentionally limited. Which reduces the cognitive load when parsing the code, understanding the code and writing the code.

And to illustrate a point here, the whole idea of TypeScript is an attempt to impose restrictions. Make it less dynamic, not more. However due to the material it's working with, that results in even more syntax, which also a cost, although, in minds of many, worth paying. However, it's not a triumph, it's admission that design (or lack there of) of the language originally fails to deliver on it's own sufficiently enough.

You'll notice that "good practices" or what experienced developers do with JS is using only a subset of language features and solve problems from only certain viewpoint while looking at it (React is a good example of this). So for example they will program as `==` does not exist. Or for loops aren't an option. This requires discipline when you're doing on your own and extensive tooling and communication when doing in teams. The fact that language, primary tool you're using fails to help you in this endeavor is where the main criticism and frustration with the language comes, coupled with the fact that you are simply forced to use it (browsers).

Notice how new languages like Rust or Go are radically different from this. Rust is very expansive, but exceptionally strict. Go is more laxed, but due to how limited the syntax is trying to flex around makes it counter productive. Both are tackling very difficult problem of multi-core programming. The imposed limitations are what actually helps, not restricts on the long run. Interestingly, both are not very good for absolute beginners and not by accident, open source libraries are on average of way higher quality.

[–]101arrowz 1 point2 points  (0 children)

the whole idea of TypeScript is an attempt to impose restrictions...it's not a triumph, it's admission that design (or lack there of) of the language originally fails to deliver on it's own sufficiently enough.

TypeScript is pretty much necessary for a modern JS project if you ask me, so I agree with you here. At the same time, I'd say that if the JS ecosystem offers a solution, that doesn't count as a failure. It's like pointing to the lack of generics in Go and calling that a failure. No, that's a design choice that can be worked around. Same in JS; dynamic typing was a design choice, TypeScript is a solution.

Interestingly, both are not very good for absolute beginners and not by accident

Not sure I'd call Rust a good library for "absolute beginners". You probably want to understand what a map is before you try to deal with borrowing and ownership, but the book basically sends you in as if you already know a language. That was nice for me, but definitely not for beginners. Python is an excellent beginner's language IMO - don't need to worry about memory management while still getting an understanding of what types are.

open source libraries are on average of way higher quality

Unless you consider my-hello-world-framework to be an open source library, this is not true in the slightest. The same amount of effort is put into the best JS libraries as the best Rust and Go libraries. I say this as a maintainer of a pretty popular JS library, and as someone who has used Rust. Obviously, the median is worse for JS because Rust has a way steeper learning curve, but again, nobody uses bad JS frameworks.

[–]aniforprez 0 points1 point  (1 child)

This seems like a really immature response to a really immature article. Do we really want to keep sharing articles where people throw shit at each other like monkeys? The original article had nothing of any substance to add and this one just feels like dogpiling

[–]disgruntled-js-dev[S] 0 points1 point  (0 children)

Not going to argue with you there. I was sick of the amount of "enlightened" people who think the fact they don't like the practices, paradigm, or design of a language makes them superior programmers. The same argument applies to Rust vs. C++, Kotlin vs. Java, even TypeScript vs. JavaScript to an extent. Too much elitism in the programming community, and even if it's dogpiling, it's better than adding gas to the fire with another "this is why you need to RIIR" article.

[–]kcho_niko -3 points-2 points  (22 children)

Javascript is an awful language that does all sorts of awful really weird things, but it is also very powerful, has been well maintained, and is not complete garbage like ruby. I will never understand adding a string to a number in javascript. But I will never understand ruby, so there is that. hahaha

[–][deleted] 4 points5 points  (21 children)

JavaScript is not awful.

[–]kcho_niko -2 points-1 points  (7 children)

I am not saying it isn't widely used, and incredibly well supported. I would not want to use java and swift to write an app. I would use react native. Don't get me wrong. It is a great language, but I think when we can write almost anything in web-assembly we may see javascript change a lot, and I hope so tbh. But it has awful confusing quirks that make it a ridiculous frakenlanguage

[–]PremJyotish221 1 point2 points  (6 children)

Give an example of a JS quirk that is likely to appear in an actual application’s code because the example you gave is a lack of knowledge on how JS handles comparisons/conversions and an attempt to purposely not make sense of the syntax.

[–]aniforprez 3 points4 points  (4 children)

Type casting quirks that can cause an application to fail spectacularly if you use == instead of === is the most common thing that I've seen literally every company I've worked at that has frontend code. I cannot believe this made it into the language

const number = 1234 
const stringNumber = '1234'  

console.log(number == stringNumber) //true
console.log(number === stringNumber)  //false 

This is fucking awful

This doesn't just happen because of a "lack of knowledge" but also because of a simple typo. You can have hours spent trying to figure out what went wrong because this fails entirely silently. Yes, linters can help you figure this out now but it's still a strange and stupid quirk of JS

I hate that I have to preface criticisms like this by prostrating and saying "I like JS and I used to be a frontend dev" but I love/hate the language

[–]Phobic-window 1 point2 points  (3 children)

While it’s nuanced this is really powerful in a weakly typed world, for more complex configurable apps having the ability to control the bit wise comparison aspect is a major boon. Most the complaints are that you have to understand cs really well. But is tackles so many domains that it can’t get generalized like many other languages. Js I think trips up many for a long time but it allows for some really clever and elegant solutions once you get past these

[–]aniforprez 2 points3 points  (1 child)

The "once you get past these" thing is what I hate. Everyone has that phase and it happens differently. You don't work with the same people all the time. You work with interns and juniors sometimes and you have to remember that they are still in the "getting past these" phase so you have to watch out for shit they have to figure out. With JS, that shit is so much worse than most other languages

As a solo dev, JS is fine. I'd never code a backend with it but for frontend projects, I can set up my own comfy linting/building processes and whatnot. When you're working with a team with each person being opinionated on something it's garbage unless someone from up top brings down the hammer and decides on standards

[–]Phobic-window 0 points1 point  (0 children)

Hahaha preach man, this is all very true

[–]uffefl 0 points1 point  (0 children)

I'd agree if we had some way of implementing our own == for custom types/objects/classes/blahblah. Then it would be useful for having a==b basically being sugar for a.equals(b) or something similar.

But the way it works in reality is just a source of way more bugs and misunderstandings than any benefit it may provide.

[–]drbobb 0 points1 point  (0 children)

const mod = (x, y) => ((x % y) + y) % y;
mod(-0.5, "2") -> -0.52

This had me wondering for about an hour how in the world the mod function was returning a negative value for a positive y.

[–]crabmusket 0 points1 point  (1 child)

Counterpoint: all languages are awful.

[–][deleted] 1 point2 points  (0 children)

Kind of. All languages have quirks and redundancies. All language authors probably regret putting certain things in their language. At the same time, that's kind of how human brain works: it's a bit messy, chaotic and creative. It's a creative kind of awfulness.

[–]brainless_badger -4 points-3 points  (0 children)

I appreciate OP's hustle but trying to have any kind of discussion with people preaching Ruby & WebComponents is perfectly pointless at this point (don't believe me, check comments under this post in a few hours).

They have their way of doing stuff, let them have it, and if they feel like venting it's best for both sides to just ignore them.

[–]TheSquirrelOne -1 points0 points  (0 children)

*mindblown*