> XML is parsed on the device wasting CPU time and battery<p>It was my understanding the XML was compiled into a binary format for faster parsing on device, am I wrong on that?<p>EDIT:
<a href="http://en.wikipedia.org/wiki/Android_application_package" rel="nofollow">http://en.wikipedia.org/wiki/Android_application_package</a> "resources.arsc: a file containing precompiled resources, such as binary XML for example." Ah yes, I think it does.<p>> Most of all, it allows no code reuse.<p>If we are talking code reuse in terms of having one common bit of layout that is used across several different layouts, actually you can: <a href="http://developer.android.com/training/improving-layouts/reusing-layouts.html" rel="nofollow">http://developer.android.com/training/improving-layouts/reus...</a><p>Also, the Android view system as it stands is incredible flexible.<p>You can provide different layouts and style rules for different screensizes and device configs - an kinda equivalent to the webs responsive design using CSS media queries.<p>Also, every view component is just a Java class. As well as allowing you to create your own class from scratch that you can just use as part of a view, you can also extend an existing view class and just change one bit of it's behaviour.<p>I don't especially mean to have a go at Anko - sorry. It's just that I think the Android views are actually pretty good, and certainly when I'm working on Android apps this isn't one of the major problems I have!
After a quick skim this seems great, but just one piece of a much bigger puzzle. Android activities, regardless of whether the view is constructed declaratively or in code, seem to always become an untestable mess that does way too much. At least, that's what happens if activities are used as intended. IMO, the bare minimum necessary to fix this is some more elegant alternative to AXML that, crucially, has some kind of declarative databinding support. Roll that into Anko and we're on our way to taming the activity.
I have a relatively medium implementation of a layout in anko here: <a href="https://github.com/burntcookie90/KotMeh/blob/master/app/src/main/kotlin/io/dwak/meh/view/MainActivity.kt" rel="nofollow">https://github.com/burntcookie90/KotMeh/blob/master/app/src/...</a><p>I'm not sold on using it as a layout DSL, it's just not as easy to format as XML, and I don't think it looks syntactically <i>that</i> much better. However, I am sold on using anko as replacement for setters and getters (ie. `setText("test")` is just `.text = "test"`). Additionally, it's incredibly easy to add more extensions for other view types, like `RecyclerView` and custom layouts.
What does it even mean for an XML layout to be type and null safe? This reads like a parody. XML resources give you orientation/screen size resolution and component re use. I haven't drunk the MVP kool aid that's the new hotness, but this is far too much in the other direction. If you're setting margins in code you're probably doing something wrong.
This is great, and looks so much easier (as does Scaloid), but I have never found a commercial project that I can use it on. #1 by choosing Anko or Scaloid you are isolating future developers to only those familiar to Anko or Scaloid OR those willing to learn (as well as the fact that Scaloid doesn't sell very well on resumes IMO; my guess is the same for Anko).<p>It's a dilemma, as Java+XML is very verbose. still, with the amount of work Android Studio does, I'm not sure its a big problem for most of us Android Developers.
I think a detailed performance comparison should be provided to be more transparent and to make developers start using Anko.
I mean I want to see how it differs in terms of app opening time, apk size, loading another view in app time etc.
Nice job. With the advent of Swift, mobile developers may benefit from something in a sweet spot between Java and Scala. Looking forward to testing this out and further developments.