Apache Cordova: after 10 months, I won't using it anymore
geekcoder.org
geekcoder.org
I think it's time to stop accusing webviews of being slow.
[1] scirra.com
The Chromium based webview is available already in Android 4.4. So about 50% penetration at this point. It is indeed a huge boost to performance.
It has a few limitations, but it's quite nice for games.
So that it's only 100 times slower than a native app instead of 200 times?
The dev team at my ex company built a demo to show that the same app could have been made to perform acceptably using the right strategies.
https://www.sencha.com/blog/the-making-of-fastbook-an-html5-...
Incorrect at least as far as Android goes. Android's WebView literally was the system browser until Chrome was released complete with the JIT since Froyo (V8) and hardware rendering since Honeycomb. And the first several versions of Chrome on Android had much worse performance than the old WebView did.
This aside the bulk of HTML content is still software-rendered. It's software-rendered into tiles which are then GPU composited. It's a different story if you use <canvas>, but at that point you aren't gaining much by paying the browser tax so why not just drop to C++ and write GLES directly and get like 10x the performance?
That aside while there have been improvements in JavaScript performance, HTML/CSS & rendering performance really has not improved much if at all over the years. Browsers are still dreadfully slow to actually produce pixels compared to any other UI toolkit.
Granted, our applications may be different and yes, Cordova, if not done right, can be excruciatingly slow. But we have managed well. Simple things like properly paginating data (rather than trying to infinite scroll), cleaning up CSS, avoiding repeated query selections (which is a bad habit of some jQuery developers) made a huge difference[1].
Our older app is built on jQuery Mobile. The latest one is Ember. The next R&D project I'll try will probably use React with Cordova. Mobile browsers are always getting better. After a while, I have the option of using App Cache instead of Cordova, without any significant code changes (I'm not using plugins yet).
[1] Edit: And not abusing local storage.
Actually, I always find it a bit surprising Cordova doesn't have more competition.
Edit; I find the title misleading. It's not so much about Cordova as it is about hybrid app development
Coding is all about trade offs. There is rarely a perfect solution for all cases otherwise frameworks like Cordova would never exist in the first place.
You mean Xamarin, Qt?
(Yes I know Crosswalk is Android only, but it works wonders).
I wonder what kind of apps they run that make them call 10-15mb call "small".
There are a few downsides though. Added complexity/possibility for bugs, and APK size.
The Crosswalk website says it should add 10-15MB to your. In our app, it's adding over 55MB to the installation size. These numbers are based on unminified JS/HTML (and I think we still have some outdated resources sitting in www/img/), but iOS: 18.0MB, Android: 78.4MB.
And then there's the additional bugs. Did you know localStorage is completely broken in the current "stable" release of Crosswalk? Once you kill/reopen your app, all storage is cleared. You'll need the latest Canary build if you want localstorage to work (and who knows what's broken in that build).
Of course you aren't going to get native performance out of cordova. You are going to get webview performance out of it. If you need native performance, write a native app.
Conversely though, if your app is a success on iOS then it's very likely that you'll want to get an Android version out before the clone-ware makers copy it, so if (and it's admittedly a big if) your app is something that Cordova can do well there's very few reasons against using it. For some use cases it's a good framework, notably "information viewing" apps, business CRUD apps and simple 2D canvas games.
Also I don't believe you can use the SQLite Plugin in a web worker either: https://github.com/litehelpers/Cordova-sqlite-storage/issues...
Luckily, you can still access IndexedDB from a web worker on both platforms (if you are able to use Safari's partial implementation). Also depending on what kind of work you're doing in the database, most of the action happens at the native level rather than the (DOM-blocking) JS level.
Having a shared C++ code base and the respective native UI code works perfectly fine for me, so I wouldn't use Cordova again. I don't see why I should. I'm just as productive there as I am with the web stuff, with the difference that I get a truly native look and feel, without having to watch performance all the time. I'm sure that, if you want to take the time, you can get perfectly well running apps. But for me, it isn't worth the trouble.
I also tried Qt and it was nice, but the app took ages to load on an actual devices (because of QML) and their licenses get more and more messed up.
Aren't Web Components still heavily polyfilled in most mobile browsers? I'm wondering how much of the problem was due to the Polymer library than Cordova proper.
I should have said that I wouldn't create any hybrid mobile apps anymore, not just Cordova. That's not because I don't like it - it's simply because the other options work just as good for me. At least for now - can't say anything about the future.
> I should have said that I wouldn't create any hybrid mobile apps anymore, not just Cordova
I must admit, I'm still quite enamored with them, if only for development time and maintainability. I'd rather not develop 3 different apps for desktop (browser), Android and iOS. As I said elsewhere, I'm waiting to rely on App Cache instead of Cordova in the future.
That's a very good reason for many developers. My UI code is usually rather small, with the C++ code being the biggest part. I really like C++ and Java, and Objective-C is OK. I'm pretty sure if I didn't, I would take a different route.
I'm still pissed off because loading in Qt apps can take very long. Writing the apps in QML, JavaScript and C++ was a lot of fun, but I couldn't recommend anything that destroys the UX so much.
They probably would have run well with the Crosswalk browser plugin, then. It's basically bundling the latest version of Chrome within your app, so all your users have a consistent and up-to-date WebView, instead of whatever the OEM decided to lock it at.
Of course, that doesn't fix every issue, and adds a few more of its own. But really, any non-Crosswalk benchmarks/performances tests on Android can be simplified to: It's slow as hell.
I guess C++ scares the web devs to go native and prefer to stay in their little sandbox.
Also tried to play around with Qt, but got disappointed that their story is more about bringing C++ apps into mobile not much the license, than a full cross-platform support like Xamarin. Even the new 5.5. still requires a lot of manually wrapping code across all mobile OSes.
However if I would be doing this commercially, Xamarin might be the way to go, as I wouldn't be willing to write glue code all the time.
Now the circle has turned with React and React Native…
React came before React Native. In one sense, React Native is just a tool to turn React HTML5/Javascript webapps into native ones - in a similar way to maybe an AngularJS webapp turned "native" with Cordova.
http://www.computerworld.com/article/2935408/app-development...
"Counting by lines of code, roughly one-third of the codebase on each platform is shared C++ code."
Source: https://code.facebook.com/posts/498597036962415/under-the-ho...
They are using a custom version of Djinni for cross-platform support.
Looks like Microsoft is going down a similar path with Visual Studio:
https://www.visualstudio.com/en-us/features/cplusplus-mdd-vs...
Ever heard of WebSQL for storing your data? After 10 months, you should have been able to work around nearly anything you mention in your article.
But that's exactly the point. Ages ago this comment on HN summarized the situation perfectly... https://news.ycombinator.com/item?id=7442766
"It takes less time to learn and build native instead of trying to hammer Javascript into a hole it doesnt fit into, and spending hours attempting to optimize it's performance to no end."
...depending on the size of the app.
I have an open source project that I devote a handful of hours a week to. I absolutely do not have the capacity to create native apps for desktop, iOS, and Android. It's great if the writer of that comment has either a tiny app that does nothing important or has a ton of free time, but not everyone is so lucky to be able to maintain an app on 3+ separate platforms.
Javascript is the one language all devices speak well, so as someone who is proficient in it, has an existing (somewhat complicated) app, and wants to port it to mobile as quickly as possible, rebuilding everything twice in two different languages and two different UI platforms is just not an option.
iOS has IndexedDB since v8.0 though the implementation is poor. I don't know if they've fixed it in any 8.x release. However, you're (mostly) not using IndexedDB directly anyway but a storage library, which supports IndexedDB, WebSQL and maybe localstorage as a fallback (e.g. localForage[1] for a simple key-value DB).
The problem right here, to have to "work around" for 10 month.
On the other hand, native-equivalent performance is no joke and c#/f# are great languages. Xamarin comes with some very sophisticated stuff like databinding, and high-level concurrency like rx, async/await, and akka.net which can really be a boon for performance, especially compared with js's comparatively meager concurrency options.
* Core functionality is broken between releases. If you ask in the IRC support channel, they will even tell you not to update if things work well! What if I need a new feature?
* Documentation is absurdly horrible or even plain wrong. I have been told several times to refer to the source code to find out how something works.
* If you face any problem, chances are you will never find an answer in Google. You may find some StackOverflow thread if you are lucky, where several clueless people argue about things they do not know and then arrive to a wrong conclusion. (The programming skill levels of Cordova users on those communities are usually very low.)
* Critical functionality (things such as local notifications) is not included. You must rely on 3rd party plugins, that could be well maintained, or could be not maintained at all.
Yes obviously a Cordova app does not look native. It's not native and it will never be. Period.
I'm currently working on a Hybrid React app, performance issues aside the real issue is documentation and support. As soon as you are beyond a basic web app wrapped in a container you realise quickly Corodova will always be a second class citizen.
On a more positive note React Native (https://facebook.github.io/react-native/) is mind blowingly amazing. I really can't recommend it enough, especially for Javascript developers.
so far it looks like React is for Mac only, looking at https://facebook.github.io/react-native/docs/getting-started... ?
Edit: It looks like i'm missing something as I can see Android apps built with it on http://www.reactnative.com/built-with-react-native/
The question is also what can you afford. Can you afford to have 2 ios & 2 android devs? Can you afford to build 2 times all the UI features, etc.
For a small company, small budgets, if you have strong front-end devs & designers you are probably going to get a good cordova app & you can move your company much faster.
You have big bugdets? Hire the native devs, get the 100% performance & experience from native.
And native fast responsive app with smooth animations might earn you more, than HTML container.
I wrote a simple game using cordova and I won't do it again. HTML+CSS+JS just not suited for mobile app development (I didn't try react native, those guys might change the game). Either you use frameworks and everything is just bad or use vanilla JS and everything might work, but you have to write a lots of spaghetti-code and device support might be limited.
The real unmatched benefit of using cordova (or any other webview) is the ability to deliver updates for your app without bothering with App Store moderation.
Unfortunately I can't agree that you can easily find easily good IOS & Android devs, I'm sure that some that can do it out there, but generally one platform always suffers more.
Has for Cordova issues, from my experience, nothing was so atrocious that writing 2 apps would have been faster.
"Either you use frameworks and everything is just bad or use vanilla JS and everything might work"
I think you might be thinking about games saying that, again I can't agree, if you don't understand what your framework does in your back that's another thing, but you can easily write optimized code when you control your render.
For example Ionic is a very good mobile UI framework for angular. It however wont save you if you start adding random things to the DOM while doing an animation.
What? As someone who does a LOT of vanilla JS, what do you consider "spaghetti code"?
Even if I have to code native like widgets in QML, it is surely way better than hacking around the DOM.
Cordova is not a replacement to build native apps. Its a tool that allows you to build really good apps that works on all platforms.
My app[1] wouldn't have exist without Cordova. And based the feedback, most users are fine with it.
I have yet to find a solid native app that is available on all platforms, not belongs to a big company or a startup with huge funding, and made by 1/2 developers.
[1]
https://play.google.com/store/apps/details?id=com.premii.hn
https://itunes.apple.com/us/app/hacker-news-yc/id713733435?m...
http://hn.premii.com/ (HTML5)
- that it can be like native; I regularly heard from management "What is so difficult about CSS? Why is it taking so long to build widget X?"
- that there is no reason why it can't be fast; I regularly heard from management "iPhones have >1ghz processors after all -- why can't it be faster?!"
- that the plugin ecosystem is bad -- "Why can't we just do X? Why do we have to build this?"
I agree with your criticisms as well. The lack of documentation, plugins, breaking between releases, and general help is surely lacking. But this is by no means a "bad article."
Everyone from VPs, Directors, to HR knows HTML, and they all have opinion about how it should be. They all want you to build a Facebook like app with 2 developers and works on all platforms.
You can get pretty close to looking native with a framework like Ionic: http://showcase.ionicframework.com/
Of course, it's not native, so there are going to be corner cases where things don't look quite the same, but I'd be hesitant to make such an absolute statement about the future when you can already get so close today.
Performance and compatibility issues for Cordova apps can be often traced back to outdated webviews, and you can resolve much of it by embedding an up-to-date webview with your app: https://crosswalk-project.org/
I have used many apache codebases, all the others were excellent. ai expect my former employer chose solr because of thevapache foundation's great reputation. I looked forward to using it and so was completely dumbfounded by its poor quality.
Not here to defend solr specifically, but every tool has trade offs. Solr is popular and there is a lot of documentation, so it is not a bad choice for a document search database. Now, picking solr without understanding a document database and its tradeoffs is a problem, but not solrs.