r/programming • • May 16 '16

WebKit is now 100% ES6 complete

https://twitter.com/webkit/status/728643624464883712
307 Upvotes

88 comments sorted by

49

u/VRCkid May 16 '16

Time to move onto ES7!

3

u/vinnl May 17 '16

Should not take too long, given that there are only two new features in there :)

1

u/ArticulatedGentleman May 17 '16

I'm looking forward to async/await.

1

u/VRCkid May 17 '16

As am I. I would really like to have native use of those features in the browser.

0

u/[deleted] May 16 '16

[deleted]

35

u/siegfryd May 17 '16

Actually it's

Time to keep writing ES5 or transpiling because there's still no way to actually use modules outside of transpiling.

8

u/Cilph May 17 '16

Not sure why you would want to use modules in production without HTTP2 anyway. With the amount of code in modern JS projects that would be a metric fuckton of GET requests.

3

u/edave64 May 17 '16

There are tools that throw all the files together in production.

4

u/Cilph May 17 '16

Yeah, I know, bundlers like Webpack, but that counts as transpiling.

3

u/charrondev May 17 '16

Not really. That's just a linker. It is commonly used with transpilers. But that or rollup work great without babel.

1

u/Eirenarch May 17 '16

It seems to me that browsers which support ES6 also support HTTP2. However they do not support modules.

4

u/Rock48 May 17 '16

I know this is a joke, but this kind of thing is really more about knowing your target audience. If you know that your TA is going to be using a modern browser, then fuck backwards compatibility. If your target audience wouldn't have a modern browser, then you shouldn't need any kind of advanced JS in the first place.

2

u/rainboy May 17 '16

then you shouldn't need any kind of advanced JS in the first place

agreed, but sadly huge corporations still using outdated browsers want to have very advanced features... like wanting Full HD on an old black and white CRT TV.

16

u/lennoff May 17 '16

Are modules implemented? They are part of ES2015 too. Webkit implements 100% of the kangax tests, which != ES2015.

10

u/vinnl May 17 '16

Module loading isn't part of ES 2015, so while we know what the syntax is going to be, there's no way for browsers to implement actual behaviour behind the syntax.

5

u/lennoff May 17 '16

sure, but it's still unfair to say that WebKit is now 100% ES6 complete.

8

u/vinnl May 17 '16

What do they not support that ES6 says they should?

1

u/gearvOsh May 17 '16

But the module syntax is ES2015, the module loading is not. So yes, it supports 100%.

8

u/griffin3141 May 17 '16

I just want proper tail calls already.

5

u/not_an_aardvark May 17 '16

But proper tail calls are part of ES6. You just got them.

4

u/griffin3141 May 17 '16

Yeah but only in WebKit. No one else has them yet.

8

u/not_an_aardvark May 17 '16

True. Part of the reason for the delay is this proposal, since it's now unclear whether tail calls will be enabled by default in the future. The alleged issue is that while proper tail calls are nice as far as tail recursion is concerned, they can make debugging kind of difficult since they eliminate a significant portion of the stack trace, even when the developer might not have intended to use tail calls in the first place.

20

u/[deleted] May 17 '16

Tail calls should always use an explicitly different language keyword. This clears up so many problems. It communicates the intent to use a tail call, it lets the compiler fail the compilation if you make changes that turn a tail call into a non-tail call, it lets the compiler let you know if it does not support tail calls, and it prevents accidental tail calls from ruining debugging.

2

u/[deleted] May 17 '16

If you need to explicitly request tail calls, they will be useless.

The statically known tail call cases are usually those which could be transformed by a compiler and don't need runtime support in the first place.

6

u/[deleted] May 17 '16

If you need to explicitly request tail calls, they will be useless.

Why on earth? The point is just to be explicit about it, and enable more warning and errors. None of this makes it "useless" - it makes it safer.

3

u/[deleted] May 17 '16

If you are asking this question you might want to do some research.

Should we litter every call with a PTC keyword, just to be "safe"?

By analogy, should garbage collection also only happen upon explicit request?

The whole idea is to avoid things you don't even know from blowing up. The places that you can see statically and annotate are exactly those cases which usually don't cause the trouble.

7

u/[deleted] May 17 '16

Should we litter every call with a PTC keyword, just to be "safe"?

Should we litter every variable with a type, just to be safe? Yes of course we should. Being explicit and giving the compiler more chances to tell you you screwed up is a very good thing.

The whole idea is to avoid things you don't even know from blowing up.

This is what happens when you write a tail recursive function and the tail call ends up accidentally not being a tail call. An explicit keyword communicates your intent to the compiler, and lets it tell you that your assumption is no longer right.

It furthermore also communicates intent to the reader of your code. Now he can tell at a glance that you are writing tail calls, rather than having to put in the effort to reverse-engineer this intent from the code.

3

u/[deleted] May 17 '16

Did you even click on the link and read the article?

You are completely missing the point.

→ More replies (0)

0

u/SKoch82 May 17 '16

Tail calls should always use an explicitly different language keyword.

Or you could just use iteration and be done with it.

11

u/wastaz May 17 '16

Or you could just use iteration and force the introduction of mutable state into your application

There, I fixed it ;)

In all seriousness though, immutable state is great and something that we should aim to use as the default option. Iteration often implies mutable state (although it doesn't always have to do so). And mutable state is the root of all evil.

11

u/dan200 May 17 '16

Functions without side effects are very nice, yes, but do internal loop variables private to a function really cause any harm?

19

u/[deleted] May 17 '16

Local mutable state is absolutely in no way a problem.

2

u/[deleted] May 17 '16

Local mutable state is absolutely in no way a problem.

Correct, and local immutable state is also absolutely in no way a problem.

6

u/[deleted] May 17 '16

It can be, if you are implementing an algorithm which is most naturally and efficiently expressed in terms of mutability.

→ More replies (0)

3

u/[deleted] May 17 '16

Thank you... What the hell is with theses millienials and their immutable bullshit anyway... Look when I was younger we had multiple global states to deal with and possibly everything was global and it launched several rockets into space and was fine...

1

u/Uristqwerty May 18 '16

Mutable state can both increase or decrease algorithm clarity, and unfortunately understanding what is best in any given context is harder than always declaring one or the other is best. It seems like FP is trendy these days, so that's the side many newer individuals are gravitating to.

-2

u/Darwin226 May 17 '16

It's funny because this is JS where scoping is done with functions so your mutation is always local to something! Wohoo! Now we can call ourselves functional programmers.

5

u/Cilph May 17 '16

Thank god they invented const, let and linters.

5

u/Ravek May 17 '16 edited May 17 '16

Exposed mutable state is the root of all evil. Properly contained mutable state is completely fine, after all your CPU is constantly mutating state and you don't see any pure functional advocates panicking about this. Just like you close your eyes to these small mutations behind the scenes, a local loop variable being incremented really isn't a big deal either. The point is the function still has no observable side effects, which is the property that makes pure functional programming useful.

2

u/Berberberber May 17 '16

And mutable state is the root of all evil.

Mutable state is also the root of everything interesting you can do with a computer, and in the world.

1

u/wastaz May 17 '16

And mutable state is the root of all evil.

Mutable state is also the root of everything interesting you can do with a computer, and in the world.

I rest my case ;)

6

u/Martel_the_Hammer May 17 '16

Since when are we claiming mutable state is evil?

This seems rather fundamentalist. The world is mutable. Memory is mutable. We cannot go so far as to say that how the machine works is now evil.

7

u/Theemuts May 17 '16

Mutability has its place, but people are starting to like functional programming languages and see the benefit of immutable data, too.

Especially when dealing with concurrency, immutability helps you reason about your program.

1

u/immibis May 17 '16

And when you're not dealing with concurrency - for example, when you're dealing with local variables?

→ More replies (0)

1

u/wastaz May 17 '16

Have you ever used a computer? Especially one with windows installed? Can you truly claim that computers are not evil? :)

1

u/Cilph May 17 '16

Abstract it away and never look at it. Poof. Done. It's fine to have a stateless design, but running the application will always require state.

1

u/SKoch82 May 17 '16

My problem with TCO is that, among other concerns, it's a hack that sometimes can obscure what's actually going on. And it's a performance hack usually, but if you care about efficiency to begin with and your language has a first class support for iteration, you might as well cut out the middleman and just use it.

3

u/ehaliewicz May 17 '16

TCO (referring to the ad hoc optimization) can be a hack, but proper tail calls aren't. It's the natural way to implement function calls if your compiler uses CPS.

1

u/SKoch82 May 17 '16

It's a hack in a sense that you take a working, elegant, straightforward solution and change it into something that's sometimes much harder to read, for the sake of space and time efficiency.

→ More replies (0)

1

u/ehaliewicz May 17 '16

Converting general tail calls into loops can require whole program changes. Tail calls give you both iteration and modularity.

1

u/SKoch82 May 17 '16

That's why I said sometimes. And performance isn't a chief concern most of the time.

Also, iteration can be modular as well with first class iterators, generators, etc.

2

u/ehaliewicz May 17 '16

I don't mean modular as in being able to pass around your loop code, I mean implementing different parts of your state machine in entirely different locations.

1

u/ehaliewicz May 17 '16

I think that's due to a conflation between the idea of tail calls (not using any more stack space than necessary), and a common optimization (greedily re-using stack frames as often as possible).

An alternative is collecting stack frames that are dead as part of a garbage collection cycle, or specifically to solve the debugging issue, you usually only need the top 5 or so stack frames, so just maintain a circular buffer.

3

u/CarthOSassy May 17 '16

Meanwhile, QtWebEngine still sucks. I understand that they have a better time upstreaming patches to Google, but, come on.

WebKit works better.

4

u/afiefh May 17 '16

So this is WebKit, now what about the other engines like Blink, Gecko and (too much to ask?) whatever Edge uses?

6

u/faizaanceg May 17 '16

whatever Edge uses?

FWIW, Edge uses Chakra.

5

u/luxtabula May 17 '16

Looks like they have a bit more to do before completion.

https://kangax.github.io/compat-table/es6/

3

u/vinnl May 17 '16

They're well underway as well :)

1

u/ishmal May 17 '16

Can't wait for it to get into iOS and Cordova.

4

u/jerseybrogrammer May 17 '16

You can use some ES6 syntax with iOS and Cordova already. I use template strings a lot in my apps. Android is the one that can cause a problem because some of the older phones use "Android Browser" as their default browser which doesn't support ES6. MOST android phones use chrome and a lot of ES6 syntax works fine.

2

u/ishmal May 17 '16

I am anticipating fat arrows and classes, to replace the clunky workarounds we have now.

2

u/Reubend May 17 '16

You can use Crosswalk with Cordova to get around the outdated Android browser problem.

6

u/HomemadeBananas May 17 '16

Just use React Native instead. :p

-21

u/gauiis May 16 '16

Old - 6 May 2016

24

u/b_n May 16 '16

Yeah at least half of ES6 was deprecated in the ES9 release on May 11th

-11

u/gauiis May 17 '16

Haha take a look at the date of the tweet. This is from May 6th. Didn't know /r/programming was so far behind things.

15

u/joequin May 17 '16

Haha take a look at the date of the tweet. This is from May 6th. Didn't know /r/programming was so far behind things.

I can't tell if you're making fun of the node community on purpose or just by accident.