Javascript Still Sucks

I’ve been experimenting with Javascript. I wrote a “video poker practice” program. It deals a hand, asks you what you would draw, and figures out the correct play by checking all the possibilities.

I had already written a C++/MFC version of the program. For that version, the calculation was instantaneous, much less than a second.

For the Javascript version, the EXACT SAME ALGORITHM, it takes 5-10 seconds, an unacceptable delay. That’s why server-side Javascript is a stupid idea.

I also experimented with some objects. Consider the following code fragment:


obj.value = 5
obj.vaule = obj.value + 1

In C++, this leads to a compiler error, “vaule not a member of obj”.

In Javascript, it’ll add vaule as a new member of obj, without giving any error.

I’ve been using Firefox+Firebug to test my Javascript. I tried it in IE, and it didn’t work. That is annoying.

In terms of performance, C/C++ blows away all the other things I’ve tried, .NET, Java, PHP, Javascript. Surprisingly, almost nobody uses C++ anymore. These other languages aren’t 2x or 3x slower than C++. They can be 100x or more slower, especially for number-crunching.

13 Responses to Javascript Still Sucks

  1. I gotta ask (just curious). What are your thoughts on languages such as Erlang and Lisp?

    I’ve worked with C++ (loved it), C (loved it… although it is an ugly duckling), Java (meh), PHP (bleh!!!!), C# (for some reason I feel better about this than Java, but not as good as C++), Erlang (weird syntax, but it does have the bonus of the actor model) and Lisp (will need to revisit, still don’t 100% “get it”).

    • Actually, there’s really only a couple of classes of languages. There’s C/C++/assembly. There’s the LISP family (featuring functions as variables), which includes SCHEME and parts of Ruby. There’s the Matlab/APL/Mathematica/R family. There’s the SQL family. There’s scripting languages, bash/shell, Perl, PHP, Python. There’s the bytecode languages (Java, .NET).

      I haven’t used Erlang, so I have no opinion. I’ve never seen a job ad requesting Erlang experience, so I’m not motivated to learn it.

      I did some LISP in college (SCHEME actually), in the introductory CS class. Now, that same class is design patterns and Java (yuck!), so I don’t know if I would even finish a CS major if I were starting today. LISP suffers the same “it’s slow” problem of any language other than C/C++. For certain AI problems, I heard it’s good, but newer languages also feature the function/map constructs that LISP uses.

      I’ve never seen a job ad requesting LISP experience (unless you’re Paul Graham).

      That was one of the biggest coups by Sun (now Oracle), convincing all the top CS departments to start using Java as their “language of choice”. As usual, marketing beats quality.

      Actually, I like PHP. If you’re doing something web-based, it’s much better than C/C++. To do the equivalent of php’s file_get_contents (from a url) in C++ requires a lot of code or libraries. PHP is a thin wrapper for C. PHP handles hashes and arrays MUCH BETTER than Perl. The website php.net is a great resource for learning php, and has answered almost any question I’ve ever had. I haven’t seen a website the same quality as php.net for fads like Ruby on Rails or node.js. I’ve written a couple of things in PHP, but then rewrote them in C++ when the PHP version was too slow.

      Technically, any Turing-complete language would work for any task. Lately, I’ve been doing some Javascript, experimenting with writing a web-based game, PHP (This blog is in PHP and has some custom code. See if you can find all of it!), and occasionally C/C++ when PHP isn’t fast enough.

      My attitude towards languages lately is “I’m learning them only for a job.” However, most jobs require you to ALREADY HAVE WORK EXPERIENCE in whatever language they are using. Learning it on your own isn’t good enough. I figure if a language is in enough demand, someone will hire me to use it even though I have no prior experience in it. However, that strategy hasn’t been working.

      In my CS classes, the professors said “Learn the theory. Don’t focus on specific languages. If you know the theory and have talent, you’ll never have a problem learning a new language.” While working and looking for a job, employers always demand experience in the specific language they’re using. Experience in similar languages and older languages is worth $0.

      Finally, Javascript was tacked on to Netscape browser in a hurry to beat out competitors, and now we’re stuck with it as a standard.

      • Thanks for the explanation.

        I’ve had a bad experience working in a PHP shop, hence my weariness towards it. I was told to write a desktop app in PHP when other languages such as VB .NET or Perl would have been better candidates. The reason? They didn’t want to have too many languages that they’re developing code in… I remember asking a Zend consultant if writing PHP desktop apps made any sense, he said no (there were other annoyances at job).

        As for Javascript, I agree with your sentiment 100%.

        • PHP is not for a desktop app. It’s for web-based only. (You can use some command-line shell scripts for PHP, but you’d probably be better off with Perl or Python for something like that. I do simple scripts in PHP because I know it better than Perl or others.)

          However, sometimes it’s easier to make something web-based rather than a desktop app, because then it’s easier to troubleshoot, deploy upgrades, and control security.

          My experience with Ruby on Rails was in a place that was using it incorrectly (in addition to Ruby on Rails itself being lousy). Also, my two Java jobs were on projects that were mostly disasters.

          I also am surprised by the proliferation of web frameworks. When applying for the job, you aren’t just expected to know the language, you’re also required to already know the framework they’re using.

          The “advantage” of a framework is that, if your problem closely matches the framework, you can bang out a simple website quickly. The problem occurs when you want more features than the framework provides. Then, the framework becomes a handicap, because you have to deal with the framework overhead. You have to write framework-compliant code in addition to the code for whatever feature you’re adding.

          I always thought it would be foolish for a startup to use one of these frameworks, because then your product looks exactly the same as everyone else using the same framework. If your startup is truly original, there won’t be a framework that covers what you’re doing.

          • I agree 100% with the framework perspective. At my last job, we had that exact same problem. The requirements were more than the framework and that was a nightmare. We had a consultant develop this little authentication piece that’s 100% not standard in any way, after he was done, no one really knew how that code worked (and the guy who wrote it probably already forgot how it works).

            Doing it straight in PHP would have been easier and without a consultant that we paid through the nose for :) .

          • Amusing, at the job for the Ruby on Rails disaster, the “architect” decided to use Ruby on Rails, having never used it before. He bet the startup on Ruby on Rails, and was wrong. Because he didn’t know Rails, he had to hire a “Rails consultant”. I tried learning Rails myself, but the documentation was incomprehensible. Rails demands a certain database layout, so I couldn’t get Rails to work with the legacy database. When I tried to do something more complicated than the built-in scaffolding, there just wasn’t any information on how to do that.

            Some pro-State trolls say “FSK couldn’t understand Rails because he’s incompetent!”, but it really was an incomprehensible mess (and still is, as far as I can tell).

          • Actually, the original product worked just fine. The problem was that we had a self-described “architect” who wanted this project moved into an “MVC Framework”, then the dude left and the manager was just cracking the whip to “Git ‘er done!”… no, he literally said this.

            Then the “architect” left and I was stuck with a self-absorbed man-child who knows only PHP and Javascript and thinks he’s a gift to the universe.

            I have the money to just not work… for years… in a savings account. I stuck around because other matters that _required_ I have a job (I prefer not to speak of these details, personal matter).

            lol, at this stage, I’ll start doing mobile game development and start selling little games for $1.00 or sell adverts. At least in that case I won’t have the urge to hurl when I’m stuck between an egomaniac and an idiot.

            Best quote from my manager: “You don’t follow our design standards.”
            Me: “But we don’t have anything written down that tells us how we should ‘design’ our apps or anything else.”
            Him: “Well, you should pick up on the flavor of what we do here by now.”
            Me:

          • Oh and I don’t know myself, but check out Zend and CakePHP for “fun”, if you’re that interested.

          • You should read “Software Architects Suck – Never Trust A Software Architect”. Everyone I’ve met someone who called himself a “software architect” was a completely unqualified loser. A software architect is a full-time manager who doesn’t code himself. That job description is tailor-made for someone who’s good at promoting himself and emotional manipulation tricks, but has no actual coding ability.

            Because the software architect doesn’t get his hands dirty with implementation details, it’s never his fault when the project fails.

            I’ve concluded that Drupal is more worth learning than Zend or CakePHP. I haven’t seen any ads for CakePHP in awhile, but I used to. Zend framework overuses design patterns from what I heard.

            That’s one big problem with frameworks. There’s so many of them, and they come and go like fads. However, to get “buzzword compliant” with a framework, I need a couple years of experience in it to get past the HR/headhunter screening filter. By that time, the framework won’t be in demand anymore and it’ll be something else.

            BTW, don’t leave your savings in a checking account. You’ll get robbed via inflation. Buy gold or silver coins, or the gold/silver ETFs. I haven’t yet followed my own advice to buy PMs and take physical delivery.

  2. Oh and I’ve worked with Javascript, it seems like it’s needlessly complex (the language itself), as if it could be done better.

  3. Head bob. Javascript is a neat little language with a simple(ish) syntax. I can’t imagine writing anything big in it though.

    I continue to be amazed how the industry has largely thrown off mature dev tools for web development which takes 10 times the effort to do 1/10 th the work.

    I graduated from UC Berkeley in 1997 just ahead of the Java monster (sounds like you had a similar undergrad experience and have, like me, watched with dismay as the curriculum has ignored useful stuff for fluff and hype). I’m still annoyed at Netscape for intentionally muddying the waters by naming their crap Javascript to jump on the Java hype. I still have to explain that one to people.

    Luckily I’ve managed to find work in the C++ performance niche. There are still some of us out here.

    • I don’t have guest posts. If you have an article on your own blog, post a link in the comments. If it isn’t spam, I’ll look at it. (I suspect this is spam.)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>