未加星标

RipVanWinkle.js ― Returning to JavaScript After 5 Years

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

If there was ever a model of a true love-hate relationship, it would be programmers and javascript. JavaScript is the language of the web, perhaps the single most powerful force for innovation and change in our modern societies. With just a few lines of JavaScript, engineers can move markets, change lives, and build the future. But the language has also traditionally been one of the most annoying programming environments available to the contemporary hacker, filled with traps, pitfalls, and awkward behavior.

You could write that

javascript == Good && javascript == Bad;

but then we would have an argument about equality operators. Such is the JavaScript life.

Or at least, to my eyes, it used to be. I got JavaScript fatigue before it was fashionable, way back in 2011. I basically ignored the entire ecosystem ― including Node ― in the interim, while happily programming away in python 3 and its excellent stats libraries.

This past year, a number of great summaries of the JavaScript ecosystem were published, including the quite critical How it feels to learn JavaScript in 2016 . In reading these articles, I realized that everything I knew about JavaScript and its platform was just completely out-of-date. ES2015? Arrow functions? Transpilers? Babel? React?

It was like people were talking in a foreign language ― and they were, for the JavaScript I had grown up with was dead, and had been replaced with something far better (although still with quirks).

I have never been more excited about JavaScript than today in 2017. And while I understand the fatigue that many engineers feel (I would too if I had churned through front-end libraries like Japan churns through prime ministers ), it seems to me that JavaScript today has never been in a stronger position to build the best products of the future. This is my story of leaving the community, and now wanting to be a part of it more than ever.

JavaScript: The DarkTimes

I have programmed since I was in elementary school, first doing basic scripting with HyperTalk and HyperCard back in the mid-1990s, then later moving on to TI graphing calculators, where I made my first tic-tac-toe AI in fifth grade (should have used deep learning to stay ahead of the buzzword curve, but alas). In high school, I mostly programmed in Java, trying to build a really awkward Civilization clone that never really got anywhere (called, inventively, StrategyGame).


RipVanWinkle.js ― Returning to JavaScript After 5 Years
Not a good artist, but not a badfractal.

It was still an incredibly early time for JavaScript when I started attended Stanford in 2007. It’s hard to believe, but almost nothing we take for granted with JavaScript today had even reached a stable release. AJAX had just been popularized by Google through Gmail and Maps, and jQuery had just been released the year before. Not only that, but popular frameworks like Ember and Angular were still years away, the whole ecosystem of Node.js was still just a glint in Ryan Dahl’s mind, and Douglas Crockford hadn’t even published his legendary JavaScript: The Good Parts yet.

That first year in school, I was working on an app written in Ruby on Rails (itself in its initial release cycle!) to create a social platform for drug discovery. It was here I learned just how exhausting it can be to use new tools for web development. Rails would work, until it didn’t, and no one could explain why. Mercurial, our DVCS, was still an early product, and had its own bugs. And of course, JavaScript itself was an absolute zoo of crazy hacks pasted together to try to get anything working.

I played with JS on and off for the next three years, and experimented with some of the new frontend frameworks as they were released. But by the end of my degree in 2011, I was really quite done with coding for the internet. I was spending more and more time in the Python world, particularly around statistics, and Python was just a joy to program compared to the kluge that web development always turned into.

So I took a hiatus. For five years.

Fast-Forward Five YearsLater

Last year, there were a number of great reviews of the Javascript ecosystem and how much it had changed. It was clear that something new was underfoot, and so I decided to dedicate some side project time to relearning the stack and getting myself back out to the bleeding edge.

I started with John Resig’s newly updated Secrets of the JavaScript Ninja , which covers many of the changes that ES2015 promises (pun intended!) Coming from the Python world, the addition of lambda-like constructs called arrow functions, generators, iterators, and classes completely transforms the quality of JavaScript code. While JS may not be entirely “Pythonic,” it certainly closed the distance in code readability. Plus, the addition of Promises significantly reduces callback hell, which is one reason I never really got on the Node bandwagon years ago.

Now, here is where these changes start to become controversial. The introduction of ES2015 meant that suddenly, developers had to use transpilers to ensure that this new code is usable in old JavaScript runtimes, usually with a library called Babel. This requirement is indeed a bit of a pain, but I found it to be fairly easy to setup and understand what is going on. Furthermore, support for the new standard is going really well (except with Android of all things), particularly given my recent experience with the Python 2 to 3 transition . We are definitely a long way from the old IE days.

In addition to the advancement in the language, perhaps the most exciting aspect of modern JavaScript is the creation of smart new frontend frameworks, most notably React and Vue.js. When mixed with a state container like Redux or Flux, it allows developers to write much more sophisticated user experiences with some degree of organized logic compared to the old days of simply hacking scripts together. These tools are decently mature, although they are not perfect, and their philosophy certainly takes some getting used to.

(To be honest, I struggled in my first sandbox app even to get started, but eventually, the construction of these apps became much clearer as I figured out my program requirements. My recommendation is to ignore the create_react_app library and to build your first app entirely from scratch. It’s super helpful, even though it can take the better part of a weekend to get all the pieces to fit together.)

Finally, there are compilers and build tools like Webpack that help to put all this together. Webpack is one of those tools that is annoying to setup (seriously, “batteries included” is definitely not a good description), but once you play around with the scripts, add in the right plugins and get the correct result, it is so quick and painless to rebuild an entire app that it is almost magical.

In short, there has just been a sea change when it comes to the maturity of the JS ecosystem. Sure, there are a lot of tools, but there are also are a lot of problems that crop up in web development. It’s great to see the community building best-of-breed tools that solve each of these problems in a modular way, and the cooperation to orchestrate them together for the developer.

It’s not just JavaScript It’s clear to me that the JavaScript community wants to succeed, but that’s not what it takes to make web devel

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

分页:12
转载请注明
本文标题:RipVanWinkle.js ― Returning to JavaScript After 5 Years
本站链接:http://www.codesec.net/view/520373.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(47)