Hacker News new | ask | show | jobs
by tinco 4331 days ago
There's a weird and arbitrary limitation in Dalvik, and the Facebook guys needed to work around it. The author makes it sound like it's some horrible sin. How about shaming the Google developers who thought 65k methods was enough for anyone? Wouldn't be good proper either, because they probably had a good reason for it.

Software development isn't always stacking neat abstractions on top of each other. Sometimes you have real hardware and real legacy and you just got to deal with it, one way or another.

4 comments

This limitation is not "weird or arbitrary" but based on the technical capabilities of Android phones in these days.

And those limits were later changed and will surely be changed in the future as smartphones get more powerful.

All kinds of limitations are in place both on Android and iOS, particularly when it's about the amount of memory an application can access or the amount of background processing an app can make.

If you don't have these limitations, then apps could affect not only the functioning of other apps, by grabbing and keeping all available memory, but also that of the phone itself, by draining the battery in 1 hour.

That's not something that the average smartphone user would expect or desire his phone to do.

Edit: I'd also like to add, that almost anything a developer creates is usually created with some limit, or at least some expectancy of costs in mind.

For example I couldn't imagine that someone creates a memory cache, where the limit = infinite without a really good reason. Or an API where the request limit/sec for any client = infinite.

You usually develop something in a way, that reduces the cost of some computation as far as possible, and when it still causes problem - introduce hard limits. Especially when it's a whole ecosystem where many companies/developers participate.

The bug they hit isn't the 65k limit, but the smaller LinearAlloc buffer size on older versions of the OS.
Yep i think the blog post referred the stuff as being LinearAlloc == dex method count, I have made it clear now.
I imagine the devs and management don't care much as they're going to migrate to ART soon, which I imagine does not have Dalvik's circa 2003 design decisions. Google hasn't been investing in Dalvik because its days are numbered.

edit: why is this being downvoted? Do we really think ART will have these limitations? Android has been hot to get off Dalvik for many reasons and they're finally doing it in L. This is very good news and makes Andy Rubin-era Android decisions, which made sense for a 2003 phone, replaced with more modern thinking.

edit2: Apparantly, I'm wrong. Looks like the 16 bit limitation in still there in the current version of ART. Maybe this will change in the final production version.

The limit is being addressed, though not fully in L. It's discussed in the podcast at http://androidbackstage.blogspot.com/2014/08/android-develop...

Basically they're aware it's an issue and they're working on it both for the future of the platform but also in a backwards compatible way (using multi-dex and reflection).

I believe ART still uses DEX as an intermediate format, so it's possible the limitations will still exist.
2^16 counts as "weird and arbitrary"?
Since we stopped using 16-bit CPUs, yes, it does.
Since Dalvik Executables run on a virtual machine, and the Dalvik virtual machine's instruction set is 16-bit, it makes perfect sense.