r/javascript • • Jul 10 '16

The JavaScript language reboot is done

https://medium.com/@velmu/the-javascript-language-reboot-is-done-7bcec4be2cb6#.dy2fyy9j1
41 Upvotes

98 comments sorted by

83

u/[deleted] Jul 10 '16

Maybe this is going to sound ultra elitist (sorry) but what is with all the medium articles from people who have just started their Javascript careers? It's like every code camp encourages people to go write an article or tutorial on medium right when they're done.

I care about the opinions of some of the real amazing JS ninjas out there. I do not care about what some random guy who recently got into programming thinks about JS and web development.

48

u/_hooan Jul 10 '16

This is my biggest problem with the JS community currently. I don't know how to say it without sounding like a dick but I wish people would stop writing strongly worded posts about JavaScript unless they're veterans.

Good: "I learned how to use this cool tool, check it out!"

Bad: "This is the future everything else sucks!"

What's funny is that aside from a few exceptions the tool creators and "famous" devs never do this. It's always noob to medium skill people who seem to want fame more than anything else. Compare Dan Abramov with all the posts about how React/Redux are the only good choice and if you don't use it you suck.

Don't get me started on all the "functional JS" posts are are just map filter reduce + couple of copy and pastes from Ramda docs and random claims about how OOP is the devil. We definitely need 100 of those.

Rant over : )

14

u/[deleted] Jul 10 '16

Agreed. JS, and other parts of the web world in general is the only area of software development where you get people thinking that they have these amazing insights after a year of programming anything.

I was utter shit for years and years after learning any new realm of software development. I'm still not an awesome JS dev, I prefer other stuff but I'm fascinated by it. And yet I wouldn't be arrogant enough to write an article about JS because I have seen the guys that are good and they're way fucking better than me.

2

u/madcaesar Jul 11 '16

Yea but the only way we all learn is by sharing and talking. If we all waited to be masters no one would ever post anything and learning would be that much harder. It's possible to learn something even if it isn't 100% polished.

6

u/[deleted] Jul 10 '16

Yeah, the amount of superficial articles that try to sound deep is high.

I'm a javascript freshman, instead of jumping on any bandwagon I've tried to do a maximum of things with vanilla code, I read the source of jQuery, underscore and angular. Now that I know the fundamentals better, I can dissect frameworks instead of being mystified by them.

0

u/[deleted] Jul 11 '16

[deleted]

1

u/[deleted] Jul 11 '16

Actually yes :) why ?

1

u/dardotardo Jul 11 '16

Really?

Reading source would do nothing for me. I wish I could read source and fully understand what is going on as a whole. I need to apply it to a problem, encounter an issue, then debug through the source to fully understand how the source is actually working.

2

u/_hooan Jul 11 '16

Reading code is really good to enhance learning and at least see where things are going. You don't need to spend a weekend reading React's code (oh god) but you can try Preact for example.

Actually I am thinking of taking 20 mins everyday to reading the code of small modules that I use but can't explain how they work off the top of my head.

Plus nothing is stopping you from cloning a repo and testing/breaking it to see how it works.

1

u/dardotardo Jul 11 '16 edited Jul 11 '16

Totally get it, and I don't want to say that reading source is a bad thing, complete opposite. In fact, you sort of just proved my point.

My point was reading source is not a good way to LEARN to code, which was in response to the previous comment. It should be used to supplement how you code with libraries. Which you just stated you're doing for modules you use but don't understand.

1

u/_hooan Jul 11 '16

Yep I agree!

1

u/beltorak Jul 11 '16

I can understand why it seems that way, but I don't think it's about arrogance. It's about youth, passion, and probably above all, innocence.

1

u/inu-no-policemen Jul 10 '16

I wish people would stop writing strongly worded posts about JavaScript unless they're veterans.

https://en.wikipedia.org/wiki/Argument_from_authority

Being a veteran or well-known doesn't mean that you're right about everything. I disagree with some of Crockford's opinions, for example. But I do of course also agree with some of his views.

Now, the great thing about opinions from non-authoritative people is that they have to work much harder to convince you. You also won't as easily agree to obviously false conclusions, because there's no perceived need to conform.

7

u/_hooan Jul 10 '16

I don't think I expressed myself right. Here's what I mean:

I may disagree with an article by Crockford or Kyle Simpson (happens often) but at least I can say "these guys have been doing JS for decades, I can see where they're coming from and I learn a thing or two (Kyle Simpson especially).

Now comes someone who has barely done any substantial work or study in the language or programming in general. If these guys wrote posts where they said "I'm new, but I've tried this technique and I like it" then it's fine—I support that. But what we're talking about is the hotshots who try hard to look like experts and come off as arrogant ("THIS is the only way to do JS!!!!"). That attitude is annoying in experts for sure—I don't disagree (Eric Elliott anyone?). It's way, way more annoying when it's by a newbie though. The issue at hand is that Medium and this subreddit is littered with posts by these guys.

16

u/kenman Jul 10 '16

This is a burgeoning problem to moderate; on one hand, I applaud those new to the industry for their enthusiasm and community involvement, but on the other hand, more times than not it turns out that it's nothing more than a shallow, ego-driven pursuit of fame.

As an aside, Medium.com has gone downhill quite a bit in the past year or so; at one time, I considered content from Medium to be well-above average, to the point where it required no moderation. I didn't have to worry about blogspam, plagiarism, listicles, transparent URL-forwarding, or other low-effort (and/or highly-spammy) practices.

But that's not the case today; I've witnessed all of the above. When I reported these things to Medium support, they saw no problems with the content. So as it stands, Medium.com is basically the new blogspot, where anyone can sign up and post pretty much anything. As far as I'm concerned, every Medium post will be scrutinized.

4

u/ebiester Jul 11 '16

It's not ego-driven. It's one of the two suggestions over the last 15 years on how to keep yourself employable: write open-source software and blog. (In the consultant world, the stakes are raised to articles on InfoQ and books.)

Most of the time, nobody will read it except the next person to google a name before an interview. However, it's a social signal and it's not going away.

3

u/[deleted] Jul 10 '16

Thanks for fighting the fight, it must be hard modding this sub. I love JS and wish we could get some more unique, quality content on here.

3

u/[deleted] Jul 10 '16

what is with all the medium articles from people who have just started their Javascript careers?

Because the rest of us are too busy actually accomplishing things in the language to take time to write articles.

1

u/[deleted] Jul 10 '16

I've read plenty of articles from accomplished devs in all sorts of industries.

11

u/hahaNodeJS Jul 10 '16

ninjas

Stop it.

0

u/[deleted] Jul 10 '16

Is it that big of a deal? This is a JavaScript community on the Internet not an academic paper.

2

u/clarle Jul 10 '16

People who have just started out haven't yet had the experience of seeing a project go from new and shiny to maintenance mode, or the cost of migrating from one technology stack to another.

If you haven't built an application more complicated than a todo list, then it'll always seem like rewriting your application is faster than maintaining something you haven't worked with before.

2

u/[deleted] Jul 10 '16

I agree, and I'm a beginner who only started making websites for money a few weeks ago.

This is just confusing. As a beginner I've often be influenced by people who, in the end, were arguably misguided.

Also I don't get this guy. I think he's wrong on lots of points.

5

u/[deleted] Jul 10 '16

That's what has made the JS community get such a bad reputation in the rest of the software dev community, it's like the blind leading the blind via buzzword. I swear to god I think all the buzzwords just get passed around and used because of new people exposed to them via camps and thinking they're really important terms to know.

2

u/[deleted] Jul 10 '16

the blind leading the blind via buzzword

Haha it's the perfect description.

Some concepts make sense when you try to grasp what the vanilla code does. But sometimes it's just fancy words.

1

u/comtrabanned Jul 11 '16

Don't read it then. Developers looking to regurgitate what they have recently learned by blogging it then good for them, someone with as little or much experience as them may find it useful.

When I first started diving into the realms of JS, I read everything and anything I came across online. I just assumed the person publishing an article had more experience and that there is always something I could learn. Even if it was disagreeing with their experience, I went through this process of read > > reflect > conclude.

2

u/[deleted] Jul 11 '16

That's ridiculous. Why wouldn't the Javascript community want to cultivate an atmosphere of high quality posts about JS? We value interesting, helpful things. Posts from beginners are often neither. I'm not trying to be mean or elitist really, it's just a real problem in the JS community.

1

u/swan--ronson Jul 12 '16

No, it's true, and I've been guilty of being one of these arseholes. If anything, it's reminded me that becoming a great programmer takes years of work.

0

u/crazyeight Jul 10 '16

Only someone who just started programming in JS would be naive enough to write an article like this.

0

u/[deleted] Jul 10 '16

[deleted]

2

u/Krirken Jul 11 '16

I did not realize that was encouraged by code camps. The focus that these (pretty expensive) camps put on "job placement" has made me wonder whether they actually teach programming or rather just self promotion.

Has anyone run into a situation where they hired a code camp graduate and soon regretted it?

0

u/[deleted] Jul 13 '16

[deleted]

1

u/[deleted] Jul 13 '16

I'd love to hear a list of the devs that you think are worth following on Twitter or their blog or YouTube, I'm always looking for more. And when you say social narcicism in JS, what do you mean exactly? The medium-newbie crowd or something else?

0

u/[deleted] Jul 13 '16

[deleted]

1

u/[deleted] Jul 13 '16

That's awesome thank you for that list! You should definitely follow through with some YT content like that, I think a lot of people would eat that up.

16

u/lechatsportif Jul 10 '16

Once again we see this medium guy has no idea what hes talking about.

7

u/[deleted] Jul 10 '16

You mean he's not a JavaScript ninja sensei?

23

u/[deleted] Jul 10 '16

Link to the original article that this one is reproducing.

0

u/[deleted] Jul 10 '16

[deleted]

6

u/BlueOak777 Jul 10 '16

OP's link is the orig authors blog. Looks like he wrote about it at the first link and then copypasted it to his blog. Could be two users reposting stuff...could be alt accounts of the author. Who knows.

1

u/kenman Jul 10 '16

Good eye, thanks.

1

u/kenman Jul 10 '16

Interesting...

13

u/kenman Jul 10 '16

Hi /u/velmu3k, why did you repost the same article but from a different host?

You've already been warned once about shady practices to avoid spam detection, and now you're continuing to do so in a different manner. Consider this your final warning; any further attempts to avoid spam detection will be dealt with swiftly and firmly.

6

u/akujinhikari Jul 10 '16

Not to sound like a dick, but I stopped reading at "catched on."

2

u/homesweetocean Jul 11 '16

I kept reading, but only because I wasn't done with my coffee yet and wanted a few more chuckles.

29

u/[deleted] Jul 10 '16

Callbacks obsolete? Seems premature to say so.

10

u/ihsw Jul 10 '16

I think it is.

Callback hell is over, promises and async/await have won.

I challenge you to find any new ES6/TypeScript projects that still use anonymous functions for asynchronous execution.

11

u/gurenkagurenda Jul 10 '16

There are cases where callbacks still make sense though, like event handling.

6

u/Sinistralis Jul 11 '16

Sounds like we need a library to fix this travesty

1

u/gurenkagurenda Jul 11 '16

I think you're joking, but honestly I really do think event handling could use a better abstraction, the same way promises did for procedural async. I don't really know what it would look like though. Something something streams, something something generators.

10

u/namesandfaces Jul 10 '16

I actually find callbacks very manageable with observable streams, just as easy as promises. Code ends up just as comprehensible.

3

u/[deleted] Jul 10 '16

I agree. I've never found major issue with callbacks.

IMO, so many of the "problems" with JS are due to the vast majority of people who look at the community and apply fixes/patterns/designs without understand how it actually affects their code.

0

u/TheIncredibleWalrus Jul 10 '16

Callbacks aren't bad because of "callback hell" and the "pyramid of hell", it's about inversion of control and the trust problem

0

u/cosinezero Jul 11 '16
Don’t call my callback too early
Don’t call my callback too late
Don’t call my callback too few times
Don’t call my callback too many times
Make sure to provide my callback with any necessary state/parameters
Make sure to notify me if my callback fails in some way

Oh my god, these apply to every function call in my application! Promises are the hammers to all the nails!

0

u/[deleted] Jul 10 '16

[deleted]

1

u/TheIncredibleWalrus Jul 10 '16

Amen, I can't believe the amount of replies it took for this reply to come up (out of a few agreeing upon the OP's misguided view on callbacks).

7

u/hahaNodeJS Jul 10 '16 edited Jul 10 '16

I challenge you to find any new ES6/TypeScript projects that still use anonymous functions for asynchronous execution.

...

new Promise(function(resolve, reject) { resolve(); })
.then(function() { console.log('hello'); });

There are two anonymous functions and two callbacks in use here.

0

u/[deleted] Jul 10 '16

[deleted]

14

u/Jafit Jul 10 '16

What's promise hell? Is that where you try to use promises without knowing how they work?

3

u/bighi Jul 10 '16

It's when you make promises you can't fulfill and your looks at you with that look on her face.

0

u/[deleted] Jul 11 '16

[deleted]

1

u/Jafit Jul 11 '16

Can you provide an example of good code layout making callbacks not horrible to use?

0

u/[deleted] Jul 11 '16

[deleted]

0

u/Jafit Jul 11 '16

Well most of my day involves writing Javascript for node.js, so there'll be a lot of situations where an operation requires multiple asynchronous database calls, or to verify something in redis before continuing, and things down the line will depend on having access to the results of previous async operations.

If this were to be done using callbacks it would involve a lot of unavoidable nesting.

0

u/[deleted] Jul 11 '16

[deleted]

1

u/Jafit Jul 11 '16

I'm not saying that callbacks are best in every situation, but I am saying that promises also aren't best in every situation.

I disagree, I find that promises are a very useful pattern for most situations. With Javascript being a single-threaded, async operations are a fundamental part of writing good Javascript, because especially with Node you really can't afford to have synchronous code blocking the stack, because it'll block the stack for literally every user connected to that specific instance of your application.

A lot of our code at work is architected around promises as a standard interface. If we use a library or module that uses callbacks, we'll use es6-promisify to wrap that in a promise so that its easier to work with.

The only instance I can think of where plain callbacks make sense are in event handlers, such as in node.js streams or event listeners in the browser.

1

u/Martin_Ehrental Jul 10 '16 edited Jul 12 '16

I think the part about async work is premature.

It's true for callbacks; I think Promises have replaced them and soon we will have async/await which should ease working with them... So, almost there.

Concerning events, Observables are replacing event listeners. Most frameworks have settles on an observable library, and there will be soon be a standard Observable set of interfaces... hopefully. But we are not there yet and it's still very unstable. We even get new observable libraries popping up.

5

u/smartalec43 Jul 10 '16

"packet management" does he mean package?

2

u/lance22me Jul 11 '16

Yep. Javascript is in it's final form. All done. History stops here.

3

u/lucidguppy Jul 10 '16

I'm afraid that the cycle will start again - and things will be reinvented.

Has anything really become simpler?

24

u/[deleted] Jul 10 '16

Has anything really become simpler?

Are you kidding me?

fetch('https://jsonplaceholder.typicode.com/posts').then(response => {
	if (response.status === 200) {
		response.json().then(data => {
			const filteredPosts = data.filter(obj => obj.userId === 1);
			console.log(`You have made ${filteredPosts.length} posts.`);
		});
	}
});

vs

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
	if (xhttp.readyState == 4 && xhttp.status == 200) {
		var posts = JSON.parse(xhttp.responseText);
		
		var filteredPosts = [];
		for (var i = 0; i < posts.length; i++) {
			var post = posts[i];
			if (post.userId === 1) {
				filteredPosts.push(post);
			}
		}
		
		console.log('You have made ' + filteredPosts.length + ' posts.');
	}
};
xhttp.open("GET", "http://jsonplaceholder.typicode.com/posts", true);
xhttp.send();

8

u/Klathmon Jul 10 '16

And the same thing with async/await is even simpler.

3

u/jcready __proto__ Jul 10 '16

You cannot abort a fetch though.

-6

u/constructivCritic Jul 10 '16 edited Jul 11 '16

So maybe just because I haven't learned about new method of doing things, but the xmlhttp version seems clearer to me.

EDIT: Whoever downvoted my comment...you're a dumbass for using the downvote button incorrectly. I was provoking some thought or some replies to better understand why the new way was better, I wasn't asking you to agree or disagree with me. Hiding my comment with downvotes detracts from the discussion... That's the opposite of what you want on a site like Reddit.

2

u/fzammetti Jul 10 '16

I for one agree with you. I think people are mistaking shortness and terseness for intrinsically better. Sometimes, more code is more expressive and the examples given here versus the older example, to my mind, bear that out.

0

u/[deleted] Jul 10 '16

[deleted]

4

u/konbit Jul 10 '16 edited Jul 10 '16

Here's my favorite:

async function getPosts() {
    const res = await fetch('https://jsonplaceholder.typicode.com/posts');
    const json = await res.json();
    const posts = json.filter(obj => obj.userId === 1);
    console.log(`You have made ${posts.length} posts.`);
}

EDIT: res.json() is a promise

1

u/[deleted] Jul 10 '16

res.json() is also a promise, no?

1

u/konbit Jul 10 '16

Yup, fixed. Still an easier read.

1

u/[deleted] Jul 10 '16

I agree, never going back from async/await if I get to choose

1

u/[deleted] Jul 10 '16

Maybe const json = await fetch('https://jsonplaceholder.typicode.com/posts').then(res => res.json());?

1

u/TheLameloid Jul 10 '16

Is there a way to extract the result of the promise out of the .then() callback (which I assume is what the await keyboard does) without running into race conditions errors?

1

u/konbit Jul 10 '16

Nope. That's precisely why async await is so awesome.

1

u/[deleted] Jul 10 '16

Cool, I wasn't aware you could chain thens like that. Although this version doesn't check if the status was ok =P

0

u/[deleted] Jul 10 '16

[deleted]

10

u/pertheusual Jul 10 '16

That's not true, the promise returned by fetch() only rejects if there is a proper network error or the connection itself doesn't get established. No matter what the status code is, it'll still resolve. There's nothing wrong with returning JSON in the body of a 500 for instance.

If there was a 404 with no JSON, your example would just throw an exception because json would be undefined so undefined.filter would be non-existant.

0

u/[deleted] Jul 10 '16

[deleted]

1

u/[deleted] Jul 10 '16

but now those days are over

They absolutely are not over, nothing has been removed from the language. The only thing making people use all these complicated systems are social pressures. The only person you have to blame for losing simplicity is yourself (or your team, if they're the instigators).

1

u/[deleted] Jul 10 '16

Yeah, despite working with arrow functions for nearly a year, I still find them infinitely more difficult to understand and comprehend than the non-arrow version. The syntax is just so poor.

12

u/hyperhopper Jul 10 '16

Alright, I really hate to be that asshole on the internet, but if you are working with them for a year, and can't figure it out, programming might not be for you.

let that = this;
function (a) {
    return a + that.b;
}

is the same as

a => a + this.b

It's really not difficult or novel at all.

2

u/WorkshopX Jul 10 '16

upvote for a simple example of arrow functions effect on this binding. Well done.

1

u/[deleted] Jul 10 '16 edited Jul 10 '16

I've been a programmer for 20 years. I have no problem figuring them out. It's just the syntax I have a problem with. And by problem I don't mean I don't understand it, I mean the syntax was poorly thought out and all around sucks. And yes, I know that the syntax was borrowed from other languages, but that doesn't mean the syntax didn't suck in those other languages too.

1

u/SuperFLEB Jul 10 '16

The place I find it more readable is in functions like map, where something like...

arr.map(thing => thing * 1000);

reads as "map thing to thing * 1000". I do agree that it can be less immediately readable or intuitive in other cases like object methods or general-use callbacks, for instance.

0

u/Asmor Jul 10 '16

And that's super handy for some common transformations, like picking values of an object:

Object.keys(obj).map(key => obj[key])

-1

u/Tysonzero Jul 10 '16

I think it is awesome that JS is slowly but surely adding more functional programming features, eventually it might start to approach the elegance of Haskell: map (* 1000) arr.

-1

u/[deleted] Jul 10 '16

The syntax is just so poor.

It doesn't help that the functional / academic coders keep coming out of the woodwork to say that the syntax is more natural because it looks like calculus.

I fucking hated calculus!

2

u/cthechartreuse Jul 10 '16

Honestly, one of the biggest concerns I have in the Javascript world is that frameworks and copy paste solutions are the expected norm. I feel this person is expressing their pleasure that we are at a place where churn is selling down, but, this is just playing into the same problem we continue to have: jquery javascripters. Only instead of jquery, it's angular or react or ember or some other framework.

I think these posts would become less impactful if we shifted our focus away from library x and thought about stuff like patterns, solving business problems and learning new, long-lived computer science ideas instead.

I don't really care where a programmer learns about common answers to common problems, I only care that they LEARN them.

Ultimately, I am less interested if someone can make some random magical thing happen with D3 or three.js than I am whether they can deal with a big JSON blob coming back from a service, since their time will likely be spent more on data and business requirements than a single page of visualizations.

So, yes, tooling will always be important, but more than tools, can the programmer get sh*t done? The fact that tools have stabilized is great, but did that make the post author, or anyone else for that matter, better at their job? I think the answer is probably no.

2

u/[deleted] Jul 10 '16

Javascript never needed a reboot.

1

u/[deleted] Jul 10 '16

The language just needed a critical mass of "missing" stuff to be implemented. I bet you this leads to significantly fewer "UGH #$*$ THIS" moments that may have led to someone trying to build another abstraction layer over something because the vanilla method was awful and the most popular alternatives still just weren't quite enough.

I've been delighted at how little lodash I need and how my Webpack is under 100 lines for once. My standard scaffold for a React app seems to be getting simpler and simpler.

-3

u/tonetheman Jul 10 '16

Yeah nope... javascript is still a large interesting mess.

-3

u/[deleted] Jul 10 '16

What do you run in the browser instead of JavaScript?

1

u/bighi Jul 11 '16

Reading interpretation fail.

-7

u/vagif Jul 10 '16

Thanks but no, thanks. Since we moved on to Purescript, descending back to javascript sends shivers down my spine.

1

u/moljac024 Jul 10 '16

I'd be interested to hear how you build the frontend in purescript. Have you looked into Elm? What made you choose purescript?

1

u/vagif Jul 10 '16

We code in haskell. (backend) So purescript was closer to haskell than Elm is. We use thermite (react wrapper lib).

1

u/moljac024 Jul 10 '16

Oh, I didn't realize there was a react wrapper for purescript. React really did rock the boat, eh?

What would you say are the biggest pain points in using purescript?

1

u/vagif Jul 10 '16

The usual: learning curve, tooling, editor support.

1

u/Tysonzero Jul 10 '16

As much as I do think the new JS features are cool, I agree with you that existing functional programming languages like Haskell, PureScript etc. are a million times more fun to work with.