15 ms·
C'mon, stop writing Java for Android
- markokocic 15y agoThis comes too late. Mirah already took the torch for javaless android development. It's much simpler language then Scala, and compile directly to bytecode without requiring any runtime. The only thing where Scala is better (for Android development) is better tooling, but I hope that will be fixed soon.
- muyyatin 15y agoIs there a noticeable size increase from including parts of the Scala library? I know Proguard will probably strip out a lot of unused classes.
- th0ma5 15y agoI haven't tried myself, but I have used GNU Kawa to great success, and your right, Proguard does strip most of it out.
- joshhart 15y agoYou absolutely need proguard since the Scala library is several megs in size, and will likely grow bigger when specialization goes everywhere.
- jamesbritt 15y agoSee answer posted elsewhere in the thread: http://news.ycombinator.com/item?id=2585541 http://news.ycombinator.com/item?id=2585541
- wccrawford 15y agoI'm underwhelmed. At that level, I find the Java version more readable. (I know, I know, the horror.) But to answer the question posed: Community. I started messing with Mirah, but there's just not much community yet. Any questions you have is a new one. And nobody knows the answer yet. That's fine if you like figuring things out and have time... But drop either of those and it's just a headache.
- jamesbritt 15y agoI started messing with Mirah, but there's just not much community yet. True, but as that community includes Charlie Nutter it has a serious leg up. :) Still, I expect things to move fairly quickly, so the number first-time-asked questions will diminish and getting solid work done will increase.
- jamesbritt 15y agoSo what’s stopping you from using Scala for your Android app? Mirah. While Mirah is still beta-ish I prefer it to Scala. Maybe it's because I'm already familiar with Ruby, but the "multi paradigm" (i.e. no paradigm) nature of Scala leaves me cold. It's kinda-sorta OO, kinda-sorta functional. But the functional part gives no guarantees of referential transparency or immutable state, so the killer value of FP is lost. But, language rant aside, even if Scala were the cat's meow, you still have to include the Scala base libraries with every app. Proguard may help, but it seems wasteful. Mirah, OTOH, compiles down to straight-up JVM byte code. No supporting runtime libs are needed. Very slick.
- FlemishBeeCycle 15y agoMirah is what finally got me started with Android development. Coming from a Ruby background there's practically zero learning curve, plus you can install it from RubyGems (which when using RVM makes it dead-simple). That being said, for my first application I decided to do it in plain old Java - since I had never worked with Java, I imagined that a rudimentary understanding of its workings would help me down the road in debugging issues that might arise when working with Mirah (somewhat like knowing JavaScript before working with CoffeeScript). There's even a tool for writing Mirah for Android called Pindah https://github.com/mirah/pindah/ https://github.com/mirah/pindah/ . All in all, it's quite a nice package.
- crux_ 15y ago> But the functional part gives no guarantees of referential transparency or immutable state, so the killer value of FP is lost. I don't think I agree here. First, the language's type system can give you those guarantees where you need them. (Even Haskell has unsafePerformIO...) Second, a lot of the "killer value" comes from first-class functions (and in statically typed functional languages, type inference). Coming from Ruby you may not see the huge benefits these would give over Java... ;) Finally I disagree with the "kinda-sorta" label: The entire Haskell standard library could be rewritten, more or less, in Scala. How is that "kinda" functional? Likewise, obviously any Java code has a direct scala analogue... and with the Dynamic trait, you may even be able to write direct translations of ruby/smalltalk/python-style code too, after a bit of plumbing. Most (any?) "kinda-sorta" lies with the programmer, not Scala. ;)
- ggeorgovassilis 15y agoSo what’s stopping you from using Scala for your Android app? The same that is stopping me from using it for J2EE production code: the insufficient IDE integration. It's quite ok for unit tests though.
- andrewvc 15y agoHas anyone written any Clojure for Android so far as anyone knows?
- GeorgeTirebiter 15y agoI've heard that folks have done it (more than a year ago) but, apparently, the runtime takes a while to load and that makes the app practically unusable.
- vmind 15y agoI think the issue with Clojure is that it does runtime bytecode rewriting for macros, so to get the whole language working on android they had to bundle the dalvik translator as well.
- runevault 15y agoThere's also the issue of all the ephemeral garbage Clojure tends to create and gets disposed. Not sure if 1.3 generates less but oh a phone that stuff adds up.
- technomancy 15y ago> I think the issue with Clojure is that it does runtime bytecode rewriting for macros This is actually very rare; nearly all bytecode generation in Clojure apps can happen ahead-of-time. But Clojure relies heavily on Hotspot's world-class JIT (the bytecode Clojure's compiler outputs is only optimized in so far as making it easy for Hotspot to optimize it.) In addition, use of persistent data structures puts more strain on the GC; another place where Hotspot is leaps and bounds ahead of Dalvik. You can bypass this by using Java arrays directly, but it's very awkward and un-idiomatic.
- ygooshed 15y agoi love to use scala on android. has anyone developed any 'real' app with scala on android?
- 15y ago
- mickeyben 15y agoI tried both Mirah and Scala and I'm sticking with Java for the IDE integration.
- squidsoup 15y agoThe IDEA Scala plugin is pretty solid now; worth revisiting if you haven't tried it in a while.
- joshhart 15y agoIt's worth noting that www.typesafe.com is now supporting the Eclipse plugin commercially as well. Both the IntelliJ and Eclipse plugins have made huge advances in the last year.
- mikemaccana 15y agoRe: mentioning Python via the ASE in the intro, it's a non-starter: the ASE can't make GUI or OpenGL apps . Other than that: yes, Scala is awesome (asides from all those curly brackets).
- hunterp 15y agoDon't take my System.out's away from me wierdo.
- nupark2 15y agoWe use Java because we don't want to foist a 'weird' language on our clients. If it wasn't for that, we'd leap at the opportunity to use Scala.
- dustingetz 15y agoI also would love to hear from someone who has put effort into and succeeded, or failed, at selling their enterprise clients on Scala.
- thepumpkin1979 15y agoIt's true that you can use the NDK to write "Parts" of the app but, don't get me wrong, I don't think it's intended as a replacement for Java or the Java libraries (unless you are writing a game that requires high performance requirements). I think Java is a decent programming language and Android comes with tools nicely integrated in Eclipse IDE. I quote: "The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications. Android applications run in the Dalvik virtual machine. The NDK allows you to implement parts of your applications using native-code languages such as C and C++. This can provide benefits to certain classes of applications, in the form of reuse of existing code and in some cases increased speed." See http://developer.android.com/sdk/ndk/overview.html http://developer.android.com/sdk/ndk/overview.html
- codesink 15y agoI think google is working to move Android to Go as soon as possible; Rob Pike replied to a related question with "I cannot talk about it" and that sounds like a good clue :) Go binaries already run on Android/ARM, the higher level code is the one that's missing. That would bring great boost in performance (compilers are available for both x86 and ARM) without adding any complexity on the language side (Go is a cool language).
- jraines 15y agoJust went to Google to see if I could find anything relating to this possibility, and was immediately reminded how annoying it is, with respect to search, that they named the language "Go".
- codesink 15y agoThey managed to optimize their golang.org homepage to get the position #5 on the word "go". They must be good at SEO. BTW the video I mentioned is at http://www.youtube.com/watch?v=-i0hat7pdpk&feature=player_embedded http://www.youtube.com/watch?v=-i0hat7pdpk&feature=playe... (at the end during Q&A)
- flogic 15y agoIt helps to include the words "lang" or "language" in the search. Kinda frustrating.
- VMG 15y agoI think everybody should just call it "golang"
- leon_ 15y ago> you don’t need as many semicolons What is up with the hate on semicolons? Luckily I know scala but if I didn't and someone would try to sell it starting with that argument I'd get very suspicious.
- bonzoesc 15y agoThey're more typing than no-semicolons and all you stand to gain is code that's harder to read for a majority of programmers. It's really as close as you get to an objectively-bad thing in a programming language.
- leon_ 15y ago> objectively-bad I guess you're confusing objective and subjective here. I think semicolons are nice - they make reading code easier. And the "extra" typing isn't really that much work. But that's my opinion and so it's subjective. I don't claim to be it the ultimate truth, like you do.
- cmars 15y agoI'll switch to scala or any other language if it will abstract away SQL cursors with minimal overhead.
- sehugg 15y agoIf Scala can give me a way to abstract all the wacky Activity/Intent/Service stuff, get around incompatibilities between Android 1.5/1.6/2.1/2.2/2.3/3.0, work around bugs in various hardware platforms, provide me a usable GUI layout tool, and maybe even make my simulator start a wee bit faster .. I'm yours pal. Otherwise I'll be sad because I'll just be pretending that I'm programming in the future.
- ikhare 15y agoAt Bump we use Scala for our the service layer of the application that manages connectivity to our servers and deals with our "business logic". It's a great language when you are within it's rules, and a great way to do succinct state management. But writing Scala in Android is chock full of gotchas as well. Just today I was dealing with the scala compiler not finding a public inner class in the Android framework, forcing me to rewrite that class in Java. I am fairly new to Scala myself but stuff like this does come up, and can eat up more time than expected. We've promised a blog post with more details on the pains and triumphs of using Scala in Android. Also if you're going to be at the Scala Days conference next week at Stanford, we're going to be giving a talk about this subject.