My Realm

My Love

It's perfectly normal to be in love with a language. And Scala is something which will make you fall for it, no matter how much you resist. I have coded in it for months now and it's the language which made feel really comfortable. With it, it's like having to just imagine what you want to do and there is a class or a companion object waiting to help you. Think and create, instantly. With scala and its actors, there is this fail fast strategy which comes along. Yup, the same one which entrepreneurs swear by. And there was this beautiful article about how languages shape companies. It becomes apparent over time. When you are all about launching fast and testing and failing and repeating, you bond with the language which lets you do that. It's a perfect match when your philosophy matches with the language you chose. Pardon me if you thought this was going to be one of those Scala tutorials, there are enough of those.

JAVA users might not understand me. And Android devs might not even think about using it. ART, the new kid in town which aims at replacing Dalvik, seems to be very hostile towards anything not JAVA. At this point I must tell you that the whole network code in Grid has been written in Scala. Won't lie, but the code to enable hostspot did not run on Android 5.0. I can almost see that smirk on JAVA devs. To fix it, I ported it in JAVA. And bingo, it did not run this time too. The only difference being that it popped an error notification stating that I don't have the permission to change the network state. Don't blame Scala if you forgot to add a permission in manifest. Admitting again, I haven't tested the scala code + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> yet. For the sake of argument, lets assume it WAS a compatibility issue, that ART did not like Scala code. But please, out of all the syntactic sugar, all the higher order functions, and all the pattern matches, ART chose to shut down reflection(Enabling a hotspot needs reflection)? 

I can assure you that the transition will help you in the long run. Just like the hotspot glitch, you may get weird bugs and maybe, just maybe you'd have to fallback to JAVA but that is it. That is the solution, don't abandon what doesn't work, adjust. JAVA and Scala do get along nicely. My bet would be on using both whenever the situation requires you to.(Kind of like double timing but gotta do what you gotta do).

Ending with some scala code snippets which may lure you into its cozy arms. 

No comments:

Post a Comment

I am on Wordpress too.|No Copyright © 2014

Powered by Blogger.