Why JavaScript On Mobile Is Slow
An anonymous reader writes "Drew Crawford has a good write up of the current state of JavaScript in mobile development, and why the lack of explicit memory handling (and a design philosophy that ignores memory issues) leads to massive garbage collection overhead, which prevents HTML5/JS from being deployed for anything besides light duty mobile web development. Quoting: 'Here’s the point: memory management is hard on mobile. iOS has formed a culture around doing most things manually and trying to make the compiler do some of the easy parts. Android has formed a culture around improving a garbage collector that they try very hard not to use in practice. But either way, everybody spends a lot of time thinking about memory management when they write mobile applications. There’s just no substitute for thinking about memory. Like, a lot. When JavaScript people or Ruby people or Python people hear "garbage collector," they understand it to mean "silver bullet garbage collector." They mean "garbage collector that frees me from thinking about managing memory." But there’s no silver bullet on mobile devices. Everybody thinks about memory on mobile, whether they have a garbage collector or not. The only way to get "silver bullet" memory management is the same way we do it on the desktop–by having 10x more memory than your program really needs.'"
Since JavaScript is so damn lacking, those libraries are ESSENTIAL for anything beyond the smallest JavaScript app.
That's because you're not familiar with JavaScript. Remember: all those "essential" libraries are written in JavaScript. You'll find that tons of features in those bloated libraries are just useless wrappers!
It's not 2006 any more. If you're still using jQuery, or some other goofy library, you're just wasting everyone's time.
You'll find that just about every feature your "essential" library provides has a native equivalent that works across browsers -- even as far back as IE 8.
Do the web a favor and just learn JavaScript. You'll find that it's more than capable. Your users will undoubtedly appreciate the performance boost!
Required reading for internet skeptics
You keep claiming jQuery is slow and crappy because a few frameworks that exist on top of it are slow.
No, I've been claiming that jQuery is slow and crappy all on it's own. jQuery UI and Mobile just happen to be even slower.
jQuery is not a performance killer.
Actual data suggests otherwise. This is completely objective. You can test this for yourself. You pay a VERY steep price for using jQuery even for very simple things.
What it does do, however, is cut development time considerably.
Have any metrics? From what I've seen, it adds significant development time over the life of the application. Do you know how common it is to see multiple versions of jQuery loaded on the same page? (jQuery even has features to help allow that to happen!) Do you have any idea how difficult is is to dig someone out of a mess like that?
The only way jQuery could possibly "cut development time" is if you never maintain your code -- and only then if typing speed is your biggest bottleneck.
I won't claim that jQuery is faster than every native solution. But it is probably faster than your native solution. And infinitely more maintainable.
Have you looked at the jQuery codebase? It's like a group of amateurs that didn't understand either JS or the DOM wrote a library. Oh, wait, that's exactly what happened! (Seriously, check the Usenet archives. It's a riot.)
No surprise, the developers are still less than competent. How on earth did this abomination get so popular? It's a complete mystery to me.
Or do you mean code written using jQuery? Now that's impossible to maintain! (For reasons mentioned earlier and later.) Add to it that jQuery code is mostly written by amateurs who don't know any better (or professionals that don't want to face the simple fact that JavaScript is not C# and they'll need to learn some new concepts). When you see jQuery, you can safely assume that the code is a mess anyway.
Provides a consistent experience across most browsers and gracefully falls back when browsers don't provide native solutions.
Nonsense. jQuery has *never* been cross-browser -- and never really did well across the few browsers it claimed to support! The word "consistent" is a bad joke. when paired with "jQuery". How long has it been around now? It still doesn't have a stable API!
Oh, and did you hear? They're dropping support for IE8 and below. Not that it did a great job of supporting those browsers anyway, but it's yet another reason that jQuery has LONG outlived its utility.
If it was you wouldn't see it on nearly every website more complicated than "hi my name is
See my earlier post. Take the challenge and see how various websites actually use jQuery. If you're not completely disgusted, I can't help you.
Here's why see jQuery used everywhere: JavaScript is difficult to learn. Well, that's not quite right. It's really easy, actually, but it's not at all like Java, C#, or any other popular language. It just looks a lot like popular languages. That causes a lot of confusion from developers who are used to picking a new language by reading a few code samples and hitting google a few times. You simply can't learn JavaScript that way.
jQuery came with false promises like cross-browser compatibility and a myth of ease-of-use. Developers who never touched JavaScript before took jQuery as an "easy way out" -- never mind that none of the promises it made were ever true, that's what they were told and that's what they believed. They were told that JavaScript is difficult or full of pitfalls. That wasn't true, of course, it's just that the language was so different from what developers were used to from language's with similar syntax that they m
Required reading for internet skeptics