Live data from Hacker News

JavaScript. The Core: 2nd Edition

dmitrysoshnikov.com

41–50 of 96 posts

Re: JavaScript. The Core: 2nd Edition

#41
post #9

This is a very solid foundation to work with, for anyone who might have struggled with the contexts and how arrow functions, local variables, thises (hah) and prototypes fit into the bigger picture. It also clearly shows that Javascript is not the mess that it looks like from a beginner's perspective. Yes, anyone can create a 15-20 min video about how == and === can mess up stuff, how you cant just pass around a func…

I wonder why nobody has created a version of JavaScript that just throws exceptions for all the WTF cases? That is, it would basically be a mode like 'use strict-at-runtime'; .

This would be incompatible, but it would be a useful development aid. Surely most frameworks like React and Angular avoid these corners of the language, and they could be trivially modified to run on such an interpreter? It would improve their code quality.

I know this would be a large amount of work, but it doesn't seem that huge compared to all the other JavaScript infrastructure out there (parsers, transpilers, etc.). There are more independent JavaScript interpreters written than interpreters of any other language, AFAICT. At least before ES6, writing a JS interpreter was a one-talented-person project, not a huge team project like a JIT.

I guess one reason is that the DOM and node.js bindings aren't easy to reproduce. But I would think people still run their unit tests in a limited environment and it would be useful for some code. It could even be based on narcissus -- JavaScript in JavaScript?

Re: JavaScript. The Core: 2nd Edition

#42
post #41
post #9

This is a very solid foundation to work with, for anyone who might have struggled with the contexts and how arrow functions, local variables, thises (hah) and prototypes fit into the bigger picture. It also clearly shows that Javascript is not the mess that it looks like from a beginner's perspective. Yes, anyone can create a 15-20 min video about how == and === can mess up stuff, how you cant just pass around a func…

I wonder why nobody has created a version of JavaScript that just throws exceptions for all the WTF cases? That is, it would basically be a mode like 'use strict-at-runtime'; . This would be incompatible, but it would be a useful development aid. Surely most frameworks like React and Angular avoid these corners of the language, and they could be trivially modified to run on such an interpreter? It would improve their…

I think the most common way to accomplish that idea is to run a linter. Linters should be able to statically catch most of the unsafe operations you're probably describing.

Re: JavaScript. The Core: 2nd Edition

#43
post #13

As much as I like dmitrysoshnikov's content, I think it can't compete with You Don't Know JS series.

Do you care to elaborate? What do you see missing, what should be improved?

I mean downvoters didn't care to elaborate, so why should I do that.

Re: JavaScript. The Core: 2nd Edition

#44
post #13

Earlier quoted context omitted.

Do you care to elaborate? What do you see missing, what should be improved?

I mean downvoters didn't care to elaborate, so why should I do that.

Because saying "X is worse than Y" is not useful unless you provide reasons as to why you believe that.

Imagine being someone reading your post. What are they to think? "Oh, this person says X is worse than Y -- I'll go ahead and take their word for it, despite no justification"? That's them buying into an appeal to your authority.

Now imagine if you'd actually provided reasoning. "Oh, this person says X is worse than Y because Z -- Z is a good point, therefore this is useful!" How different.

Providing baseless opinions is not useful, which is why you got downvoted; and incidentally, it's the exact same reason why you should "care to elaborate".

Re: JavaScript. The Core: 2nd Edition

#45
post #30

Earlier quoted context omitted.

>I fail to get the flak that javascript faces ! I personally don't like that Javascript has had to have a ton of work done on it to get it to the point of other languages that were better at their first release. It was just a ton of time spent on something that was weak to begin with. If Javascript were better at the beginning, and this same effort was spent on it, it probably would be ruling the world, front and bac…

Something wasn’t done right, right off the bat, thats grounds for not liking it, sure. But to dismiss it as immature despite it overcoming most (not all) of those flaws seems unfair. I like it, some dont. I get it. All I ask is to not dismiss it. Folks new to programming find these edge cases as a reason to not learn it. That irks me.

It has not overcome any of the flaws, we have just learned to work around them. They are still there and can bite you.

Some of us value our time and would like to improve our discipline. In other fields it's called being professional. It's a shame we care so little about it.

Re: JavaScript. The Core: 2nd Edition

#46
post #30

Earlier quoted context omitted.

Something wasn’t done right, right off the bat, thats grounds for not liking it, sure. But to dismiss it as immature despite it overcoming most (not all) of those flaws seems unfair. I like it, some dont. I get it. All I ask is to not dismiss it. Folks new to programming find these edge cases as a reason to not learn it. That irks me.

It has not overcome any of the flaws, we have just learned to work around them. They are still there and can bite you. Some of us value our time and would like to improve our discipline. In other fields it's called being professional. It's a shame we care so little about it.

You've got me thinking now. Can you/anyone give me 3 solid cases where the flaw was in javascript and not the programmers understanding of the language ? I can't. (Not at the moment at least). Most of the times I got things wrong it was my understanding of how js works that was at fault.

Re: JavaScript. The Core: 2nd Edition

#47
post #42
post #41

Earlier quoted context omitted.

I wonder why nobody has created a version of JavaScript that just throws exceptions for all the WTF cases? That is, it would basically be a mode like 'use strict-at-runtime'; . This would be incompatible, but it would be a useful development aid. Surely most frameworks like React and Angular avoid these corners of the language, and they could be trivially modified to run on such an interpreter? It would improve their…

I think the most common way to accomplish that idea is to run a linter. Linters should be able to statically catch most of the unsafe operations you're probably describing.

Yeah, that's probably true -- linters do an OK job at attacking this problem.

But then there are still people complaining about JS semantics... I think there is a gulf between what tools professional JS programmers use, and what tools X programmers use when they write JavaScript, where X != JavaScript.

Re: JavaScript. The Core: 2nd Edition

#48
Does JavaScript have some special definitions for delegation and dynamic dispatch? The definitions provided in the article appear to particularly relate them to inheritance - which is not the traditional definition applied to either term in object-orientation?

Re: JavaScript. The Core: 2nd Edition

#49
post #32
post #22

Earlier quoted context omitted.

I fail to get the flak that javascript faces ! Coming from java it was a breath of fresh air. This was the car that let me drive without a seatbelt when i wanted, let the doors be open if i wanted, stepping on the gas accelerated without fail and the brakes functioned fine, i could change the gearbox orientation, choose which side the steering wheel i wanted to be in general let me do what i wanted to without getting…

It gets flak for the same reason php gets flak. They both more or less accidentally became popular. None of them were very well designed. They both lacked type safety. Unlike php though javascript became not only popular but it actually ended up being the only alternative.

I want my programming language to be predictable and easy to use. I'll "well design" my code, thats what I get paid to do. Type safety, yeah, never bothered me much anyway.

I agree, it sucks that js the only alternative in some cases. But hey, imagine if Java was the only alternative!

Re: JavaScript. The Core: 2nd Edition

#50
post #24

Earlier quoted context omitted.

>It also clearly shows that Javascript is not the mess that it looks like from a beginner's perspective. Let's agree to disagree. I suspect your bar is too low. You could have made that argument for early versions of PHP (i.e. before 5)

Full disclosure: I've been writing JS for pretty much as long as I can remember and currently do it professionally, and I'm speaking mostly to my personal experience with having used both of them personally and professionally. The question is how often you get bitten in the ass by it, specifically as a professional rather than a beginner, and in my experience it's been very little with Javascript but quite often with…

I think this is a fair way to read it. I have made my bones on ripping PHP and JS up and down, left and right; I didn't trust them as far as I can throw them. SPAs sucked because JavaScript sucked, and PHP sucks because its existence has put more frustrating work on my plate than anything else.

I still feel that way about PHP. ES6 and ES2017 changed my mind about JS, though, along with the eventual maturity of the stack: babel, eslint, good testing in Jest. Everything I always hated about JS totally does still exist in its bowels, that's never going to change. But the guard rails have gotten very good and more modern flavors of JavaScript have added a lot of stuff that makes life easier (strongly opaque modules, async/await, and arrow functions are probably my top three). The build ecosystem is still bonkers, yeah--but there's a baseline level of sanity that I can work with. I know there are still land mines in there, but they're flagged and mostly out of the way.

On the other hand, any time I'm stuck back in PHP, it is fundamentally the same stuff that has been sticking needles in me since I was in high school. Yeah, the language has advanced--but I'm not sure the general practice has advanced all that much, and the parts of the language that are problematic are right up in your face.

Post reply on HN