Slashdot Mirror


JavaScript Decoder Plays MP3s Without Flash

An anonymous reader writes "The introduction of HTML5 and super-fast JavaScript engines to the latest web browsers has brought with it a wealth of new functionality. The focus seems to have been put on the ability to play video in a browser without Flash, or making games. But a project born out of a Music Hackday in Berlin is just as exciting. It's called jsmad and is a pure JavaScript decoder that allows you to play MP3s in a browser without Flash. So, for example, a music artist could create a website and upload songs for visitors to listen to without need of any plug-ins. Alternatively, why not have an MP3 jukebox that can play songs off your hard drive or Dropbox folder just by loading a website? You can try out the decoder by visiting the jsmad.org website where there is a sample song, on the same site you can browse for your own local file to play. Be warned, it only works in Firefox 4+ at the moment, but Chrome support is coming and already works in some cases." Another reader tips news of a JavaScript PDF viewer.

158 of 250 comments (clear)

  1. It works! by drsmack1 · · Score: 2, Funny

    Actually, my subject makes me seem more excited than I am. I regret any misunderstanding.

    Carry on.

    1. Re:It works! by ottothecow · · Score: 2
      Why doesn't have a volume control though?

      I have noticed a lot of the new "trendy" streaming sites have decided to do away with or hide the volume control...
      Sometimes I like to adjust the sound of one application vs another and on my work computer, the headphone volume is too loud at the lowest click unless I turn down the application volume (but dropping wave volume all the way down messes with the speaker sound which application volume seems to behave well with)

      --
      Bottles.
    2. Re:It works! by drsmack1 · · Score: 1

      Would you possible be classified as "neurologically atypical" by the teams of specialists that you were paraded in front of as a young child?

      March for a cure, dude.

    3. Re:It works! by Kalriath · · Score: 1

      Any modern OS allows you to modify the volume per application (Windows Vista and Windows 7 do, I'm told Linux does as well with a particular mixer installed. Mac OS doesn't though).

      --
      For a site about things like basic rights, Slashdot users sure do like to censor "dissent".
    4. Re:It works! by RobbieThe1st · · Score: 1

      I too agree. Now, I don't often need to mess with the application volume if it's all I'm doing, but if I'm trying to, say, listen to music in addition to Teamspeak, then yes, I need to be able to adjust it.

    5. Re:It works! by jesser · · Score: 1

      Perhaps browsers should let you modify the volume per hostname or per tab, since they are also application platforms.

      --
      The shareholder is always right.
  2. another reason to not have to use flash by Nick · · Score: 2

    Now if only the pr0n industry would hurry up and get with the program.

    --
    Fuck Ajit Pai
  3. mp3? Acrobat! by Joce640k · · Score: 4, Insightful

    I'd say that getting rid of the Acrobat plugin is far more interesting.

    --
    No sig today...
    1. Re:mp3? Acrobat! by ByOhTek · · Score: 3, Interesting

      I use foxit. There's also Okular. I probably shouldn't forget [g|k|x]pdf... Plenty of alternatives to acrobat.

      --
      Self proclaimed typo king, and inventor of the bear destroying coffee table (patent not pending).
    2. Re:mp3? Acrobat! by TerranFury · · Score: 1

      On Windows, Sumatra is the fastest, and by far the best for use with pdflatex. Its printing is poor, so on those occasions when you actually want to print a PDF you probably want Foxit.

    3. Re:mp3? Acrobat! by Lunix+Nutcase · · Score: 1

      But a Javascript API means PDFs be much more optimized, because you don't need a software plugin loading and running in the background.

      Because Javascript just executes itself through magic and requires no background processes running to compile and run it, right?

    4. Re:mp3? Acrobat! by Xelios · · Score: 1

      Apparently the Firefox team is working on this right now.

      --
      Murphey's fighting Occam, and we're in the stands.
    5. Re:mp3? Acrobat! by layer3switch · · Score: 1

      Actually that would be correct (except it being magic) because they are all single thread anyhow and every page view these days has to utilize jvm in one form or the other, because any ECMAScript engine with framework libraries supporting swfobject and pdfobject, pdf/swf wrapper api to external execution stack is necessary. hence having ECMAScript engine able to support full pdf data stream without extra execution stack does make sense. As for developer's sake, I can see some value in not dealing with extra layer of the onion just to serve uniform data stream.

      --
      "Don't let fools fool you. They are the clever ones."
    6. Re:mp3? Acrobat! by RobbieThe1st · · Score: 1

      No, but I *will* say that JS is a lot more stable(and faster to load) than trying to run a third party plugin, mainly because the JS engine has been tweaked to work right with that version of FF/Chrome/Opera; The plugin hasn't.

  4. audio by Anonymous Coward · · Score: 1

    How to play mp3s in your browser using HTML5:

    <audio src="song.mp3">

    What, me worry?

    1. Re:audio by PwnzerDragoon · · Score: 1

      ...Unless your browser doesn't support MP3. Firefox, and (I think) Opera for example.

    2. Re:audio by kiddygrinder · · Score: 1

      that doesn't work in firefox or opera

      --
      This is a joke. I am joking. Joke joke joke.
    3. Re:audio by DaVince21 · · Score: 1

      That's "How to play mp3s in Chrome and Safari using HTML5". I'm pretty sure this script was created so Firefox/Opera/whatever else that doesn't natively support MP3 isn't left out.

      --
      I am not devoid of humor.
  5. I hope Subsonic adds a version of this by Nimey · · Score: 2

    it'd be kind of nice to be able to stream music to my Kindle, which for obvious reasons doesn't have Flash, but does have a rudimentary web browser that's based on WebKit.

    --
    Hail Eris, full of mischief...

    E pluribus sanguinem
  6. Err by The+MAZZTer · · Score: 1

    Chrome (and I'm pretty sure Firefox too) already supports MP3s without plugins, that's the purpose of the audio HTML5 tag. What is the benefit of this that the audio tag doesn't offer?

    1. Re:Err by Dishwasha · · Score: 3, Insightful

      Not having to have a native mp3 decoder codec on your machine. Also being javascript it is theoretically compatible across all platforms that the browser supports, particular those that may not have native mp3 decoder codecs. The HTML5 standard isn't attempting to establish a standard for codecs. Not saying it's worthwhile or anything, just pointing out potential benefits as you requested.

    2. Re:Err by amliebsch · · Score: 1

      Great! So now instead of the browser user (or OS user) needing to purchase a license, every website does!

      --
      If you don't know where you are going, you will wind up somewhere else.
    3. Re:Err by BZ · · Score: 3, Informative

      Gecko does not support MP3 in HTML for exactly the same reason it doesn't support H.264 in : it's patent-encumbered and you have to pay licensing fees to use it.

      In 6 years, when the MP3 patents expire, we'll see.

    4. Re:Err by Em+Adespoton · · Score: 1

      In theory it's great... in practice, can you name a single environment that supports an HTML5 compliant browser that doesn't already bundle an MP3 codec? And what happens if the available audio is AAC, PCM or FLAC? Also, what does this do to the security model? Could someone write an "MP3" that exploits the javascript decoder?

    5. Re:Err by iluvcapra · · Score: 1

      Gecko does not support MP3 in HTML for exactly the same reason it doesn't support H.264 in : it's patent-encumbered and you have to pay licensing fees to use it.

      They could just divert and use the codecs that are included with the OS and already licensed by the OS vendor, be he Microsoft or Apple, and that would cover 90% of cases. However, they probably wouldn't do that because it would make the Linux version less competitive by comparison, because many Linuxes don't have codecs or they're an additional install, and Mozilla would rather have an equal less-functional playing field between the ports of Gecko/Firefox than have versions that competed with each other on features. They also have an ideological commitment to give patented formats no quarter or support, unless they meet some definition of "open" they're comfortable with, like WebM.

      --
      Don't blame me, I voted for Baltar.
    6. Re:Err by BZ · · Score: 2

      Actually, Mozilla could just license the MP3 patents or the H.264 patents if all they cared about was their own exposure.

      But that wouldn't help the patent restrictions on authors and such.

      So the stance against patent-encumbered codecs is less about a level playing field for Linux than about a level playing field for all who would like to put content on the web. And that last part is in fact one of the core aspects of Mozilla's reason for existence.

    7. Re:Err by julesh · · Score: 1

      The MP3 format was first published in 1993. Other than changes and improvements made since then, any patent on the basics *should* therefore have been filed by 1994, and expire by 2014 (unless it was delayed for longer than 3 years before the patent was granted).

    8. Re:Err by Lennie · · Score: 1

      It also does not solve the problem of others repacking Mozilla products. Like let's say Linux distributions.

      --
      New things are always on the horizon
    9. Re:Err by DaVince21 · · Score: 1

      It will run in Firefox, which doesn't do MP3 natively. The audio tag works arbitrarily with some formats (but most certainly with Ogg) because in the end they decided not to put in the spec what format is accepted.

      --
      I am not devoid of humor.
    10. Re:Err by hitmark · · Score: 1

      One funny thing is that Ogg audio is big in computer games. Easy to implement and no license issues.

      --
      comment first, facts later. http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm
  7. Jerky sound by Ricarus · · Score: 1

    It does work indeed, but the sound is pretty jerky while the browser is loading other websites... Maybe a bug (or feature?) in the FF4 JS scheduler.

  8. Interesting, BUT by vga_init · · Score: 1

    We've had this kind of functionality for a long time. I don't mean through flash, but there has always been some client-side software that decodes and plays back audio files, usually by one plugin or another. A javascript player basically follows the same model of loading some code on the client machine that does the playing. The only difference here is that it's being done using slightly different facilities.

  9. Re:Can't HTML5-compatible browsers play MP3s nativ by emj · · Score: 2

    MP3 is patented so I'm guessing Mozilla and Opera won't pay the license fees for it..

  10. why? by TRRosen · · Score: 1

    anyone?

  11. 5...4...3...2...1...Slashdotted! by ckthorp · · Score: 1

    And we're there.

  12. Re:Old News is old by madprof · · Score: 1

    No it hasn't. We're talking about a pure JavaScript decoder.

  13. It's coming by TRRosen · · Score: 3, Funny

    I'm writing a browser in JavaScript that will run on itself !!!

    1. Re:It's coming by idontgno · · Score: 1

      Hotjava. A browser which could run Java applets, written in Java.

      On all the Sun servers I ever administered, I ran that browser just long enough to download and install Mozilla. (Yeah, it was the IE of Unix browsers, for the simple reason that it was pretty limited.)

      This cries out for a "'Yo Dawg" joke which I am not going to stoop to make.

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    2. Re:It's coming by maxume · · Score: 1

      Much of the interface of Firefox is written in javascript and XUL.

      It's part of the reason the extension ecosystem is so robust.

      --
      Nerd rage is the funniest rage.
    3. Re:It's coming by Em+Adespoton · · Score: 1

      Ever used Cyberdog? You could run HotJava in Cyberdog in HotJava in Cyberdog....

    4. Re:It's coming by Junior+J.+Junior+III · · Score: 1

      Please name your project xibit.

      --
      You see? You see? Your stupid minds! Stupid! Stupid!
    5. Re:It's coming by psema4 · · Score: 1

      I'm writing a browser in JavaScript that will run on itself !!!

      Use jsdom with node.js. Still need decent GUI bindings (Gtk is in the works IIRC), but other than that it's ridiculously easy.

  14. Super-fast is a bit of a misnomer by Wrath0fb0b · · Score: 2

    It's more like "no longer agonizingly slow" due to herculean (and well-appreciated) efforts to optimize a language that was just not written for speed. You might as well say you upped the voltage to your Prius and say now it's a "super-fast hybrid" -- people that prioritize speed don't buy hybrids and people that buy hybrids obviously didn't consider speed to be a priority.

    This is not a criticism, it's just a statement of fact. Even the fastest javascript engines don't even remotely compete with modern interpreted languages (Java, C#), let alone actual bare-metal code (C and friends). Both have their place depending on what you are doing. Having a natively written plugin handle MP3 decoding with a well-defined API seems to me far more logical than expending effort to write it in javascript, especially when it doesn't even run across all browsers yet.

    Then again, that's just my $0.02, and as much as I don't think it's a great use of effort, it's damn cool!

    1. Re:Super-fast is a bit of a misnomer by Shados · · Score: 1

      Even the fastest javascript engines don't even remotely compete with modern interpreted languages (Java, C#)

      I'd think it would depend which part you're considering. Overall, yeah, you're right. But in parts, at the end modern Javascript engines, just like Java or C#, have just in time compiler and they execute native code. Javascript preemptively has to auto-detect the types, but recent progress allowed engines to do that ahead of time as much as possible. So after that, native code is native code. I wouldn't expect differences to be THAT large. DOM operations would be the majority of the bottleneck.

    2. Re:Super-fast is a bit of a misnomer by Lunix+Nutcase · · Score: 1

      Even the fastest javascript engines don't even remotely compete with modern interpreted languages (Java, C#)

      *facepalm* C# is not an interpreted language. The IL is either AOT compiled or JIT compiled to native code at runtime.

    3. Re:Super-fast is a bit of a misnomer by Lunix+Nutcase · · Score: 1

      Now you could write a C# interpreter if you want but that is not how C# code is executed. It is always compiled whether it be AOT or through a JIT compiler.

    4. Re:Super-fast is a bit of a misnomer by djdanlib · · Score: 1

      New $engine: Now with more jiggawatts! Hey, I have an idea. Let's also re-invent the multithreading wheel by putting a totally new code you guise scheduler into our awesome for real browser. That ought to run nice and smooth... wait, the OS and that other site that pings the twittlers is pre-empting it, so now my mp3 is all skippy.

      My point is: Software that needs to keep a buffer filled in real-time should probably not be written in Javascript. While you CAN do it under ideal circumstances (powerful enough CPU, low system load, enough RAM, no other websites open contending for the browser's JS engine's time) there are far better ways to do such a thing that can guarantee the CPU time you need. You know, like all those other audio plugins and standalone apps, which have more direct access to the audio hardware.

      I do agree though that it's pretty cool to see someone actually try something so brain-wrecking as to implement mp3 decoding in Javascript. I wonder what the licensing situation is when that happens?

    5. Re:Super-fast is a bit of a misnomer by Nadaka · · Score: 1

      Same for Java, but the JVM happens to be a lot more mature than the CLR and generally runs faster.

    6. Re:Super-fast is a bit of a misnomer by shutdown+-p+now · · Score: 1

      Javascript preemptively has to auto-detect the types, but recent progress allowed engines to do that ahead of time as much as possible.

      That's where the catch it. Semantically, JavaScript is dynamically typed. Optimizers have to jump through a lot of hoops to infer types, and even then they often end up with "it's either X or Y here, not sure which", necessitating a runtime check before one of the two optimized versions is chosen. The problem is that it's very easy to write such JavaScript without realizing that, whereas in something like Java or C#, this is explicit in the code of your program in form of "instanceof" and casts.

    7. Re:Super-fast is a bit of a misnomer by Lunix+Nutcase · · Score: 1

      Sure, Java does now. But originally Java was purely interpreted. C# has NEVER been interpreted.

    8. Re:Super-fast is a bit of a misnomer by amRadioHed · · Score: 1

      Are you sure about that? When was Java ever an interpreted language?

      --
      We hope your rules and wisdom choke you / Now we are one in everlasting peace
    9. Re:Super-fast is a bit of a misnomer by Nadaka · · Score: 1

      In the mid 1990's, more or less.

    10. Re:Super-fast is a bit of a misnomer by GCsoftware · · Score: 1

      What? Java has ALWAYS been compiled down to bytecode, even Oak was like this - the virtual machine that runs said bytecode is a core feature of the platform. Java was NEVER an interpreted language.

    11. Re:Super-fast is a bit of a misnomer by Nadaka · · Score: 1

      A lot of people will argue that the byte code was then interpreted rather than compiled. Some people still insist that even JIT isn't really compiling.

    12. Re:Super-fast is a bit of a misnomer by FranTaylor · · Score: 1

      And this matters how exactly? Please be specific.

    13. Re:Super-fast is a bit of a misnomer by julesh · · Score: 1

      people that prioritize speed don't buy hybrids and people that buy hybrids obviously didn't consider speed to be a priority.

      Really?

    14. Re:Super-fast is a bit of a misnomer by Wrath0fb0b · · Score: 1

      For between £700,000 and £900,000, sure. I suppose you could also buy a supercomputer to run your website solely in Visual Basic.

      For the rest of us with limited means, we have to chose between competing priorities.

    15. Re:Super-fast is a bit of a misnomer by hitmark · · Score: 1

      Iirc, ARM chips can do java bytecode in hardware.

      --
      comment first, facts later. http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm
  15. I predict... by cruff · · Score: 1

    In the future there will be a slashdot posting about a Javascript script being able to post comments to stories on slashdot from a browser without needing a human to be present at the keyboard. When this happens, there will be remarks made about the change in the quality of comments. Some one will welcome the new Javascript comment posting overlords, etc.

  16. Re:The rise of Javascript. by fuzzyfuzzyfungus · · Score: 1

    Arguably, with the existence of tools like the "Google web toolkit" and its analogs, which let you do the writing in some other language and then convert it to javascript for deployment in-browser, I suspect that javascript's sins against developers will become somewhat less relevant. Admittedly, it almost certainly isn't what you would design if you were asked to design a platform-independent intermediate representation for complex programs; but it is pretty much the only platform-independent intermediate representation for complex programs that you can be fairly sure that any idiot can "install" just by typing something into a browser bar...

    It would have been nice if something better had been standardized; but your options pretty much break down into "javascript" or "assorted architecturally superior; but single-platform and/or deeply fucked in the code quality plugins".

  17. Re:Wow!! by haystor · · Score: 1

    I think this was posted due to /.'s obsession with everything mp3.

    --
    t
  18. Re:The rise of Javascript. by nschubach · · Score: 1

    javascript's sins against developers will become somewhat less relevant.

    Or do you mean: "developer's sins against javascript"?

    Just because there is a history of poor programers does not make the language any less interesting/powerful.

    --
    Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
  19. Is this news? by NeoXon · · Score: 1

    We have already have html5 h.264 video players for more than a year. Why is it news that from now on we can not only play videos (with sound, probably in mp3 format), but even sound without video?

    1. Re:Is this news? by NeoXon · · Score: 1

      Sorry, I got the point. html5 video players use h.264 decoders that are most probably written in assembly or C, whilst this is a pure javascript based mp3 decoder.

  20. Re:The rise of Javascript. by TerranFury · · Score: 3, Insightful

    your options pretty much break down into "javascript" or "assorted architecturally superior; but single-platform and/or deeply fucked in the code quality plugins".

    You'd think Java would be filling this role, but it isn't.

  21. This is not the fix you're looking for... by DoomHamster · · Score: 1

    The fix is coming: https://twitter.com/#!/nddrylliog/status/81798532717228032

    err...that tweet says:

    Stuck in my hotel with no SSH access, cannot bring http://jsmad.org/ back up. Going to Starbucks.

    Wrong kind of fix.

    1. Re:This is not the fix you're looking for... by maxume · · Score: 1

      Now imagine a world where Starbucks provided internet access.

      --
      Nerd rage is the funniest rage.
  22. Re:Can't HTML5-compatible browsers play MP3s nativ by Anonymous Coward · · Score: 5, Insightful

    And once agan, just like with H.264, they wouldn't have to pay any license fees if they just used the OS's own media API instead of trying to support specific codecs themselves.

    Modern OSs provide such an API for playing audio and video, and some (ie. Mac OS and Windows) even provide licensed proprietary codecs... not to mention that OS-provided codecs often work with things like video drivers to provide hardware acceleration that is transparent to applications. For example, VLC, while awesome, uses a huge amount of my CPU to play 1080p H.264 video, since it's software decoding (possibly with some generic "hardware assist"). On the other hand, Windows Media Player, which uses Microsoft's DirectShow codec which takes advantage of my GeForce card's full H.264 decoding, uses 1% of my CPU to play the same video.

    Browsers already make use of other OS-specific features, and this would make the whole codec licensing thing a non-issue for the browser makers, and for the vast majority of users. They need to stop trying to reinvent the wheel. The OS provides services to applications... browsers should use them.

  23. Re:The rise of Javascript. by Millennium · · Score: 1

    My guess: yet another person complaining about how JavaScript doesn't use their specific pet paradigms.

  24. Re:The rise of Javascript. by Nadaka · · Score: 1

    I am an expert with javascript at this point, and I can do amazing things with it. But that does not mean that it does not suck. No good IDE's, debugging and validation are a pain. The worst part of all is that its GUI is tied the crapfest that is the modern web browser running any one of a number of almost but not quite entirely unalike implementations of the HTML DOM.

  25. Re:Can't HTML5-compatible browsers play MP3s nativ by Haedrian · · Score: 2

    A multi-platform browser tightly coupling itself so that a certain subset of the users can't use some of the features. What a good idea.

  26. Re:HTML5 and Javascript (The Emperor's New Clothes by Intron · · Score: 1

    This nonsense may inexplicably result in feverish night terrors among those in Redmond, but the rest of us - the best of the best?

    Not impressed. Not interested. Don't care. Never will...

    Redmond? ITYM San Jose

    --
    Intron: the portion of DNA which expresses nothing useful.
  27. Wrong. by Anonymous Coward · · Score: 1

    Languages are not slow. Algorithms are slow. Execution environments are slow. There is nothing fundamental about JavaScript that makes it slow. Until recently, browsers executed it inefficiently and with few optimizations.

    1. Re:Wrong. by Wrath0fb0b · · Score: 1

      Languages are not slow. Algorithms are slow. Execution environments are slow. There is nothing fundamental about JavaScript that makes it slow. Until recently, browsers executed it inefficiently and with few optimizations.

      Languages impose constraints that require the execution environment to do more work for a given algorithm written in one language rather than another. Consider the following algorithm in C:


      const int N = 1000000;
      int someNumbers[N] = GetArrayOfIntsWithLength(N);
      int sum = 0;
      for(int i = 0; i

      If you implement this in Java instead of C, it turns out that the call to operator[] must, according to the language constraints, check to see if the value is within the range [0,size) for that array. The JVM may not skip that check and still be compliant Java. So in the end, the algorithm cannot really run as fast on Java because the are simply more operations to be done (to wit, checking that (i > 0 && i absolutely immutable, it has to create a new int for 'sum' whose reference is then assigned to 'sum'. This causes the old object to be dereffed and garbage collected.

      So by the time you are done adding up your numbers in Python, the interpreter has done a massive amount of work that the C version didn't, through no fault of the algorithm and only because of language design choices.

    2. Re:Wrong. by Wrath0fb0b · · Score: 1

      Oh for fuck sake slashcode. Less-than isn't meant to close tags.

    3. Re:Wrong. by SanityInAnarchy · · Score: 1

      That's what <ecode> is for.

      --
      Don't thank God, thank a doctor!
  28. HTML5 can already do this by OverTheGeicoE · · Score: 1

    HTML5 browsers already have support for audio file playback, depending on the browser. For example, Chrome can play MP3 and Ogg Vorbis files. Firefox 4 can play Ogg Vorbis but not MP3 due to licensing issues. Safari can do MP3 natively; Ogg Vorbis requires extensions from Xiph.org that are easily installable.

  29. Ugh. by Dracos · · Score: 1

    This will allow unthinking people another way to implement one of the things listed in every bad practices top ten list for the past decade: websites that make noise.

  30. Power efficiency??? by goombah99 · · Score: 1

    My guess would be that native plug-ins will always be more efficient on power than java script interpreted code. Not sure where exactly flash lies in that spectrum. It's a power hog compared to most apps but but my guess is flash has a lot of high level functionality running natively (audio and video) with just the command and control being in the flash language.

    --
    Some drink at the fountain of knowledge. Others just gargle.
    1. Re:Power efficiency??? by Pieroxy · · Score: 1

      But the more you do in JavaScript, the less attack vectors you have.

  31. Java, anyone? by xded · · Score: 2

    Can somebody please remind me why we moved from Java applets to Javascript applets?

    It can't be just a matter of tight browser-VM integration or GPLiness.

    Why are we coding the whole thing all over again?

    1. Re:Java, anyone? by shutdown+-p+now · · Score: 2

      Java applets took several seconds to load, but more importantly, that was visible to the user (remember those ugly gray rectangles)?

      That, and they have their own sandbox, not particularly well integrated with HTML DOM.

    2. Re:Java, anyone? by Eskarel · · Score: 1

      They were also a fairly huge pain in the ass to code.

      That said, using Javascript for this is a fairly stupid idea.

  32. Re:Can't HTML5-compatible browsers play MP3s nativ by iluvcapra · · Score: 1

    There is this thing called conditional compilation, ya know. Let alone environment-aware code paths.

    --
    Don't blame me, I voted for Baltar.
  33. Re:Wow!! by Tarlus · · Score: 1

    Anything that can phase out the necessity for Flash is welcome news in the web dev community.

    So, yeah. Posting snooty Slashdot criticisms as AC is pretty cool too.

    --
    /* No Comment */
  34. Re:The rise of Javascript. by petsounds · · Score: 2

    It would have been nice if something better had been standardized

    No, the problem is that the "standard" has barely changed since Javascript was introduced many years ago. The base language, ECMAScript, is shared with Actionscript (Flash's coding language). Except JS still looks like Actionscript from ten years ago. This comes down to the intractability of the standards committee to move forward with any large design changes due to various corporate dissenters, as well as between the ECMAScript committee and W3C. I mean, the first update since *1999* was in 2009, and that was a very, very, very watered down update (based on the few things the committee could agree on) intended to show everyone they'd made progress, but seemed more like the Bring Out Your Dead sketch. More or less, the ECMAScript committee is the software version of the UN. Now they're planning for another update, but they've already said they won't be adding classes or the things that would pull it out of the software dark ages, and there's no release date.

    After that internal meltdown, Adobe pulled a Cartman and continued on with Actionscript development. And who can blame them? ECMAScript/Javascript is a disaster. There's many JS apologists out there who think that Javascript is like some kind of totally expressive free jazz ensemble, and that everyone else *just doesn't get it*, man. The real fact is, most of these Javascript developers have only ever worked in Javascript (or PHP...tomato, tomato) and don't see the performance/efficiency gains of moving to a language with modern features. It doesn't help that browsers are putting nitrous and rocket packs on what is effectively a '78 Pinto; it tends to mask the fact that the language is a hurtling fireball of death. Hey, I sympathize with JS developers. They've been working with the same screwdriver for 12 years. You get used to the tool. Actionscript developers went through the same thing with the intro of AS 3.0, when it moved to a strictly-typed environment with many new language features. But you know, Adobe had the cojones to do that and risked pissing off its developers. Unlike the ECMAScript standards committee.

    And so here we are sadly, with a language that has becoming the de facto web language, that hasn't changed much at all in 12 years. A language mostly unsuitable for OOP development. A language that's a pain to debug. A language lacking basic, basic features. It's a '78 Pinto with some racing stripes and a jet engine strapped to the top. But it's totally paid off!

  35. Re:Wow!! by the+linux+geek · · Score: 1

    It's always been enough to "do" things traditionally done with C/C++. The problem is that it does it one or two orders of magnitude slower.

  36. Re:Wow!! by Lunix+Nutcase · · Score: 1

    Great. But do we really need a story for each and every piece of software written? Secondly, having used this decoder it is no where near as performant as a traditional decoder written in C and assembly optimization. It stutters quite badly.

  37. Re:Wow!! by Lunix+Nutcase · · Score: 1

    Except that this does absolutely jack and shit to phase out flash for almost anyone. How many people are saying to themselves "Well I'd only get rid of flash but I need a flash-based mp3 decoder!!". Anyone who is going to want to play mp3s on their computer are ether going to use a media player installed on the system rather than using a browser player to play mp3 files off of their hard drive.

  38. bettter than I tought by JonySuede · · Score: 3, Interesting

    I was worried about the cpu consumption of this and it only took between 7 and 13 % of one q6600 core on firefox 7.0a1 nightly

    --
    Jehovah be praised, Oracle was not selected
    1. Re:bettter than I tought by adolf · · Score: 1

      I was worried about the cpu consumption of this and it only took between 7 and 13 % of one q6600 core on firefox 7.0a1 nightly

      Wow. It only takes between 7 and 13 percent of a 2.4GHz Core 2 core with a couple of megabytes of cache to do what I was doing on a not-so-special 486 (15 years ago)?

      If this is the future of computing, then I'm turning Amish.

    2. Re:bettter than I tought by UBfusion · · Score: 1

      That's too much.. on my Q6700 @ 2.66 and FF4.01 it was less than 5%. Something must be wrong with FF7

    3. Re:bettter than I tought by JonySuede · · Score: 1

      or somethings in another tabs did something while I was pseudo-benching.

      --
      Jehovah be praised, Oracle was not selected
    4. Re:bettter than I tought by owlstead · · Score: 1

      Turn Amish then. With a quad core processor 7-13% isn't a lot. I admit, even with Java this would normally take 1%. But honestly, who cares? As long as it trash my HDD and doesn't consume oodles of power, most users would be quite alright with that. Hell, most users even put up with trash like McAfee.

      Besides that, the 486 was *just* able to play MP3 if I'm not mistaken. And you had to spring for an expensive 16 bit sound card, or you might as well skip it altogether. Of course, C/C++ decoders and sound capabilities have matured quite a lot within that time.

  39. Cool hack by McBeer · · Score: 2

    It's cool that somebody got this working. That said, looking at this sort of things further enforces my belief that we're all barking up the wrong tree by going with JS+html as client side development environment of the future. Compared to a Silverlight solution, the JS player is 3.5 times larger (535kb vs 154kb), uses about 3.6 times as much CPU power (25% vs 7%), and has to have significant modifications to work in multiple browsers. Not really progress.

    --
    Hikery.net - The best hiking site ever. Made by yours truly.
    1. Re:Cool hack by nschubach · · Score: 2

      You forgot to include the 20MB+ of Silverlight libraries that need to be installed on the PC to make that 154kb file work.

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
    2. Re:Cool hack by Anonymous Coward · · Score: 1

      (lead developer here) I agree with you only one point: currently, it's not a practical solution: it's a proof-of-concept.

      However, as history as shown: 1) jsmad will be optimized 2) browsers will continue optimizing their JS engines 3) JavaScript the language will continue to improve, and maybe provide an integer type? That would make jsmad almost as performant as libmad, if not better (=I can foresee JIT optimizations trump AOT optimizations for this usecase).

      It's "progress" in the sense that it pushes the boundaries of what has been done with JavaScript. Your point about plug-in (and, let's admit it, Silverlight propaganda) is completely off: you can decode MP3s with 0% CPU if you have an external chipset that does exactly that... but who would go the trouble of buying+installing the chipset? No one. This is exactly the same for coding pretty much anything with JS: I'm not particularly a fan of the language (I pretty much hate it actually) - but it's the largest thing EVER deployed ANYWHERE. Soon, FF4 will be the new IE6 - and jsmad will run on that, acceptably fast (hardware continues to get better).

      You need to see the big picture and forget your commercial interests.

    3. Re:Cool hack by Anonymous Coward · · Score: 1

      And a Windows machine. After all this is Microsoft's solution for open web :-)

    4. Re:Cool hack by rabtech · · Score: 1

      It's cool that somebody got this working. That said, looking at this sort of things further enforces my belief that we're all barking up the wrong tree by going with JS+html as client side development environment of the future. Compared to a Silverlight solution, the JS player is 3.5 times larger (535kb vs 154kb), uses about 3.6 times as much CPU power (25% vs 7%), and has to have significant modifications to work in multiple browsers. Not really progress.

      I certainly agree and if I were going to deploy a website or do a project for a customer today, I wouldn't even think about using this kind of stuff. However Moore's law combined with the compsci work on making dynamic languages fast will eventually make JS a valid contender. I'm glad to see people out there pushing the boundaries of what can be done in JS, which will certainly drive further performance improvements and perhaps even future extensions to the language.

      It's a bit funny... designing a UI in HTML+CSS+JS is definitely a huge step backwards compared to almost any GUI library, but it turns out that the only way to get a bunch of humans with competing priorities to agree on a cross-platform widely supported project like this is to start really small and simple, solve a huge need, then ramp the project up as it reaches wide deployment. When you think about it, getting various vendors, open source projects, working committees, standards organizations, developers (paid, hobbyist, etc), and end-users to all agree to adopt one single piece of technology is almost impossible by definition (image trying to get everyone to agree on CSS+JS+AJAX in HTML v2). The fact that HTML+CSS+JS is so widely adopted is an amazing feat of technological and social engineering. I can only think of a handful of human endeavors that have ever come close to this eg: cell phones, electricity, fire, the wheel, etc.

      It also amuses me that one private company's embrace-extend (Microsoft with the first AJAX implementation to make a more Outlook-style interface for Exchange web on IE) led open-source groups to turn embrace-extend around and create a new web standard. I think that must say something about accidental innovation being necessary for any standard to do something revolutionary, as well as the pent-up demand for a true cross-platform UI standard with backwards-compatibility and built-in abilities to run across the network.

      --
      Natural != (nontoxic || beneficial)
    5. Re:Cool hack by HalWasRight · · Score: 1
      I agree that this is a cool hack. But I just don't understand the fetish for JS as a language for writing software beyond the fact that it is integrated inside the browser. Ok, sure, look at the cool hacks (I liked the Google Guitar). But please please please, people, remember that statically typed languages greatly reduce the incidence of bugs. JS is a fine tool for integrating pieces of interactive code in browsers, and yes people have written some amazing large systems with it too. But just because you CAN doesn't mean you SHOULD. Frankly I value having a compiler tell me about bugs BEFORE someone manages to run a test case that breaks my code.

      This is a cool hack, not a justification of using JS for being a primary development and deployment language for applications.

      --
      "This mission is too important to allow you to jeopardize it." -- HAL
    6. Re:Cool hack by mad.frog · · Score: 1

      > Compared to a Silverlight solution, the JS player is 3.5 times larger (535kb vs 154kb), uses about 3.6 times as
      > much CPU power (25% vs 7%), and has to have significant modifications to work in multiple browsers. Not really progress. ...compared to a Flash solution, the JS player is >100 times larger (a Flash version could be under, say, 4k, including UI, since the MP3 decoder is built in).

    7. Re:Cool hack by FranTaylor · · Score: 1

      ". Compared to a Silverlight solution, the JS player is 3.5 times larger (535kb vs 154kb), uses about 3.6 times as much CPU power (25% vs 7%), and has to have significant modifications to work in multiple browsers."

      Can you please tell me what modifications are necessary to use the silverlight plugin on my Solaris SPARC system? You say it works in multiple browsers so I would like to test your assertion.

    8. Re:Cool hack by FranTaylor · · Score: 1

      25% vs 7%

      Yes because lord only knows that you can't get by without that extra 17% of CPU

      Personally I key in all my text from the front panel in ASCII because I don't like the overhead from the keyboard driver.

    9. Re:Cool hack by MrSteveSD · · Score: 1

      Obviously it's very important that browsers be able to run code, and increasingly large web applications are being developed. Given that is the case, it has to be asked whether a scripting language like Javascript is the right tool for the job. Clearly the interpreters have been improved greatly, but even so, speed is a real issue. It's not the only issue though. Writing a full application (like Microsoft Word for example) with Javascript would be a pain to say the least. Static typing is important for developing large applications. It helps you catch bugs early and greatly aids analysis of the code/auto-completion etc.

      One way around this issue has been to develop plugins, e.g. Unity3D for games, but many users are put-off by the need to install a plugin and if everyone embraced this approach, we would be overwhelmed by endless plugins. Google's Native Code project seems quite promising. Perhaps the future lies there.

    10. Re:Cool hack by McBeer · · Score: 1

      The big picture is we're all getting on board with a language that, like you, most everybody hates and hates for a good reason :p My post wasn't intended to be Silverlight propaganda (though I do like Silverlight). I'm sure Java or Flash would have also beat the pants off a JS implementation. I just happened to find a Silverlight player to test quickly.

      --
      Hikery.net - The best hiking site ever. Made by yours truly.
    11. Re:Cool hack by McBeer · · Score: 1

      ". Compared to a Silverlight solution, the JS player is 3.5 times larger (535kb vs 154kb), uses about 3.6 times as much CPU power (25% vs 7%), and has to have significant modifications to work in multiple browsers."

      Can you please tell me what modifications are necessary to use the silverlight plugin on my Solaris SPARC system? You say it works in multiple browsers so I would like to test your assertion.

      No modification needed, just install it: http://www.mono-project.com/Moonlight. If Silverlight isn't your thing, Flash or Java would also be better solutions. The point wasn't that Silverlight is great; it was that JS is terrible.

      --
      Hikery.net - The best hiking site ever. Made by yours truly.
    12. Re:Cool hack by McBeer · · Score: 1

      In this case, maybe not a big deal. Say, however, you'd like to take an app that would normally consume 30% of your CPU and convert it to JS: Then it would require 105% of your CPU and you'll be screwed. (It's actually worse than that: I have a dual core processor, so a JS app couldn't use more than 50%, An app that would normally consume 15% would not work in JS)

      I'm the first to admit that premature optimization is the root of all evil, Javascript has severe performance and functionality limitations. The language itself is arguably worse than languages that don't. This isn't like c#/java vs C. Javascript isn't easier or faster to develop in for most situations.

      --
      Hikery.net - The best hiking site ever. Made by yours truly.
    13. Re:Cool hack by UBfusion · · Score: 1

      Where did you get that 25% CPU? On my Q6700 @ 2.66 and FF4.01 it was less than 5%.

    14. Re:Cool hack by Jack+Greenbaum · · Score: 1

      Which developer do you think is going to be more productive? The dude having to know 3-4 different technologies, or the dude who just needs to know JS?

      The developer that uses the right tool for the job will be more productive.

      That means using a language with static type checking and a productive debug environment. Learning a new system infrastructure takes time, but only finding out about easily preventable failures during testing instead of compile time costs more.

  40. Re:The rise of javascript based malware by JonySuede · · Score: 1

    go away host file troll

    --
    Jehovah be praised, Oracle was not selected
  41. Fail by yourlord · · Score: 2

    It's useless on my work laptop running FF4.

    The sound is so choppy it's essentially noise, and it causes my FF4 memory footprint to triple. This is on a 1.6GHz Pentium M with 1GB of RAM..

    Just another example of our wonderful ability to come up with ways to waste immense amounts of computational power. It's completely ludicrous to write a decoder in such a high level interpreted language.. I was playing mp3's on p200's, and whoever did this managed to waste so much time executing bloat that a 1.6GHz cpu can't plow through it in real time. This thing would probably take 2 weeks to play the 1st minute of a song on a p200.

    Yep, we can write an mp3 decoder in javascript. But, should that really be our goal?

  42. Re:Just because you can, doesn't mean you should. by Pope · · Score: 1

    AutoCad runs on OS X!

    --
    It doesn't mean much now, it's built for the future.
  43. How incredible by loufoque · · Score: 1

    Bleeding edge Javascript "compilers" are now fast enough to run some elementary code.

    Great, how about they move to real programming languages and compilers instead?
    I don't want to need a supercomputer to run Javascript code that would run as fine with a proper programming language on a computer from 1980.

    1. Re:How incredible by Anonymous Coward · · Score: 1

      You had a computer in 1980 that could play mp3s?

  44. Re:Can't HTML5-compatible browsers play MP3s nativ by westlake · · Score: 1

    Modern OSs provide such an API for playing audio and video, and some (ie. Mac OS and Windows) even provide licensed proprietary codecs... not to mention that OS-provided codecs often work with things like video drivers to provide hardware acceleration that is transparent to applications.

    Canonical licenses both MP3 audio and H.264 video for its OEM partners: which may help to explain why the Ubuntu Linux PC has some presence and visibility on retail shelves.

    Licensed Companies, AVC/H.264 Licensees

  45. Re:The rise of Javascript. by nschubach · · Score: 1

    I would almost go out on a limb and say it does do whatever paradigm they are looking for if they actually tried... but I don't consider myself an expert so I won't go that far. Sure, things like multiprocessing aren't there unless you consider that a feature of individual browser/sandboxes. The only limitations I can think of right now involve said sandboxes, but most core programming strategies that I'm aware of can be done in JavaScript. Some of the syntactical sugar and performance may not be there, but that doesn't mean it can't do it.

    Also, I'm not sure that's what he meant.

    --
    Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
  46. Re:Wow!! by Lunix+Nutcase · · Score: 1

    1. combine this with Amazon Cloud Drive or Google Music and no, you won't need a system player or local MP3s.

    Or you could use the already present music player in Google Music that will probably be far better performing than this Javascript turd that stutters to high hell.

    2. MP3 playback requirement is prevalent all over the web, though thankfully it's becoming less common.

    But how many of them are actually using a flash mp3 player over an embedded player using the system codecs? Seriously, almost no one is sticking to flash for mp3 playback so this will do fuck all to eliminate the flash plugin.

  47. Re:The rise of Javascript. by dgatwood · · Score: 2

    Maybe, but that doesn't mean the GP is wrong. The design of JavaScript borders on absurdity. It's a terrible language.

    • The closest thing it has to actual classes feels like a crudely bolted on hack (like Perl, but with even less syntax support).
    • It uses the same symbol for addition and string concatenation, leading to the necessity of ugly hacks like parseInt() that could just as easily be done transparently if the two (conceptually dissimilar) operations had separate symbols.
    • Most of the commonly built-in JavaScript APIs abuse developers by forcing them to use callbacks because JavaScript has no notion of blocking calls and doing work in other threads at the same time.
    • Worse, most JS APIs (e.g. XHR) don't provide any extra parameters for passing context data through them to your callback. This forces you to do such awful hacks as hiding program data in the DOM tree and building generated helper functions on the fly for every freaking call. Such design makes the use of those functions very, very cumbersome, to say the least.

    And so on.

    As someone who programs regularly in half a dozen languages and knows way more than that, in my opinion, JavaScript is the absolute worst of the non-esoteric modern scripting languages. I would much rather code in Perl, and I've grown to really despise Perl over the years, so that's saying something.

    Heck, I'd just about pick BF or whitespace over JS. That said, as an output target for LLVM, I'm okay with it.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  48. Re:Can't HTML5-compatible browsers play MP3s nativ by Lunix+Nutcase · · Score: 1

    That subset of users you mention encompass less than 1% of these browser users. Windows, OS X and iOS, Android, Windows Phone 7, even most major Linux distros all come with either build in software decoders or in the case of portable devices come with either software decoders or built-in ASICs for decoding. You would have to be using some obscure Linux distro or willfully choose to not install the codecs needed to make this possible. Such a group of people are statistically irrelevant.

  49. What Output API Does it Use? by jubei · · Score: 1

    Normal MP3 decoders result in some uncompressed samples that can be sent to the sound hardware through an API provided by the OS?

    What API is the Javascript using to output the sound?

    I know HTML 5 has a canvas tag that can be used to draw on a surface. Is there something analogous provided for sound?

    1. Re:What Output API Does it Use? by robmv · · Score: 1

      I think they are using Mozill Audio Data API and that must be the reason it only work currently with Firefox, until the API advance from experimental to something more standard

  50. Re:Wow!! by unrtst · · Score: 1

    Um... pandora isn't exactly unpopular, and uses flash to play music to many many people.

    IMHO, the roadblock to moving away from flash isn't that local media players were hard to work with or something like that... it's because pandora can lock down the stream more using flash. If it were javascript delivered to the client to play the stream, it'd make it easier to hack, and come at a performance hit compared to flash, and would lack all the other goodies flash gives them.

    For any service were I can get access to the mp3's (cloud drive included), I'd much rather use my local media player and have it support that as a data provider.

    I agree with where you ended up ("Except that this does absolutely jack and shit to phase out flash for almost anyone"), but not with how you arrived at that conclusion. There are loads of good uses for a web based media player (or media player controller), but this is unlikely to have a substantial impact on any of those for many other reasons.

  51. Re:Can't HTML5-compatible browsers play MP3s nativ by BitZtream · · Score: 1

    Yea, because the browser doesn't already do that in hundreds of places in order to perform as fast as possible.

    If you're using a firefox backed by Cairo, you're most certainly using OS specific extensions or using an OS with no features worth talking too.

    The browser is the shim between the presentation layer of the native OS and the web. Its very job is to provide the native hooks in uniform way so that web pages are rendered.

    You have to be tightly coupled with the OSes native features if you want your web browser to work. How do you intend to draw to the screen? You realize that Firefox uses OS specific APIs for doing its IO right? Its not like it uses kpoll for sockets on Windows or OSX. The browsers job is to provide a common interface between the OS and the web so that the web can be experienced on the OS.

    Your app won't be doing any graphics or sound without being tightly coupled to the OS, even if you're using some API like OGL and OAL, they are still tightly coupled with the OS, you're just ignoring that fact for the sake of your point of view.

    --
    Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
  52. Awesome by GrumpySteen · · Score: 1

    Now javascript based popup ads can run an MP3 of a woman loudly faking an orgasm or a guy screaming "PUNCH THE MONKEY". Maybe we'll even get the fake cell phone ringing sounds like radio commercials just to really make life wonderful.

    1. Re:Awesome by RobbieThe1st · · Score: 1

      Same with flash... But I don't see it thanks to NoScript blocking Flash and Media tags. I'm sure whatever output API is used can be similarly controlled, solving the problem.

  53. Re:Can't HTML5-compatible browsers play MP3s nativ by SanityInAnarchy · · Score: 1

    More frustrating than that, to me, is that while I would love to find a solution that works for those less-than-1% group, I don't think I own any machines that don't come with hardware decoders for all of these things.

    Still, it is nice to have another option. This works surprisingly well -- Firefox uses ~40% of an 800 mhz CPU. Chrome used ~20%, but didn't actually play, so it's not quite the same. What we need now is better detection/negotiation, so I can use native HTML5 audio on sane browsers and fall back to hacks like this when they aren't supported.

    --
    Don't thank God, thank a doctor!
  54. Re:Wow!! by JavaBear · · Score: 1

    I can only assume you are either full of it, or running it on a very old system with an outdated browser.

    Considering for comparison that this decoder barely registers more than a few % above idle on my CPU monitor apart an occasional singe spike on one of the cores, and definitely does not stutter. This is on my three year old PC.

  55. Re:Simple question to you, 7-digit NEW user (right by Vegemeister · · Score: 1

    I don't know what his objection to hosts files is, but mine is this:

    O(n)

  56. More than slightly different. by SanityInAnarchy · · Score: 1

    What's cool about this is that at least for audio, it's actually efficient enough that we can stop caring about whether browsers support a given codec. Maybe use <audio> when supported, fall back to pure JS when it isn't.

    All that without relying on any plugins, which means the entire process can sit inside the same sandbox browsers have been building for years.

    What we had before this required users to download and install software, and give it full rights to the machine, in order to play back media. It's similar superficially, I suppose, but it has massive practical differences.

    --
    Don't thank God, thank a doctor!
  57. Fallback for . by SanityInAnarchy · · Score: 1

    Try <audio>, if they don't have MP3 support, fall back to this.

    Before this, the fallback would've been Flash, which sucks.

    --
    Don't thank God, thank a doctor!
  58. Wow. by Tolkien · · Score: 1

    I remember my 486 DX4 100MHz only barely being able to play MP3s. My entire computer would freeze up for the duration of the song though it played flawlessly. I'm not 30 yet and I feel old. Damnit.

  59. Re:Learn to SPELL & WRITE, properly, illiterat by Tolkien · · Score: 1

    If you're going to bother signing your posts AC "apk" why don't you just create an account? Honestly, it baffles me.

  60. Re:The rise of Javascript. by DoomHamster · · Score: 1

    It uses the same symbol for addition and string concatenation, leading to the necessity of ugly hacks like parseInt() that could just as easily be done transparently if the two (conceptually dissimilar) operations had separate symbols.

    IMHO, using the same symbol for string concatenation and addition is actually a fairly logical choice that many modern languages implement. The problem is that it allows you to concatenate a string and a number by just converting the number to a string. So 'blah' + 11 gives you 'blah11'. The problem, of course is that if you have input that you expect to be a number but is actually a string representation of a number you may not get what you are expecting ('1' + 1 = '11').

    It forces you to pay attention to your data. I hate that. :)

  61. Re:The rise of Javascript. by DoomHamster · · Score: 1

    Oh...I forgot to add that I agree with the rest of your post. JavaScript just feels annoyingly hacked together. Working with it is getting better all the time, though, and if we continue to see it used for so many things that were not envisioned when it was created, I expect we will see it modernized...at least I hope so.

  62. Re:Great... if it worked. by Anaerin · · Score: 1

    Oh, that's easy. You're using IE8. Try getting a proper browser.

  63. Re:Repost. by Wrath0fb0b · · Score: 1

    Languages are not slow. Algorithms are slow. Execution environments are slow. There is nothing fundamental about JavaScript that makes it slow. Until recently, browsers executed it inefficiently and with few optimizations.

    Languages impose constraints that require the execution environment to do more work for a given algorithm written in one language rather than another. Consider the following algorithm in C:


    const int N = 1000000;
    int someNumbers[N] = GetArrayOfIntsWithLength(N);
    int sum = 0;
    for(int i = 0; i \LessThan N; ++i)
            sum += i;

    If you implement this in Java instead of C, it turns out that the call to operator[] must, according to the language constraints, check to see if the value is within the range [0,size) for that array. The JVM may not skip that check and still be compliant Java. So in the end, the algorithm cannot really run as fast on Java because the are simply more operations to be done (to wit, checking that (i > 0 && i \LessThan N) must be done once per iteration.

    Now that's not much a slowdown but let's suppose we go a further level up and write it in python (trick question, python already has a 'sum' builtin, also that builtin effectively uses the C version) then it becomes even slower. Each time through the loop, the interpreter must check the types on both sides of the '+=' to make sure they are still ints. Why? Because I can override the int::operator-left-addition to return a string. Now we look up int::operator-left-addition(int) and call that function, passing the two references. That function 'unboxes' the ints (copies them from the heap onto the stack), performs the addition and then creates a new int object on the heap to store the result. Why a new object, because ints in Python are absolutely immutable -- in python, A += B is actually semantic sugar for A = A + B. After we are done with this reference, the old 'sum' object has its reference count decremented and is garbage collected, releasing the memory it held on the heap.

    So by the time you are done adding up your numbers in Python, the interpreter has done a massive amount of work that the C version didn't, through no fault of the algorithm and only because of language design choices. Optimizing around those choices is a lot harder than writing a language optimizing for speed in the first instance. On the other hand, I love Python and use it extensively where I think it's appropriate, which is for many non-performance intensive tasks.

  64. Great, but has some audio artifacts by Anaerin · · Score: 2

    Listen to something with an opening speech over silence, like "Eve of the War" (Track 1, Disc 1) from "Jeff Wayne's Musical Version of War of the Worlds", or the bass-heavy opening to "Angel" from Massive Attack's "Mezzanine". You can hear some odd ringing/distortion type effects. Chances are this can be corrected, but I also noticed in the code a fair amount of loop unrolling and table flattening to increase speed. A nice touch, but it does tend to bloat the download a little. Admittedly, it's only text (Which, of course, is highly compressible), but still.

  65. Re:The rise of Javascript. by julesh · · Score: 2

    The closest thing it has to actual classes feels like a crudely bolted on hack (like Perl, but with even less syntax support).

    In some senses, this is a good thing. The fact that you don't need specific syntax to declare a new kind of object is quite liberating. I can define new object kinds by manipulating old ones, or by the more traditional ruote of declaring a constructor function. You're quite able to set up functions that produce new object kinds when you call them. All this makes the environment very flexible. Yes, there is the down side that certain simple tasks become a little harder, and a certain amount of boilerplate code becomes necessary to achieve them. You can't have everything,.

    It uses the same symbol for addition and string concatenation, leading to the necessity of ugly hacks like parseInt() that could just as easily be done transparently if the two (conceptually dissimilar) operations had separate symbols.

    Turning a string into a number is an information-losing transformation. In my book, such transformations should never occur automatically, so parseInt() is IMO better than automatic conversion.

    Most of the commonly built-in JavaScript APIs abuse developers by forcing them to use callbacks because JavaScript has no notion of blocking calls and doing work in other threads at the same time.

    This is an issue with the design of the web browser object model, not javascript itself. To be frank, allowing multithreaded web pages would be a nightmare for browser developers, and is not something I would have expected in any reasonable timeframe. The fact that it is supported (sort-of) by HTML5 came as quite a shock to me.

    Worse, most JS APIs (e.g. XHR) don't provide any extra parameters for passing context data through them to your callback. This forces you to do such awful hacks as hiding program data in the DOM tree and building generated helper functions on the fly for every freaking call. Such design makes the use of those functions very, very cumbersome, to say the least.

    This is only an issue because you're doing it wrong. JS supports closures, which means you do not need a parameter to pass context data to your callback. You do it like this:

    function setCallbacks(object, context)
    {
        object.callback = function () { // code that uses context
        };
    }

    Or like this:

    function bindMethod (fn, object)
    {
            var boundFn = fn;
            var boundObject = object;
            var outerargs = arguments;
            return function () {
                    var newargs = Array (outerargs.length - 2 + arguments.length);
                    for (var i = 0; i < outerargs.length - 2; i ++)
                            newargs[i] = outerargs[i + 2];
                    for (var i = 0; i < arguments.length; i ++)
                            newargs[i + outerargs.length - 2] = arguments[i];

                    return boundFn.apply (object, newargs);
            }
    }

    object.callback = bindMethod(context.method, context, "additional parameters go here");

    This turns the object callback into an invocation like context.method(context, "additional parameters go here", [parameters that would normally be passed to the callback).

  66. Re:The rise of Javascript. by zzyzyx · · Score: 1

    JavaScript is actually a very fine language. It is a fully object language (unlike Java), it allows class prototypes (like Ruby), it has first-class functions, closures, exceptions, etc ... many features you'd find in modern dynamic weakly typed languages.

    The actual issues with JavaScript are the lack of tools (modern IDE with completion, debugger, testing) and the browser environment you usually have to work with. But you can't really blame the language itself for that.

  67. Re:The rise of Javascript. by Timmmm · · Score: 4, Informative

    No, there are many things wrong with Javascript. Just a sample:

    1. The == operator. What. The. Hell. (Yes I know about ===; that's beside the point).
    2. No true arrays. They are actually maps/associative arrays. (And that's the only thing you get.)
    3. No typing. E.g. you can't have a 16 bit int, or an array of bytes.
    4. No real integers. Bitwise operations are done by converting from doubles to int, and then back again.
    5. Way too much implicit conversion (the stupid '1'+'1' -> '11', but '1'-'1' -> 0 thing).
    6. No data hiding of any kind. Everything is public (unless you use crazy hacks). You can't even be sure third party code hasn't modified your classes.
    7. Implicit semicolon. It's just a bad error-prone idea. (And I have *no* idea why Go made the same mistake.)
    8. No support for proper modules. You basically have to put everything in one file, which wouldn't be so bad if the IDEs didn't all suck.
    9. It's basically impossible to reason about performance, partly because of the new-fangled tracing/JIT engines, and partly because the spec doesn' make any
    guarantees about complexity.

    I'm not saying it doesn't have nice features, it just has a lot of ugly "let's make this easy for noobs" mis-features that actually fuck everything up, which is a shame.

  68. Re:Stupid by thegarbz · · Score: 1

    How about compared to having a client side CODEC library in the browser and just adding a one liner to your HTML code?

    Seriously my first thought was after all this effort to standardise video CODECs in browsers so HTML could natively display video was WTF! Playing music in a webpage was something that worked fine in the early 90s and now suddenly we're talking about Silverlight, or writing a native coder in Javascript?

  69. Re:Wow!! by GNUALMAFUERTE · · Score: 1

    Exactly my thoughts.

    Also, since Chrome supports all browsers, Safari only MP3, Opera and Firefox only ogg, all you need to support all browsers is MP3, and the audio tag.

    That means, the entirety of this functionality is already in the browser, and all you need is 2 file formats, and there's automatic failover with multiple source tags in the audio tag.

    Of course, it's still a nice hack and POC of what can be acomplished in JS, but pretending it has real life uses as the article does is just plain stupid.

    --
    WTF am I doing replying to an AC at 5 A.M on a Friday night?
  70. Re:Wow!! by GNUALMAFUERTE · · Score: 1

    hello? We are in 2011. All browsers support the audio tag. All you need is to dual-encode your files in MP3 and OGG to support Chrome, Firefox, Opera, Safari and Explorer. If you are like me, You'll only encode in ogg, which will work in Chrome, Opera and Firefox. Explorer/Safari represents Mac/Windows, so fuck them.

    --
    WTF am I doing replying to an AC at 5 A.M on a Friday night?
  71. Re:Yes by GNUALMAFUERTE · · Score: 1

    Grooveshark has already been rewritten in HTML5 ages ago. It doesn't work on Android/iPhone because they want to profit from app sales.

    --
    WTF am I doing replying to an AC at 5 A.M on a Friday night?
  72. Re:The rise of Javascript. by Millennium · · Score: 2

    The closest thing it has to actual classes feels like a crudely bolted on hack (like Perl, but with even less syntax support).

    Most of the commonly built-in JavaScript APIs abuse developers by forcing them to use callbacks because JavaScript has no notion of blocking calls and doing work in other threads at the same time.
            Worse, most JS APIs (e.g. XHR) don't provide any extra parameters for passing context data through them to your callback. This forces you to do such awful hacks as hiding program data in the DOM tree and building generated helper functions on the fly for every freaking call. Such design makes the use of those functions very, very cumbersome, to say the least.

    Yep, as I thought: complaining over the lack of pet paradigms and refusing to learn new ones. You in particular also seem to prefer syntactic handholding to dynamism: an odd case since the arguments you make sound like those of someone who favors PHP. Rather than learn prototype-based OO and closures, you prefer more rigid, static techniques.

    It uses the same symbol for addition and string concatenation, leading to the necessity of ugly hacks like parseInt() that could just as easily be done transparently if the two (conceptually dissimilar) operations had separate symbols.

    Here you mostly have a point, though I'm not sure how much benefit changing to a dot really gains.

  73. Big fan of JS by Boxtracod · · Score: 1

    It is good that we can now play MP3 in FF. I remember being stunned when I found FF could only play WAV!

  74. someone please enlighten me by Tooke · · Score: 1

    Why is this paired with the chrome image? It's not about chrome, and chrome isn't even mentioned until the second half of the last sentence. If there isn't a suitable image, the firefox one would make more sense as it's the browser that the decoder actually works in.

    --
    Anybody want a peanut?
    1. Re:someone please enlighten me by caspy7 · · Score: 1

      Mod parent up for truthiness.

  75. Re:The rise of Javascript. by dgatwood · · Score: 1

    Rather than learn prototype-based OO and closures, you prefer more rigid, static techniques.

    Real closures are great. What passes for closures in JavaScript (defining a function by gluing strings together or using global variables to work around the fact that there is no good way to store any arbitrary data in the constructed function so that it will be available when the function calls it) is not.

    Contrast blocks in Objective-C with the disaster that is constructed functions in JavaScript, and there's just no comparison. Don't get me wrong, blocks aren't perfect, either—I wish I could trivially make static (permanent function-local) variables into block variables—but it's a lot better than the clumsy hack that JavaScript programmers are forced to use to approximate a proper closure.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  76. Re:The rise of Javascript. by dgatwood · · Score: 1

    var outerargs = arguments;
    return function () {
    var newargs = Array (outerargs.length - 2 + arguments.length);

    Does this actually work? Every time I've tried to access a variable in the enclosing context, I've had problems with it being undefined. That said, it has been a few years since I tried it. Maybe the browsers were just buggy as all **** back then.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  77. Re:The rise of Javascript. by dgatwood · · Score: 1

    I retract that comment. I've just been informed that something that I thought didn't work actually does. Not sure why it wasn't working for me in certain cases, but since I can't actually find any of my code where closures didn't make local variables available to the enclosing function, I'm going to assume that either I was doing something else wrong or it was a browser bug. *shrugs*

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  78. Re:The rise of Javascript. by Lennie · · Score: 1

    No the language hasn't changed much. People just didn't know what was possible.

    Most of the programmers thought it was just a simple language with a lot of bad parts.

    Turns out, it is actually a very flexible and effective language and you can avoid the bad parts.

    Read a book like "JavaScript the good parts" or watch a video [0][1] Douglas Crockford in it, he wrote that book and the JSON-specification.

    [0] http://developer.yahoo.com/yui/theater/
    [1] http://www.livestream.com/etsy/video?clipId=pla_1463e546-47ed-4a93-b59a-bd52b236e8b8

    --
    New things are always on the horizon
  79. Re:The rise of Javascript. by Lennie · · Score: 1

    I think Microsoft, Adobe and other vendors are really busy trying to change that.

    --
    New things are always on the horizon
  80. Re:The rise of Javascript. by Lennie · · Score: 1

    I wouldn't call the solutions to 6. crazy hacks, it is just closures.

    --
    New things are always on the horizon
  81. Re:LulzSecuritys' website example? by DaVince21 · · Score: 1

    JS != Java, so...

    --
    I am not devoid of humor.
  82. Re:The rise of Javascript. by Millennium · · Score: 1

    it sounds more to me like you were talking about the create_function() function in PHP, which actually does work pretty much like you described. PHP recently got closures (with some warts, like having to explicitly specify which variables are made available to the function being specified), but for a long time create_function() was the closest thing it had.

  83. Re:The rise of Javascript. by nschubach · · Score: 1

    I'm not sure what you mean by #8.

    JavaScript is run in order of inclusion. If I create two JS files and in the first I type:
    function test() {
          this.value = 'hello';
    }

    In the second I type:
    var tester = new test();
    alert(tester.value);

    It will alert 'hello.' I do not have to have that code in the same file.

    --
    Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
  84. Re:Just because you can, doesn't mean you should. by Alex+Belits · · Score: 1

    Only a tiny fraction of AutoCAD does, their most basic configuration. All those packages that AutoCAD is actually bought for, are Windows-only.

    --
    Contrary to the popular belief, there indeed is no God.