Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Should JavaScript Get More Respect?

kdawson posted more than 7 years ago | from the ugly-duckling dept.

Programming 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."

cancel ×
This is a preview of your comment

No Comment Title Entered

Anonymous Coward 1 minute ago

No Comment Entered


easy answer: NO (-1, Troll)

Adolf Hitroll (562418) | more than 7 years ago | (#17310388)

This is a flamebait
This is the truth because:
  • It dealls with a loser [imdb.com]
  • Which is retarded [imdb.com]
  • ...and colored [imdb.com] (I just couldn't make it about the guy from the AlBook 17" as I kinda like him)

That's why:
  • It mustn't be modded "Offtopic" unless the mod is a moron.
  • It mustn't be modded "Overrated" unless the mod is a poltron.
  • It mustn't be modded "Funny", unless the mod has no life out of reading it.
  • It mustn't be published as a story unless somebody gave Taco is poppers back.
  • It mustn't be erased, unless I forgot to remove the mention concerning Hemos' erroneous abducation of Gary Coleman [imdb.com] (for expectedly pedophiliac purposes which turned to be more zoophilic, Gary being the big man in that case).
  • It mustn't be modded "Insightful" because this makes baby-Jesus cry.
  • It must be read to prove yourself you've got a life because you also have time to lose.

About the story (so that I cannot be modded down as offtopic by moronic fucks):
  1. Whoever submitted this story is an imbecile.
  2. Whoever published it has no life besides his publishing quotas.
  3. Whoever hired him is a fat, sweaty, dickless nerd.
  4. Whoever gave birth to *it* is a sad, dishonoured person.
  5. Whichever country they grew in is bankrupt and smells like laden bins.
  6. ...and me, well, I'm none of these retards, just having fun spoiling your surfing experience with that bit of reality.

Have an horrible Xmas/Hanuccah/whatever kind of loser your education's made you worship... Under Gawd. ...MOD THIS DOWN UNLESS YOU'D BETTER HAVE SEX NOW!

Javascript gets enough respect (1)

bakana (918482) | more than 7 years ago | (#17310946)

Javascript has been used to do so many things, I dare say most web developers have used it with great success to complete a wide variety of projects. But until further improvements are made to it there is no need to give it "more" respect.

JS (5, Interesting)

djupedal (584558) | more than 7 years ago | (#17310402)

it remains the most broadly available scripting language for Web development.

As someone who has written applets with over 25,000 lines, I can easily agree. Out of the roughly two dozen languages (scripting, etc.) that I know, JS has been a cornerstone of both simple and solid applets and the quick & dirty prototype. Let's hope the future agrees :)

Re:JS (0)

Anonymous Coward | more than 7 years ago | (#17310430)

I knew you could make Applet with Java....but with JavaScript, I just thought you could only write 'js script....'
but after 25000 lines you should be right...or did I miss something ?

Re:JS (4, Insightful)

Schraegstrichpunkt (931443) | more than 7 years ago | (#17310440)

And yet you don't seem to know the difference between an embedded Java applet and integrated JavaScript code.

Re:JS (3, Interesting)

djupedal (584558) | more than 7 years ago | (#17310732)

'integrated JavaScript code'

...as opposed to what? JS that isn't integrated...? I knew someone would complain. A rose by any other string of characters...

The uppercase 'A' should be enough of a hint as to why I went with that particular label :) - No? Since when is 25,000 lines small...?

For the grammar goons among us:
applet ['aplit ] noun - Computing A very small application, esp. a utility program performing one or a few simple functions.

And a utility program it was. Put up to accomplish a temporary (9 month), semi-automated process of data gathering, consolidation and PDF summary reporting via email...yes, 25k lines is nuts. Would I ever do it again? Not likely. And if you think this was crazy, you should have seen the process it replaced.

In this case it was easy enough to do, which meant we were providing the reports that senior management needed right away, giving us time to relax and build a proper & full scale SQL replacement. In the end, the recipients never knew when we migrated from the stop-gap to the final - all of the routine post-deployment feature requests went in and were tested long before it went public, with bonuses all around :) Thank you JavaScript!!!

Re:JS (0)

Anonymous Coward | more than 7 years ago | (#17310858)

Dude, you failed it and no buzzword is going to make his comment invalid.

Re:JS (-1)

Anonymous Coward | more than 7 years ago | (#17310970)

What on earth are you banging on about? You don't write applets in JavaScript, you write them in Java. Clearly you are an all-bullshit-and-no-brains management type who wouldn't know the difference if it smacked you in the face.

Re:JS (2, Funny)

CmdrGravy (645153) | more than 7 years ago | (#17310454)

25,000 lines of Javascript ? What could you possibly be doing which requires that level of Javascript interaction ?????

Re:JS (4, Funny)

ignavus (213578) | more than 7 years ago | (#17310610)

"25,000 lines of Javascript ? What could you possibly be doing which requires that level of Javascript interaction ?????"

document.write('25,000 bottles of beer on the wall, 25,000 bottles of beer. Take one down and pass it around - 24,999 bottles of beer on the wall');
document.write('24,999 bottles of beer on the wall, 24,999 bottles of beer. Take one down and pass it around - 24,998 bottles of beer on the wall');
document.write('24,998 bottles of beer on the wall, 24,998 bottles of beer. Take one down and pass it around - 24,997 bottles of beer on the wall');

etc ...

Re:JS (4, Funny)

mikek3332002 (912228) | more than 7 years ago | (#17310742)

document.write('25,000 bottles of beer on the wall, 25,000 bottles of beer. Take one down and pass it around - 24,999 bottles of beer on the wall');

A much better form for 25000 lines would be having, 12499 bottles of beer on the wall lines, an initlization statment, and a decremeant function after every write line. That way you can easily modify the code to start off with what ever number you want.

Re:JS (4, Funny)

Anonymous Coward | more than 7 years ago | (#17311040)

Also, it's a good idea to Write and Save your JavaScript a Word document (eg in an editor like Notepad), not scrawled in Paintbrush and saved as a Bitmap File. It's funny how the Internet can't compile my Paintbrush Javascripts lol! My fried says thats how all the best programmers do it, but I can't get it work. maybe I don't get something? something vital? I think that must be it

Re:JS (4, Informative)

HxBro (98275) | more than 7 years ago | (#17310736)

After writing javascript for the past 6 years on digital tv platforms, I can say I've seen EPG's, Games, Apps running on liberate based set-top boxes and various IPTV set-top boxes could be running apps of similar size at time too.

Granted you do try keep the sizes down but in some cases especially and EPG you do end up writing lots of code.

Dense != Good (4, Insightful)

Marcus Green (34723) | more than 7 years ago | (#17310410)

According to the article

"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:Dense != Good (4, Funny)

MichaelSmith (789609) | more than 7 years ago | (#17310428)

The author seems to equate dense with good, not an association I make

By that standard APL would be hard to beat.

Re:Dense != Good (2, Insightful)

Anonymous Coward | more than 7 years ago | (#17310482)

He then says that JavaScript programs are often 10 times as dense as similar Java programs

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.

Re:Dense != Good (0)

Anonymous Coward | more than 7 years ago | (#17310872)

$_ is the devils variable

Using it puts your soul in peril - yet it is amazingly powerful if obscure and occasioanlly considered black magic

Re:Dense != Good (1)

MemoryDragon (544441) | more than 7 years ago | (#17310494)

I would not call javascript more dense, scripting languages usually have a denser syntax due to shortcuts and introspection on language level. Javascript is one of the weakest scripting languages thanks to missing namespaces and prototype handling in those aspects. I would not even call it denser the missing namespaces result in overly long class and function names. Actually javascript has good concepts, but its execution is missing the vital 5% of namespaces, and good object syntax constructs. If you want to see javascript done right check out groovy for instance, same idea as javascript in language design, but way better in execution.

Re:Dense != Good (1)

rjshields (719665) | more than 7 years ago | (#17311018)

Since the current purpose is for light scripting of other applications, the lack of namespaces is not really too important. If it was to become a standalone scripting language it would need to have namespaces and some kind of standard library added.

Re:Dense != Good (4, Interesting)

sholden (12227) | more than 7 years ago | (#17310502)

Since developers seem to code about the same number of lines of code/statement per unit time, regardless of language. 10 times as dense means the developers are 10 times as productive. Since programmers are reasonably expensive needing 1/10th as many is a good thing.

But Javascript is no where near 10x as "dense" as Java, http://www.theadvisors.com/langcomparison.htm [theadvisors.com] while flawed in many many ways puts Perl at 2.5 times as "dense" as Java. There is no way in the world that Javascript is four times as "dense" Perl...

Re:Dense != Good (2, Informative)

Eivind Eklund (5161) | more than 7 years ago | (#17310818)

I consider the numbers in that comparison so deeply flawed that they can't be used for comparing density of two languages like this.

In my experience, Ruby is about twice as dense as Perl *in direct translation* (I have taken Perl libraries and translated directly to Ruby). It is even more dense when the code is idiomatic Ruby - that might be up to 10x. Idiomatic Common Lisp is about as dense as Ruby.

Yet, Perl comes out at 15 and Common Lisp comes out at 5 in that "programming languages comparison", and Java comes out above Common Lisp at 6. These results are completely ridicilous. They probably have some statistical correlation with reality for some kinds of programming with some kind of developers - they're just far from exact enough to be useful for specific language comparison, like you do above. (They're also a decade out of date.)


Re:Dense != Good (2, Interesting)

CaymanIslandCarpedie (868408) | more than 7 years ago | (#17310938)

10 times as dense means the developers are 10 times as productive. Since programmers are reasonably expensive needing 1/10th as many is a good thing.

That sounds great for little one-off scripts. However, if you are working on an application with any decent expected lifespan, well than that is just wrong. Say your average application will be in production use for 5 years (I'd think this is a pretty low estimate). In that case I'd guess your intial development costs would be a fraction of your support costs over the life of the product.

By your logic whenever designing a database you should always just name tables as A, B, C, D, E, ... and the columns within those tables as a, b, c, d, etc. Also, any comments in code are just a frivilous waste of money.

As much of a pain as writing verbose code can seem at times, it certainly does have its merits.

Re:Dense != Good (0)

Anonymous Coward | more than 7 years ago | (#17310972)

Since developers seem to code about the same number of lines of code/statement per unit time, regardless of language.

It could be argued that they are correlated but one doesn't cause the other. After all, Perl can express anything in a single line :)

If a programmer was twice as capable, they could write a program in half the time, and with twice the density (for example due to greater confidence with inline increments and suchlike). That is, 10 lines in 10 minutes instead of 20 lines in 20 minutes.

However, this doesn't mean speed is dictated by density.

That said, with Perl I can apply a regexp with =~ whereas with JavaScript you need to go off creating a new RegExp object with more verbose and hence hard-to-remember syntax...

Re:Dense != Good (5, Funny)

D-Cypell (446534) | more than 7 years ago | (#17310504)

The author seems to equate dense with good

The irony of this is so elegantly compact I am concern a singularity may form around the vacinity of this article.

Re:Dense != Good ==Wrong: It's not dense (2, Informative)

Gavin86 (856684) | more than 7 years ago | (#17310752)

Javascript is anything but dense. The most impressive part about the various flexible agents is that they are easily understandable programming patterns. That makes it very easy to make an assessment for which methodology you will employ.

Re:Dense != Good (1)

Ricardo Lima (29902) | more than 7 years ago | (#17311004)

Sorry to disagree, but dense can be good. I mean "select employee_name from employee where employee_id = ?" is much more denser than a similar code in C. Sometimes expressiveness can be bad, I admit, but dense languages mean that I can say more with less words. If density was so bad, we would still be programming in assembly.

Yes, but Javascript is a bad language. (0)

Anonymous Coward | more than 7 years ago | (#17310434)

- It is not possible to have two methods with the same name and different parameters (only one of those will ever be called).

- On the other hand methods behave like objects. One can have arrays of methods and then call mymethods[2](param);!

This is just plain weird.

Re:Yes, but Javascript is a bad language. (0)

Schraegstrichpunkt (931443) | more than 7 years ago | (#17310448)

Weird? Does JavaScript support something like varargs? If so, then this is no different from Perl, Python, C, probably Ruby, bash, and basically every other language I've used except C++ and Java.

Re:Yes, but Javascript is a bad language. (4, Informative)

Myen (734499) | more than 7 years ago | (#17310518)

Every function has a variable number of arguments. You can access it via the keyword arguments - it's an array. So yes.

function foo() {

Re:Yes, but Javascript is a bad language. (1, Informative)

Anonymous Coward | more than 7 years ago | (#17310832)

Java 5 has vargargs.

Re:Yes, but Javascript is a bad language. (1)

bensch128 (563853) | more than 7 years ago | (#17310994)

I would consider Ruby to be the correct direction that Javascript should evolve towards.

The way it it allows you to easily add properties and it's reflexiviness is extremely similar to javascript.
It has a bunch of other freatures I'd love to see in JS one day, like hiding instance variables, class+module concepts instead of having to using function() to initialize members, and continuations.

Otherwise, I think that JS is a perfect lowlevel scripting language.


Re:Yes, but Javascript is a bad language. (4, Informative)

masklinn (823351) | more than 7 years ago | (#17310552)

It is not possible to have two methods with the same name and different parameters (only one of those will ever be called).

Because Javascript has no ways of dispatching: all functions (remember that Javascript methods are exactly like functions) use varags, and the arguments you ask for are but pointers to vararg cells.


  1. function foo(a, b, c) {
  2. return [a, b, c, arguments]; // `arguments` holds every single argument of your function no matter what
  3. }
  4. foo() // -> [null, null, null, []]
  5. foo(1) // -> [1, null, null, [1]]
  6. foo("foo","bar","baz","buzz","bon") // -> ["foo","bar","baz",["foo","bar","baz","buzz","bon" ]]

On the other hand methods behave like objects. One can have arrays of methods and then call mymethods[2](param);!

It's not that JS functions "behave" like objects, JS function are objects, period. Callable objects maybe, but objects nonetheless, they're no different from strings, integers or lists in that aspect.

And this is one of the nicest features of the language (along with lexical scoping and complete closures)

Re:Yes, but Javascript is a bad language. (1)

rjshields (719665) | more than 7 years ago | (#17311036)

- It is not possible to have two methods with the same name and different parameters (only one of those will ever be called).
That's because a function is an object. You can't have two objects with the same scope in most languages.
- On the other hand methods behave like objects. One can have arrays of methods and then call mymethods[2](param);! This is just plain weird.
Yes they do, because they *are* objects. No it's not.

Why the pressure ? (1, Insightful)

unity100 (970058) | more than 7 years ago | (#17310444)

Lately it is like as if some circles are almost pressuring the developer community to pay more attention to java, javascript and affiliated stuff. Every now and then someone pops up and says something to that effect and chaos ensues.

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:Why the pressure ? (4, Informative)

tpwch (748980) | more than 7 years ago | (#17310468)

Java and Javascript? Why would anyone do that, since those two are not related other than the name. Sun developed Java, and Netscape developed Javascript. Totally independent of each other. I'm starting to get tired of people thinking that they have something to do with each other.

Re:Why the pressure ? (1)

unity100 (970058) | more than 7 years ago | (#17310566)

whats the rush to conclude that someone thinks they are the same ?

in case you have noticed i said that there have been a lot of debates ensuing from various articles that are bent on java AND javascript are underrated. not java/javascript. It might as well be apples and liquid cooled rockets.

actually there is one debate that is in a few day older articles that is still not cooled down, about java this time.

Re:Why the pressure ? (1)

Aladrin (926209) | more than 7 years ago | (#17310940)

Because the discussion was about javascript and you just threw java in there, and even suggested it was related: "java, javascript and affiliated stuff"

You might as well have thrown cobol in, since they are just as much 'affiliated' as javascript and java are.

Re:Why the pressure ? (0)

Bastard of Subhumani (827601) | more than 7 years ago | (#17311026)

whats the rush to conclude that someone thinks they are the same ?
This guy [slashdot.org] sure seems to have them confused - he writes javascript applets, apparently.

I won't even mention HR departments.

Re:Why the pressure ? (-1, Troll)

masklinn (823351) | more than 7 years ago | (#17310562)

Please, you don't have the slightest idea of what you're talking about, just shut up and stop wasting slashdot's database space

Re:Why the pressure ? (1, Insightful)

Anonymous Coward | more than 7 years ago | (#17310624)


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.

Re:Why the pressure ? (4, Insightful)

Aqua OS X (458522) | more than 7 years ago | (#17310840)

Developing interactive content for the web is a lot like building a house out of crap you find at the junk yard. None of the materials are great, you'll be forced to use a lot of jankie things you'd rather not use, and you may need to substitute sheet-rock for side panels from an '82 Corolla.

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.

Should JavaScript Get More Respect? (0)

Anonymous Coward | more than 7 years ago | (#17310472)

In the opionion of a retired Windows cleaner: NO!

Feared? YES

Re:Should JavaScript Get More Respect? (1)

polar red (215081) | more than 7 years ago | (#17310782)

retired MS-Windows cleaner ? or retired glass-thingies-you-put-in-walls-cleaner ?

Security is a problem (2, Informative)

Anonymous Coward | more than 7 years ago | (#17310498)

Hey guys. I'm an online gamemaker, so 'toy' languages are right up my alley.

The main problem with writing games with some of the most applicable web tools out there (Javascript, Flash) is that once it hits the web anyone with access to the View Source command can steal your work and throw it on their own site as theirs. This is highly discouraging.

Nowadays I do use Javascript and Flash extensively, but the most significant part of any game machinery is always on the backend somewhere, usually in PHP.

Re:Security is a problem (1)

Abasher (778648) | more than 7 years ago | (#17310588)

Yes, the main problem is security, but not in the way you mean. Just have a look at how many remote exploits through javascript have been found this year. On one who's concerned about security (and doesn't trust every webserver he/she goes to 100%) has javascript turned on. It's not a big hassle to allow in in NoScript, but still.

Re:Security is a problem (1)

pubjames (468013) | more than 7 years ago | (#17310652)

Surely there are many things you can do to make the Javascript delivered to the client practically unmodifiable.

why don't you use PHP to deliver the Javascript, and have the PHP obfuscate it?

Re:Security is a problem (3, Insightful)

vadim_t (324782) | more than 7 years ago | (#17310716)

Oh, bullshit.

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.

Re:Security is a problem (1)

tacocat (527354) | more than 7 years ago | (#17310744)

That may be true but there are still a lot of people out there who are willing to write applications in other languages that can also be "stolen" from the web. I've looked at some javascript in the past that I wanted to steal and the canned libraries that are available to day.

In the long run, stealing someone else javascript is not going to be that prolific. Good thing you aren't a musician, eh?

Javascript could become a language to actually use, if it actually worked as a language and not a conglomerate of many language influences that are all fighting for the same space. Some call this software platform dependency. I call it the death of javascript.

I love the autopointerage & hate the scope iss (5, Informative)

cyclomedia (882859) | more than 7 years ago | (#17310534)

Would be nice to have everything my way, the sheer built in extensibility of the language is in my opinion nothing short of beautiful, and something other languages could do well to imitate (check out D [digitalmars.com] , for example).

allow me to elaborate, suppose you want to know if the version of the language on your platform supports an intrinsic array push function, and if not, attatch your own:

if( !Array.push )
  Array.prototype.push = function( item ){ ... }
firstly the reference to .push in the if has no brackets, so it becomes a pointer to the function within the intrinsic Array class. you can then create a function and assign it to that pointer. Sheer magic and gorgeously intuitive.

sticking with arrays you can grow and shrink them with little to zero fuss:

function array_push( arr , item )
  arr[arr.length] = item;
magically the array is one index longer. you can just set arr.length and it will append or delete indexes for you.

you can also use this to assign functions to other object's handlers, most notibly events

someObject.onclick = myFunction
But this has brought up the thing that really really needs fixing, suppose i want that onclick function to pass some info to myFunction when i call it i have to do this

someObject.onclick = function(){ myFunction( this.someAttribute ) }
so instead i've created a function inline to hold my custom function, firstly it's not immediatley obvious to what object the "this" applies. if i'm running this code in a class does the this mean the class or someObject, one hopes it means the someObject.

next is the scope issue i've talked about suppose i'm dynamically creating objects on the fly and want the callback to reflect the id thus

for( i=0 ; i<10 ; i++ )
  someObject[i] = new SomeObject();
  someObject[i].onclick = function(){ myFunction( i ) }
every single object will pass the value of 10 to myFunction, because after the function has finished the instance of i in memory that was used is still sat there and every myFunction has been given a pointer to it, not the value it was when it was initialised!

so some oversights still exist, if only there were ways you could explicitly state "pointer to" or "value of" like in, oh, every other language including visual basic

Re:I love the autopointerage & hate the scope (0, Redundant)

rucs_hack (784150) | more than 7 years ago | (#17310628)

You may well be right, but

"It's multiparadigm: supporting imperative, object oriented, and template metaprogramming styles"

Is just too geeky for me before my second cup of coffee.

Re:I love the autopointerage & hate the scope (4, Informative)

Shano (179535) | more than 7 years ago | (#17310670)

That isn't really an oversight, it's the way closures work. Most functional languages let you create closures explicitly so the problem doesn't arise. Javascript does it automatically, and usually when you don't expect it. In Javascript, you can do:

someObject[i].onClick = function(i) { return function() { myFunction(i) } } (i);

That creates a closure for each handler, with its own copy of i, so they will all get the values you want. I have no doubt there are other ways to do it, but this works for me.

Re:I love the autopointerage & hate the scope (1)

cyclomedia (882859) | more than 7 years ago | (#17311044)

i'm aware of closure and that solution but deliberatley avoided bringing it up, but wouldn't it be nicer to just:

someObject[i].onClick = &myFunction(*i)
or introduce a friendlier concept from, of all places, VB : byRef and byVal

Re:I love the autopointerage & hate the scope (1, Informative)

Anonymous Coward | more than 7 years ago | (#17310674)

Parent wrote:

for( i=0 ; i<10 ; i++ )
  someObject[i] = new SomeObject();
  someObject[i].onclick = function(){ myFunction( i ) }
every single object will pass the value of 10 to myFunction
Well if you don't like that, then just make a function that its arguments by lexical closure:

make_function = function (n) function() { myFunction( n ) };
for( i=0 ; i<10 ; i++ )
  someObject[i] = new SomeObject();
  someObject[i].onclick = make_function (i);

Re:I love the autopointerage & hate the scope (2, Interesting)

Anonymous Brave Guy (457657) | more than 7 years ago | (#17310838)

While I agree that some of the concepts you mention could be useful, I don't see that Javascript's implementations are particularly powerful or elegant.

It's hard to comment on the function-attaching example you gave, since obviously any real implementation of most languages already has functions such as those you describe. In general, however, I've found these dynamic features to be overhyped, and usually no substitute for having a decent design in the first place. I don't miss them in languages where they aren't there.

As for the scoping and closure stuff, IMHO having first class functions in a language is a big plus. Javascript's version always seems a bit like Functional Programming Lite, though: in real functional programming languages, the rules on scoping and such tend to be absolutely clear, and the syntax clean and powerful. So-called scripting languages tend to try but fail on this count here; Javascript is certainly not alone in the field.

LCD (0, Troll)

ComaVN (325750) | more than 7 years ago | (#17310538)

the most broadly available scripting language for Web development

The expression you're looking for is Lowest Common Denominator

What a piece of shit that language is.

Re:LCD (1)

zoftie (195518) | more than 7 years ago | (#17310606)

I do agree, it is for small hacks, and it hasn't improved too muvch on fundamentals since 2002 when i have used it. You can get alot of funding for ajax related stuff, but that doesn't mean that it is useful for masses at its foundation. Diversity of browser behaviours will make sure of that. And it isn't about languages too, for the other half, but about behaviours, inconsistent and broken alot of times. You really have to do a balancing act. See how trivial application of google maps, doesn't work the same on all browsers. Until there is a rigid standard about ECMA script, akin to Java ones, one can't talk about proper interoperability and usefulness of such language.

Many projects incorporate python as a scripting language of choice.

Why do I think replacement of Java/ECMA script with python is good in terms of browser language? Because it is fast. It mandates proper and consistent tabulation. It eradicates puctuation in many, and un-necessary cases. It is also very very fast, if precomplied codes are used. Also I takes alot of C/Java programmer design, without making you feel like a downgraded programmer, who is allowed to use a knife only with safety blade that can't cut skin or meat. As well it has very clear way to lay out code in clear ideas. Proto-currying is built in, which is useful and full real currying in 2.5 is very usable with libraries. Sort of functional onto generic procedural programming.

Yes I am one of those python people.

Re:LCD (1)

giuntag (833437) | more than 7 years ago | (#17310708)

As far as I'm concerned, PHP would also be a good contender for "ideal scripting language in the browser".

Advantages over js:
- using the same lang both server and client side is easier on the coder (applies to python too, and might apply to js, if it ever becomes widespread server side)
- huge set of functions in the interpreter core: I really miss a lot of them when coding in javascript
- the object model, albeit more restrictive than the prototype based model, makes a lot more sense to people used to C++, java, php et al

Re:LCD (0)

Anonymous Coward | more than 7 years ago | (#17310766)

Flamebait, perhaps, but troll? hardly.

Look at this [cryer.co.uk] and tell me javascript is not an ugly language

WTF is that about.

The language is fine, but it's got baggage (5, Insightful)

Radium Eyes (1041164) | more than 7 years ago | (#17310540)

JavaScript/ECMAScript really is an interesting language; the way objects work takes some getting used to, but it's powerful, and definitely definitely not a toy language. It's when you bring the HTML DOM and browser inconsistencies into the equation that things start to get painful.

Re:The language is fine, but it's got baggage (1)

ChrisZermatt (892665) | more than 7 years ago | (#17310922)

Take a look at qooxdoo.org - a very slick framework that irons out the DOM hassles of different browsers for us developers.

Re:The language is fine, but it's got baggage (1)

kestasjk (933987) | more than 7 years ago | (#17311110)

Browser inconsistencies really are the worst thing about JavaScript. If all HTML was XHTML compliant, and there were no differences between browsers, AJAX would be so much simpler. Depending on what you're coding it can often take far less time to write it for one browser than to get it to work on the four common browsers.

JavaScript is wonderful (1, Insightful)

Anonymous Coward | more than 7 years ago | (#17310544)

JavaScript is an absolutely great language marred by the fact that people can't distinguish a language from its library. When most people say "JavaScript sucks!" they are really saying "DHTML/the DOM object model/HTML/CSS sucks!".

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.

Re:JavaScript is wonderful (3, Insightful)

killjoe (766577) | more than 7 years ago | (#17310854)

To be fair you use the library as much if not more then you use the language. If I can't interact with databases, if I can't download a library that scrapes web sites, connect to SOAP services easily, authenticate against a LDAP server then no matter how beautiful the language is I can't use it.

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.

Like Visual Basic ... (2, Insightful)

Anonymous Coward | more than 7 years ago | (#17310554)

... it's not because you have to use it, that it makes it a good language.

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.

What interpreters are available? (2, Informative)

Myen (734499) | more than 7 years ago | (#17310590)

Sadly, when Javascript gets mentioned most people think of browser scripting. That's like thinking of MFC every time C++ gets mentioned... :(

What sorts of shells interpret JS? I know of Mozilla's js shell [mozilla.org] , and they also have a xpcshell (which adds XPCOM things to make it fully Mozilla-y). Sadly js shell has no built-in file access (it's a compile-time option you have to jump through hoops to enable, and buggy), and xpcshell has lots of XPCOM baggage.

Are there any others using different engines? Anything from Adobe (ActionScript) maybe?

Re:What interpreters are available? (1)

bensch128 (563853) | more than 7 years ago | (#17311076)

There's also M$ jscript inside IIS.
On a project awhile ago, I had the choice of working with VBscript or JScript.
Of course I went with JScript and was Incrediably happy that I had done so. There's some weird problems in IIS's implementation but in comparsion to VBScript, it was heavenly....

Additionality, it allowed me to share cope between the backend (in JScript) and the flash frontend (in ActionScript). Maybe a bit bizarre but it worked!


Javascript is nice... the problem is... (2, Interesting)

vhogemann (797994) | more than 7 years ago | (#17310604)

The inconsistence between the two major implementations, Mozilla and IE. And the huge amount of annoying bugs that IE has.

I don't hate JS, its a rather nice language, but I tend to keep minimal use of it on my applications because I really hate to lost one entire day fighting against IE.

Too Hard to unit test (3, Insightful)

Anonymous Coward | more than 7 years ago | (#17310636)

javascript is too hard to unittest but most of that has to do with the web browser container . javascript is a victim of its environment.

Me too (3, Interesting)

Jens de Smit (1041964) | more than 7 years ago | (#17310666)

I am one of those people that cursed JavaScript (after being enthusiastic about it when I was 14). I am just now beginning to turn around and think "well, it IS pretty nice". One of the things that has changed is that it does not "[mutate] faster than a fruit fly in an X-ray machine" (bonus points if you know who wrote this) anymore, with support becoming more standard over different interpreters, and incompatibilities becoming better documented and workaround libraries that unify the differences all over the place. Debuggers also become more widely available, helping the people when they exclaim "WHY the HECK doesn't it work this time!". It's still easy to shoot yourself in the foot with it, but hey, the same goes for C. At least it generally does not blow your leg up like C++. This behaviour is caused by the extreme felxibility of the language, which also allows for interesting constructions, as long as you're careful as a programmer. In other words: you have to know what you're doing to keep the code organized and understanable, something that is lacking with most starting web developers. Still, the availability and functionalty of JavaScript allows rich, interactive web applications to be developed, which is a good thing if you ask me.

XSS Attacks (0)

Anonymous Coward | more than 7 years ago | (#17310682)

JavaScript should get more respect, XSS-holes are one of the most prevalent and useful attacks against websites there are.

Overlord (2, Funny)

Dude163299 (906461) | more than 7 years ago | (#17310686)

I for one Hate our new Javascript writing overlords.

And for the record im suppose to be writing various Javascript programs at this moment.

JS is not the problem, the whole environment is. (4, Interesting)

master_p (608214) | more than 7 years ago | (#17310692)

Javascript is a fine language with elements from functional and object-oriented programming. The problem with web development is the whole environment:

1) the coupling of the UI with the code that actually does stuff.
2) the non-efficient and error-prone methods of communication between client and server.
3) the non-existent security regarding JS code; anyone can see it.
4) the mixing of a tagged document language with a programming language.

Ideally, web applications should only consist of source code in one language which is clever enough to be able to provide all the necessary abstractions. In reality, such a language does not yet exist, making web applications development 10 times more difficult than what they should be: the minimum number of languages to use for a web app is 5: 1) html, 2) css, 3) javascript, 4) java/php/ruby/python/perl/whatever, 5) XML...and let's not count the various XML schemas required for various domains of the back end, because the number of 'languages' one needs to know will grow exponentially!

Re:JS is not the problem, the whole environment is (4, Interesting)

AlXtreme (223728) | more than 7 years ago | (#17310902)

3) the non-existent security regarding JS code; anyone can see it.
Repeat after me: Obscurity is not the same as Security

If you are sending information to the browser that you don't want to be known, then you're doing something wrong. This is the case for JS, as well as for AJAX, Flash or Java applets. Or client-side code in general.

Seriously, I've seen students faces turn white when I mention that I could log into and mess up their remote SQL database, thanks to them putting their (administrator!) username/password combinations in client-side Java bytecode. They would then try to obscure their passwords somehow, which leads to an arms-race with other teams trying to break in. Security can be loads of fun!

Re:JS is not the problem, the whole environment is (1)

Mopatop (690958) | more than 7 years ago | (#17310916)

Wrong, you do not need to know XML. I write "AJAX" applications at work all the time and haven't used XML for months. Look up JSON [json.org] and make your life better.

Remember that with XMLHTTPRequest you are restricted to your own domain, so more often than not you are in charge of the message encapsulation language. You only have to make it as complicated as you want to.

On a slightly weaker note, some people are lucky enough to drop CSS from that list as well. Frequently I work with a designer who takes care of all the CSS for me - all I deal in is IDs and classes.

Dear god no. (2, Insightful)

el_womble (779715) | more than 7 years ago | (#17310694)

My wish for web 3.0 is that Javascript is replaced entirely. The ONLY thing that Javascript has going for it is ubiquity (which I guess is down to its ease of implementation). Its not all Javascripts fault, in general, as in most things webby I blame Microsoft, but hte language itself seems to make everything you write look lke a dogs dinner.

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| ... end

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:Dear god no. (1)

Crayon Kid (700279) | more than 7 years ago | (#17310720)

I don't see why you'd want JavaScript replaced by Python or Ruby. As a programming language, it is more powerful than both. By powerful I mean simplicity and power of the language itself, not comparing sets of features.

For proof, [re]read Revenge of the Nerds [paulgraham.com] . Search for "Appendix: Power" on the page, look at the problem. Try doing that in Python, Ruby, PHP, Java, C of any kind.

Re:Dear god no. (1)

el_womble (779715) | more than 7 years ago | (#17310834)

Ruby: def foo n Proc.new {|i| n += i } end or with the lambda synonym def foo n lambda {|i| n += i } end Looks pretty neat to me.

Daft story title... (2, Insightful)

Aphrika (756248) | more than 7 years ago | (#17310724)

Respect is earned, not given. As far as I'm concerned, AJAX has given JavaScript a new lease of life. Without it, there would be no Gmail, no Google Maps, or at least not in the way we've come to admire them. When you see the fantastic stuff Google (and Windows Live for that matter) produce, XMLHTTP was the catalyst that made that possible, but all the donkey work is done by JavaScript.

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.

Javascript might have a future, but.. (3, Interesting)

tacocat (527354) | more than 7 years ago | (#17310828)

Look at the history of Javascript. It's not the history of a programming language. It's the history of a marketing battleground.

Programming Languages have a few key elements that Javascript lacks. For one, everyone who writes Perl, Ruby, Java, Python, even Bash expect it to have consistent behaviour where ever it might be. And for that behaviour to be well documented, reliable, and owned by the language itself.

Javascript has an evil dependency to run based on the Operating System and Browser that you are using. Mozilla on Windows works differently than Mozilla on Linux. Mozilla on anything works different than Opera or MSIE. MSIE6 works differently than MSie7. And some of these differences in javascript behaviour isn't really javascript. It's javascript trying to do CSS/DHTML stuff.

If you were to have something similar under a real programming language there would be an active development team working to resolve the differences and get consistency in the language. The finest example of this is the Java JVM. It tries to be write once run anywhere. I don't know that it actually accomplishes that -- but it's closer than javascript.

javascript has no such activities. I don't do much with Javascript but when you pull a 10 year old book off the shelf you find 1/2 of it is talking about MSIE vs Netscape in how to work around code differences. Then you get a new Javascript book and it's still talking about many of the same problems a decade later. That's a dead language lacking any real development.

AJAX is cute because Microsoft went ahead and implimented something on their own and didn't bother telling anyone about it. I'll assume that Mozilla implimented the exact same thing but under a different name because they were afraid of getting sued. Why they did it doesn't matter. The fact that they implimented the exact same thing under a different name is why Javascript must fail. It's not a real language. You won't find a language the does the exact same thing in two different commands and those two different commands only work on distinctly different machines.

If someone takes Javascript away from the companies and starts to impliment there own version of it there's no chance. Javascript needs a replacement.

JavaScript is #1 (0)

Anonymous Coward | more than 7 years ago | (#17310906)

I've been a web developer since summer 1998 and not once have I ever thought JavaScript was a "necessary evil", I have in fact said many times that JavaScript is God's gift for web developers. It's my fav language and I have used it to create many unique web experiances.

Server-side JavaScript (5, Interesting)

sveinb (305718) | more than 7 years ago | (#17310926)

I've been using PHP and Perl server-side and, reluctantly, JavaScript client-side for years before I actually bothered learning JavaScript. When I finally did, I discovered a language which was similar to PHP and Perl in that it supported most, if not all of their language constructs and which in many ways was more elegant (IMHO). So my dream was to use JavaScript both server- and clientside. That can be done in .net/mono, I guess, but I prefer the lightweight nature of PHP, Perl, Python etc. So I started http://www.sf.net/projects/jsext [sf.net] - check it out! The plan is to support C libraries (done on Linux, Windows version under construction) and Python modules (not done). There are other, similar projects, too: http://en.wikipedia.org/wiki/Server-side_JavaScrip t [wikipedia.org]

Re:Server-side JavaScript (1)

Tarwn (458323) | more than 7 years ago | (#17310966)

Javascript can also be used as the scripting language for class ASP pages. has been a choice since before .Net made it onto the scene.

Higher order functions? Whats the big deal? (0)

Viol8 (599362) | more than 7 years ago | (#17311058)

Can someone explain these to me since I'm confused. The article states:

"This example shows that I can treat a function just as I treat any other variable. C developers think of this concept as a function pointer, but JavaScript's notion of higher-order functions is much more powerful...
Using a function as a function argument, or returning a function as a value, elevates this abstraction into the realm of higher-order functions. "

Whats so new and powerful about this? Using the C example you can easily return function pointers as arguments from functions and pass them too functions as well. So why is javascripts method so much more powerful that C's? Using a standard C compiler you could also pass to the same piece of code function pointers to functions with variable arguments(though I suspect a C++ compiler might complain about this).

Not sure what his point is.

No printf in javascript ? (1)

herve_masson (104332) | more than 7 years ago | (#17311074)

Beside the lack of a good way to debug your javascript code (using traces, not the infamous alert method), I really miss printf like functions. Why was this not available in the base language is beyond my understanding.

Anyway, if you're like me, you can use my own implementation of printf functions here [mjslib.com] .

Needs a Concatenation Operator (4, Interesting)

ajs318 (655362) | more than 7 years ago | (#17311086)

JavaScript has one really, really nasty flaw. It "recycles" the + operator (which usually is used for adding numbers) to concatenate strings. In some languages (e.g. BASIC), which treat numbers and strings as distinct data types, this is not a problem. But JavaScript is dynamically-typed -- in other words, you don't have to tell it what is a number and what is a string; it tries to work that out for itself. And this is the source of the error. When you innocently write
document.theform.hours.value += 1;
in a bit of form-munging code, what happens is that a figure "1" gets appended onto the end of the value in the "hours" box. If you want to increment it by one, you have to use something like
document.theform.hours.value -= -1;
which is mathematically sound, but looks very weird.

JavaScript really needs a dedicated string concatenation operator, in recognition of the fact that numeric addition and string concatenation are different operations. Unfortunately, the "dot", which would be the most obvious choice as it's already used for the concatenation operator in other languages, is already very much in use -- not to mention that changing an operator in this fashion is likely to break things. And the breakage will be even worse than register_globals in PHP, since JavaScript runs on the client side -- meaning no webmaster can ever know for sure what JavaScript engine is in use.
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Sign up for Slashdot Newsletters
Create a Slashdot Account