News for hackers. Stuff that matters.
Re:Server APIs Project by sacheendra on Tuesday October 25, 2016 @02:35PM (#12790376)
I think most languages thatare popular today are 'best of most worlds' for their users. For example, Scala has all the features you specified and has an even larger ecosystem of libraries for the server side.

I am still happy that this has been done as I know having a common API to program against does ease development and creates a great ecosystem as evidenced by node.JS.

Re:Server APIs Project by hota_mazi on Tuesday October 25, 2016 @04:26PM (#12791365)
The problem with Scala is not that it has all the features of Swift, it's that it has way more. Scala developers see this as an advantage, everybody else sees that as a liability.

Swift and Kotin manage to capture the perfect amount of "a few new features but not too many" of all languages I've played with these past ten years.

They are both the perfect example of languages that hit the right compromise in many dimensions.

Re:Server APIs Project by threeseed on Tuesday October 25, 2016 @05:54PM (#12792053)
I am terrified of working with experienced Scala developers.

The code they write is less about implementing some business functionality in the most elegant way possible. But rather it's an exercise in who can use the most obscure parts of the language.

And unfortunately there are far too many obscure parts.

Re:Server APIs Project by naasking on Wednesday October 26, 2016 @09:26AM (#12796244)
> The code they write is less about implementing some business functionality in the most elegant way possible. But rather it's an exercise in who can use the most obscure parts of the language.

I think it's rather more likely that you simply don't understand why they're using the more obscure parts of the language on any given problem. They're probably trying to rule out certain invalid uses as type errors, which is typically encouraged in the more advanced typed languages.

Re:Server APIs Project by justinhj on Wednesday October 26, 2016 @10:38AM (#12796765)
I work with a team of 8 scala developers of varied experience. We try to set the bar at the sweet spot of power and readability. If someone's code becomes super dense because they've gone crazy with scalaz constructs then we ask at review stage to simplify, to comment and/or educate the rest of the team. I don't think experienced coders should be irresponsibly using Scala at a level that is inappropriate for the team.
Re:Server APIs Project by premium-concern on Tuesday October 25, 2016 @07:33PM (#12792734)
I have never seen this.
Re:Server APIs Project by threeseed on Tuesday October 25, 2016 @08:08PM (#12792890)
The levels of enlightenment: http://www.scala-lang.org/old/node/8610

Most Scala developers are in the A bracket. The experts are in the L. The code written by either is so different they could almost be different languages. You don't get this sort of split in Swift, Java etc.

Re:Server APIs Project by premium-concern on Tuesday October 25, 2016 @08:43PM (#12793053)
This is more of a split between techniques for programming-in-the-small vs. programming-in-the-large.

All languages have this. You could write more or less the same list for Swift or Java with minimal changes.

Again, do you have any actual experience with this, or is this just your assumption? Because I have never seen this issue in the wild.

Re:Server APIs Project by timv on Tuesday October 25, 2016 @11:00PM (#12793569)
I have absolutely seen it in the wild, but at least in my case it seemed to be more a case of "People who wish they were writing Haskell, but found more commercial opportunities with Scala" compared with "People who found Scala to be an improvement over Java".

At the extreme of the first group you'd have people for whom it seemed like every problem was best solved with a higher-kinded-type. And while it might well have been technically (and mathematically) elegant, the rest of the team was left scratching their heads trying to understand it.

Re:Server APIs Project by flukus on Tuesday October 25, 2016 @11:35PM (#12793698)
It's only a disadvantage if you work with people that try to use every feature for every job. Admittedly some people do this, but you'll get the same problem in many languages like c++, ruby and c# as well.

The features are great for people writing libraries, but general purpose code should usually only need a subset.

Re:Server APIs Project by timv on Wednesday October 26, 2016 @12:18AM (#12793841)
I hear that argument a lot, but it only seems to be true if you never need to look at code from outside your immediate team/project (either because you don't use it, or you use it without ever understanding it)

In the case of Scala:

If you ever browse the standard collections library you'll run into a lot of different variance rules and implicit constraints. It is quite hard to really understand the collections library if you don't get your head around those.

If you want to use Spray for anything more complex than they spell out in their examples, then you need to understand their magnet pattern.

If you want to be able to debug a problem in Slick then you'll need to understand shapeless.

If you ever go anywhere near scalaz then you'll need to understand every esoteric symbol and operator in Scala, as well as be able to read and understand Haskell (because the patterns and types in Scalaz are often explained by reference to the Haskell equivalent)

Yes, I can set rules for my own team about what features we use internally, but I want my team to at least broadly understand the syntax and patterns used in the APIs that they interface with, which means you need to either read & understand most of the features that you aren't using internally, or avoid a very large percentage of the scala ecosystem.

Re:Server APIs Project by karim on Wednesday October 26, 2016 @12:14AM (#12793818)
The problem with gargantuan languages like Scala and C++ is not that some people will try to use every feature, but that everybody will use a slightly different subset.

Most reasonable people will agree on using a subset of the language but few will agree on what goes into that subset :)

Re:Server APIs Project by flukus on Wednesday October 26, 2016 @12:50AM (#12793951)
> Most reasonable people will agree on using a subset of the language but few will agree on what goes into that subset :)

Why is that a problem? Different people/teams will have different needs.

If I'm working on a problem where generics is a good fit and bob across the office is working on more business code where it isn't a good fit then it makes sense that we would both be using a different subset of the language.

Re:Server APIs Project by tatterdemalion on Wednesday October 26, 2016 @01:36AM (#12794108)
I need to understand all of the features to understand both your code and Bob's, especially when they interact. The point of "using a subset of a language" is having less feature interactions to understand.
Re:Server APIs Project by dman on Wednesday October 26, 2016 @01:45AM (#12794144)
Flip side is languages with such a small intellectual footprint that the moment that the problem domain / workloads shift a bit you are forced to switch to a different language.
Re:Server APIs Project by premium-concern on Tuesday October 25, 2016 @07:27PM (#12792690)
> The problem with Scala is not that it has all the features of Swift, it's that it has way more.

Please have a serious look at Swift. I don't think this claim stands up to any kind of scrutiny.

Swift is more like C++ than anything else in terms of features, Kotlin has roughly the same amount of features as Scala but more special-cased ones. Kotlin solves one problem well, and only that one: If you want to write Java, but want it to be a bit less verbose, then Kotlin is perfect.

Re:Server APIs Project by akst on Tuesday October 25, 2016 @09:37PM (#12793248)
> The problem with Scala is not that it has all the features of Swift, it's that it has way more. Scala developers see this as an advantage, everybody else sees that as a liability.

Well for it's intended audience it's exactly what they want I guess, same could be said for Swift IMO. That said, Swift definitely has boarder appeal.

Re:Server APIs Project by premium-concern on Tuesday October 25, 2016 @10:03PM (#12793355)
In which sense?
Re:Server APIs Project by akst on Wednesday October 26, 2016 @04:14AM (#12794783)
I was saying Scala was designed for a certain audience in mind, probably Haskell/OCaml devs forced to develop for Java or something like that. Similarly Swift was designed for an intended audience in mind, iOS developers, and so certain programming features would not mesh well like higher kind types.

Maybe this is more of a case of an ideal feature set as envisioned by Odersky vs' Lattner, idk. Either way different people look for different things in a language and that's all I'm saying really.

Re:Server APIs Project by jowiar on Wednesday October 26, 2016 @10:59AM (#12796944)
Seeing Odersky's talks, that is a gross mischaracterization of what he has said on the topic. There's a certain readable, elegant, concise style of code that is expressed very naturally in Scala, and if you take Odersky's courseras, it's very clear that it's something that was a preeminent design goal of the language.

The Scala community, on the other hand, got hijacked by a bunch of Haskell neckbeards who spew executable ASCII art over every codebase they get their hands on. The formation of the Scala Center feels like a response to this -- an effort to "retake" Scala.

Re:Server APIs Project by premium-concern on Wednesday October 26, 2016 @09:38AM (#12796318)
Scala was designed to provide the best of OOP and the best of FP, without adding cruft or having multiple non-orthogonal features of one concept.

I think there is large audience of people who want the best OOP tools, or the best FP tools or both.

Re:Server APIs Project by 3pt14159 on Tuesday October 25, 2016 @08:52PM (#12793094)
The real problem with Scala is Java. Most of us over here in C / Ruby / Python land or .NET land have been bitten by dipping our toe into Java and now avoid it like the plague.
Re:Server APIs Project by premium-concern on Tuesday October 25, 2016 @09:10PM (#12793159)
Then use Scala!

You almost never need to deal with Java except if you want to.

Plus, unlike C/Ruby/Python/.NET you get a JS backend that actually works¹ (unlike mess like GWT, or various other languages).

¹ In the sense of: Scala.js is stable, mature and production-ready. You can use it, save a lot of time, share a lot of code, use mny of the libraries you already know, enjoy great IDE and tooling support, use it in real projects and make money with it.

Re:Server APIs Project by BoorishBears on Wednesday October 26, 2016 @09:43AM (#12796363)
Scala on Android is pretty terrible
Re:Server APIs Project by premium-concern on Wednesday October 26, 2016 @10:34AM (#12796725)
How? Even the tooling seems to be vastly superior to the Gradle one.

Deals with SDK dependencies automatically, typed resources and views, better Instant Run, ProGuard caching, extremely low overhead, fast compiles, ...

Re:Server APIs Project by BoorishBears on Wednesday October 26, 2016 @03:09PM (#12799460)
Method count forces multidex insanely early into development and for people who want the best UX that alone is a show stopper.

Very slow compiles (contrary to what you claim).

Language style encourages constructs that cause GC spikes, closures are not low overhead

SDK dependencies automatically meaning what? The thing AS does for imports from AppCompat and co?

Better instant run?

Re:Server APIs Project by premium-concern on Wednesday October 26, 2016 @06:22PM (#12801235)

  Method count forces multidex insanely early into 
  development and for people who want the best UX that 
  alone is a show stopper.
That's a complete non-problem. Minimal overhead of Scala is 30kB (see http://scala-android.org/) and it doesn't grow much larger even after dragging in the collections API. Every single of Google's Android compat shims is way larger.

Here is a data point from a small example app written in multiple languages: https://github.com/SidneyXu/AndroidDemoIn4Languages

If you need multidex (you probably don't), it's a single setting away.

  Very slow compiles (contrary to what you claim).
After saving in my IDE, the plugin has incrementally compiled, ProGuarded, dexed and deployed the app to my phone before I can even grab it. That's pretty fast in my book.

testQuick is also amazing as it runs only the tests that have failed, haven't run before or depended on code you just changed: http://www.scala-sbt.org/0.12.4/docs/Detailed-Topics/Testing...

  Language style encourages constructs that cause GC 
  spikes, closures are not low overhead
Google has official recommendations on what to avoid in Java. You can follow the same rules and be fine. Closures have the same overhead as if they were written in Java.

  SDK dependencies automatically meaning what? The thing AS 
  does for imports from AppCompat and co?
No. SDKs (and NDKs) are treated like every other dependency, which means the plugin resolves, downloads, installs and manages them automatically (see https://github.com/scala-android/sbt-android#usage). This is especially useful if you work for multiple clients that have different SDK requirements. No need to write wrappers around Gradle scripts to run https://developer.android.com/studio/intro/update.html. No need for setup instructions if you hand the project to a colleague.

  Better instant run?
Protify existed before Google released Instant Run and is therefore more stable and mature: https://www.youtube.com/watch?v=LJLLyua0bYA It's so seamless that people use it for live-coding Android apps.

...

And then you have goodies like typed resources: http://scala-android.org/tips_and_tricks-typed_resources/

Or the automated Gradle config import which means you don't need to do configure anything except adding the plugin: https://github.com/scala-android/sbt-android/blob/master/GRA...

Re:Server APIs Project by BoorishBears on Thursday October 27, 2016 @12:36AM (#12802950)
Method count has nothing to do with size.

Look at your own link: Java => 16,306 Scala => 67,608 (Already in multidex territory)

Proguard removes most of those methods, but you'll still need multidex for any non-proguard build like tests and debug builds.

And if you do grow an app past the point of being trivial as that example is Proguard gains will not be nearly as drastic

Multidex on pre-Lollipop ruins app start time, and only very specific types of apps can go to targeting minSdk 21

Predexing with Multidexing and Proguard are also slow for development for non-trivial apps. Your measure of "how long it takes to pick up a phone" is far from scientific", but to compare, not a single app non-trivial app I've worked on is so simple that installing a fully compiled APK over ADB would be less than a 5-10 second process.

That would leave 0-5 seconds for the entire app to build, proguard, and predex (with multidex). Not possible.

Gradle 2.2+ has the SDK download feature, and before that everyone I know was already using "sdk-manager-plugin", not even for convenience on dev machines (it's not that often that SDKs come out after all), but for CI builds.

Protify is not Scala exclusive if one really wants to use it, but JRebel also has a more mature Instant Run solution. Instant Run type features are useful for very specific types of changes that I don't find to be very common anyways. The layout editor + proper use of the edit mode flag and the tools namespace can already reliably replicate half of what I see instant run and co used for, with the added benefit of having even speedier development cycles.

Also: Typed resources are part of Google's databinding library, not that I know anyone who uses findViewById when we have libraries like Butterknife

To me using languages other than Java for Android dev is a risk about balancing mindshare, UX, and continued support for workflows in Android.

Kotlin has mind share, UX doesn't suffer, and it's gotten big enough that while Google has not come out officially and said it's supported, it's mindshare is large enough that Google knows that efforts like Jack and Jill cannot adversely affect workflows (The transformation API is great example, if projects like Realm, Dagger, and co didn't have so much mindshare I doubt it'd be much of a priority for the project).

Scala on Android has a much smaller mind share and is much less proven despite it's maturity, can kill UX a lot easier because of an insanely method-expensive core library which brings in thousands of methods once you use certain features, and is has not gained enough traction to to have to work around Google's plans than with them.

To me the proof is in the pudding, if there were real gains to be had with Scala it'd have more traction than it does.

Re:Server APIs Project by premium-concern on Friday October 28, 2016 @01:08PM (#12818220)

  Method count has nothing to do with size.
Nobody ever said that. It should still be obvious though that 30kB can't even remotely fit the method overhead you are claiming.

  Look at your own link: Java => 16,306 Scala => 67,608 (Already in multidex territory)
I even read it! I suggest you do the same.

  And if you do grow an app past the point of being trivial as that example is Proguard 
  gains will not be nearly as drastic
They are. Been there, done that.

You pay for exactly the stuff you are using, just like with every other library.

  Your measure of "how long it takes to pick up a phone" is far from scientific", but 
  to compare, not a single app[sic] non-trivial app I've worked on is so simple that 
  installing a fully compiled APK over ADB would be less than a 5-10 second process.
Well, it works without issues here. How many apps did you develop with the SBT-Android plugin to be so damn sure about its capabilities?

  That would leave 0-5 seconds for the entire app to build, proguard, and predex (with 
  multidex). Not possible.
Perfectly possible. Used that for a while now.

  To me the proof is in the pudding, if there were real gains to be had with Scala it'd 
  have more traction than it does.
That only seems to be a proof that good marketing is more important than good technology.
Re:Server APIs Project by manojlds on Tuesday October 25, 2016 @10:39PM (#12793495)
Typescript is C# in spirit
Re:Server APIs Project by premium-concern on Tuesday October 25, 2016 @10:50PM (#12793537)
Except IDE and tooling support, maturity and stability, and you can't share any libraries between Typescript and C#.
Re:Server APIs Project by virtualwhys on Wednesday October 26, 2016 @12:35AM (#12793912)
Scala.js is Scala.
Re:Server APIs Project by pjmlp on Wednesday October 26, 2016 @06:44AM (#12795407)
The only Java I have issues with is a fork called Android Java.
Re:Server APIs Project by Cyph0n on Tuesday October 25, 2016 @04:20PM (#12791311)
One benefit Swift has over Scala is that it compiles down to LLVM and is statically linked. I still love Scala though, hands-down my favorite language to work with.
Re:Server APIs Project by paulddraper on Tuesday October 25, 2016 @05:25PM (#12791768)
Scala compiles to LLVM too.

https://github.com/scala-native/scala-native

Though it's experimental (and will likely remain that way for a while).

Re:Server APIs Project by virtualwhys on Wednesday October 26, 2016 @12:47AM (#12793939)
> and will likely remain that way for a while

Not so sure, the alt-Scala train is moving fast (i.e. Dotty, Scala Meta, and Scala Native).

Scala.js is already production ready; come 2019 I'd consider present day Scala deprecated, replaced by Dotty with Scala.js and Scala Native compile targets.

In fact, initial release of the Scala to Dotty Migration Tool[1] is now available

It's happening ;-)

[1] http://scala-lang.org/blog/2016/10/24/scalafix.html

Re:Server APIs Project by paulddraper on Wednesday October 26, 2016 @12:56PM (#12798179)
I base my statement on that fact that it's basically just a student working on it.

Scala.js acquired significant community help because it has some very strong motivation: tons of software is written for browsers, and sans-plugins, browsers only run JS.

Re:Server APIs Project by premium-concern on Wednesday October 26, 2016 @06:11PM (#12801144)
Scala-Native has already a sizable community around it. It got almost 100 PRs shortly after it was published.

Is everything perfect? No! Can you write stuff with it and have it work? Absolutely!

Re:Server APIs Project by erichocean on Tuesday October 25, 2016 @05:42PM (#12791929)
Woah! That's badass. :)
Re:Server APIs Project by Cyph0n on Tuesday October 25, 2016 @07:13PM (#12792613)
I am aware of that, but it's not a fair comparison.
Re:Server APIs Project by paulddraper on Tuesday October 25, 2016 @07:18PM (#12792640)
Also, most Scala deployments are "statically linked", i.e. all JAR/class files are together.
Re:Server APIs Project by Cyph0n on Tuesday October 25, 2016 @07:23PM (#12792662)
Yes, but you need to bundle a JRE and the Scala library (~5 MB).
Re:Server APIs Project by trevor-e on Wednesday October 26, 2016 @12:18AM (#12793845)
I don't know a whole lot about any of this, but isn't Swift's library bundled with iOS apps? Or is that for a different purpose, such as iOS being able to run apps that target different versions of Swift?
Re:Server APIs Project by stiGGG on Wednesday October 26, 2016 @03:48AM (#12794665)
Yes, it's because Swift's ABI isn't stable yet.
Re:Server APIs Project by pjmlp on Wednesday October 26, 2016 @06:45AM (#12795413)
Starting with Java 9 you will be able to trim down the JRE just for your application, with the new introduced linker.
Re:Server APIs Project by pjmlp on Tuesday October 25, 2016 @06:06PM (#12792156)
Any JVM based language can in theory be AOT compiled to native code.

There are quite a few commercial JDKs with option to AOT compile to native code.

Of course, if one wants to stay in the realm of free, the existing options aren't that great.

Re:Server APIs Project by Cyph0n on Tuesday October 25, 2016 @07:27PM (#12792691)
In theory. I've never actually tried Excelsior or any other AOT Java compiler, so I can't comment on that. What I do know is that Swift is free and has first-class support for AOT compilation.
Re:Server APIs Project by pjmlp on Wednesday October 26, 2016 @03:43AM (#12794647)
I think it was an error from Sun not to offer AOT in addition to JIT, but apparently they were religious against the idea, only offering it on the embedded JDKs.

This could have made Java actually relevant on the desktop, ignoring for a second how clueless Sun was about doing good desktop libraries.

However with Java 9 you will be able to use the new Java linker and create you own little VM + AOT startup code.

So that coupled with the large Java eco-system is already good enough for many of us.

Swift does compile to AOT today, but the tooling and libraries outside Apple platforms is almost insignificant, and only good enough for startups willing to bet on it.

Re:Server APIs Project by Cyph0n on Wednesday October 26, 2016 @12:35PM (#12797925)
That Java 9 feature would definitely be amazing. I agree, Swift is nowhere near the maturity of the Java ecosystem.
Re:Server APIs Project by pjmlp on Wednesday October 26, 2016 @01:38PM (#12798610)
The linker part is described in these JavaONE 2016 talks

https://www.youtube.com/channel/UCdDhYMT2USoLdh4SZIsu_1g/sea...

Re:Server APIs Project by Cyph0n on Wednesday October 26, 2016 @05:43PM (#12800916)
Thanks for that. Are you aware of any numbers on the size savings you get for a typical app using jlink?
Re:Server APIs Project by pjmlp on Thursday October 27, 2016 @04:28AM (#12803613)
No, as I am yet to play with it.

So far I only seen the presentations.

But looking at Java 8 on this PC I would say:

jvm.dll (8 MB) + main.exe (200 KB) + trimmed down JRE

Also notice that from the presentations they have some experimental support for jlink plugins, which can further shrink down the size.

Re:Server APIs Project by jorgengorg on Wednesday October 26, 2016 @12:29AM (#12793890)
Can you explain why this is such a significant benefit? Honest question.
Re:Server APIs Project by Cyph0n on Wednesday October 26, 2016 @08:00AM (#12795720)
With Scala, if I want to build a distributable application, I need to bundle a JRE and the Scala library, which means that a "Hello World" installer would be around 30 MB in size. It's bad practice to assume that your user has Java installed.

With compiled languages like Go or Swift, that same application now is 2 MB or so. On top this, the application runs natively on the OS since it is compiled to LLVM.

Re:Server APIs Project by premium-concern on Wednesday October 26, 2016 @08:19AM (#12795822)
Same with Scala.
Re:Server APIs Project by Cyph0n on Wednesday October 26, 2016 @08:29AM (#12795881)
If you're talking about the currently very experimental Scala Native, my response is that comparing such a fledgling implementation to languages built from the ground up for AOT compilation and static linking is just silly.

If not, please explain.

Re:Server APIs Project by premium-concern on Wednesday October 26, 2016 @08:46AM (#12795978)
I don't think it is vastly different from Swift.

In Scala the language is stable, the std lib is stable and the runtime is being worked on, in Swift the language is changing heavily, the libraries are under development, but the runtime might be slightly ahead. (If one can describe reference counting as "ahead".)

Re:Server APIs Project by tormeh on Tuesday October 25, 2016 @04:11PM (#12791241)
Swift was influenced by Scala, so that's no surprise.
Re:Server APIs Project by desdiv on Tuesday October 25, 2016 @04:35PM (#12791434)
Re:Server APIs Project by yvsong on Tuesday October 25, 2016 @05:13PM (#12791690)
The comparison should be updated to Swift 3. Swift syntax is more intuitive and readable than Scala. A common mistake in language design is to depart from C syntax, without substantial gain. For example, replacing {}, &&, || with other things. Swift strikes a great balance between intuition and innovation.
Re:Server APIs Project by premium-concern on Tuesday October 25, 2016 @07:28PM (#12792699)
> Swift syntax is more intuitive and readable than Scala

Example?

Re:Server APIs Project by manojlds on Tuesday October 25, 2016 @10:44PM (#12793508)
And scala doesn't have {}, &&, || ?
Re:Server APIs Project by chris_7 on Tuesday October 25, 2016 @05:09PM (#12791663)
Some of these comparisons aren't great. The "Variable Number Of Arguments" example is better expressed in Swift with "reduce", and it's really comparing "summing an array", the varargs aspect is a minor detail of the example. The "Idiomatic Scala" example doesn't even declare a function with varargs! (yes, it uses one, but that's not really the point)

The Swift function in the protocols example doesn't need to be generic, as the protocol doesn't have any associated types, and really ought to be a protocol extension regardless.

Re:Server APIs Project by tormeh on Tuesday October 25, 2016 @04:43PM (#12791506)
Wow. They're basically identical. Scala has a bit less boilerplate sometimes, but it's also older, so I guess Swift will get syntactical sugar to catch up in time.
Re:Server APIs Project by melling on Tuesday October 25, 2016 @04:57PM (#12791589)
Re:Server APIs Project by vorg on Tuesday October 25, 2016 @06:09PM (#12792177)
Neither Scala nor Apache Groovy are listed in the 8 languages Swift was influenced by on its Wikipedia page. That Groovy link was written by the Apache's Groovy PMC chairperson, and is more wishful thinking that fact.
Re:Server APIs Project by melling on Tuesday October 25, 2016 @07:33PM (#12792731)
Yeah, I already knew what Wikipedia said. My point was that a lot of languages look similar.

Scala might have influenced Swift. Zip you go to the author's blog, he says lists those languages and says many more that he doesn't name:

http://nondot.org/sabre/