Should JavaScript Get More Respect? 439
An anonymous reader points out an article in IBM's Crossing Borders series about the language features of JavaScript, surely the Rodney Dangerfield of scripting languages. But with increasing use in such technologies as Ajax, Apache Cocoon, ActionScript, and Rhino, some industry leaders are taking a fresh look at the language. From the article: "Nearly every Web developer has cursed JavaScript at one time or another. Until recently, many developers had all but written off JavaScript as a necessary evil at best or a toy at worst... But JavaScript is becoming increasingly important, and it remains the most broadly available scripting language for Web development."
Dense != Good (Score:5, Insightful)
"My friend and colleague Stuart Halloway, one of the foremost experts on Ajax, begins a JavaScript class with a provocative statement: "By 2011, we will recognize JavaScript as a language with a better set of features for developing modern applications." He then says that JavaScript programs are often 10 times as dense as similar Java programs and goes on to show the language features that make it so."
The author seems to equate dense with good, not an association I make
Re:JS (Score:4, Insightful)
Why the pressure ? (Score:1, Insightful)
I just dont get why ?
Theres something called freedom. If something is useful for developers, they like it and they use it, and they think good of it, they pay it respect. If something does not catch their attention, or they think its not to their liking, they just ignore it.
I just dont get why are we being pressured to look into matters java, javascript. If they are respect-worthy, they will earn the respect by themselves good enough. If not, noone can make developers to respect something by propaganda or by coercion.
Re:Dense != Good (Score:2, Insightful)
So are the javascript developers in my experience. I kid, I kid...
I agree with parent poster that there seems that a lot of people take lines of code as the only measure of how good a language is. Something like 80% of developer time for an average project is spent on maintenance, and often there are new developers doing it. So in my opinion clarity is at least as important.
I admit that fewer lines of code can make code more readable, but brevity does not automatically mean clarity. Witness many perl based apps, especially those that make heavy use of regexp. I have also seen some pretty unreadable Ruby code where the programmer was clearly in love with all the clever things you can do. Metaprogramming, activerecord magic, method_missing stuff, runtime changes of objects where it was just more convenient than thinking through the model, and so on. Probably fun to write, nightmare to maintain.
The language is fine, but it's got baggage (Score:5, Insightful)
JavaScript is wonderful (Score:1, Insightful)
What I don't get is why developers use PHP, which looks like it was thrown up after a frat party. JavaScript would fill the bill as a decent language with a C-based syntax much better.
Like Visual Basic ... (Score:2, Insightful)
Only reason people are using it, is because it's the only thing that let you manipulate a web page and will work more or less for 99% of the people out on the internet. Would all browsers ship with only COBOL people would be using it. Would I have the coice between JS and let's say Python or Ruby, I wouldn't even have a look at it.
Re:Why the pressure ? (Score:1, Insightful)
How many web developers respect IE, relative to how many make their pages IE compatible?
In the case of javascript, if you were developing a browser you would have to include javascript support or be marginalized. So while those developers have the choice not to implement it, realistically, they have to.
Same with developing for Windows, working with it in some cases can be a pain in the ass. But that is where the market is. Thus programmer time can be wasted working with a beast while greener pastures are available, but not commercially viable.
Standards can be forced on people, even if they are bad.
Too Hard to unit test (Score:3, Insightful)
Dear god no. (Score:3, Insightful)
Wouldn't the web be a nicer place if you could script the browser using Ruby or Python? Can you imagine the fun you could have working with constructs like:
@page.findById( "myID" ).each do |ajaxReturn|
The web could be beautiful. Next on my hit list is an improved HTML / CSS. Should rounding corners, or drawing shapes / shadows really be done with gif/pngs?
Re:Security is a problem (Score:4, Insightful)
No obfuscation will make it very different from what it is. A code indenter, a variable name replacement, and it'll be already understandable to pretty much any programmer.
Daft story title... (Score:3, Insightful)
Thus I have a lot of respect for it as a client scripting language, in most cases it's the only way of getting something done in a browser.
Re:Why the pressure ? (Score:5, Insightful)
In the case of anything involved in web development, I use tools because they're the best thing for the job. Unfortunately, "best" for web dev tools usually means "only" or "no one will be able to view your page if you develop with something else."
Java Script / J Script is the devil. Development is a sloppy crap shoot, but we use it because it's there. It's now being used for ridiculous things that it was never really designed for.
On one hand, web 2.0 AJAX sites are cool, on the other hand, AJAX makes me throw-up a little bit in my mouth every time I type it's name.
Re:JavaScript is wonderful (Score:4, Insightful)
One lesson ruby learned early was that you don't get anywhere till you build your own version of CPAN (still the king!). Build your library, build a way to install, uninstall and upgrade your libraries smoothly and your language will take off.
In conclusion. It's the library stupid.
Re:JS is not the problem, the whole environment is (Score:3, Insightful)
Re:Dense != Good (Score:3, Insightful)
Maybe, but writting the program is fast. What is slow is writting a program that works.
Now, How does Javascript helps you to wite code that works at the first try, or maintanable code, or code that is easier to debug? Well, the answer is that without sane objects, a workable type system, some rules that prohibit bad patterns of code, and most of the other things that make Java verbhose Javascript simply doesn't help you.
Re:JS (Score:3, Insightful)
It strains credibility to claim that, after producing something functional, management would give you the time to replace it with something such that, "the recipients never knew when we migrated from the stop-gap to the final".
And I don't mean that as a typical geek management-slam - If they can't tell the difference, why should they approve the team spending twice as long on the cleanup as on the prototype? Yeah, the engineers might know the difference, but the aesthetics of the underlying code rarely counts as making for a better a business case.
Re:JS (Score:3, Insightful)
Only because Sun trademarked "Applet" it doesn't mean they invented it, or that they own it.
An applet is a small app. More often, it's a web, client side app. Much more often, it's a "Sun Java Applet".
In the context of this discussion, the second meaning was obvious. All of your responses were too pedant. There _are_ applets that are not "Sun Java Applets". In the context of _this_ discussion, it was clear what he was talking about.
Re:Dense != Good (Score:2, Insightful)
Of course this is a humorous post, but I have to ask, what does a namespace construct provide that you don't have with JavaScript already?
to quote Wikipedia [wikipedia.org] a namespace is an abstract container providing context for the items (names, or technical terms, or words) it holds and allows disambiguation of items having the same name (residing in different namespaces)
Couldn't you achieve the same thing by grouping variables (or functions) as attributes of an object prototype since JavaScript allows dynamically adding variables (or functions) to objects?
Wouldn't something like
be equivalent to
Now granted, a namespace usually exists only once in a running context where as a JavaScript object can have multiple instantiations, but nothing would prevent the program from only creating and using one copy of the object to simulate the same environment.
Basically all this is syntactic sugar anyway. Object Orientation, Namespaces, Classes vs Prototypes, just different high level means of segregating data and grouping functions which are byte arrays in memory.
Re:Why the pressure ? (Score:3, Insightful)
What exactly is wrong with the javascript language? Everything you're ranting about is the fault of browser manufacturers and faulty/incomplete/deliberately broken implementations of javascript. The DOM support of various browsers sucks
Some news: Lisp would be shit if there were three or four wildly-divergent implementations, each claiming to be "the" lisp. And especially if the dominant version was a bastardised Microsoft Lisp-alike which everyone who didn't know better coded-to.
Javascript the language is actually quite compact, elegant and usable.
Re:It's not the best.... but it's not bad, either. (Score:3, Insightful)
It strikes me, however, that one of the best scripting languages out there, python, took a similar path. Once python had no object orientation, and people faked it with syntactic hacks. Then the syntax changed slightly and it was slowly added over the years, even as compatibility was kept with previous versions.
Javascript could take such a route. It's not a bad languages; it could get better.
Re:Disagree (Score:4, Insightful)
I said, "As a language". Javascript's standard library is small, but the functionality the language itself supports is quite advanced. Closures, prototyping, mutable objects, and consistent OO (i.e. everything is an object), make Javascript rather flexible; just look at the additions Prototype has added in.
Ah, you're quite correct; Javascript is singled threaded. However, considering the amount of asynchronous callbacks from setTimeout, setInterval and XMLHttpRequest, one has to wonder whether the very lack of threading could not be construed as a disadvantage on its own. Since each Javascript function is axiomic, one would have to split up complex functionality to run across several functions.
What do you mean by "Javascript"? Are you referring to the ECMAScript dialect (which, so far as I'm aware, does have a standard library), or are you using "Javascript" to mean "Any ECMAScript browser implementation" (in which case you are technically correct)?
Regardless, the standard libraries of JScript and Javascript overlap considerably, so although you can point out, quite correctly, that ECMAScript does not define a standard library per se (so far as I am aware), from a practical standpoint the major browsers have a number of EMCAScript objects in common, which mounts to the same thing as a standard library in practise.
(Browser as development platform)!=AJAX (Score:5, Insightful)
I have a hard time understanding why I hear so many people complaining about JS as a language. I think a lot of Java programmers don't like it because it's not Java (not strongly typed, ...), and a lot of C++ programmers don't like it because it's not C++.
The truth is that you can do some pretty amazing stuff with JavaScript. My favorite demo is here [chapman.edu]. It's a web-based calculator, and if your browser has MathML set up correctly, it'll display your equation on the fly, as you type it, in standard math notation. For instance, if you type 1/(2+pi), it displays a fraction bar, with 1 on top, and 2+pi on the bottom (pi rendered as a Greek letter). (I think recent versions of Firefox have MathML and its fonts set up correctly by default, but if not, you can download the necessary fonts (instructions) [lightandmatter.com]. For IE, you need to install MathPlayer.) What I think this calculator app demonstrates pretty dramatically is how powerful a development platform the web browser can be, without messing with the ugliness of AJAX at all. WYSIWYG mathematics typesetting is the kind of application that people used to pay $100 for ca. 1995, and now it's not only free, it's open-source, and it's an app that you can just run in your browser, without having to install anything.
Re:JS (Score:3, Insightful)
prototype.js (Score:4, Insightful)
If you also use Firebug (make sure you get the latest beta) for debugging then programming web and javascript becomes fun!
With prototype.js the javascript code becomes probably 30-70% smaller. No self respecting javascript programmer should be without prototype.js. It rocks!
Re:Needs a Concatenation Operator (Score:1, Insightful)
In C++, string + int doesn't concatenate the int onto the string. If you're lucky it's an error. If you're not lucky, it converts the int into a character and appends that character. If it's a string literal rather than a std::string, even worse. Reusing << would have been a better choice than + in C++.
Which doesn't solve the grandparent's problem, because it doesn't remove the functionality from +