7 ms·
ES6 is great, until it’s not
- nickthemagicman 10y agoJavascript has always been a turd. Actually the whole front end including CSS and dealing with browser incompatibilities is a turd. The people who work with this have lots of grit, determination, and genius in my book. Brendan Eich has more or less apologized for JS and said it was written in 10 days meant to do things like make text flash. The goal of front end has always been "this feature sucks less than before!" Wow a let variable to fix scope! Arrow operators to dekludgify callbacks! Lol CLASSES WOW is this heaven? Web Assembly is my hope for getting rid of opinionated langs in the browser and allow in langs built on decades of experience, which will make front end reasonable like the rest of the sodtware world
- sAbakumoff 10y agoThat's interesting that the general tone of HN comments drastically differs from that of reddit replies where guys furiously protect ES6 and stuff https://www.reddit.com/r/javascript/comments/5d9v3k/es6_is_great_until_its_not/ https://www.reddit.com/r/javascript/comments/5d9v3k/es6_is_g...
- elcct 10y agoTo me first version carry less cognitive load. But maybe I've been using new JS features for too long.
- TheCoelacanth 10y agoI think the same if you format it properly Obviously I can't read this mess easily ( { ...state, [ siteId ]: { ...state[ siteId ], [ postId ]: { requesting: false, success: false, error, } } } ) but this is pretty easy to read ({ ...state, [ siteId ]: { ...state[ siteId ], [ postId ]: { requesting: false, success: false, error, } } }) Though even easier to read would be to use icepick import { setIn } from 'icepick'; setIn(state, [siteId, postId], { requesting: false, success: false, error, });
- chmln 10y agoGood point, but I wouldn't discredit all of ES6 because some github repo contains misused deconstructions. Its not just about which language is used, but how its used. ES6 has brought on many necessary improvements.
- sAbakumoff 10y agoAbsolutely! I agree that one can write confusing/poor code in just about any language out there. But I didn’t try to highlight how horrible ES6 is..In fact I used ES6 features in the modified version of the original reducer’s code. The main point of the article was in that using new JS features blindly may cause the significant problems, not with readability, but with the script size and the running time of the code after it’s transplied to ES5. And it has to be transplied because it’s using ES7 features which even not in the specification.
- heisenbit 10y agoWhat are features for if we don't use them 8-) Not all features increase complexity. The fat arrow functions are more easy to reason about as "this" can be understood more locally. When transpiling the code may be larger but in the long run maintainability should be better. I found the Crockfords talks on ES6 (e.g. https://www.youtube.com/watch?v=vJKDh4UEXhw https://www.youtube.com/watch?v=vJKDh4UEXhw) useful as a guidance what could be a minimal set of sane features.
- sAbakumoff 10y agoI agree. I love ES6 in fact. The fat arrows really rock. I like how I can use them together with promises to write a concise code like create_project(prj_name).then(project=>addTeam(project, team_name)).then(team=>addMember(team,name)) The main point of the article was in that using new JS features blindly may cause the significant problems, not with readability, but with the script size and the running time of the code after it’s transplied to ES5.
- 33degrees 10y agoTo me, the problem here is Redux and how it's often used. I see code like the Calypso example all the time, and I don't understand how people tolerate all the repetition. To me it's like writing all you SQL by hand when a decent ORM could do the same thing in 1/3 of the code.
- sAbakumoff 10y agoBy the way, I thought that the name of the article "ES6 is great, until it's not" should mean "ES6 is OK until it brings serious problems in your code"..But the comments and replies imply that the meaning is slightly different..it's like I am trying to discredit ES6 which was not my intention at all...Could anyone tell me whether "X is great until it's not" has fully negative meaning?