Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming IT Technology

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."
This discussion has been archived. No new comments can be posted.

Should JavaScript Get More Respect?

Comments Filter:
  • JS (Score:5, Interesting)

    by djupedal ( 584558 ) on Wednesday December 20, 2006 @04:42AM (#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 (Score:4, Insightful)

      by Schraegstrichpunkt ( 931443 ) on Wednesday December 20, 2006 @04:47AM (#17310440) Homepage
      And yet you don't seem to know the difference between an embedded Java applet and integrated JavaScript code.
      • Re: (Score:3, Interesting)

        by djupedal ( 584558 )
        '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 te
        • Re: (Score:3, Insightful)

          by pla ( 258480 )
          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.

          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
        • Re: (Score:2, Informative)

          'integrated JavaScript code'
          ...as opposed to what? JS that isn't integrated...?

          Perhaps I chose my phrasing poorly. The JavaScript interpreter is integrated into the browser, and has direct access to the web page's content. As opposed to Java applets, which are mostly isolated from the browser and the surrounding page content.

          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.

          I don't get my computing vocabulary from some unnamed dictionary. I get it from usage, and I've never heard anyone who isn't confused use "applet" in reference to JavaScript code. You wouldn't use it either, if you actually cared to communicate your thoug

          • Re: (Score:3, Insightful)

            by orasio ( 188021 )
            Cut the guy some slack.
            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: (Score:3, Funny)

      by CmdrGravy ( 645153 )
      25,000 lines of Javascript ? What could you possibly be doing which requires that level of Javascript interaction ?????
      • Re:JS (Score:5, Funny)

        by ignavus ( 213578 ) on Wednesday December 20, 2006 @05:25AM (#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 (Score:4, Funny)

          by mikek3332002 ( 912228 ) on Wednesday December 20, 2006 @05:54AM (#17310742) Homepage
          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 (Score:4, Funny)

            by Anonymous Coward on Wednesday December 20, 2006 @07:07AM (#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: (Score:2, Informative)

          by datadriven ( 699893 )
          for (i=25000;i=1;i--) {
              document.write((i + ' bottles of beer on the wall,' + i + ' bottles of beer. Take one down and pass it around ' + (i-1) + ' bottles of beer on the wall\n');
          }

          I only had 3 lines.
          • Re:JS (Score:4, Funny)

            by hobo sapiens ( 893427 ) on Wednesday December 20, 2006 @10:32AM (#17312948) Journal
            I only had 3 lines.
            Yeah, 3 lines and an endless loop. You meant:

            for(var i=25000;i>0;i--)
            document.write((i + ' bottles of beer on the wall,' + i + ' bottles of beer. Take one down and pass it around ' + (i-1) + ' bottles of beer on the wall\n');

            Dude, this is slashdot. You can't be posting endless loops like that, that could be dangerous! Have you any idea how many geeks will be frozen in front of their computers until they involuntarily fall asleep?
      • by hummassa ( 157160 ) on Wednesday December 20, 2006 @05:31AM (#17310642) Homepage Journal
        Any serious Ajax application.
      • Re:JS (Score:4, Informative)

        by HxBro ( 98275 ) on Wednesday December 20, 2006 @05:52AM (#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.
      • Re:JS (Score:5, Informative)

        by h2g2bob ( 948006 ) on Wednesday December 20, 2006 @05:55AM (#17310746) Homepage
        How about Mozilla firefox [mozilla.org] (or any of it's extensions).
      • Re:JS (Score:5, Funny)

        by walt-sjc ( 145127 ) on Wednesday December 20, 2006 @08:27AM (#17311460)
        25,000 lines of Javascript ? What could you possibly be doing which requires that level of Javascript interaction ?????

        1000 lines of application code, and 24,000 lines of browser compatibility code.
      • by julesh ( 229690 )
        A CMS with a relatively advanced JS UI that my company's currently working on has around 7,000 lines of JS. That's not a particularly complex application, either. I could easily imagine something like a webmail system reaching five times that.
  • Dense != Good (Score:5, Insightful)

    by Marcus Green ( 34723 ) on Wednesday December 20, 2006 @04:43AM (#17310410) Homepage
    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
    • by MichaelSmith ( 789609 ) on Wednesday December 20, 2006 @04:45AM (#17310428) Homepage Journal
      The author seems to equate dense with good, not an association I make

      By that standard APL would be hard to beat.

    • Re: (Score:2, Insightful)

      by Anonymous Coward
      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 cod
    • 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
      • 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: (Score:3, Informative)

          one word check out the dojo toolkit www.dojotoolkit.org, then you can see which codesizes we are already dealing with. The dojo toolkit is not the only javascript codebase of significant size already outside in the wild, the more interactive the applications become the more you see toolkits of that size becoming the norm not the exception.
    • Re:Dense != Good (Score:5, Interesting)

      by sholden ( 12227 ) on Wednesday December 20, 2006 @04:59AM (#17310502) Homepage
      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: (Score:3, Informative)

        by Eivind Eklund ( 5161 )
        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", an

      • Re: (Score:3, Interesting)

        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 co
      • Re: (Score:3, Insightful)

        by marcosdumay ( 620877 )

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

        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 t

    • by D-Cypell ( 446534 ) on Wednesday December 20, 2006 @05:00AM (#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.
    • 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: (Score:3, Funny)

      by Rufty ( 37223 )
      Dense *is* good. Suck all the bugs out of your code, you just need a perl regex with an event horizon.
    • As we all know, programmers are most productive in assembly, which is by nature many times denser than any programming language.

      Oh wait! Never mind assembly, lets just do binary.
  • by Anonymous Coward
    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.
    • 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?
    • by tacocat ( 527354 )

      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

    • by DrSkwid ( 118965 )
      If only you;d know that when you started ... oh wait ...
    • by uradu ( 10768 )
      > anyone with access to the View Source command can steal your work and throw it on their own site as theirs

      Don't flatter yourself. As any halfway experienced developer will realize, that would only be true of the most trivial code, or perhaps some fancy algorithm that calculates the meaning of life in five lines of code or less. Most larger real world applications that do something useful are more tedium than brilliance, and are so problem domain specific that code "stolen" from them would be all but us
  • by cyclomedia ( 882859 ) on Wednesday December 20, 2006 @05:06AM (#17310534) Homepage Journal
    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
    • by Shano ( 179535 ) on Wednesday December 20, 2006 @05:37AM (#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.

    • 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 the

  • by Radium Eyes ( 1041164 ) on Wednesday December 20, 2006 @05:08AM (#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.
    • 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.
    • You remind me of comments I first saw at JavaScript: The World's Most Misunderstood Programming Language [crockford.com].

      Despite its popularity, few know that JavaScript is a very nice dynamic object-oriented general-purpose programming language. How can this be a secret? Why is this language so misunderstood? ...

      JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional

  • by Anonymous Coward
    ... 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.
  • 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
  • by vhogemann ( 797994 ) <victor.hogemann@com> on Wednesday December 20, 2006 @05:24AM (#17310604) Homepage
    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.
  • by Anonymous Coward on Wednesday December 20, 2006 @05:29AM (#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 (Score:3, Interesting)

    by Jens de Smit ( 1041964 ) on Wednesday December 20, 2006 @05:36AM (#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.
  • Overlord (Score:2, Funny)

    by Dude163299 ( 906461 )
    I for one Hate our new Javascript writing overlords.

    And for the record im suppose to be writing various Javascript programs at this moment.
  • by master_p ( 608214 ) on Wednesday December 20, 2006 @05:41AM (#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!

  • Dear god no. (Score:3, Insightful)

    by el_womble ( 779715 ) on Wednesday December 20, 2006 @05:41AM (#17310694) Homepage
    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?
    • 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.
      • 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.
      • Call me old fashioned but K&R will always be my definition of simplicity and power in programming.

        The thing that makes it messy in C is C's strong typing, you would have to pass and return everything as strings, but this is to be expected since the problem is contrived to demonstrate the brevity possible with weak-typing. The trade off is that you don't know exactly what your dealing with. In well written scripts that's no big deal, in a system with thousands of source files written by dozens of prog
        • Re: (Score:3, Informative)

          by arevos ( 659374 )

          The thing that makes it messy in C is C's strong typing, you would have to pass and return everything as strings, but this is to be expected since the problem is contrived to demonstrate the brevity possible with weak-typing. The trade off is that you don't know exactly what your dealing with. In well written scripts that's no big deal, in a system with thousands of source files written by dozens of programmers it will quickly turn your brain to mush.

          It used to be that weak typing in a language was a BadThing(TM), now it's a "feature".

          You're confusing weak typing with dynamic typing. C is not strongly typed; it has static weak typing. Languages like Java have static strong typing, Python and Ruby have dynamic strong typing, and PHP and Javascript have dynamic weak typing.

  • by Aphrika ( 756248 ) on Wednesday December 20, 2006 @05:49AM (#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.
  • by tacocat ( 527354 ) <tallison1 AT twmi DOT rr DOT com> on Wednesday December 20, 2006 @06:11AM (#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.

  • by sveinb ( 305718 ) on Wednesday December 20, 2006 @06:41AM (#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]
    • by Tarwn ( 458323 )
      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.
  • C-like ugly syntax...
    weak typing...

    No. No respect.

    I may use it, but respect it? Nah...
  • by ajs318 ( 655362 ) <sd_resp2@earthsh ... minus herbivore> on Wednesday December 20, 2006 @07:21AM (#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.
    • Plenty of other mainstream languages reuse + for string concatenation (C++, C#, Java), including dynamic ones (Python, Ruby). I haven't really observed any problems with that so far, but if you're really worried, you can always declare something like: function strcat(s1, s2) { s1.toString() + s2.toString(); } And use that throughout your code.

      All in all, it's really a very minor issue.

      • Re: (Score:3, Informative)

        by ajs318 ( 655362 )
        It's not a "very minor" issue. It's fundamentally broken. Essentially, everytime you want to add numbers, you end up having to subtract a negative number instead, or use ParseInt() / ParseFloat() to force things to be numeric (concatenating strings seems to be the default behaviour of +). This just looks messy (and coming from someone who uses Perl, that's a damning indictment indeed).

        Your strcat() example is nice, but it can only ever concatenate two strings -- a limitation of the language. (JavaSc
      • Re: (Score:3, Informative)

        by Scarblac ( 122480 )
        Python and Ruby may be "dynamic" in some sense, but in both of them string += int will cause an exception. They're strictly typed, just with dynamic binding. Javascript really is a bit odd in allowing += for both addition and concatenation, and giving no warnings if you mix types. That's the sort of fuzzy thing that you'd only expect in PHP.
  • JavaScript, surely the Rodney Dangerfield of scripting languages.

    I don't get no respect, you know, the other day I told a friend that I wanted to try out the online dating scene, and he set me up to use Outlook Express on Usenet!
  • And Ajax is worse. Now I can be writing an email in gmail, hit back to check something, and bye bye everything.
  • by CTho9305 ( 264265 ) on Wednesday December 20, 2006 @08:48AM (#17311658) Homepage
    You can do some pretty fun things with it, such as a true 3d engine [ctho.ath.cx], a raytracer [ctho.ath.cx], games [ctho.ath.cx] (careful, robots is addicting!), out-of-order CPU simulators [ctho.ath.cx], and other stupid things [ctho.ath.cx] without any plugins - all the user needs is a halfway decent browser.
  • by bcrowell ( 177657 ) on Wednesday December 20, 2006 @11:55AM (#17314072) Homepage

    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.

  • by bryanbrunton ( 262081 ) on Wednesday December 20, 2006 @12:01PM (#17314150)
    While developing an Ajax application called Grand Strategy, an implementation of the board game Risk, I have found one of my main gripes with Javascript to be the download times involved with using large amounts of it. There are things that you can do to mitigate: gzip compression, displaying progress bars, use short variable and function names, and then caching. There are ways to do dynamic downloading of portions of a library; you can see these in Dojo. However, these dictate that you radically structure your code to support it.

    It would be very nice if the whole browser based development environment had mechanisms to deal with the dynamic loading of javascript.

    Next we come to the next major javascript issue: the unreliable browser cache. Users of my game will occasionally not be able to log in, or a portion of the game becomes unusable, even after having played the game for weeks on end. Inevitably, some javascript in their browser's cache will have become corrupted, or seemingly partially downloaded.

  • prototype.js (Score:4, Insightful)

    by Lothar ( 9453 ) on Wednesday December 20, 2006 @01:40PM (#17315462)
    I have one word for all of you: "prototype.js" ( http://prototype.conio.net/ [conio.net] ). The day I discovered prototype.js I stopped hating javascript. It also made me appretiate the really cool ways javascript lets you do inheritance etc + reading the prototype.js code really gets you learning.

    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!
  • by freezin fat guy ( 713417 ) on Wednesday December 20, 2006 @03:00PM (#17316418)
    The problem with developing Javascript code is that you are shooting at a moving target.

    Unless the use is restricted to a highly controlled intranet setting it will be executed on an indeterminate set of runtime environments. Different browser vendors, different versions, different sub-builds... where does the madness end?

    Unless you are doing something trivial you can wind up with several times the code necessary to get the job done on any one Javascript runtime. And bug testing? Well that takes far longer than it should for exactly the same reason.

    I don't have a problem with the language itself. Or any one interpretation of the language to be more precise. But give me some solid footing.

    Beef #2 - is your Javascript accessible to disabled users? Standard response: "F*** the disabled; they're a minority and we all know minorities deserve to be shot and pissed on." As I lack the Satanic vitriol necessary to punish people for unfortunate circumstances I find myself at odds with the Web 2.0 community.
  • Hell No! (Score:3, Interesting)

    by h4ck7h3p14n37 ( 926070 ) on Wednesday December 20, 2006 @03:38PM (#17317000) Homepage

    Hell no Javascript doesn't deserve more respect. Unlike, say Java applets, there's no security sandbox so rogue Javascript code can connect to the network and leak information from the client system.

If you steal from one author it's plagiarism; if you steal from many it's research. -- Wilson Mizner

Working...