How to fix Javascript… maybe

A plea to the community

Drew Hamlett
Feb 5, 2016 · 4 min read

I’ve done some more thinking about Javascript recently. Not really sure why I think about it so much. Maybe it’s because I love Javascript. Maybe it’s because I see a language that is on the verge of greatness held back not by its syntax and edge cases, but how it is formatted.

Library surplus

Developers want to be known for their creations. Developers want to make a dent in the world. Developers want other developers to use their software. When I was in middle school, I loved to make Dragon Ball Z characters for M.U.G.E.N. After a while though, I wanted to do more. I wanted to make a game engine. I didn’t really give a shit about making a game(at least initially). I wanted people to use my game engine to make a game much like I used M.U.G.E.N. So I read C primer plus and downloaded Allegro. It was kind of dumb looking back on it, but I got pretty far.

I think most developers have this mindset of creating something awesome. I don’t think this explains why we have so many Javascript libraries doing seemingly the same thing with no iteration on the older ones.

No one likes your style

Developers create new libraries because they hate other developers style choices. That’s right I said it. No one wants to iterate on older libraries because they hate what the code looks like.

I think Browserify and Webpack are awesome tools, so you could imagine I was baffled when I saw Rollup.js. Instead of adding tree shaking to Browserify, lets create a new library that does 95% of what Browserify does. Here are the 5 reasons Rollup.js was created

  1. The author prefers 4 spaces instead of 2
  2. The author likes to name files with title case
  3. The author likes spaces in parenthesis around the arguments
  4. The author wanted to quote a song by Wiz Khalifa
  5. Trees… Related to Wiz Khalifa?

The fundamental problem with Javascript

There’s no fucking style guide. I believe this is the one thing in the Javascript community that hurts it the most. This is really hurting juniors too. I’ve seen a junior struggle for 5 minutes trying to name a file with two words. Do you use underscores, dashes, titlecase, combine the words, etc?

When I look at a Python project there are no surprises. I see Python. When I look at a Go project I see a language that has its shit together. If Go was 50% slower than Ruby and looked like Perl I would still consider using it(hint: I don’t currently), just for the fact that it has linting and formatting built in. No one is surprised by Go. It looks the same no matter who wrote it. This is awesome for open source and more importantly it’s awesome for teams.

When we started a large Node project at my last job, the one thing I wanted to have right from the start was linting and formatting. We didn’t argue for days, we just picked Standard and went with it. We enforced the style on Codeship. You couldn’t ship code unless it passed the linter. Sure I used 4 spaces in Javascript since 2008 but that was ok. I took one for the team. I didn’t know how I would feel about Standard and lack of semicolons, but I got over it. Now I can’t stand writing Javascript with semicolons. I read something somewhere that said: “If you want to know what it’s like writing Javascript with semicolons, then put 2 semicolons after every statement.” That is what it feels like.

More recently I’ve been using Airbnb(eslint) style guide(with semicolons turned off) because it enforces quite a bit more than standard. I just want someone to tell me how to write the code. I don’t want to configure Eslint for days.

A Plea

This is a plea from me to the community leaders. Please create a style guide for Javascript. I don’t care what it looks like. I really don’t. If you told me to write 3 semicolons after each statement I would do it. I can change my style to fit every one else. I’m not that fucking hard headed. I hope that other developers would do the same.

Before any new features are added to the language can we a get a proposal to standardize a style guide(much like PEP 8). Brendan Eich, if you’re reading this, please consider it.

How to actually fix javascript

Ok so a style guide from the top may not actually do anything initially. How do we actually fix the existing code? Well you know all the developers that sent pull requests for typos in Swift? We get those guys/girls to go to every Javascript repo that doesn’t follow the style guide and send pull requests to fix all the formatting. What if they don’t accept the pull request? Well we fork the project and name it after a Wiz Khalifa lyric.

Drew Hamlett

Written by


Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade