427 points · by kolodny · 11y ago · 315 comments
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 :).
Will take you a weekend to read at the max and it's well worth the effort.
[1] https://promisesaplus.com/
[2] https://www.youtube.com/watch?v=Pd6Ub7Ju2RM
[3] https://medium.com/javascript-scene/learn-javascript-b631a4a...
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.
Right now, the world only has 3.5 base browser engines. Those browser developers have no interest in adding a new standard language like Python, even though more people prefer that to Javascript.
So, if you were to develop a new browser language, you need to build a new browser from scratch, and then move a billion people to it.
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.
The complexity of doing that would be needlessly high compared to just improving JavaScript. Having to integrate a C++ DOM with a JS DOM is hard enough. Think about how you handle cross-language cycles…
> Or, they could take their own medicine, and try and write the browser in JS.
You mean like Firefox?
This is a very strange comment, especially coming from you.
Everybody knows that the bulk of Firefox is not written in JS. You personally have spent years of your life working on a new programming language precisely because JS is not suitable for writing a web browser.
I'll take your position on JS seriously when you abandon Rust and begin writing the bulk of Firefox in JS.
In browsers, the OSes of the web, nope, just a bad language designed in 10 days that resists all attempts to make it not bad.
It doesn't really matter if you like javascript, there's so many people who don't.
Why do you get to dictate whether we can or can't develop on the web? You leave us with a horrible choice, use what we consider to be one of the worst modern languages, or not develop. Why do you get to make our professional lives miserable?
However, cries of foul "vendor lockin" erupted. So I dunno what to tell you, man.
Just let me know when Intel, AMD and VIA are going to break down the two-tiered system, and let us run the legion of alternatives alongside -- instead of under -- x86 assembly language.
> What does that even mean? It's nonsensical.
What it means is that the situation with browsers is not much different from the situation on native platforms. CPUs support one language, the browser supports one language. And yet I don't see anyone complain about CPUs only supporting one language, because you can compile anything to it. The same is true for JS, so why do people complain?
>Underneath x86 assembly language is the processor microcode, and underneath that is the actual hardware, and the two are intricately intertwined.
Underneath JavaScript is native code produced by a JIT compiler. It's not super-intricately intertwined with the underlying OS and hardware, but it's not incredibly abstract either.
>You can replace the hardware; C compiles, for example, to everything from ARM to x86 to Atmel's AVR harvard architecture.
>You can replace the language; everything from C to Swift to Rust can target almost any processor architecture, without externally enforced limitations.
You can also retarget stuff compiling to JS to compile to something else, like Lua.
>Microsoft can ship the CLR for ARM, x86, PowerPC.
> You can't replace JavaScript. Everything must pass through a JS JIT, and the JS JIT is written using functionality that 1) it requires, and 2) is totally unavailable to you.
Yes, everything must pass through a JS JIT... you don't have access to the underlying native code. But everything on a CPU must pass through its microcode translator. That uses functionality it requires which is unavailable to you.
> Microsoft can't ship a fully functioning CLR for JS.
This simply isn't true. You can write a CLR for JS that compiles to something like asm.js at runtime. Bytecode VMs with JIT compilation have been written in JS before, see Emterpreter for instance.
Like Blink-in-JavaScript[0] ? ;)
That's a legitimate complaint.
There's so much inertia that without the backing of the major browser manufacturers, any effort to introduce a change is doomed to obscurity.
People are allowed to complain, even while not being able or willing to work on a solution. We used to do that with DOS all the time.
I like Javascript, in many ways it's a neat little language, but manipulating the small little ad-hoc data structures (arrays and hashes, and combinations of them) that seems to be half of most programming tasks is definitely a step backwards compared to Python.
I'm a Python fan but I can't disagree more on that point. Python has terrible lambdas, and poor idioms when working with collections (list iteration over chainable/fluid interfaces).
Underscore.js, which at this point stands for 'idiomatic JS for collections', and the ES5 methods on arrays (filter/map) which are largely supported now provide a better way to handle arrays & hashes than idiomatic Python. With ES6 fat-arrow functions it's even better.
It's one of Python's biggest weaknesses when compared to other dynamic languages IMO -- that the idiomatic way to deal with 'collections' is not a chainable/fluid pattern, but instead to do multiple list comprehensions, or use the ugly filter-plus-lambda patterns which compose badly.
Double evens in a list:
ES6:
[1, 2, 3]
.filter(x => x % 2 == 0)
.map(x => x * 2)
ES5: [1, 2, 3]
.filter(function(x) { return x % 2 == 0 })
.map(function(x) { return x * 2 })
Python: map(lambda x: x * 2,
filter(lambda x: x % 2 == 0, [1, 2, 3]))
# or
evens = [x for x in [1, 2, 3] if x % 2 == 0]
[x*2 for x in evens]
The ES6 & ES5 JS examples are both clearly superior syntax IMO. More readable and the anonymous functions support multi-line so extend to more use-cases.EDIT: Removed the word 'objective' because I'm talking syntax.
map(lambda x: x * 2,
filter(lambda x: x % 2 == 0, [1, 2, 3]))
But the list comprehension version is just completely wrong: [x*2 for x in [1, 2, 3] if x % 2 == 0]
Which, in our subjective world, is cleaner than the ES5 version and almost as clean as the ES6 version.This sentence reveals a deep misunderstand of either what "objectively" means.
(FWIW, I prefer the ES5/ES6 syntax to Python here, as well; I just don't mistake that preference for something other than subjective.)
'The depths to which JavaScript sucks are well-documented and well-understood.'
Same applies to Haskell. As with any language, humility please.
This would require people like Eich to entertain alternatives to his diseased progeny.
-Bob Burns
If one believes that "JS is the worst thing to happen to the web" and that "some other language would miraculously solve all of the problems" then going off into the wilderness to "create" is almost certainly a dead-end endeavour. A language is only one component of what's needed to replace JS - there's also winning over 4 major browser vendors who've dumped no trivial quantities of money, time, and PhDs into polishing this particular turd.[0] Then there's the standardisation peeps and so on. It's not so much a technical challenge - many existing languages could add support for DOM APIs and become an in-browser candidate relatively trivially - but a political one. And when was the last time you heard of someone solving a political problem by saying "hey guys, I've got a great idea here"?
Some not-absurd propositions:
1. "The finance system is shit"
2. "Modern government is shit"
3. "JS is shit"
All 3 of these have many potential non-shit replacements - but things never change. Why? Because barriers are very, very real. These things could only ever fall to the most expertly executed, well resourced, and lucky of targeted attacks.The only viable strategy for the average "hater" (whose "hate", incidentally, is emphatically not invalidated by his lack of perfect solution) is to try to affect top-down change. Now, no one person is likely to achieve this - even exceptional people have a fearsome challenge when faced with groupthink (Galileo, anyone?)
So what is in the "haters" toolbox? Well, seeing as web standards authorities are run like district councils in the 1980's (go try to find out how to make your view officially known on an ECMAScript draft), us in the peasantry have little but our ability to create and maintain a murmur - and occasional scream - of discontent which hopefully, one day, might have some psychological effect on those who do hold the power, because lord knows it's not us users. You may recognise this particular strategy from historical great hits such as "representative" "democracy" and friends where it has been, on the whole, a slow, inefficient, wasteful, but occasionally effective way of going about things.
So my well thought-out and actionable strategy is to ignore this advice and continue to grumble - and, if you can manage it, try to be just a little bit louder than last time: shit adds up at scale.
[0]: Mr Eich told me himself that they're too invested in JS, see https://news.ycombinator.com/item?id=9264531"...but things never change." I think you're wrong. Things do change. They just don't change at a pace that is fast enough and obvious enough for someone who feels passionate about an issue (Gay rights, Women's rights, Black's rights, all civil rights crusades, anyone?) And it often takes a long time for people to realize they need to be actively engaged instead of complaining from the sidelines before any change occurs.
By all means, continue to grumble on comment boards, just don't act surprised or upset when the direction of the thing you were grumbling about doesn't go the way you want it to.
I don't want a web where all my software and data is owned by other people who don't have my best interests in mind. JavaScript allows "free" websites to replace programs running on my machine which is fundamentally opposed to my goals. I don't want all the power that computers have brought to humanity to be concentrated in the hands of corporations, I want it to be free for anyone to use. I'm glad JavaScript is shitty and I wish it were shittier, because that would slow the growth of corporate control over our capabilities and data.
Conversely, I can write open-source javascript that does something useful for you, that does not mine your data or do anything of that sort.
I don't see how this relates to javascript.
I would venture that I could solve all the problems you would solve with open source JavaScript with another programming language, because almost no program actually needs to be a web application.
The second thing I tried was clicking the blue text, which brought me to Brendan Eich's Twitter page. And then Twitter did what Twitter does, and popped up a sign up/log in dialog in front of the content so I can't actually read any of it.
Pressing the right arrow key was my third guess.
I want to call it a bad user experience, but maybe it's actually a clever way of limiting your audience to web developers.
EDIT: Blockscope... what? More than a few of these changes point to JS being a functional version of PHP, but doesn't blockscope just fundamentally change the language?
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.
https://api.dartlang.org/apidocs/channels/stable/dartdoc-vie...
or
how Java 8 finally fixed DateTime inspired by Joda Time (http://www.joda.org/joda-time/): http://www.oracle.com/technetwork/articles/java/jf14-date-ti...
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.
I've used quite a few DateTime libraries extensively, I'm yet to see someone "better" the DateTime .Net class. It "just works" and has few to no "gotchas."
You can paper over syntactic annoyances and semantic confusion with a mental mind-shift, and once they do, they become barriers to entry for your competitors. You can't paper over an inability to deploy your software in front of a customer. From the POV of "what's a showstopper, vs. what's an annoyance", ubiquity is the most important feature a language can have.
It has just as much to do with the tooling, community, support and adoption - again, just like natural languages.
I think the ubiquitous languages ARE the best languages because the purpose of any language, natural, computer or otherwise is to transmit information and meaning. And the ubiquitous ones are, by definition, best suited for that.
Seriously. Even if there was the goalposts would keep moving anyway as things like functional programming get more popular.
My ideal language is one that I can use as often as possible in as many different contexts as possible. JavaScript is alright for that.
You have a real choice of language! You can use any language you like, and compile to JS.
Or are you going to complain that x86 CPUs provide no "real choice of language", offering only x86 assembly?
There are no optimizations missing from x86 so complaining about it is pointless.
Especially given the improvements in sandboxing having a more powerful underlying language could improve things (note that this doesn't mean it needs access to the API of the underlying OS, which is where Java got itself in trouble).
> There are no optimizations missing from x86 so complaining about it is pointless.
Not true. x86 is a high-level language and modern x86 CPUs do a lot of fancy stuff behind-the-scenes to try and make code run better.
To me, JS is one of the best languages out there. It's expressive, functional and versatile.
This isn't meant as a "JavaScript sucks" type of comment, but as a "being good at presenting your work is really important" type of comment. Too many really strong engineers aren't good at selling their work, so we end up with JavaScript.
2. O please. Stop with this arrogance. Even if you didn't mean it, it totally comes off as "JS sucks" comment. JS as a language has a huge value in it being a first mover and generating network effect. Would you rather have that we use Java VM on browsers? Or would you rather have 12 different languages used in differently, implemented differently in 12 different browsers? To make matters worse, would you like browsers to change its languages based on what's considered a flavor of the week?
JS succeeded in spite of all my "salesmanship", because it was fitter in its basics and of course its place of priority.
The joke in those slides was how I went from my before-Netscape health (the picture of me doing a back handspring was from 1993; I joined Netscape in April 1995) to the after-those-ten-days-in-May-1995 state (looking like Ash from Evil Dead 3, with chainsaw for hand).
From 1992 to 1995 I worked for MicroUnity. No JavaScript there! It was not even a gleam in my eye, although I did write a language processor for editing MPEG-2 streams.
So I indeed created JS in a mad rush to get it into Netscape 2, along with other things Netscape tried as part of a platform play against Microsoft.
If I had not rushed, I would have missed not only Netscape 2, but also Netscape 3. Netscape 3 was supposed to be version 2.1, a minor release, until a company Netscape had acquired was given the browser and screwed up their release schedule so badly that it slipped into 1997 and became Netscape 4.
In 1998 or even 1997 it would have been too late to ship JS and have it make a de-facto standard. MS had already shipped VBScript as a me-too, and if they did not have JS to imitate, it would have been even more Microsoftian.
VBScript was the alternative to the JS rush job, in my settled view. I don't write this out of pride, joy, or defensiveness. I simply think it's the likeliest alternative outcome.
(Updated to correct Netscape 4 date per http://en.wikipedia.org/wiki/Netscape_Communicator to June 1997. It was so buggy that a series of firedrill releases were required to get it into barely usable shape by '98, which is what burned that year into my memory.)
Talk about dystopian alternative universes.
Also, I think that the number of problems in JS normalized by the time it took to make the first version (and that time limit was due to a deadline that the creator did not choose) is very likely smaller than in many, many other languages, if not all the remotely popular ones.
Are numbers real? Would you say we discovered them, or invented them? Do ideas exist even if you haven't thought of them yet? If so then they are discoveries.
A thing happens because of what happened before it, and before that thing another thing happened etc.
It just so happens that the prototype approach didn't catch on early enough. Developers are now just really set in their ways and are rather pretend that JavaScript is not a true OO language.
I feel that the addition of a 'class' concept to ES6 adds no value to the language itself, but I think it was probably a good decision anyway - Because JavaScript is more flexible and adaptable than the minds of most people - It might as well use that to its advantage.
Unlike the stubborn developers who refuse to learn about prototype inheritance, JavaScript is capable of change.
That's pretty impressive actually, but I don't currently have access to any other computers to read it on, so it's also quite bothersome.
Does anyone have an alternative URL with the content, but without the slideshow or whatever it is? I'm presuming it's some JavaScript that is causing the crash.
Yes, I appreciate the irony and no, I'm not trolling. I really want to read this!
I think the web would be a lot better if we just ran lisp in the browser. Heck, I think lisp is pretty much the answer to all our problems. But nobody ever asked me.
As someone who was developing for the web in the (late) 90s, using web browsers and java as a cross-platform UI for educational software (mac and windows!) who tried to get java applets to communicate with each other (possible but difficult, and I ended up running a local java application that the applets RPCd to), I can say this with distinct clarity: the DOM and current (modern ES6) javascript system are pretty great. Sure, they could be better in some ways, but I don't trust Joe Programmer (just for example here) to understand re-entrant code well enough to write stuff that actually works in a multi-threaded environment, so single-thread event-driven is great.
People complain about this binding and so forth, but it provides a great borrowing / mixin mechanism to the language that is just flat out impossible in other languages. The prototype inheritance system is funky, but es6 classes mean you don't need to worry about it. If you want to, you can do some pretty rad metaprogramming with it, though.
Type coercion is kind of a pain, and frankly I'd love to be able to override operators (writing === semantics for objects over and over is kind of a PITA). But seriously, Javascript is pretty great. I pass around functions, chain together stuff with functional-based approaches (front-to-back no less), and can do all sorts of hip kinds of programming with it.
Maybe if we had some truly-different language driving the web, things'd be different, but don't complain about javascript and just put forward python. Put something like haskell or smalltalk on the block. Let's go big with the radical differences. I mean, c-ish languages are c-ish languages. I only wish CSS was as nice as Javascript. If I had my druthers, that's where we'd be focusing; that and namespaces within the DOM (hello, shadow DOM!)
Okay, longpost over. And late no less - serves me right for working all day instead of reading HN. Writing JS no less.
When I think of generators and string templates, Python is not one of the first three languages I think of.
ES6 is awesome and there are so many good things happening in it. I was always a little irked that ES4 (ActionScript 3 was built on it) that had some of these elements was nixed for ES5 like typing, extending and cleaner events.
Great overview and I picked up a few things I have missed in js advancements like string handling changes (startsWith, endsWith, trim), templating with `, multiline strings!, extend, math functions, arrow, default/rest params, octal/binary literals and tons more. Many of these are probably in everyone's js libs but nice to have them standard.
I am most excited for asm.js of all due to the WebGL and gaming/app performance impact that will make when fully integrated in all browsers this year. asm.js and WebGL gaming is already giving benefit to performance in Javscript and added typed arrays to ES6.
Also in his 90's TV pic, how could you forget Seinfeld?
But could you please fix the damn boolean logic? And while at it, get rid of most implicit conversions.
Or forget all those features and bake in a macro system, so that we can fix anything without having to wait for the next ES[N] standard to get adopted.
Last time I checked, !, && and || worked like they do in every other language.
> And while at it, get rid of most implicit conversions.
If you get rid of them JS ceases to be JS because all JS code ever written stops working, rendering the language about as useful as something I suddenly decide to create myself in 10 days.
Use TypeScript or similar if the implicit conversions bother you. You don't need to write JS directly.
> Or forget all those features and bake in a macro system, so that we can fix anything without having to wait for the next ES[N] standard to get adopted.
This was mentioned in the slides. Did you read them?
Brendan's talked about adding a macro system. I'm not sure if a macro system could really let you redefine everything that's built in though...
edit: Sounds like I'm behind the times; found out about sweet.js (http://sweetjs.org/).
Actually "use strict" actually makes JS an almost good language as mistakes are immediately flagged rather than "working anyway." But strict mode doesn't go nearly far enough in my opinion.
I will say for backwards compatibility you're always going to have to write "===" the only thing a flag would do is break "==" on purpose.
It does those things poorly, and at great expense.
Eich did one thing, in 10 days, that was market positioned such that it became ubiquitous, and he's been banging that drum ever since -- to everyone's detriment, given how much power over technical direction he wielded at Mozilla, and how much impact Mozilla had on the web pre-Chrome.
However, even if we talk about market adoption; how is Firefox OS holding up against iOS, Android, and Windows?
> What part of that statement is incorrect?
"Always bet on JS" from Brendan Eich really meant, for 16 years, starting in 1998 and during the time that Firefox was most influential over the future of the web: "I'm never going to bet on anything other than JS".
It's a uselessly self-fulfilling declaration when its stated by a (now former) browser vendor executive.
The point is that if JS couldn't do these things, it would be eclipsed by a competitor. It instead grew the ability to do those things, and its competitors never gained widespread adoption.
> However, even if we talk about market adoption; how is Firefox OS holding up against iOS, Android, and Windows?
In terms of languages on the Web, JavaScript has always won. It's clear at this point that the Web isn't going anywhere, even though mobile apps are important.
Oh no, I've been caught, called out on my Throne of Skulls on my Skull Island again! Yes, I had so much power over all the people working on Mozilla, I clouded all their minds with my superpowers.
And post-Chrome, I still do, since apparently in spite of Chrome, your hero, villainous-me managed to kill Dart as a 2nd VM-based language in browsers -- even in Chrome. Mwahahahah!
I had the... experience of working next to Brendan Eich for a while. His Throne of Skulls is no joke and I have no idea how it got past either HR or the ergonomics coach. I kept cutting myself on the damn thing when I'd bump against it, had to keep a first aid kit at my desk. We didn't even know where the skulls came from either, but more kept appearing mysteriously each day.
The laugh was annoying too. I'd be sitting there trying to work on the monolith of doom (which was actually the name for multiple technologies, but no one could decide which was doomier so we just called them all that) and all of the sudden, it's evil laughter time. Nothing breaks concentrating on code like a roar of pure malevolent guffawing. I'm sure many engineers at startups can sympathize.
Much like the rest of this comment thread, I have no idea how this much of the web happened around this man.
-- Web Henchman #1982587
Does it? So far it seems to be remarkably successful at these things.
Mark Dalgleish's bespoke framework is tiny. The images are not, so maybe blame your ISP? Dunno, not guessing, but JS is last on the blame-guess list.
Also, I can open it in Lynx. The un-alt'd images mean there's a bit of inaccessible content, but it's actually more or less coherent, which might be useful to those whose machines are struggling with the content or even (potentially) to those rendering opinions on whether the web just sucks.
It only consumes a few MB RAM. But the favicon of his website is missing - that's why it looks like it loads several seconds.
Do you have any extensions installed? It took less than 2 seconds to load for me in a blank Firefox profile, which isn't particularly long for any website with a decent number of images on my connection.
My only complaint is that the animations make me seasick - I wish there were an obvious way to turn them off.
history.pushState = function (){};I also worry about the pushState function being misused to hide URLs in XSS attacks which involve query string parameters. It's clear you can also stop a user from going back from your page too, something I imagine could also be misused.
Edit: It seems to be Safari's fault, as Chrome handled it nicely.
But the ones that are good for presentations--that is to say, visual interest hooks, not the info being repeated--yeah, not great unless they include an audio track or something.
Edit: this one's somewhere in the middle.
The text version of a talk, however, can be a wondrous thing, and here's a great example: http://idlewords.com/bt14.htm
Thanks for your comment. After I read it I went back and clicked an arrow key and the cubeshow started.
Thanks javascript.
Slide-size chunks of information can be a really good format.
I would expect isNaN("LOL") to be true. Why does he put "true?!", and why does Number.isNaN("LOL") evaluate to false?
Adding a new, proper isNaN function under a new namespace (Number) lets them do that without breaking the old functionality.
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.
Personally I don't see how this solves much, but then again I'm not a JavaScript guy.
Standard NaN is even weirder: http://en.m.wikipedia.org/wiki/NaN
Serial example:
async function someAsync(list) {
let ret = [];
try {
for (let item of list) {
let res = await asyncFn(item)
ret.push(res)
}
} catch(e) { /* ignore */ }
return ret;
}
Parallel example: async function someAsync(list) {
let promises = [];
try {
for (let item of list) {
let promise = asyncFn(item)
promises.push(promise)
}
return await Promise.all(promises)
} catch(e) { /* ignore */ }
return [];
}I wonder if we'd be better off with a proper scheme in the browser in the first place...
The only real benefit I can think of from function scoping is hoisting, reliance upon which strikes me as an antipattern.
The fat arrow '=>' in ES6 adds yet another way. Personally I think the added complexity in ES6/7 mostly just add bloat and syntactic sugar rather than necessary fixes.
I mean, do we really need both let and var; function * , function and => (I suppose having to mark a function as re-entrant at least one can understand, though)?
In the presentation, it's not clear (granted without commentary) why one would ever, for new code, write:
// Interpolate expressions into a template string
var name = "Bob",
time = "today";
console.log(`Hello ${name}, how are you ${time}?`);
function dedent(strings, ...values) {
let result = '';
for (let i = 0; i < strings.length; i++) {
result += strings[i].replace(/\n\s+/g, '\n') +
values[i];
}
return result;
}
console.log(dedent `Hello ${name},
How are you ${time}?`);
And not: let name = "Bob",
time = "today";
console.log(`Hello ${name}, how are you ${time}?`);
let dedent = (strings, ...values) => { // is this valid?
let result = '';
for (let i = 0; i < strings.length; i++) {
result += strings[i].replace(/\n\s+/g, '\n') +
values[i];
}
return result;
}
console.log(dedent `Hello ${name},
How are you ${time}?`);
I understand backwards comparability, but for at least Firefox, let won't work without marking the code in question as v1.7 anyway. It might as well have been Self, Ruby or R6RS.While having as compact syntax as Smalltalk or Lisp might be going a bit far in the other direction -- I do wish they'd taken the time to simplify the language.
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? (e.g. "lifetime support" of the device)
Polyfills can be used for pre-JS5 browsers. But can you polyfill "let" and "class" syntax keyword? One can today still browse the web with IE6 and Phoenix 0.l (early Firefox), despite a few glitches and layout bugs. Many sites use polyfills like JQuery and still use JS3 functionality made popular by Crockford "JavaScript the Good Parts". JS5 added a few things that JQuery made popular.
The syntax changes between previous JS versions were smaller in comparison to ES4 and ES6 (ES4/E4X failed and was abandoned).
Edit1: I added "What if you already code in ES6 and transpile it to JS5 at the moment." as the second sentence to make it clearer. As several down voters misunderstood my serious question.
Backwards compatibility on the web has long been backwards compatibility of source. Sites written in the IE6 era and not touched since should continue to work in browsers of today (which is why things like vendor-prefixed features proved to be a poor idea and are mostly no longer created). You'll get some rendering oddities, but this is still very much true.
Sure, you can use a transpiler and serve JS5 the next ten years (2025). What do you plant to do? It seems most simply haven't thought about the problems lying ahead.
Many were against the ES4/E4X changes that e.g. Firefox supported for some time, as they would have broken backwards compatibility. ES6 breaks backwards compatibility with the new syntax keywords and there is no fallback afaik. If there is a fallback, well then everything would be fine.
Wouldn't it be better if such vendors would ship an security & ES6 syntax support update to their old browser software?
On the other side of things, though, new features that break in old browsers are added all the time. Try and run Date.now or Function.bind in old browsers and they'll immediately throw an error. It's only through polyfilling (and in some cases transpiling) that sites work in even IE8 today, and it will be the same situation in the future if a site wants to still work on an old Android or iOS device.
But yes, staying up to date as a user does depend on a newish browser being available for the platform you're running, and it would be great if old devices could continue to get updates. Really old iOS is out of luck, but Firefox supports back to Android 2.3, so users stuck there can download that browser to continue browsing the web.
Never, probably. Why would you? When most browsers support ES6 you would want to write in ES7, or 8, or TypeScript, or CoffeeScript, or — most likely — in some new exciting language that will transpile to JS.
For me at least, running a build script in order to develop is worse than simply refreshing the page.
No, but you can compile ES6 code using it to ES5 code.
if ES6 {
use "mycode_js6.js";
}
else {
use "mycode_js6_to_js5.js";
}
or something similar.Well, it depends who your target audience is. If users with old browsers don't matter, you don't need to transpile.
Today we can use native JS5 and use polyfill for JS1-3 browser. In future (e.g. 2017) one will have to rely on a transpiler or stay with JS5 for many years - right?
Honestly, much as it's a pastime to grumble about the flaws of whatever language we find ourselves using, I suspect if you could rerun history a hundred times, not more than ten of the reruns would give us a better outcome than JavaScript.
As it's just an object you can stick non-sequential-positive-integer keys on it, but that rather defeats the purpose.
Yeah, that's why it took you so long to get basic things in the language. The JS crowd is finally excited that they have these nice shiny things. Quite a few of those have been a standard part of numerous languages for so long.
"Always bet on JS" basically means this: "JS is too big, so all the fuck ups I and others made will eventually be fixed. Because nobody is going to try to bet on anything other than JS now."
It's circular, Eich.
I close with a slide containing bullet points rebutting all the dumb things said about how JS-can't-do-X, not to say how great JS is, but to show that software is hackable, and if Java, or Flash, or Dart can do X, so can JS. Evolving JS or doing something else is a matter of choice. JS's priority of place is not, it happened and it makes JS very hard to replace. But not hard to evolve.
I use a pic from one of Wesley Snipes's lesser movies, "Passenger 57", where the bad guy gets TOLD in a macho-funny scene on a plane, over an in-plane phone yet: "Always bet on black!" It has a great build-up with camera-work and music to match the delivery. But it doesn't mean anything more or less than always bet on Wesley kicking that pale-eyed, blond-haired villain's ass, because Wesley is a bad-ass and way more fit than Bruce Payne (who played the villain).
JS is way more fit than the comers whose fans spewed all those bogus detractions. Deal with it.
https://www.w3.org/community/webed/wiki/A_Short_History_of_J...
Every time these guys brag about how quickly they put together the first version I just want to say to them, "yeah, we can all tell. And every day we suffer for it."
In this talk, I couldn't decide whether his saying JS was written in ten days was a rueful admission that it's only natural for it to be a huge pile of shit, or some self-aggrandizement based on how quickly he managed to write it. I always found JS rather tasteless, so, naturally predisposed to think somewhat uncharitably of its author, I'm going to assume it's self-aggrandizement. This might be a bit rude of me, but if it's OK to rush out JS then slowly make it ever so slightly better over the next 20 years, then I think it's OK for me to form my opinions in the same manner ;)
JS happened, I made it in ten days because it wouldn't have happened otherwise. Had I thought it through, I might have insisted on more time -- but then: VBScript.
We don't get to call these shots. Taste and morality have little to do with their hitting targets (whether the ones we aimed at, or others). All the good stuff in JS came from giants on whose shoulders or heads I stood.
I'm not a nihilist or materialist, but I have to laugh after 20 years. JS was not planned out this far in advance!
Anyhoo, my sense of self does not depend on ten days in May 1995. My work on the Web, not just JS but especially on Mozilla, Firefox, and HTML5, doesn't need aggrandizement. My best work has yet to be seen. I'm not doing these talks to boast. Peace.
He is now spending a huge amount of time trying to fix his mistakes, so perhaps he suffers more than most...
Uhhh what? This is a pretty weird thing to say, also kinda messed up to reference something as a "teenage suicide"
You got it. ES6, ES7 are making JS look better and better.
While javascript has obvious flaws, nobody would ever agree on what a sane language would be.
I would also say that, personally, I think that how the DOM is implemented is itself the biggest pain point of web development, not really javascript.
Seriously, there have been a large number of compatible ECMAScript implementations, which still astounds me because that is no easy feat.
My biggest gripe would actually be CSS. I mean, wtf.
And I obviously referred to JS just passing its teenage years, which I would prefer it didn't manage to. I am one of those crazies that are implementing a desktop-like functionality app for creatives in a browser, created a car racing game in pure JS without a single 3rd party library, did computer vision in a browser via webcam etc. and every time I have to use JS/DOM/CSS it just makes me feel I need to go to Queenstown and jump off the Kawarau bridge...
Not to mention that as a Mozilla fanboy I even use bleeding edge Firefox OS on my primary business phone.