Aug 04
2008

ECMAScript 4: Interesting language but poor successor

Posted by Christopher Diggins in Programming LanguagesJavaScript

cdiggins

I have been looking over the ECMAScript 4 overview paper (http://www.ecmascript.org/es4/spec/overview.pdf) and my conclusion is that it is an interesting language with lots of potential, but that it violates the spirit of previous versions of ECMAScript.

In case you aren't a language nerd like myself ECMAScript is the core language behind many popular languages like JavaScript, JScript, ActionScript, etc. What I liked about early versions of ECMAScript was that almost any level of programmer could read, write, and understand ECMAScript code in almost no time. This was one of the core ideas of the language: to make it an appropriate scripting language. It's simplicity is why it so darn successful.

I expect a new language iteration to correct major flaws, reduce ambiguity in the specification, and make small tweaks to the language. ECMAScript 4 does this, but it also adds a type-system, new binding primitives, and a dozen other new features! What seems to have happened, is that the designers are attempting to turn ECMAScript into a language that is appropriate for larger scale programming.

Here is a quote from the introduction to the overview document:

ES4 is compatible with ES3 and adds important facilities for programming in the large (classes, interfaces, namespaces, packages, program units, optional type annotations, and optional static type checking and verification), evolutionary programming and scripting (structural types, duck typing, type definitions, and multimethods), data structure construction (parameterized types, getters and setters, and meta-level methods), control abstraction (proper tail calls, iterators, and generators), and introspection (type meta-objects and stack marks).

Of course these are all good ideas for a general-purpose programming language , but are they really appropriate for ECMAScript's original intended usage?

To get an accurate sense of what kind of impact the changes will have (the paper does a poor job of conveying this), I recommend downloading the reference implementation ( http://www.ecmascript.org/download.php ) and take a look at the "builtins" folder which contains implementations of the standard library. In it you will find code like the following:

 __ES4__ class Map.<K,V>
{
  static const length = 2;

  function Map(equals=function(x:K,y:K):boolean
    { return x === y; },
    hashcode=function(x:K):uint { return hashcode(x); } )
      : equals = equals
      , hashcode = hashcode
      , element_count = 0
  { }

   meta static function invoke(x : Object!) {
      let d = new Map.<EnumerableId,V>;
      for ( let n in x )
      if (x.hasOwnProperty(n))
        d.put(n, x[n]);
        return d;
    }
   ...
}

Nothing wrong with this as a general-purpose statically typed programming language, but it isn't what I want from a scripting language. There are too many features now. I am a pretty experienced programmer, but the meaning and correct usage of all the new features will require some study (unlike the original ECMAScript).

So what would my suggestion be? Fork ECMAScript 4 into two branches, one that simply improves the ECMAScript 3 specification and keeps the overall spirit of the language, and another that goes and adds all the fancy programming language features they want (call it E4?). In other-words leave the kitchen sink out of my ECMAScript.



Comments (2)Add Comment
might be a little quick to judge...
written by Hamlet DArcy, August 05, 2008
I'm not sure it's fair to judge the language by the implementation of the builtins. The builtins are library/framework code at its purest, and that type of code commonly does show the warts of the underlying language. For instance, looking at the source to the Groovy language won't tell you one thing about how elegant and concise the finished product is... most the source is in Java after all!

ECMAScript 4 seems to take backwards compatibility seriously, and it's my understanding that you don't have to use any of these advanced features if you don't want to. The idea of gradual typing seems to be good, and I blogged about it at length here: http://hamletdarcy.blogspot.co...rator.html

I get the impression that the language is trying to continue supporting the lower end/scripting pieces while also offering better constructs for the high end/framework writers. This is good. Personally, I'm excited about ECMAScript4 and would urge others to read several sources before claiming that it has blown its complexity budget.
Judging ECMAScript4 via ActionScript3
written by Roger Voss, August 09, 2008
Adobe says that ActionScript3 is based on ECMAScript4 (though they finalized AS3 and shipped it prior to ECMAScript4 standard being finalized - it is finalized, right?).

As such AS3 is widely used now in practice due to popularity of Adobe's Flex RIA solution. (I'm involved with multiple Flex-based products.)

I've heavily used Object Pascal, C++, Managed C++, Java, and C#.

Relative to those languages, AS3 borrows some of the OOP package and class concepts, such that OOP is first class in the language now, but retains overall a very nice, yet expressive simplicity.

The compile-time static typing is not at all syntax cluttering, and it does aide large team development - and especially clarity of code for long term maintenance. The last attribute is especially important for enterprise apps - which live for much longer than the PHP web page stuff that Yahoo cranks out like sausage.

None-the-less, AS3 retains some of the goodness of original javascript in terms of using functions as closures. It has very nice facilities for doing out-right functional programming in combination with the array classes and certain methods those support.

It also has mechanisms to escape static type restrictions and allow for dynamic programming behaviour at runtime. There is a performance cost for using that, so it's nice that there are judicious means to enable it where it's deemed useful, but otherwise be under static type regimen as the default mode.

Relative to Java and C#, and relative to original JavaScript (which I confess I did not care for much at all, though I like some of its capabilities), I've found AS3 a very decent language for doing what it was designed for - programming the GUI of RIA apps that run in a browser. For that purpose it strikes a very good balance indeed. Also, folks are able to learn and pick it up very quickly. (Mastering its potential for functional programming would take longer, but that is not essential in order to be immediately productive in writing decent OOP code.)

Write comment
You must be logged in to a comment. Please register if you do not have an account yet.

busy

Get your FREE Subscription to Dr. Dobb’s Digest today!

Dobbs Code Talk Quick Poll

This time next year, your most important operating system (host and/or target) will be:

Look Who's Code Talking


Bob Stout
City: Houston

Ken Weinert
City: Westminster

Brian Cardarella
City: Boston

Vince Landi
City: Millburn

Brendan LeFebvre
City: Billerica

Jon Erickson
City: San Francisco

Dobbs Code Talk Tags

.NET abstraction Ada Adobe Agile Ajax algorithm Algorithmic complexity ALM Analogical reasoning Android Anecdotes Apple Application Development AppStore Architecture and Design ARM Artificial Intelligence Artificial Life Assembler Programming Audio files AVX AWK Banking Bazaar Best Practices Blender Books Brain computer interfacing Build C C Programming C Sharp Cartoon Category theory Cellular automata Clojure Cloud Computing Cobol Cocoa Coder Of The Month Cognition as compression Collaboration Common Process/Frameworks Compilers Computational humour Computational narrative Computational politics Computer Science Computers in art computing pioneers concurrency Conferences Consciousness research Contest Contest140 contests CPlusPlus crime CSharp D Programming Data Centers Databases Debugging Delphi Deployment design Design Patterns Digital Signal Processing Distributed Django Documentation DSL dynamic language Eclipse EDA education Emacs Embedded Systems Encryption engineering Erlang Etymology Excel exception handling Facebook Financial computing Five Questions Flash Flash Lite Flex Forth Fortran Fraud FreeBSD Fun Functional Programming gadgets Games Gender Git gnuplot Go Google Graphics GUI hardware Heron High School High-Performance Computing History Holographic reduced representations HTML5 Humanity Humour Hungarian Notation Identity Inkscape Innovation Intel Interview iPhone J2EE Java JavaFX JavaOne JavaScript language engineering Legal lex LINQ Linux Lisp Literate Programming Logic Programming m4 Mainframes Make Mathematica Mercurial Mesh messaging Metaprogramming Microsoft MID Miscellaneous Musings ML Mobile Software Mobility modeling modular programming multicore Music MVC myblog Natural Language Processing Networking Neural networks newspeak Nokia numerical computing Object Rexx ObjectiveC Office Office 2007 Online spreadsheets OOP Open Source Openaccess publishing OpenBSD OpenSolaris Operating Systems Optimization Oracle Pair Programming Parallelism Concurrency Parsing Pascal Patents Patterns Performance Perl PHP Podcast Pop11 Poplog Privacy Processing Productivity Programming Language Implementation Programming Language One Programming language semantics Programming Languages Programming Style Project Management Prolog Psychology Public understanding of science puzzle Python QA Quantum Computing Quotes Rails Realtime recls Requirements Research practice REST Review RIA rich internet applications Robotics Ruby SaaS Software as a service Scala Schadenfreude Science fiction Screencast Scripting SD Best Practices Search Security Semantic Web Silverlight Snobol SOA social Social Networks Society for the Study of Artificial Intelligence a Software Development Methodology and Management Songs and poems Spending Priorities Spreadsheets SQL Startups Statistics Storage String pattern matching Survey Teaching Testing The Business of Programming The Dobbs Challenge The Future Theory Topology Transhumanism Travel on the Job Twitter Types Unix Upgrade Usability Use Cases USENET User Experience User Interface Design Version Control video virtual machines Virtualization Visual Studio Visual Studio Sponsored Post WCF Web Development Windows Windows 7 Windows Live Wireless WOA WPF X Window System yacc

Subscribe to Dr. Dobbs Newsletter

Email:
Dr. Dobb's Update
Delivered twice a week, Dr. Dobb's Update provides unbiased and objective news, commentary and technical features spanning the entire software development marketplace.

Latest Comments

Jonathan's Last Day at Sun
For the 8 years I worked there, it was fantastic. I worked there under McNealy and I have undying admiration for the guy. I only knew Jonathan periphe...
Implementing Thread Local Storage on OS ...
Back in the day, I did a fair amount of work with PThreads. Wonderful design. Some quirks, but basically really, really nice. Although I wrote a lot ...
More Technonecrophilia with Snobol One-L...
Yeah, It's probably identical except for the (embedded) copy number, I would think. Once it became freely distributable, the copy I've been distribut...
More Technonecrophilia with Snobol One-L...
There's a spitbol-3.7-win.exe at http://code.google.com/p/spitbol/downloads/list . I found it via Dave Shield's blog page http://daveshields.wordpress...
Jonathan's Last Day at Sun
Sadness.

The Latest From Our Member Blogs

How To Select Trainees
Written by Joel Wiesen   
01/27/10
Hiring the right trainee can be harder than hiring a trained programmer.  One approach is described at my website: http://www.aprtestingservices.com/business/lpat/
 
Technical Job Interviews
Written by Keith Kerlan   
01/20/10
What is the best way to interview for software developer positions?  I've been on both sides of the job interviewing table, but have been on the interviewee side of some not too  great inter
 
Timers/timeouts in multi-threaded event-loops
Written by Christof Meerwald   
01/03/10
The traditional way to integrate timeout handling (or timers) in (single-threaded) event loops was to just pass the appropriate timeout value to the select/poll/epoll syscall. While this works fine
 
C vs C++
Written by Issam Lahlali   
12/04/09
I think that the debate "C vs C++" will end when the two langages died, and each one have its advantages and inconvenients, the choice of one instead of another depend on the application c
 
Great Jobs at CISCO
Written by Brent Rogers   
11/30/09
Hello! I am a recruiter at CISCO. We have a number of great jobopportunities at CISCO right now. Please take a look at the job links listedbelow and please send me an updated resume if you are interes
 
OK Labs, ST-Ericsson, and the Mobile/Wireless Ecosystem
Written by Steve Subar   
11/17/09
Two weeks ago, OK Labs and ST-Ericsson announced the selection of OK Labs as ST-Ericsson's mobile virtualization partner. To earn this coveted position, OK Labs prevailed in a rigorous evaluation
 
C++ Ninjas Needed in Santa Clara, California
Written by Brent Rogers   
09/30/09
Hello! I am a recruiter at CISCO. Our PostPath teamin Santa Clara is building a new Email SaaS business at CISCO. We are looking forsenior developers with Zimbra expertise to help us accomplish this t
 
Fighting Fragmentation with Mobile Virtualization
Written by Steve Subar   
09/21/09
Last week Motorola and T-Mobile announced the launch of a new and innovative Android-based smartphone, the Cliq. This attractive, feature-rich slider handset happens to build on a chipset and firmware
 
Insights into Router Design: Unit Testing of Networking Protocols
Written by Rajesh Kumar Venkateswaran   
09/07/09
  Unit testing is a software validation methodology through which a programmer tests individual modules or units of source code. If the programmer has been responsible for developing a networ
 
Insights into Router Design: Implementation of Networking Protocols
Written by Rajesh Kumar Venkateswaran   
09/06/09
  Modern data networking consists of a large number of networking protocols, each of which has its own domain of applicability. Some run on end stations (also called hosts), some on enterp
 
Insights and Innovations in Networking
Written by Rajesh Kumar Venkateswaran   
09/05/09
Networking devices such as routers and switches have evolved quite a bit over the past years, both in the service provider network and in the enterprise. It is a challenge to build these devices, bo
 
reddit threads community
Written by Christof Meerwald   
08/30/09
I have just started a threads community over at reddit to cover topics such as multithreading, concurrency and parallel programming. Feel free to join if you are interested. -- cmeerw.org 
 

The Latest From Dr. Dobbs

DDJ