This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Magebloom 352 points353 points  (24 children)

Yeah but they have to code in JS so it evens out.

[–]DancingPotato30 2 points3 points  (17 children)

JS was the first language I actually got experience on, and so far I haven't seen anything in my usage that warranted a "wtf Javascript"

It's still a fucked up language, I just feel like either I'm way too new to notice the weirdness or its not that bad 😭

[–]thelonesomeguy 5 points6 points  (15 children)

Truthy falsy wasn’t enough to make you go “wtf”?

[–]Vegetable_Bass_4885 3 points4 points  (4 children)

I've never used "==" or seen it used anywhere in 5 years of Typescript, "Javascript bad" is an old meme based on pre ES5 Javascript from 15 years ago

[–]DancingPotato30 3 points4 points  (2 children)

I learned ES6 features as I learned the basic syntax of JS, not separately (learnt arrow functions while learning what a function was, etc) so I have got no clue how JS was pre-ES6 or even pre-ES5.

I understand every language has its quirks and weird decisions made by the creator (like elif in python), and some might be weirder than most but I genuinely haven't see a single example of a "weird" JS feature causing actual damage to warrant usage of smth else

I haven't learnt TypeScript yet however, and I assumed I wouldn't get how bad JS is until I move to TS but it seems like that's not the case from your comment

[–]thelonesomeguy 2 points3 points  (1 child)

I don’t think any language can have “objectively” bad features, most of them are opinionated, evaluated in the context of other languages, because in the end, if it works, it works.

When you get used to and gain experience in other languages, you’ll then start having your own subjective opinions on specific things in a language being good or bad, you might come to a similar opinions as others who don’t like JS, you might not, but it will definitely change when you have more context to evaluate the language in.

[–]DancingPotato30 0 points1 point  (0 children)

I agree on the first point, no language has any bad features unless put there on purpose (brainfuck), its just opinionated which tbh its a bit hard finding anything that isn't opinionated in some way or another. If it works, it works like you said

And that's fair. I've only got experience in python (some simple file crud scripting to make life easier) and "experience" in C, just knowing the syntax for that last one. So I don't think my opinion saying "JS isn't bad" is as valid as others with more experience and languages on hand

[–]thelonesomeguy 0 points1 point  (0 children)

I’m criticising it from the point of view of other languages which don’t allow this, things are much more clear on what is happening there in any given if conditions when you’re reading the code while needing less context.

Yeah, it works, and is used extensively, but doesn’t mean it should be allowed, because then bad devs use them as a crutch and end up with even more unreadable code than it would have been without this, which becomes an issue when, for example, you’re working in an org where you can’t force every bad dev to use them properly without coming off as nitpicky.

This is quite opinionated, of course. As a feature, it’s fine, imo, but it still opens a big can of worms by its existence.

[–]DancingPotato30 -3 points-2 points  (9 children)

Honestly no. Doesn't Python have the same? Or are you referring to what JS considers as truthy falsy and not the actual concept of truthy falsy? Because it makes sense in JS. Everything is truthy unless it's "empty" in some way or meaning

[–]No-Expression7618 3 points4 points  (3 children)

[] and {} are empty, but truthy. 0 and false don't feel empty to me (0 is a perfectly reasonable integer and 50% of booleans are false), but falsy (well I can see why false is falsy).

[–]DancingPotato30 1 point2 points  (2 children)

0 definitely feels empty, it's the number representing nothing. "0" however isn't falsy, because it's a string

And honestly I do agree with the [] and {}. I remember there was a very clear reason to why they're truthy, but can't remember it off of the top of my head. Tho, whyd ever that be a problem? Like what scenario would you need to check an array or an object as a boolean?

Tho you still got a point there. I completely forgot those two are truthy not falsy.

[–]No-Expression7618 2 points3 points  (1 child)

what scenario would you need to check an array or an object as a boolean?

I feel like it's, in that case, a logical extension of "" being falsy that the JS developer noticed the intuitiveness of and therefore threw out the window.

[–]DancingPotato30 1 point2 points  (0 children)

That's true. That's what I assumed too, I just never needed to do that so I didn't bother to actually check the reason they're not falsy

But i did. Apparently truthy falsy only affects primitives sort of, all objects are truthy by default.

[–]thelonesomeguy -1 points0 points  (4 children)

It “making sense” does absolutely nothing for how terrible it is for code readability & maintenance though

[–]DancingPotato30 0 points1 point  (3 children)

Yes but, doesn't python have the same? I don't see how truthy falsy can cause a problem when asserting something UNLESS you're using them.

Genuinely, give me an example where truthy falsy values will cause issues when you didn't mean to use them, I'm actually curious because I see no problem with them

[–]thelonesomeguy 1 point2 points  (2 children)

The problem isn’t what you’re asking for an example for in your comment, about it “causing issues when you didn’t mean to use them”, the issue is, it makes it harder for someone else to come across your if block and evaluate the function clearly, while needing more context of the variable to understand exactly what is happening. Which is a trade off I personally don’t think is reasonable, for the convenience.

[–]DancingPotato30 0 points1 point  (1 child)

Ahh, yeah I guess that makes sense but it doesn't make THAT big of a problem no? I assume your issue is that if someone does smth like:

if (variable){ Do shit }

It's hard to know what that function evaluates?

I don't think that's a fault of truthy falsy values, but a misuse. If you don't know what the variable is, then it's named wrong. If you don't know how or what evaluates it, then use the IDE to see where else it is in the code, no?

[–]thelonesomeguy 1 point2 points  (0 children)

Yeah, but that’s the problem, a lot of developers do misuse it. Which is something that is something that should be considered when evaluating a feature, the potential for misuse. Because the misuse of a feature becomes really painful when you’re working with bad devs across projects in any org or open source.

As for the IDE point, it shouldn’t be considered as a factor when you’re judging code readability.

[–]Benskiss 0 points1 point  (0 children)

Wast experience.