神刀安全网

Why I Set Out to Learn Ruby and Came Out Coding JavaScript

JavaScript Eat World

JavaScript is taking over the internet. Even if you’ve never written a single line of code you’ve probably heard of this mysterious thing that lives in your browser and is only mentioned by people with waxed moustaches and plaid shirts.

There are good reasons why it’s penetrated the zeitgeist: it’s arguably the most popular programming language in the world and you interact with it every day when you’re browsing the web. Over the past couple of years it’s even gone full-stack ; this means that you can now use JavaScript to write programs not only in the browser, but on the server that hosts your program, as well as the database that stores all of its information. This is a big deal, as it’s the only language that can do this.

However, JavaScript is a clunky , ugly language — it’s a real pain to write, especially in comparison to hip, new languages like Ruby. And yet, in a recent survey , more than 55% of developers use JavaScript, while only around 9% use Ruby. Even I fit into this paradigm to some extent: I went to coding bootcamp to learn Ruby and somehow ended up writing my final project entirely in JavaScript. I’m still not sure if it’s just plain old masochism, but in this post I explain what, in my opinion, makes JavaScript the best love-hate relationship a programmer can have. Up first, a quick primer.

JavaScript Wasn’t Built In a Day

JavaScript was infamously written in 10 days :scream: back in 1995. Its purpose was to add programs to web pages in the browser, and to its credit it’s still going strong more than 20 years later. Pretty much every modern website relies heavily on JavaScript, so you can probably appreciate its role in your everyday life — email, news, directions, communications, Google… It’s thanks to JavaScript that we have web apps (think software in your browser, like Netflix or Google Drive).

Unfortunately that reduced amount of time is painfully obvious when coding in JavaScript. It’s the butt of many programmer jokes (such as this hilarious talk ) because it’s so quirky. You could easily spend an hour in a heated debate about whether or not you should use semicolons. Semicolons!!! More importantly though, its standard library — the set of functionality that the language comes with “out of the box” — is relatively terrible .

Every new version of the language tries to improve on this issue, however, such a foundational technology is difficult to change. When so many programs and websites use JavaScript, it’s almost impossible to make significant changes without simply pulling the rug out from underneath them. Every change has to be incremental, backwards-compatible and thoroughly discussed and reviewed. The entire process can be overwhelmingly difficult; One does not simply re-build the foundations of something. Witness the chaos caused by the roadworks to fix the foundations of the Hammersmith Flyover in West London! (Sorry, personal gripe…)

As a result, the JavaScript world has grown reliant on tiny packages that you can pull into your program to give you extra functionality: these are a great way to make your code more modular and cut down on development times, but when they’re not built into the language they risk being volatile. A recent trademark debacle pushed a developer to withdraw his packages, including one (a whopping 11 lines of code ) that almost broke the internet as so many programs and applications depended on it for an arguably basic task. This all caused a lot of interesting debate about the past, present and future of JavaScript and will certainly improve the publishing process for packages, but it might not necessarily have an effect on JavaScript itself.

So why the hype?

You Don’t Node What You Don’t Node

JavaScript’s popularity might be an attractive enough reason to learn it in itself. Stack Overflow, the go-to online forum for programming questions, recently released its latest developer survey — something of a "State of the Union" affair in the developer word — and JavaScript blew all other technologies out of the water in terms of both usage and interest.

Some of the most popular technologies out there at the moment, whether on developers’ to-do list or employers’ hit-list, are JavaScript variants or frameworks. Two salient names are AngularJS and Node.js , a front-end framework and a back-end environment respectively. This is a particularly clear indicator that JavaScript, the ugly duckling of modern programming languages, is taking over the stack in an impressive coup d’état — and not without some top-notch branding too, since one particular JavaScript stack has the catchy acronym MEAN (MongoDB, Express.js, AngularJS and Node.js).

A full-stack language is an entirely new paradigm in the programming world and its long-term viability remains to be proven, as mentioned earlier. Nonetheless, there are some clear benefits to having a full-stack language, the first of which is that developers can reuse their skills up and down the stack. This means tighter integration as developers are more au fait with the stack in its entirety, more reusability and mobility of developers and more standardisation in the industry.

Moreover, JavaScript lends itself particularly well to certain uses that are becoming more and more common on the web. Two such examples are:

  • Storing data in the same format that you would then use to send the information to the browser (called JSON , or JavaScript Object Notation).

  • Handling high volumes of real-time traffic, which is one of the reasons Node.js is being used at companies like Netflix, Uber and PayPal.

One Language to Rule Them All

JavaScript is like English: despite it being a vibrant pastiche of different languages with some mind-boggling rules, it is flexible and ubiquitous, making it an unlikely shoo-in as the de facto language of the web.

If you’re a curious developer or someone who is thinking about learning to program, I strongly recommend looking into JavaScript, as it will open up many, many doors to exciting technologies and opportunities (as long as you can stomach a barrage of brackets and semicolons).

And whether or not you’re into code, next time you fire up Chrome, take a moment to appreciate the awesome and bizarre dark horse that is JS.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Why I Set Out to Learn Ruby and Came Out Coding JavaScript

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址