Slashdot Mirror


Why JavaScript Is the New Perl

theodp writes "'People are thoroughly excited [about JavaScript],' writes Lincoln Baxter. 'However, I'd akin this to people discovering Perl during the advent of C and C++ (mirror). Does it work? Yes. Is it pretty? Not by a long shot.' Baxter adds, 'While I do like both languages, JavaScript [is] just waiting for the next technology to come around and make it look like Perl does today: pervasive, but lacking enterprise adoption on large applications.'"

3 of 453 comments (clear)

  1. Re:Modem noise by hobarrera · · Score: 4, Informative

    I've heard many respectable criticisms of Python, but I've never heard anyone say it looks bad.
    Visually, it's probably the most elegant-looking language there is.

  2. Perl's purpose by Darinbob · · Score: 5, Informative

    Perl wasn't an alternative to C/C++. It became popular because it was a nice replacement for all those other Unix apps, a combination of sh+awk+sed, etc.

  3. Re:I don't.. by IICV · · Score: 5, Informative

    The weird scope rules and lack of proper object/class support drive me up the wall when working on projects with ~40,000 lines of code.

    I don't know, maybe I'm just weird myself but I don't think Javascript's scope rules are that hard to grasp, and the class support is workable but honestly most of the time you don't need to use classes at all.

    I mean, the scope is easy - are you in a function? If so, the variable is scoped to the function. If not, the variable is globally scoped. That's about it. Just wrap something like

    (function(){
    // code goes here
    }())

    around your script file, and everything will be local to that script file while still being able to see the global scope. There's some other funky stuff involving weird cases like using a locally scoped variable before it's defined, but as long as you're not writing crap on purpose it's not a huge deal.

    And as for classes - well, honestly, a lot of the time when you think "I need a class for this", what you really mean is "I've got some data that needs to travel together". In Javascript, you can just do that - you can just say:

    //here's a thing to hold my data
    var thing = {};
    //here's data to put in the thing
    thing.item1 = "something";
    //here's some more related data
    thing.item2 = {message: "I'm important!"};

    And then tada! You've got a class that carries your data around. Hooray!

    But if you really want classes, with methods and stuff like that, they're there too - but if you're writing a project large enough to actually need those sorts of tools, you really ought to be using a framework that'll handle the nitty-gritty of classes for you.