4 ms·
Over the last few months I've been writing Scala full time, and have even written some (demo grade) Android apps in it. My opinion is: Android should not adopt
by DCKing 12y ago
Over the last few months I've been writing Scala full time, and have even written some (demo grade) Android apps in it. My opinion is: Android should not adopt Scala as one of its primary languages.
I think a platform's primary language should be accessible. It is an unfortunate fact that the stuff that most people only know about programming using some object oriented imperative language. People find it harder to hobby with unfamiliar styles, and it is hard to find leverage within your organization to go into unknown territory. If it isn't a popular widely known language (Java) it should at least resemble popular widely known languages (Swift). Give people a piece of Java or Swift code, and they can read it. Give people a piece of Scala code, and they usually cannot.
Scala can be an accessible language; its imperative syntax is really nice. But Scala is not an accessible language in that idiomatic real-world Scala and most of its libraries are written in a wholly unfamiliar style. Powerful, yes. People should learn it, yes. But if Scala comes to Android it will only serve to make the platform seem less accessible. And that's a much bigger downside than whatever expressivity Android Java currently lacks.
Scala can't even properly be a primary language in parallel to Java at the moment. Swift is just a better syntax for expressing idiomatic Objective C programs. Good Swift programs should look mostly like good Objective C programs with a different syntax - Swift has been made for this purpose [1]. Scala is not a better syntax for expressing idiomatic Java programs. Despite backwards compatibility, good Scala programs look very different to good Java programs. This means that Google cannot present them as equivalents. The Android platform APIs heavily promotes mutability which makes writing idiomatic Scala code for Android a pain in the ass. Should Google ask people to write non-idiomatic code for their new primary language, or should Google provide new APIs for their new primary language?
I dislike Java very much. But I think it's a great language for Android, because everyone can do it and that makes the platform accessible. There's only one other language I can even remotely imagine in its place, and that's Dart. And that's not happening either.
In the meantime, making Scala run on Android is perfectly doable. That is good enough for me.
[1]: I'm aware that this comparison doesn't do Swift as much justice as it should.
- frowaway001 12y ago> If it isn't a popular widely known language (Java) it should at least resemble popular widely known languages (Swift). Give people a piece of Java or Swift code, and they can read it. Give people a piece of Scala code, and they usually cannot. You realize that Swift not only resembles Scala syntax closely, but also adopts many of the same concepts? Oh, right. Just the usual Scala bashing ... I think you have forgotten to mention C++.
- DCKing 12y ago> You realize that Swift is not only resembles Scala syntax closely, but also adopts many of the same concepts? If you think that superficial syntax comparison is a fair comparison of the two languages, then you haven't written idiomatic Scala code. It's true that Swift looks a lot like imperative Scala. But that means nothing as nobody writes or should want to write imperative Scala. > Oh, right. Just the usual Scala bashing ... I think you have forgotten to mention C++. Did you miss the part where I said I wrote mostly Scala for the last couple of months? Look at my post history, I love Scala.
- zak_mc_kracken 12y ago> Scala can't even properly be a primary language in parallel to Java at the moment. This is a very important point. There is a lot of ambivalence about Scala in the non Android world already, it's naive to think this ambivalence would completely go away on Android. The same problems that are crippling Scala's adoption in the non Android world will be present on Android.
- lmm 12y agoThe advantages of immutability are real. At some point an improvement has to be a change. Even if Google sticks with Java-only, I would very much hope they will offer a more immutability-friendly API in parallel with the existing one. Certain Scala libraries are indeed not accessible. But the trend is in the right direction (there are better alternatives to requests now, and even scalaz has become less symbolic in recent releases). If Google were to provide the same APIs and sample programs that they currently do, those programs would be as accessible as they currently are - probably more so, given Scala's cleaner syntax. You say this could make Android less accessible. Maybe. But it could also make Scala more accessible, providing a whole new class of developers with a stepping-stone from somewhere very familiar towards these valuable high-level features. As the Python folks say, a good language should make easy things easy and hard things possible. IMO Scala does both halves better than Java. It's just that so far, people have mostly been using it for hard things.
- DCKing 12y agoGoogle should do something about their APIs, sure. But they should do something about their APIs before doing something about their language. The problem with Scala is not symbols or legibility (although that used to be a major problem), but the fact that its programming style tends to be mostly functional. Monads, for-sugar, implicits, immutability: stuff everyone should master but in practice very few do. > You say this could make Android less accessible. Maybe. But it could also make Scala more accessible, providing a whole new class of developers with a stepping-stone from somewhere very familiar towards these valuable high-level features. The Android developers unfortunately have no interest in making Scala more accessible. They have an interest in making Android more accessible. They would have to make a lot of sacrifices to make Scala a primary language for Android, and the benefits would be rather small from their perspective. Scala's killer apps are on the server side. That seems to be going quite well so far.
- frowaway001 12y ago> The Android developers unfortunately have no interest in making Scala more accessible. They have an interest in making Android more accessible. They would have to make a lot of sacrifices to make Scala a primary language for Android, and the benefits would be rather small from their perspective. I think just fixing their god-damn bugs would be enough to make people happy.