5 ms·
Great Analysis! I agree that languages are becoming more like Scala. I'm not sure about the JIT part though. Aren't many of the recent language success storie
by agbell 6y ago
Great Analysis! I agree that languages are becoming more like Scala.
I'm not sure about the JIT part though. Aren't many of the recent language success stories now about AOT compiled languages like Go, Rust and Swift?
- mark_l_watson 6y agoI am working on an AI book using Swift. Yesterday in a meeting, my manager was asking why Swift. I compared it to Scala, but built on LLVM, and a rich CoreML and other library infrastructure. REPL + closures, very fast build times. I haven’t had much opportunity to use Scala, but I did take Martin’s Functional Programming with Scala course years ago, and that was great.
- agbell 6y agoScala is a great language. I haven't done that coursera course, but many people swear by it. To me, Swift and Kotlin look like they have taken inspiration from Scala. I think Kotlin explicitly did. That idea transfer from one area to another is how we get better langauges.
- zepto 6y agoHaving programmed professionally in both Scala, and Swift, and enjoyed both, I can see basically nothing that Swift takes from Scala. The common ancestor is OCaml, and the ML languages in general. To be fair, that may change as Swift adopts Actor based concurrency.
- asimpletune 6y agoI wish swift were like Scala. It attempts to look and feel like it, but there’s one huge aspect of Scala that is missing in swift that basically makes swift a world apart, which is expressions vs statements. In Scala everything is an expression, meaning everything evaluates to some result even if that result is void. In swift everything is a statement. There’s a big difference because statements don’t return things, only functions do. It sounds minor, especially since swift has pattern matching and first class supper for functions etc, but the truth is these are all improvements over a more oop (in the Java sense) way of programming. They don’t however make the languages very similar because at a more basic so level they’re very different. I would even go as far as to say that rust is more like Scala than swift is, although it’s been a while since I coded in rust.
- ebruchez 6y ago> In swift everything is a statement. There’s a big difference because statements don’t return things, only functions do. That sounds absolutely awful.
- asimpletune 6y agoIt’s such a small, non-flashy language feature, that honestly matters much more than almost everything else.
- yw3410 6y agoComplete aside, but how is Swift these days? I used it literally a week after release and promptly stopped because the compiler kept segfaulting - I imagine it's more stable now?
- darksaints 6y agoThere are very few optimizations that a JIT can improve over a static compilation of a strongly-typed language. Strong typing brings immense capability for static analysis and subsequent optimizations. The most successful JIT optimizations out there typically are ones that make dynamic languages about as fast as statically typed languages by making assumptions about the runtime types of objects, while trapping/reoptimizing when those assumptions don't hold true. It also does pretty well finding hot loops and selectively optimizing those, but PGO gives you that too without any performance hit in your final executable. A strongly typed language like Scala has the potential for massive optimizations under the whole program optimization umbrella...and no JIT would ever dare to try those types of optimizations, because they are extremely memory and compute intensive. They'd have to pause execution for minutes at a time just to figure out what to do. I think it is unfortunate that Scala was designed for the JVM first. It brought a lot of syntactic baggage for interop purposes, and it saddled it with weird things like reflection and dynamic class loading, making it hard to statically compile. The ideas behind scala's type system are extremely powerful and could have fundamentally changed programming for the better, but all we got was a JVM me-too that was quickly usurped by Kotlin. I don't think it is dead or a lost cause...but the legacy that the JVM has on Scala is one that slowed it down, not sped it up (like what was claimed would happen with JVM languages).
- agbell 6y agoI agree that a AOT scala would be great. But don't JITs have the ability to react to real world usage and do hotspot optimization and stuff. I assume they are very complicated to build, and if you do thing ahead of time you should, but aren't the things that can only be done in a JIT important?
- kaba0 6y agoIt’s not as black and white. What about GC, compacting objects and the other myriad of optimizations the JVM does? I do want to mention that I am not overly knowledgeable on these topics, only really interested in compiler technology, but a program compiled with PGO will have to add code for each specialized function, won’t it? So perhaps not every sort of application would win by PGO AOT compilation; a structure over the running code, and manipulations over it are a great and powerful idea. But I do agree that Scala in the early years did have some ugly artifacts from compiling to the JVM and trying to remain a “good citizen“ there, not sure about current trends.
- ebruchez 6y ago> Aren't many of the recent language success stories now about AOT compiled languages like Go, Rust and Swift? Scala also has Scala Native which, well, compiles to native. It's not yet as polished as Scala JVM and Scala.js, but the plan is to make it so. https://scala-native.readthedocs.io/en/v0.4.0/ https://scala-native.readthedocs.io/en/v0.4.0/
- dboreham 6y agoScala is AOT. The JIT part is just to speed up execution of the machine code its compiler targets, it not being the native ISA typically.