JavaScript is said to be getting better, with advances planned in upcoming upgrades to the ECMAScript specification that serves as the basis for the popular dynamic scripting language. But still more can be done to improve the language that has become a linchpin of Web development, prominent developers say.
Elements of the upcoming ECMAScript 6 (ES6) release already are being implemented in browsers such as Mozilla's Firefox. Version 6 was said by ECMAScript committee member Jafar Hasain to be returning JavaScript to its original intent, offering an easier-to-use syntax. Also in development is ECMAScript 7 (ES7), with capabilities including async programming and Object.observe, for using JavaScript objects and tracking changes to them.
Still, developers see areas where JavaScript could be improved, including process changes. They also offered their insights on what they expect and don't expect from ECMAScript upgrades.
"The only thing I'm not particularly happy about is the actual process. It's not always easy for 'outsiders' to provide good feedback on specs," said Rob Eisenberg, a former member of the AngularJS JavaScript framework team and developer of the newly announced Aurelia JavaScript framework. "I've found that sometimes the spec authors have a hard time understanding some of the real-world use cases."
Eisenberg cites an issue he has had in getting a particular hook added to the JavaScript module loader specification. "At this point in time, I don't think there's even a productive way to provide the feedback. So I do hope they improve that as much, if not more, than they focus on improvements to the language. I've been told this is being addressed soon, so I'm hopeful."
Deficiencies still a sore spot
Technical issues remain for some key JavaScript advocates, including Eisenberg and Joel Webber, prominent in the founding of Google Web Toolkit (GWT), which lets developers use Java development skills to build JavaScript applications.The lack of a 64-bit numeric type remains a point of contention with JavaScript, developers said.
Webber describes the problem as "a giant pain that's actually caused me to ship bugs in the past month." The issue seems like a subtle point but there are instances where a value must be shipped from the server that actually uses the full 64-bit range, such as database keys, he said.
Ray Cromwell, Google senior engineer, concurs about the 64-bit issue. "It still has only one numeric type, which is doubles," for floating-point support, he said.
Also a problem with JavaScript, at least for now, is the absence of a built-in map set/type, said Webber, who is now at Fullstory, which provides DVR-like capabilities for websites. "It's basically impossible to build a map in JavaScript if you can't convert the keys to strings and this can be a huge problem in some code," Webber said.
The lack of a weak reference, meanwhile, can make it difficult to manage memory, he added. "This is of particular concern on mobile, where browser memory use frequently causes Web apps to dump all the other apps running on the device." But help is on the way, with both the built-in map/set type and weak reference issues getting fixed in ES6, Webber said. But until ES6 can be relied upon, there is no good way to emulate them correctly, he added.
While mostly happy with ES6, Eisenberg sees static properties on classes as an omission. "But it's a huge release and I'll be happy when it's wrapped up and we see it fully in the browsers. That will take some time, but it will transform the way we write JavaScript," he said. "I'm also pleased that it appears ECMA is moving to an annual release cadence. That means we won't have to wait so many years for new features, as we have with previous versions."
The situation is improving
Developers see JavaScript improving, even if they have some remaining issues. "ES6 does at least go a long way towards fixing a lot of the basic structural issues with the language, and I'm quite happy about that," Webber said. "I still find it amazing that no one can agree on even the 'right way' to implement even the most basic abstract data types in JavaScript, so ES6 putting a stake in the sand and saying 'this is the way, and here's the better syntax for it' is a big step forward."
"A lot of the points are being solved in ECMAScript 6," Cromwell said. A proper module system, for instance, provides a way of including dependencies such as import statements, he said. "JavaScript for a long time didn't have an official module system. So people have rolled their own," with Node Package Manager (NPM) being one of the most popular, Cromwell noted.
"ECMAScript 6 actually adds modules as a first-class concept to JavaScript." ES7, meanwhile, "is still early," Eisenberg said. "But I'm excited about Object.observe and Decorators. Those are features which are important to library authors and will help us to improve developer productivity quite a bit."
JavaScript performance is on the upswing as well, Webber said. "It's still not on par with native code in most real-world code, but [it's] far better than any other script language, with the possible exception of LuaJIT."
JavaScript also offers the most vibrant ecosystem, Webber added. "Part of that vibrance is likely attributable to the fact that everyone comes up with their own solutions to the language/platform inadequacies, but if you need to solve a problem in JavaScript, chances are someone's already done it and shared the code."
And the existence of Node.js, offering a server-side JavaScript platform, has made it possible to "sanely" share code across application tiers, Webber said.
Webber co-developed GWT, which was first released in 2006, at a time when there were few tools for JavaScript, reasoning that cross-compiling with a language with much better tools would be beneficial.
"We were working with teams building these kinds of apps around this time and saw that they kept banging their heads against the overwhelming complexity of wrangling large JavaScript apps," he said. "Remember that there were almost no tools for the language, and both the browsers and the language were ridden with incompatibilities."
These days, Webber says the need for GWT is perhaps not as great as it was then, although developers still want to cross-compile. "The JavaScript ecosystem is vibrant -- almost to the point of bursting at the seams with libraries, tools, and cross-compiling languages -- and that's undoubtedly good for the Web."