Live data from Hacker News

JavaScript at 20

brendaneich.github.io

131–140 of 327 posts

Re: JavaScript at 20

#131

"Haters gonna hate." Anyone claiming that JS is the "worst thing to happen to the web" and/or that some other language would miraculously solve all of the problems present in JS should do the following, "Go create it." Don't whine about the barriers and how a new language would never be adopted because "JS is already everywhere." There are plenty of people already trying to solve this problem by actively doing someth…

I don't believe that someone needs to have a solution in order to observe that there is a problem.

The resources available to an individual for creating and reasoning are finite, and as long as one is able to give good reasons why they know that there is a better way, "there is a problem" may still be valuable information.

Re: JavaScript at 20

#132
post #101

Earlier quoted context omitted.

There are no end of alternatives out there today, from mobile platforms to research languages exploring a myriad of aspects of computer science. Just let me know when browser vendors are going to break down the two-tiered system, and let us run the legion of alternatives alongside -- instead of under -- JavaScript. Or, they could take their own medicine, and try and write the browser in JS.

Internet Explorer had a pretty clean API for adding extra scripting languages.

Yes, the Windows Script Host. But I don't believe two languages could very effectively talk to eachother, right? Couldn't they only really interact with the native code stuff (DOM etc.), i.e. the easy part?

Re: JavaScript at 20

#133
post #122

Edit2: When do you switch off your transpiler and serve native ES6? In 2020? Original: What do you do in 2017? What if you already code in ES6 and transpile it to JS5 at the moment. Do you simply switch from serving JS5 to JS6? Older browsers (todays current browser) don't support "class", "let" and other new syntax constructs. The just fail with JS errors. Can one browse the web with IE11 and iOS 8 Safari in 2017? (…

> Polyfills can be used for pre-JS5 browsers. But can you polyfill "let" and "class" syntax keyword?

No, but you can compile ES6 code using it to ES5 code.

Re: JavaScript at 20

#134
post #121

Can someone explain the isNaN part of this slide: http://brendaneich.github.io/ModernWeb.tw-2015/#46 I would expect isNaN("LOL") to be true. Why does he put "true?!", and why does Number.isNaN("LOL") evaluate to false?

I think I can. The old isNaN() coerces to Number, and non-numeric strings become NaN in JS, e.g. +"LOL" is NaN. However, the new isNaN() just returns false if the value passed isn't of the type Number, which I guess might be useful if you're going to use isNaN() on non-Number values?

Before someone says that NaN means "not a number", technically yes it does, but it is really just a special value of the Number type.

Edit: Oh, zastavka's comment has enlightened me now. I think the reason they changed it is because now it'll check if it's NaN (return true) or anything else (return false), so it'd be like === NaN if you were able to do that. Previously it'd check if it coerces to NaN. I guess the new behaviour is more intuitive.

Re: JavaScript at 20

#135
post #121

Can someone explain the isNaN part of this slide: http://brendaneich.github.io/ModernWeb.tw-2015/#46 I would expect isNaN("LOL") to be true. Why does he put "true?!", and why does Number.isNaN("LOL") evaluate to false?

probably because NaN has a specific meaning when the value being considered is a number, which "LOL" isn't. If you're calling isNaN, it usually means you're checking explicitly for a number like 1/0, not a string. So really this is a matter of types.

Personally I don't see how this solves much, but then again I'm not a JavaScript guy.

Re: JavaScript at 20

#136
post #122

Edit2: When do you switch off your transpiler and serve native ES6? In 2020? Original: What do you do in 2017? What if you already code in ES6 and transpile it to JS5 at the moment. Do you simply switch from serving JS5 to JS6? Older browsers (todays current browser) don't support "class", "let" and other new syntax constructs. The just fail with JS errors. Can one browse the web with IE11 and iOS 8 Safari in 2017? (…

I believe something like http://sweetjs.org can polyfill "let" and "class" syntax.

Re: JavaScript at 20

#137
If you're interested in learning ES6 basics in 20 minutes, this is a great starting point: https://github.com/lukehoban/es6features

Check out this repo, if you have a "little more" free time: https://github.com/ericdouglas/ES6-Learning

To be honest, I used to dislike JS not so long ago - it was hard to debug, I had to use strange conventions to write OO code etc. But after learning more about the ES6, react/flux, node, Flow etc. I can honestly say that I really, really like JS. I think that I had negative feelings towards JS because I was using it "the old way" and completely ignored the language improvements & community/ecosystem that grew aroud it. But I learned my lesson :).

Re: JavaScript at 20

#138
post #125

"Date hand-ported (h/t ksmith@netscape.com) from java.util.Date" I knew it!! The Date class is/was the worst thing about the Java library. It has confused a generation of programmers about dates and time zones. The main problem is that it's not a date, it's a time stamp.

[deleted]

> In Java you legitimately have alternatives, since the alternatives can make the same raw OS calls that the java.util.Date library does. Not so in JS. So instead we HAVE to work with Date and work around its many warts.

Uh, what? Yes, JavaScript's Date is the only way to get at that browser/OS stuff. So an alternative will use Date underneath to obtain that information. That doesn't mean the end-user has to work with Date.

Re: JavaScript at 20

#139
post #122

Edit2: When do you switch off your transpiler and serve native ES6? In 2020? Original: What do you do in 2017? What if you already code in ES6 and transpile it to JS5 at the moment. Do you simply switch from serving JS5 to JS6? Older browsers (todays current browser) don't support "class", "let" and other new syntax constructs. The just fail with JS errors. Can one browse the web with IE11 and iOS 8 Safari in 2017? (…

> Polyfills can be used for pre-JS5 browsers. But can you polyfill "let" and "class" syntax keyword? No, but you can compile ES6 code using it to ES5 code.

Is the only solution to transpile ES6 to ES5 until 2025 or whenever IE11, Safari 7 and all current Smart TVs and Cars and what not have their end-of-life and simply vanish? Let's remember the problems with Internet Explorer 6 and its long actual lifetime. At the moment IE8 (WinXP), IE11 (Win8) as well as various other browsers will never receive an update on their platforms.
Post reply on HN