News for hackers. Stuff that matters.
Re:Some Memories of Niklaus Wirth by Martin Odersky by santiagobasulto on Wednesday January 17, 2024 @06:27AM (#39026334)
For the unaware: Odersky himself is a “modern day Wirth”. Amazing language designer. He’s responsible for generics in Java and the Scala language.
Re:Some Memories of Niklaus Wirth by Martin Odersky by nickpeterson on Wednesday January 17, 2024 @07:03AM (#39026599)
It’s interesting that odersky helped put generics in Java and also made Scala. Don Syme helped put generics in .net, and then made F#. It feels like two people on a very similar trajectory.
Re:Some Memories of Niklaus Wirth by Martin Odersky by mjburgess on Wednesday January 17, 2024 @07:21AM (#39026730)
The question, "how do we make functional languages popular, (useful?) in the enterprise?" was a question in the air for, i'd, say decades. The 00s answer was to create a merger between enterprise langs (Java, C# etc.) and functional langs in a new language.

The net result, as we know now, was to push those langs to adopt functional features -- rather than to shift to others.

I suspect the question for the niche programming community, of the next decade, will be "how do we make effect systems popular?" or some such thing.

Or, "how do we make AOT metaprogramming popular?" etc. (cf., jai, zig... carbon, circle, ...)

I suspect if a post-C++ new-wave gets popular, with structural typing and ct metaprogramming, we might see the same in C# quite easily

Re:Some Memories of Niklaus Wirth by Martin Odersky by pjmlp on Wednesday January 17, 2024 @07:37AM (#39026880)
You already get them with code generators and Rosylin, but it is a bit painful to use.
Re:Some Memories of Niklaus Wirth by Martin Odersky by SideburnsOfDoom on Wednesday January 17, 2024 @08:46AM (#39027583)
There is also a new compiler feature, "interceptors" that swaps in calls at compile-time. https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/cs...

This looks very hard to use well, but that's because "it's not for you" to use directly in app code, rather it's a low-level building block for such AOT and code generation patterns and toolkits.

Re:Some Memories of Niklaus Wirth by Martin Odersky by pjmlp on Wednesday January 17, 2024 @09:10AM (#39027866)
I hate it, as it is a bad approach to what should have been a proper AOP framework like PostSharp or Microsoft Fakes.

Instead we will end with a special cased mini framework, designed to override reflection code for the purposes of AOT code generation.

Something that AOT toolchains for Java have solved much better with agents, PGO and config files.

From my point of view, it is neither a good approach to sort that out, nor a good AOP alternative.

Re:Some Memories of Niklaus Wirth by Martin Odersky by gfraiteur on Thursday January 18, 2024 @02:15PM (#39046246)
Agreed. Roslyn analyzers, code generators, refactoring providers and other extension points are not designed for application developers but are rather building blocks.

We built a code generation and analysis framework based on these Roslyn extension points. It's called Metalama: https://doc.postsharp.net/metalama.

Re:Some Memories of Niklaus Wirth by Martin Odersky by santiagobasulto on Wednesday January 17, 2024 @10:39AM (#39029198)
I didn't know Syme helped with generics in .net. Very interesting indeed.

I think it makes sense for these people to create their own "perfect" languages. I'm not aware of C#, but I know (or knew) Java very well. And Generics always was a half-baked option for a broken language.

From a purists' perspective, in Java "everything is an object", except ints or floats, but we have Integer or BigInt, but then we have `null`, but then... if Integer extends from Number, does that mean that a List<Integer> extends from List<Number>? Nobody knows...

Those things are what I feel Odersky wanted to solve and couldn't with Java, so he went "Bender Style".

Re:Some Memories of Niklaus Wirth by Martin Odersky by throwaway89988 on Wednesday January 17, 2024 @10:30AM (#39029055)
Sorry, but Odersky is nothing like Wirth.

Scala failed hard because it is kitchen sink of every half baked feature someone wanted to write a PhD thesis about. The graphs of the interdependencies of the standard library are an excellent example of a totally insane design, the Scala data structures have been at least an order of magnitude slower than the JVM native ones. Don't get me started about the tooling, which is too slow for any real world projects. (The only ones I regularly see to use Emacs are Scala developers, because opening projects in an IDE like IDEA could take up to 30 min on high end workstations.)

Wirth valued clean design, speed and simplicity. Odersky wants to compete with C++ for complexity. As the article stated, for Wirth a feature would have to pay for itself regarding complexity, speed and usability. If someone can demonstrate how Scalas features came to pay for themselves, I would appreciate a pointer.

Finally... generics in Java are a shit show, thanks to type erasure. Fair enough, Odersky was probably forced for this implementation, thanks to backwards compatibility, still, nothing to be proud of.

Re:Some Memories of Niklaus Wirth by Martin Odersky by bombcar on Wednesday January 17, 2024 @01:53PM (#39031799)
This all sounds right to me - scala needs first class support for what it is doing in the JVM itself - which it doesn’t have. Trying to ASM scala is a pain.
Re:Some Memories of Niklaus Wirth by Martin Odersky by kagakuninja on Wednesday January 17, 2024 @02:35PM (#39032335)
Type erasure is an interesting discussion, because functional programmers love type erasure. Consider the function:

    def foo[T](t: T): T    
If the function is truly generic, then we know nothing about the implementation details of T. The only meaningful implementation of foo is identity:

    def foo[T](t: T): T = t
From a FP perspective, T should be erased, and the programmer should not cheat and use reflection. The type signature should tell you much about what the function does.

I've used Scala professionally for the last 8 years. The tooling is fine, assuming you avoid exotic libraries like Shapeless. Compile times are fast enough that I don't think about it much, using IntelliJ incremental compilation. A full recompile of a micro service might take 30 seconds, whatever it is is not a big deal IMO.

> opening projects in an IDE like IDEA could take up to 30 min on high end workstations

This is insanely wrong. Maybe you are operating on experiences from 10 years ago? I have a new M2 MacBook Pro, and opening projects is quite fast. The first time you do it, it will resolve the SBT dependencies and index files. That can be done in the background, and is probably less than a minute for a typical project. Even my previous laptop could open projects quickly despite being 3 years old.

> the Scala data structures have been at least an order of magnitude slower than the JVM native ones

They are slower, but not an order of magnitude slower. Perhaps you are remembering the infamous email from the Yammer CTO that got leaked, but that was a long time ago, and the compiler and libraries have improved greatly since then.

But yes, in performance critical code, you can just switch to an imperative style and use Java collections.

I don't have time to explain the benefits of Scala features, but I'll just point out that other than implicits, many ML inspired features of Scala have made their way into modern languages, including Java, C#, Rust and Swift. Scala didn't invent those ideas, but repackaged them in a novel way.

Re:Some Memories of Niklaus Wirth by Martin Odersky by throwaway89988 on Thursday January 18, 2024 @10:40AM (#39043083)
IMHO the keyword is 'microservice': Compile times of 30sec for a microservice are not acceptable for me, btw. The projects I am referring to were bigger, and the time to compile/open projects in IDEA where _not_ acceptable at all. (Btw.: I am speaking about Scala experts, not some new grads which didn't know what they were doing.)

Concerning your type erasure example, the id function obviously doesn't need to know anything about types. In the real world, types have traits/interfaces/expected attributes etc. and type erasure prevents the compiler to verify this when using binary dependencies, which is obviously _not_ what one wants in a statically compiled language.

Re:Some Memories of Niklaus Wirth by Martin Odersky by kagakuninja on Thursday January 18, 2024 @02:05PM (#39046130)
I just compiled our oldest, largest micro service, it was 17 seconds. This is a full recompile, which I rarely need to do, because IntelliJ has incremental compilation. If you have a giant mono-repo, then compile time becomes important.

I can only guess what these "Scala experts" were doing, there are certain language features that can slow your compile times, and libraries like Shapeless that leverage those features in amazing ways, but can kill your compile times.

Scala is a toolkit that enables amazing things, but you have to understand the trade-offs, both in terms of compile time, and understandability of the code.

>In the real world, types have traits/interfaces/expected attributes etc. and type erasure prevents the compiler to verify this when using binary dependencies, which is obviously _not_ what one wants in a statically compiled language.

Scala has ways of recovering the information, such as using context-bounds and type manifests. Scala can actually verify an amazing amount of constraints at compile time, but the more exotic tricks will increase compile time.

What you are complaining about are foot-guns that rarely happen in my 20 years experience with JVM languages (I think generics were added in Java 5, but still...)

Re:Some Memories of Niklaus Wirth by Martin Odersky by switchbak on Wednesday January 17, 2024 @06:32PM (#39035167)
Come on now, Scala has its issues, but statements like "because opening projects in an IDE like IDEA could take up to 30 min on high end workstations" are just not true unless your project is straight up broken.
Re:Some Memories of Niklaus Wirth by Martin Odersky by dragosiulian on Thursday January 18, 2024 @03:59AM (#39039563)
> it is kitchen sink of every half baked feature someone wanted to write a PhD thesis about.

Having been a PhD student in his lab between 2005-2010, I can attest that's not true. Language design was definitely Martin's prerogative. As a PhD student, a lot of time went into implementation efforts, and while several features did end up in PhD theses, the last word on what goes in the language was Martin's.

Scala was ultimately a research project, with ambitions to succeed outside of academia. As such, some ideas worked better than others (pattern matching and case classes vs specialization). As it became clear that the language was picking up in the industry (lead by Twitter around 2008), many of these experiments moved into compiler plugins, macro libraries or research forks.

> Sorry, but Odersky is nothing like Wirth.

I haven't known Wirth to venture into such broad statements, but given what's been written about the way he lead his lab, I would say there were many similarities: a strong bias for solid implementation work, the (bootstrapping) compiler as a litmus test for features or performance work. And yes, a focus on simplicity.

Unfortunately, simplicity is often confused with familiarity. What's simpler: having statement and expressions as separate concepts that don't mix well, or only expressions? Most people coming from C and Java would have internalized the dichotomy and find it (or at least, back in the day, found it) "complex" to think of every expression having a type ('void' vs 'Unit'). The same goes for the split between primitive and reference types vs a unified type hierarchy.

This is not to say Scala doesn't have its warts, and implicits (in particular, implicit resolution rules) combined with macros could lead to a lot of pain. Hopefully there are lessons learned there and Scala 3 is better.

> Scala failed hard

Far from obvious. Databricks has probably upwards 10MLOC of Scala code, and seem to be doing very well (https://www.lihaoyi.com/post/TheDeathofHypeWhatsNextforScala...). Plenty other examples.

Could Scala have been more successful? Undoubtedly. But it's far from a "hard failure". New languages have adopted many Scala features, so nowadays Scala is believed to pay for itself only when using pure-FP libraries. That's very unfortunate if you ask me, since I believe there's a pragmatic sweet spot that lies around the style best illustrated by Haoyi Li's ecosystem of libraries.

Re:Some Memories of Niklaus Wirth by Martin Odersky by throwaway89988 on Thursday January 18, 2024 @10:58AM (#39043332)
Thanks for the inside story.

Let me elaborate: Scala failed hard in the sense, that it was IMHO a far superior language compared to Java around 2010 (! JDK 7/8 times) and basically is dead now for new projects (unless there are some die hard Scala fanatics on a team, and even they are moving for greener pastures), also see how Kotlin succeeds everywhere at the moment.

What I totally don't get is, that Scalas failure was _not_ surprising at all, and there were a lot of kind people giving constructive feedback, why Scala fails in the industry (example: https://gist.github.com/alexo/1406271):

- Slow compile times - No binary compatibility even between minor updates - Every feature under the sun was stuffed into Scala, making it impossible to transfer projects to 'industry programmers' w/o too extensive training - Tooling support (like IDEs) was extremely lacking/slow/bad - Not to speak about the community infights about the right way(TM) to approach a problem

Personal experience from me: Scala was too slow/cumbersome to use with subpar tooling. And I consider myself a target group: In love with FP but forced to deploy on the JVM. Besides my own experience, I saw teams of Scala developers fail to materialize any significant benefit in real world projects over 'dumper' programming languages, not even speaking about transferring Scala projects to non academic 'elite' teams.

I like some ideas in Scala 3 and IMHO it is sad that Kotlin (which is IMHO just syntactic sugar over Java) gets so much attention, but in the end Scala hat plenty of years to fix its problems and its failure comes as no surprise, because there was plenty of feedback. Are there still some Scala projects around? Yes, mostly Scala 2 because, surprise, libraries still don't have binary compatibility etc. For Scala 3 I have neither seen industry adaption or any enthusiasm from a wider community.

Re:Some Memories of Niklaus Wirth by Martin Odersky by geodel on Wednesday January 17, 2024 @12:07PM (#39030433)
So modern day Wirth is quite different from antiquity Wirth. Java generics are quite complex they have multi hundred pages books to explain it all. Scala a really clever language, perfect for 1 line code doing 50 line equivalent of Java code. Slow compile times and immature tooling is another important feature of Scala.
Re:Some Memories of Niklaus Wirth by Martin Odersky by kagakuninja on Wednesday January 17, 2024 @02:40PM (#39032394)
Current Scala compile times really aren't that bad. Yeah, Go will be 10x faster, but then you have to use Go...

For a typical micro service, I never think about compile time, thanks to incremental compilation. Even a full compile is not bad. Tooling is also fine, although Scala 3 set things back. IntelliJ now supports Scala 3 adequately.

Re:Some Memories of Niklaus Wirth by Martin Odersky by geodel on Wednesday January 17, 2024 @05:08PM (#39034230)
Well, its like one can always tolerate shortcomings when they like something/someone. Reasons can always be added later for liking something but rarely other way around.
Re:Some Memories of Niklaus Wirth by Martin Odersky by kagakuninja on Thursday January 18, 2024 @01:52PM (#39045950)
Look, I've been using Scala professionally for 8 years. I don't notice that my compile times are any slower than Java, although I haven't tried any meaningful comparison. There are some notorious libraries like Shapeless than can kill your compile times; the solution is to not do that, unless the trade off is worth it to you.

It could be x1.2 slower, maybe even 2x, and I wouldn't notice it, because it is fast enough. IntelliJ has incremental compilation. Compile times only matter when I do a full rebuild, and it is still fast enough.

If I had to build a giant mono-repo like at Google, then the compile speed of languages like Go become important.

Re:Some Memories of Niklaus Wirth by Martin Odersky by jll29 on Wednesday January 17, 2024 @05:08PM (#39034233)
There was a language called Pizza that Odersky wrote while in Karlsruhe (before moving to EPFL Lausanne), and that became part of "standard" (not as in ISO, but as it SUN-approved) Java as "generics".

https://en.wikipedia.org/wiki/Pizza_(programming_language) https://www.reddit.com/r/scala/comments/8c7h8f/history_the_p...