… stop! I see you there upgrading a dead man (think ECMASscript.next) or even trying to replace it with some backwards compatible gibberish (think Google Dart). Let’s talk first…
So, yes, JavaScript is one hell-of-a pain-in-the-ass language, which is dynamically typed and then again not – think arrays and objects. It’s not OO, but yet you can do it – think anonymous functions and objects or functions within functions, ala funception :). The list might go on, and in overall it’s messy, not that easy to read and not that easy to maintain, not that easy to refactor and not at all easy to extend or build some modular systems, yet it’s specified by ECMAScript. Now JavaScript is not the only language conforming with the ECMAScript specifications, there is one more player on the field, it’s just running in it’s own VM for now and has it’s own community – ActionScript 3.0.
Why can’t you take this beautiful language, with full OOP support, events and anonymous functions and adapt it in to a web browser? I’m not saying you should implement the whole Flash framework as well, just the core classes and the syntax.
How it would conform with the web as we know it, you may ask. Well one of you has already implemented two different languages in one browser – Internet Explorer with VBScript and JScript. It would look like this for starters:
<script type="text/actionscript"> package { import dom.*; class MyClass extends DOMDocument { public function MyClass(){ super(); addEventListener('onload', init); } private function init(e:DOMEvent):void { alert('we\'re done!'); } } } </script>
DOM events, dom classes, Xpath, everything you need to build a web. Built-in objects like: Date, Number, Array – they are already there in JavaScript. Take the syntax, add fully blown OOP, throw in some new classes like Mouse, MultiTouch, Browser (for example, for user agent information) etc. – do it as Macromedia did it when they created version 3 of ActionScript when the previous one was more like JavaScript. This is one of reasons why Flash will not die that soon – it has is it’s very well built language and frameworks (Flash and Flex).
How about performance – AS3 does it that well, because it’s compiled – the answer might lay in cache – do not cache plain source files, cache bytecode, cache compiled source – for faster execution.
And finally – for the love of god, do this thing together. Yes I know I’m trying to ask for the impossible in this corporate world, but then again – you did well with HTML5. 🙂
And again, if you have some pros or cons on this subject, let’s discuss it in comments section.
Sincerely yours,
Gusts
Well, this could be a start for great changes. You should contact mozilla’s spidermonkey team or maybe someone who’s responsible for ECMAscript specs. That would be W3C, I suppose.
Sorry to say that but even if we can agree on most, why actionscript? why not dart? Why not anything else?
Honestly, I don’t care if tomorow language for the web is actionscript or anything. Whatever, this will not be what we really need.
Language evolve and the web has to stay compatible with old browser versions, and worse with differents browsers vendors.
If we had to settle on a technology, I would like to see a real VM. Something that would concentrate on a good low level API, a good deployment and delivery mechanism for web apps (why not dowload your whole page as a zipped bynary for example?) and of course good bytcode that would allow easy compilation and interoperability from any possible language.
You could like to program in classic javascript, java (think GWT it’s already here) or lisp (think clojurescript). All of this should be covered and possible with the new VM.
If this is just to bring a little less bad language that will not fit in many case, who really care? We already compile to JS anyway. At least this is working now.
You can write your app in more languages now, as soon as they compile to JavaScript, and there are several. Think Dart and CoffeeScript. They have nice syntax, and could be extended with types. Extending built in objects will never work in SOME browsers, and for some extension, it doesn’t even exist in either JS or ActionScript. For example you cannot make an object that works as an Array even in ActionScript.
My main concerns are the syntax and built in classes. JavaScript as we know it is still living in 1995 when it was first introduced – it’s lazy event driven first-class function language with basically only one object – the window. in which you can kinda write inner objects.
You are saying that “Extending built in objects will never work in SOME browsers” it’s only because the developers of these browsers are lazy as f**k (sorry for my language), but you can see that every day in for example IE – it’s still in it’s 2001 form which is being extended to mimic the features of today. And then Microsoft is talking about HTML on the desktop (again, remember windows 98 with ActiveDesktop?) in their newest OS – win 8. What they actually are talking about is – bringing a new OS back to 1995.
Well, I’m not saying that ActionScript is perfect, but it’s a good start and it brings lots of opportunities – It could bring a common OOP approach to the web. It has a great community, which could bring lots of ready to use libraries (think as3corelib with all the JSON, Base64, Image processing etc. classes written purely in AS3).
The difference here is that JS is 16 years old and hasn’t changed much. AS3 is 5 years old. We need to bring a new language which would be next logical step from AS3, not just some new invention which could be translated/compiled into JavaScript – this is not an upgrade, it’s just a lousy fix. It is just a solution for a developer to write things easier, but once you’re done, you compile and then you have to go through the JS code and optimize it by yourself.
Erm, was this post written in 2008? We’ve had this debate and (very unfortunately) ECMAScript 4 lost. You can blame Microsoft:
http://gskinner.com/blog/archives/2008/08/javascript_stal.html
Sorry, that I jumped late in the game, but you know, better late than never. 🙂 I read your post from 2008 and it’s actually quite sad that, because of Microsoft’s (kinda) monopoly at the time, this idea went into a oblivion. But now the times have changed – there are new market share statistics and they are still changing, and Microsoft has shown it’s will to write something new, not just upgrade. So I want to stir up the waves in the tea cup, and try to bring this topic back on the table.
The difference between JavaScript on the web and ActionScript in Flash, is Flash needs compiled. That process allows it to build a mapping of packages to allow for importing. It is built right. As of right now, this will not work in the web world. The code is sent as source, so it can’t make a mapping to packages and namespaces. If there were a way to get that complication process in before the browser downloads, then I think you’d be onto something. But that is a very hard step to over come.