Go to bottom

Javascript as a "serious" development language?

category: general [glöplog]
Just wondering out loud a bit here, after seeing palm's new pre phone. It looks really interesting as a phone, so I looked into the sdk a little, and it seems that the development is all done in javascript / html.

Now, that sounds utterly shit at first.. html + javascript for complex apps, running on a slow mobile phone processor? urgh. But it seems to work well, people working with it seem to think it's good, and they're providing APIs to access phone hardware and services, so presumably it'll handle accelerated drawing, opengl perhaps, and other stuff.

So how would javascript work out for something like this? Without the horrible browser drawing methods holding it back, would javascript actually be a pretty good and fast choice for mobile apps?
added on the 2009-02-27 14:59:28 by psonice psonice
I like the simplicity.
added on the 2009-02-27 15:01:36 by Preacher Preacher
Yeah, it's not to bad.
added on the 2009-02-27 15:02:08 by mrdoob mrdoob
Well, I've basically been doing that for 3+ years now. So yes, it works. It works even better when this an actual design choice of the device manufacter and there's well thought APIs for device integration. JavaScript itself ain't slow. The bottle neck is usually the rendering and DOM manipulations, and network on devices.
added on the 2009-02-27 15:27:22 by p01 p01
make a demo with it :-)
added on the 2009-02-27 15:31:28 by aftu aftu
JavaScript actually made a nice comeback with AJAX/Web2.0, considering the limited usefulness ten or so years ago (basically input validation and "DHTML"). But dev-tools seem still to be a little sketchy or so I've heard.
added on the 2009-02-27 15:45:02 by tomaes tomaes
thanks for the answers :)

So would javascript be anywhere near the speed of equivalent c++ or whatever if it was accessing the same APIs? (assuming the platform is well optimised for it, and you're doing some "average code" rather than some special case, which somebody is sure to point out here ;)
added on the 2009-02-27 17:22:06 by psonice psonice
Naa, it's still significantly behind the speed of equivalent c++ but it's fast enough. More and more JavaScript engines developers are moving towards doing JIT and native code generation, both for desktop and device usage.
added on the 2009-02-27 17:33:16 by p01 p01
I definitely agree with p01 on that one : rendering and DOM manipulations are most likely to kill you. Now, it also depends on the browser you're running it on. With some really big differences in some cases.

Some months ago, I was working on an Intellivision emulator written in 100% javascript and using DIVs and SPANs for rendering (i.e. no canvas) :


(hit Run to give it a try)

For what it's worth, here's a quick and dirty benchmark on different browsers :

IE7 : 18 fps, d'oh...
FireFox 3 : 57 fps, eh?
Google Chrome : 78 fps, woohoo!
added on the 2009-02-27 18:17:04 by knox knox
On Opera I get 90'ish fps.
added on the 2009-02-27 18:19:46 by xernobyl xernobyl
True. Opera is pretty fast as well. On the title screen, I go up to about 135 fps with Chrome and 125 fps with Opera.
added on the 2009-02-27 18:25:06 by knox knox
With FF 3 I get 98-100 FPS.
added on the 2009-02-27 18:26:45 by xTr1m xTr1m
firefox 3.1 beta2 - 170fps \o/
added on the 2009-02-27 18:39:36 by psykon psykon
oh, but it crashes on reset ;)
added on the 2009-02-27 18:40:33 by psykon psykon
IE7: 55
Opera 9.62: 173
Opera 10alpha: 173 Portable version from Opera@USB site
FF3(Feb 09): 147
Chrome: 281 (Latest SRWare Iron - http://www.srware.net/en/software_srware_iron.php)
added on the 2009-02-27 19:07:22 by Intrinsic Intrinsic
Opera 10alpha: 173 Portable version from Opera@USB site

btw, it looks like Opera 10 will get a new JavaScript engine which is not yet in the current public alpha version.
Details (including some background tech infos) here: http://my.opera.com/core/blog/2009/02/04/carakan
added on the 2009-02-27 19:24:58 by jua jua
javascript is the new basic
added on the 2009-02-27 19:25:55 by texel texel
added on the 2009-02-27 19:44:10 by xyz xyz
From what i read the other day Carakan will prolly not debut until Opera 11, maybe it'll sneak into 10.5 though. But Carakan is incredibly fast for sure, much faster than anything else available or in development atm.
added on the 2009-02-27 19:45:24 by Intrinsic Intrinsic
Is is me or that benchmark game just plain awesome?
added on the 2009-02-27 19:49:03 by LiraNuna LiraNuna
I wouldn't even be surprised if we'll all be using a JavaScript OS 5-10 years from now. (I wish that would be a joke, but it probably isn't).

Technically speaking, I'd rather like to see .NET or JVM succeed since JS is/was meant only for "additional" glue code, validating forms etc. JS is not type-safe, static code analysis is kind of hard with dynamic typing..I wouldn't wanna code anything larger than a few thousand lines of codes in that kind of language.

IMHO, this whole DHTML/JavaScript craze is totally insane and a waste of energy/resources. At least the heavy lifting should be left to "real" languages (like good ole C/C++..)

Maybe there should be a MIPS/ARM like VM in every OS (or browser) that translates the opcodes to the actual native opcodes. You could still build a JS frontend for that, or a C frontend if you wanted to. Why focus only on JS ? With the proper browser plugins you could easily achieve a performance similar to classic native code compilers (or even better, because the VM could analyze/optimize the code at runtime).

added on the 2009-02-27 20:04:19 by xyz xyz
what p01 said, and what p01 said.

flash actionscript is actually ecmascript, and it's pretty fast, because it uses flash player api instead of rendering stuff possible with js, also, it uses jit compiler (which was made opensource and released by adobe to the tamarin project). so the language itself is not bad at all. if js is used properly as a native development platform for some device like cell phone, i guess it's good enough to do some impressive stuff with it. just take a look at webapps for iphone.
added on the 2009-02-27 20:18:39 by unic0rn unic0rn
JS isn't too bad. But it has a few problems:

- many people think it's a normal OO language and try to use it as that, while it really is a Prototype-based language

- It has some really bad design decisions, so much that I consider it broken by design, for example
Code: 0 == 0 is true 0 == "0" is true 0 == "" is true 1 == [1] is true 0 == [0] is true 0 == [] is true, but [] == [] is false [0] == [0] is false

BTW: most of the time you want to use ===, this variant doesn't try to convert types (0 === 0 true, but 0 === "0" is false)

Oh, and always use "var", never omit it or you will have nasty side effects
added on the 2009-02-27 20:19:33 by Joghurt Joghurt
Yes One time i Make javascrip in my browser it goe Like OK YOU HAVE NO JAVASCRIPT INSTALL Please continue ok??
Make Fuck To You M*****!!! !
knox: nice little emulator there :D Got 208fps in safari 4 beta, on 2,8ghz core2.

Seems javascript could be good for mobile use after all then, as it presumably won't be bogged down by the rendering stuff if they've designed it well. Interesting, I hope palm gets some success with it, I always liked their stuff in the past but they really fucked up with their OS for the last few years. I'll write some stuff for it if they do well.
added on the 2009-02-28 00:45:21 by psonice psonice


Go to top