Web 2.0, Meet JavaScript 2.0 248
Jeremy Martin writes "Well I suppose it's an undeniable fact about us programmer-types — every now and then we just can't help but get excited about something really nerdy. For me right now, that is definitely JavaScript 2.0. I was just taking a look at the proposed specifications and I am really, truly excited about what we have coming."
Ugh (Score:5, Insightful)
Operator overloading? Great, now you can enjoy C++ style code, where left shift and print are the same command.
All of the proposed changes are a step backwards. JavaScript is currently a language with great, clean, semantics and slightly ugly syntax. They want to make the semantics less clean and the syntax even more horrendous.
Re:Ugh (Score:5, Funny)
But wait until Sunday and we'll hear that Javascript 2.0 has arisen and all the stains of previous imperfect languages will be taken away.
Re: (Score:2)
Re:Ugh (Score:4, Funny)
Re: (Score:2)
Re: (Score:2, Informative)
User-defined overloading, obviously. And it's considered by some to be a bad idea. [elharo.com]
Re:Ugh (Score:5, Insightful)
Grand-parent gave an example of built-in operator overloading, not user-defined operator overloading. So no, it isn't "obvious" that he means user-defined operator overloading.
From the linked-to article:
Features that are guaranteed to be misused should be eliminated.
What a load of utter bollocks! Show me a feature that cannot be misused, and I'll show you a feature that isn't terribly useful.
If you dont know the difference between a group, a ring, and a field, you have no business overloading operators.
What an arrogant asshole! That's as non-sensical as an assertion that only parents have any business creating class hierarchies.
Re: (Score:2)
1. The feature will be misused every single time. There is NO POSSIBLE correct use.
2. The feature will be misused at least once.
Meaning 1 is completely indefensible, and the author doesn't even make an effort at substantiating it. He provides exactly one example of misuse. Chances that meaning 1 were intended: slim to none.
Meaning 2, on the other hand, actually fits with the rest of the article.
As the number of uses of a featu
Re: (Score:2)
If you'd bothered to read the comments on that page, you would've seen plenty of examples why operator overloading is a good thing.
It's amusing seeing Java fanbois whining about operator overloading being a "bad idea", since Java is already riddled with shitty implementations. Just look at containers, for example.
Re: (Score:3, Insightful)
I think thats the point. (Score:2)
And in my book having more javascript is the huge step backwards.
Re:Ugh (Score:5, Insightful)
I do agree with you there -- we don't need classes. And if we did, we could implement them, in JavaScript.
If you really, really want to, then yes. But that it can be abused doesn't strike me as a serious reason for not including it.
I had a problem awhile ago. It was developing for HD-DVD, meaning we didn't have full JavaScript -- meaning I couldn't, say, extend Array. Even if I could, I'm not sure how much better I could make this... I had created a control for displaying a scrolling menu of widgets of some kind. The point is, the control itself shouldn't care about what those widgets are, or even that it's operating on something that's actually an array. It would've been nice to let it work with an array for now, knowing I could always roll something that pretends to be an array later.
Instead, what I ended up doing was wrapping the Array in a monstrosity which contained methods like getValue(), setValue(), etc. It was hideously ugly, but it would tend to work, and would even automatically wrap an Array if needed.
But it's ugly hacks like that which drove me away from Java in the first place. I'd rather duck-type it properly, like I do in Ruby. If it claims to have a working [] operator, and has methods like size() or length(), either it's an array, or it's pretending to be one, so treat it like an array.
Or as James Gosling is supposed to have said... (Score:2)
James Gosling: "I'd leave out classes!"
The functional/prototype hybrid in Javascript was a little odd and hard to get used to, but once I did, I've found I like it better than a Class model. Interface/implementation works for me too, but especially in Javascript, I never feel like I really need that fancy keywords to get that done.
There's an awful lot of serious work in the Java community, but I sometimes feel like a lot of *common* practices have
Re: (Score:2)
I'm interested! Care to point to any patricular papers? Thanks in advance.
Re: (Score:2)
Re: (Score:2)
Why would
print("astring" + "anotherstring" + "thirdstring");
be better than
cout << "astring" << "anotherstring" << "thirdstring";
?
Semantically, they're both equally bad.
Re: (Score:3, Interesting)
Well, for one thing, 'print' is a verb instead of a noun. Also '+' is often used as shorthand for 'and' in English, so it's probably semantically clearer and more intuitive.
Now, if anyone can tell me why C's indirection operator is the same as 'multiply', and its address operator is the same as bitwise AND?
I always thought it would make more sense to use '$' = 'v
Re:Ugh (Score:5, Interesting)
I always thought it would make more sense to use '$' = 'value of' and '@' = 'address of' for these.
I think that by far C's main syntatic problem is using a prefix operator for pointer types and pointer dereferences, when the other type operators (arrays and functions) are postfixes. Because of this mistake, virtually all C programmers to this day, do not fully understand C's declaration syntax.
For example, to declare a function that takes a pointer to a void function(int) as an argument, and returns a pointer to a function(void) that returns a pointer to an array[SIZE] of chars, you would have to write: It also means we have to write: because:
(*m).x is required with a prefix operator, and is hard to type.
There are few C programmers who can read that first example. Now lets try a Pointer-as-postfix syntax for the same thing. We shall not use * as a postfix operator, because it would make the expression: "a * - b" ambiguous ("a*(-b)" or "(a*)-b"?). Instead, let us use your suggestion, and make "$" the postfix type operator, and dereference operator, and see the consequences. Lets also put the base-type after the expression instead of before it, and see what happens to the above declaration: Note that this simply reads left-to-right now (because we removed the mishmash of prefix/postfix operators), and there is no need for parenthesis to denote precedence, just functions.
The "->" syntax is no longer needed, as like in Pascal, we can have: which clearly means: dereference m and then get the x member.
Re: (Score:2)
That's fine, sounds to me like they're throwing away the prototype part. Bastards.
> Operator overloading? Great, now you can enjoy C++ style code, where left shift and print are the same command.
Yes, because of course that's mandatory. God forbid that anyone be allowed to express a thought not approved of for the original datatypes hardwired into the language. Seriously, do you actually consider this argument valid? I gu
Re:Ugh (Score:5, Interesting)
Wrong!
The justification for classes in a prototype-based language is to use type safety properties in library and infrastructure code. Read enough from Brandon Eich and Douglas Crockford and you realize there are strict limitations on what safety properties can be guaranteed by current JS. At least, providing such properties is convoluted and error prone. Classes help provide needed structure for places that JS cannot hope to provide solutions today.
For example, I have a suspicion that Brandon is really attempting to replace the the Mozilla DOM code (C++) with JS2 code. This would simplify the interaction of the garbage collectors (some of those "memory leaks" everyone fusses about, ESPECIALLY in IE) and other infrastructure code.
Classes in JS2 are NOT about needed to emulate Java, so much as it is about providing tools to write robust libraries. Want more proof: MS Silverlight and Adobe Air are both based around JS2-like enhanced scripting languages. Those products make extensive use of the type safety properties brought by classes. This is also Brandon's main complaint against MS ATM. MS is promoting proprietary products with a JS2-like language, but stonewalling support for an open standard (with a robust reference implementation). Think about that for a minute: JS2-like languages are shipping today. Why can't we have a public standard for everyone else to use? Prototypes stay useful, though. MS incorporated extention methods in .NET 3.5, which have much the flavor of prototypes (when combined with generics) in a class-based language. Classes also bring some performance improvements, but that seems to be a secondary concern.
So, we have classes to build robust libraries and prototypes to glue them together with random code. Best of both worlds.
Finally, JS2 is 95% backwards compatible with JS1. The missing 5% is due to clarification of murky parts of JS1 and fixing a few issues everyone complains about. This also obliterates the need for multiple implementations of JS1 and JS2. The JS2 engine can take care of code, old and new. Even with class-based programming and you can "route around" classes using prototypes to extend functionality if you don't need the safety properties (most web code, but not libraries).
Re: (Score:2)
Cross-Browser (Score:3, Insightful)
javascript or DOM/etc.? (Score:2)
The latter having nothing to do with the actual javascript syntax, semantics... i.e. the language
Re: (Score:2)
I write CLI programs in Javascript, you insensitive clod!
Re: (Score:3, Interesting)
For example, some corporate environments think that disabling all the programs in system32 to be a "security feature"... which means you can't do things like fix corrup
Re:Cross-Browser (Score:5, Informative)
Re: (Score:2)
Not defending it, but why were "layers" so different than the now standard "z-index"? People were strangely hostile to them.
JavaScript 2.0, Meet NoScript 2.0 (Score:5, Funny)
Re: (Score:2)
You can disable that new tab that gets opened after every update by opening a new tab to about:config and searching for
noscript.firstrunredirection
and setting to false.
Just wanted to put that out there in case n
Re: (Score:2)
extensions.update.interval
It is measured in seconds (no kidding), and by default, looks to update extensions every single day. I set mine to 15 days. There is also:
extensions.update.notifyUser
If you set this to false, extensions will be updated silently.
Firefox has a whole slew of undocumented se
Javascript (Score:2, Funny)
JavaScript changing into Java (Score:5, Insightful)
JavaScript changing into Python (Score:5, Interesting)
There are indeed many Java-y features being added, such as "use unit" and classes, but these are also Python features. The one feature I saw from the article that looked distinctly Java-ish was static type checking at compile time, and Python will have something similar by the time JS 2.0 is generally usable (i.e. both are optional).
Features in nearer-term versions of JS are even more obviously Pythonic, though. Generators and tuple unpacking, for example.
I'll lay my cards on the table and say that I think Java makes programming laborious and unpleasant, and Python does just the opposite. These features don't seem to make JS any more programmer-unfriendly, and they add a lot, so I'm looking forward to Pythonic JS 2.0.
Re: (Score:2)
Unless you're talking about PyPy, it won't. It sure doesn't in 3.0, which added type annotations that only work on functions and methods. And these annotations? They don't actually do anything at all.
As long as I got my Framework (Score:3)
As for specific features. I'm looking forward to cleaner and easier to manager asyncronous AJAX. While the client requesting from server has been well thought out, the server sending to the client is still very patchy and not particularly easy to develop for.
It would be nice if I could create socket connections with AJAX to say IRC but still go over HTTP proxy.
I'd also like to see AJAX file uploads that don't have to run through Flash. I think FF3 supports this already.
Re:As long as I got my Framework (Score:5, Interesting)
Re: (Score:2)
Re: (Score:2, Informative)
you can track the status.
Use a perl (or some other language that handles everything manually*) script to receive the upload submission and write it to disk in a known location with a known name*. A second script can then compare the file size as it's uploading. Somewhat ugly
* PHP won't work since file uploading is handled behind the scenes.
** this may involve storing statistics in a database, manipulating session data, etc.
Re: (Score:2)
Javascript 2.0, usable by 2015... (Score:5, Insightful)
By the time JavaScript 2.0 is available in nearly all browsers you find in the wild, there will already be a JavaScipt 4.0 spec out and you'll be able to write this exact comment with the dates and browser versions updated.
The point being that client-side programming is a complete mess right now. Instead of new versions of scripting languages, we should be pushing browser makers to allow scripting to be installed via plug-ins rather than being native to the browser. That way, a website can trigger the user to update to the latest version of the language spec (ala the much-maligned-here flash plugin). That should also allow website authors to use any language, not just JavaScript. After all, if you're developing your site in RoR, wouldn't it be easier to use Ruby for the client-side scripting as well as the server-side? The same would go for Python, Perl, PHP (/me shudders) or even Java/Groovy.
But as long as we are beholden to the browser manufacturers to release updates of their browsers in a timely and compliant manner, we'll be stuck in this cycle where we can't use the latest-and-greatest features until they're no longer latest-and-greatest.
Re: (Score:2)
Re: (Score:2, Interesting)
http://wiki.mozilla.org/Tamarin:ScreamingMonkey [mozilla.org]
Don't forget about ECMAScript and Actionscript! (Score:2, Informative)
That being said, Flash Actionscript 3.0 (available now) includes many of the new features found in ES4 such as real classes. The next version of Actionscript will most likely be ES4-compliant.
Notable features in ES4 include:
- Classes and interfaces
- Generics
-
Re: (Score:2)
All it would take is one example to set the bar for others to follow.
Re: (Score:2)
I'm afraid of this idea. Partly because it reminds me of Java applets and Flash.
Re: (Score:2)
Thanks, but no thanks.
Here's the short list of potential problems with that:
Re: (Score:2)
Re: (Score:2)
"Program Units" - potential for misuse (Score:4, Interesting)
William
Re: (Score:3, Insightful)
Re: (Score:2)
I realize that when used properly, this is probably not an issue - hence "misuse" in the title. But the language should be designed such that it does not promote dangerous code. We are talking about running code from a remote host - that can always result in problems.
My first thought is that allowing for
Re:"Program Units" - potential for misuse (Score:4, Informative)
No, really, there's no new security problem here. Different hosts? How is that different to <script> elements pointing to different hosts today? Compromised hosts? What's different to today?
Browsers have been able to download code from disparate, potentially untrustworthy remote hosts since they first started executing JavaScript. You have not discovered a new problem.
Somebody already did, but you didn't like the answer.
Re: (Score:2)
I would guess the first implementations will not allow code to be downloaded from a site/tree other than the one the page belongs to.
Re: (Score:3, Interesting)
You're talking about signed scripts, something not very commonly used. Something about being endlessly prompted to approve your browser's verification of the script's authenticity, or some crazy shit like that.
Point is, however, you're talking about a vulnerability that's in the ne
Is writing Evil Javascript still supported? (Score:3, Insightful)
Yes, I'm aware of NoScript and similar add-ons, and I'm happily using them. That helps, but there's still too much bad and ugly stuff out there to be happy about anything good that JS can do.
Re: (Score:2)
Re: (Score:2)
I took that as a challenge, and in just under a minute I had an implementation of the naive (exponential performance) Fibonacci algorithm in Java, and told it to spit out the first 1000 Fibonacci numbers. It's sucking CPU like there's no tomorrow. Were you under the impression that Java couldn't do that?
Re: (Score:2)
That's different from Java... how?
Re: (Score:2)
Re: (Score:3, Insightful)
Things to come... (Score:2)
I'm predicting "NoScript 2.0" :-)
Bleah. Classes. (Score:2)
Re: (Score:3, Informative)
Gosling's argument against classes is that they encourage implementation inheritance, instead of interface inheritance.
Javascript lacks interface inheritance, and that's what makes it weak.
IMHO, inheriting the implementation from an object buys you nothing of value because well-structured code simply doesn't need it.
Standards rule (Score:3, Interesting)
class keyword (Score:3, Insightful)
Re: (Score:2)
IIRC, IIUC, AFAIK, etc.
xss 2.0 (Score:2)
Great. (Score:2)
Interesting evolution (Score:2, Funny)
Is it humanly possible to make this any more complicated, brit
Here's the link to the real info. (Score:3, Insightful)
First, ignore the ad for the blog and go directly to the language specification. [ecmascript.org]
I read through that and winced. It's one of those backwards compatible hacks that makes a language ugly. Current Javascript has a class implementation based on copying a base object, but no real class abstraction. This follows the model in Self. Most other object oriented languages (C++, Python, Java) have explicit class declarations. Javascript 2.0 adds class declarations without throwing out the old mechanism. This is a mess. I understand why they were forced to that decision, but it's still a mess.
The trend continues. They threw in most of the things Python 3K has and current Javascript doesn't: type annotations, generators, and packages, and namespaces. There's type checking, but it's optional for now. (This is like the transition from K&R C to ANSI C). Java-type interfaces where thrown in. At least they didn't add templates. It's a collection of features in search of a design.
In the end, we get something that's like a mixture of Java and Python.
Re:Here's the link to the real info. (Score:4, Informative)
A parameterized type is a template for new types and is defined by adding type parameters to class, interface, type, and function definitions:
A parameterized type is instantiated by supplying concrete types for its parameters: The predefined types Map, Vector, IteratorType, and ControlInspector (among others) are parameterized.
The parameterized types in ES4 do not allow for type parameter constraints or variance annotations. However, nothing precludes the inclusion of these in a future edition of the language.
Adoption (Score:2)
And I am really, truly depressed about... (Score:2)
Re: (Score:2)
I have a hard time imagining this as something that is actually going to be used in cases where there's another option available.
It definitely looks like a step in the right direction, but until I don't have to choose between worrying about browser specifics or being overly limited, I'll remain skeptical.
Re:v2.0 (Score:5, Insightful)
I can. Javascript makes it really quick to hack together a dynamic page. Sure, it results in spaghetti code and the resulting HTML tends to be out of standard, but people will keep using Javascript as long as it remains so damn easy.
Re:v2.0 (Score:4, Insightful)
"On a scale of 1 to 10, how would you rate yourself with Javascript?"
"I'd say about an 8."
"Okay, can you write a simple Javascript object on the whiteboard for me?"
"..."
Lucky for them, I mostly looking for smart people I can train. I've only met one other person IRL who even knew how to code Javascript properly.
Funny, my Javascript tends to be well structured, object oriented, and reusable.
The #1 problem with Javascript is that everyone "learned" it from cutesy little toolbar/cursor scripts rather than actually learning the language. As a result, it's not immediately obvious to most coders how to use the language. Thus they tend to run into variant typing issues and write a procedural mess of spaghetti code. Which is silly, because Javascript has some of the best features of functional languages like LISP!
Netscape published an excellent guide to the language [mozilla.org] over a decade ago (now maintained by Mozilla.org). I'm going to take a wild guess and say... you've never read it, have you? If you had, you might be bemoaning the lack of good Javascript knowledge in the market rather than placing blame on the language itself.
Re: (Score:3, Interesting)
Re:v2.0 (Score:4, Insightful)
So I've been trying to wrap my head around this statement. I'm not too sure what it means. Am I supposed to be angry at javascript because it's ease of use causes terrible code to appear in the world because Joe Sixpack thought he was a js coder by looking up examples in the internet? Or is it more of an elitist coder mentality, like a secret javascript club where Joe Sixpack should not be allowed in?
Re: (Score:3, Insightful)
Like HT
Re:v2.0 (Score:4, Insightful)
Insightful? What? In the old days of the web the whole javascript / dynamic html nonsense was a mess. But modern javascript/html interaction is much more sensible.
It might surprise you to learn this but javascript is actually quite a nice language -- I'm a Real Programmer(TM) and I've been dabbling with a bit of javascript recently for UIs to our tooling -- and the only thing dragging it down is DOM's uglyness (and, frankly, life's too short to try to learn the stupid inconsistencies between Firefox, Safari and IE). However there are solutions: a library called jQuery makes working with the browser rediculously easy: it abstracts away various inconsistencies for you (and also makes the syntax nice and elegant/compact).
A nice example is setting CSS properties - with jQuery you simply use: $("p.showable").css("font-weight", "bold").show("slow"); this code selects all paragraphs with the "showable" class, makes their contents bold and fades them into view (if they're not already visible)
Debugging isn't as bad as you'd think, either thanks to Firebug. And AJAXy things can make a page much more useful - we update a log viewer based on the restrictions specified (eg. from machine X,Y or Z, from application B, log level >= INFO) which makes it at least as useful as ssh+tail :-)
Re:v2.0 (Score:5, Insightful)
Re: (Score:2)
I'd love to see JavaScript outdated or made obsolete by a real language each browser could understand.
Re: (Score:2, Insightful)
Re: (Score:2)
You have no idea whether or not I'm a good programmer, so you have no qualifications to make that judgement.
And, incidentally, I was not focusing on the incompatibilities, but it's interesting you assume so.
In the past 6 years I've taught myself 6-8 languages that didn't even exist when I used to program in 6502 Assembler. It's been enough to create a small business that sustains itself on 2 hours of work a week and still
Re: (Score:3, Insightful)
Given that your main objection to JavaScript seems to be that you refuse to learn the paradigms it espouses, I think that's plenty of evidence right there. Just because you don't understand a language does not make it weak.
Re: (Score:2)
Quote the part in either of my posts where I state that is my main objection.
I didn't.
I never gave or stated any specific objections to JavaScript. I (thankfully) haven't had to use it in 4 years
Yet, somehow, someone seems to think I did, and you seem quite eager to take that misunderstanding and use it as an excuse to make judgements about someone you don't know.
While you're at it, do you want to go
Re: (Score:2, Funny)
For starters there's your hair. YOU ARE NOT MARGE SIMPSON! That look does not work for you.
Re: (Score:2)
I only wear the blue wig when...
Well, you really don't need to know anything about that!
Re:v2.0 (Score:4, Insightful)
Re: (Score:2)
And what the hell is wrong with primitives, anyways? Everything doesn't need to be an object.
Re:v2.0 (Score:5, Funny)
To paraphrase Palmerston:
Re:Meh. (Score:5, Interesting)
Re:Meh. (Score:5, Interesting)
Re: (Score:2)
Having known Microsoft since the early 80s, I can tell you I won't.
Flex (Score:2)
Flex is pretty clean, fast, and the language is great. Lots of pretty stuff, as well as lots of scope to create great platforms.
Screw Silverlight. Why muck around with unnecessary complexity and vendor locking. Flex is comparatively elegant and simple. Just my opinion for having used both.
Re: (Score:3, Funny)
Re:Sounds awesome, (Score:5, Informative)
Seamonkey even has a javascript debugger.
If your using IE, well then *snigger* your screwed.
Re: (Score:2)
Re:I'm actually not looking forward to this (Score:5, Insightful)
JavaScript is a language with first-class closures and a rich Self-style object model. The syntax is a bit ugly, but the language is really a joy to work with once you get past the 'it looks like Java' stage.
Re: (Score:2)
The dog's lunch that is web coding is the reason that Web 2.0 has virtually 100% penetration (yes, at a cost in complexity and reliability). All those pieces are interchangeable (ASP/JSP instead of PHP, flash instead of HTML/CSS), so no company can get a lock o