News for hackers. Stuff that matters.
Re:Scala 3.0 by acjohnson55 on Friday May 14, 2021 @08:09AM (#27153342)
I'm so psyched about this. I've followed the development of Scala 3 for pretty much the whole voyage, and I think they've done an incredible job bringing the community along through some pretty radical changes to the language. It has definitely not been an easy process herding a community with very big, informed, divergent opinions on the language.

In the end, I think they did an awesome job. Many, many sacred cows of old Scala were confronted. I think the result is a much more approachable language, where simple things are easier.

Re:Scala 3.0 by agbell on Friday May 14, 2021 @08:50AM (#27153670)
I totally agree. I love the direction of Scala 3. This quote says it all I think:

"Scala 3 takes a slightly different approach [from Scala 2] and focuses on intent rather than mechanism. Instead of offering one very powerful feature, Scala 3 offers multiple tailored language features, allowing programmers to directly express their intent"

So rather than something like implicits, that can be used N different ways, only 2 of which are practical, Scala 3 adds those 2 features explicitly.

https://docs.scala-lang.org/scala3/new-in-scala3.html

Re:Scala 3.0 by swader999 on Friday May 14, 2021 @10:10AM (#27154514)
The days I spent chasing implicits are still lost to me forever.
Re:Scala 3.0 by darksaints on Friday May 14, 2021 @10:17AM (#27154592)
They should have never been a language feature before IDEs were capable of working with them and exposing them. Luckily they do now...but Scala 3 makes it so that understanding them with a simple text editor is much easier. The fact that they have to be imported in a way that acknowledges their usage is a simple but important way to ease that burden, and the distinction between `given` and `using` is extremely helpful for understanding them.
Re:Scala 3.0 by agbell on Friday May 14, 2021 @10:31AM (#27154731)
Rumor has it Kotlin was inspired by frustrations getting Scala edge cases to work in IntelliJ.
Re:Scala 3.0 by valenterry on Friday May 14, 2021 @12:23PM (#27156037)
I don't believe that this is true. Because, one can just write simple Scala and has pretty much everything that Kotlin has (minus its nullability magic) and never deal with these edgecases. Even compiletimes are decent then.

But with Kotlin, it is actually enforced that the more advanced features of Scala are not available, so it makes sure that compiletimes etc. stay short. It also simply reduces the burden of the IntelliJ devs, because it's not just "Language -> IDE" but IDE capabilities impact how the language is designed too. And having a good IDE is very important for productivity.

Re:Scala 3.0 by adamgordonbell on Friday May 14, 2021 @02:08PM (#27157639)
I love Scala.

The thing is as an IDE author you can't just "write simple scala" because you aren't the author, you are the IDE. You have to be able to offer your refactoring tools and other tooling for all of it and cover all the edge cases.

LSPs do remove this problem to a large extent though.

Re:Scala 3.0 by valenterry on Saturday May 15, 2021 @12:03AM (#27162251)
I think I understand your posting now - what you are saying is exactly what I mean, but it's of course only true for IDE developers.

And actually, I'm not sure if LSPs help so much. To my knowledge, IntelliJ still uses its own compiler to support the user at least partially of the code is incorrect and doesn't compile.

Re:Scala 3.0 by ovis on Friday May 14, 2021 @06:46PM (#27160468)
Do you think IDEs would have grown support for them before they were a language feature?
Re:Scala 3.0 by darksaints on Saturday May 15, 2021 @10:12AM (#27165397)
There are plenty of IDE features that get released at the same time as a language feature, or shortly thereafter. Implicits were not like that.
Re:Scala 3.0 by seertaak on Saturday May 15, 2021 @02:19AM (#27162892)
I'm a programming language design geek... Out of curiosity, could you explain some of the ways you've been bitten by implicits?
Re:Scala 3.0 by alexfoxgill on Saturday May 15, 2021 @04:18AM (#27163414)
I will never forget the hours I lost debugging an issue where I had not realised that if you declare any variable in scope that coincidentally has the same name as an implicit that you're relying on, the implicit will be shadowed and unable to resolve. Of course, it 'makes sense' when you consider that you would be unable to refer to it by name explicitly... But if you're not using the name, the fact that it can have an impact on visibility is pretty confusing
Re:Scala 3.0 by nautilus12 on Friday May 14, 2021 @10:30AM (#27154726)
I always felt like implicits were a weaker design in the language, glad to see they put some more thought behind it.
Re:Scala 3.0 by acjohnson55 on Thursday May 20, 2021 @10:57PM (#27230009)
It was a brilliant concept, but the ergonomics weren't great. It was like working with the lambda calculus. Sure, you can literally model anything, but it's not intuitive to most people.
Re:Scala 3.0 by Buttons840 on Friday May 14, 2021 @11:53AM (#27155579)
What's an example of something they made more approachable?

One of my first impressions of Scala, which I have barely seen, and do not know, is that there is a lot of syntax. Has anything been done to help with that? I don't think syntax matters much, but it's one of the only impressions I have of the language and wanted to ask about it.

Re:Scala 3.0 by peq on Friday May 14, 2021 @01:52PM (#27157404)
Scala is one of the smallest typed languages in terms of syntax.

See slide 13: https://www.slideshare.net/Odersky/preparing-for-scala-3#13

With scala 3, syntax has been simplified even more, e.g.:

No more braces necessary. Top level declarations. Extension Methods.

Re:Scala 3.0 by stock_toaster on Friday May 14, 2021 @02:42PM (#27158144)
> No more braces necessary

Optional braces seems like a weird feature to me. I would prefer consistently. I think a language should either be "bracey" or not. Just pick one!

Re:Scala 3.0 by harveywi on Friday May 14, 2021 @03:26PM (#27158681)
I personally wanted to be able to use underscores instead of braces.
Re:Scala 3.0 by oxnrtr on Friday May 14, 2021 @03:09PM (#27158467)
Joking? Scala 3 added 20 keywords (14 of them contextual), many of them with entirely new syntactic constructs behind it.
Re:Scala 3.0 by phillipcarter on Sunday May 16, 2021 @01:35PM (#27175392)
> Scala is one of the smallest typed languages in terms of syntax.

Eh, that slide isn't really worth looking into. None of the languages there have a uniform way to represent the grammar. If you look at the C# and Scala grammars you'll find that the Scala one is highly compacted, whereas the C# grammar is intentionally not compact. They're encoded in different formats.

Re:Scala 3.0 by cbolton on Sunday May 16, 2021 @04:40AM (#27172208)
I think "lots of syntax" means many rules to learn, rather than many characters to type. So this change means even more syntax.
Re:Scala 3.0 by OOPMan on Friday May 14, 2021 @12:12PM (#27155871)
That's an interesting take, as someone that's used Scala for a while I feel like there actually isn't that much syntax.

I guess my perception is warped :-)

Re:Scala 3.0 by patrickthebold on Friday May 14, 2021 @01:59PM (#27157516)
Scala has a lot of 'sugar':

f(...) becomes f.apply(...)

matching calls unapply with some various binding.

Some parenthesis are optional: Some(1,2,3) is Some((1,2,3))

optional . so a + b is a.+(b)

colon changes associativity, so a +: b is b.+:(a)

for expressions become, map, flatMap, filter, withFilter and forEach, according to various rules.

def f[A: B]() adds an implicit parameter of type B[A]

I'm sure there's more but that's the top of my head. Of course it's not actually a long list, but none of that is obvious for a newcomer.

Re:Scala 3.0 by nikitaga on Friday May 14, 2021 @04:43PM (#27159473)
The fact that you can make any instance callable like a function by adding an `apply` method to it isn't just "syntax sugar", it's a pretty fundamental mechanic of FP-OOP fusion that Scala is built around. Same for `unapply`.

At any rate none of this "sugar" was a problem to anyone I know who learned Scala. There are harder things about it than learning basic syntax.

Re:Scala 3.0 by dyadic on Friday May 14, 2021 @05:43PM (#27160034)
It’s a long time since I used scala and none of this was ever a direct problem, but it was all extra complexity. I think there’s a split between people that appreciate sugar and people that find it not worth the additional complexity.

That problem does lessen with familiarity, but knowing a lot of complexity makes me wary of unknown complexities. It adds an overhead which takes energy that could be better utilised elsewhere.

Re:Scala 3.0 by nikitaga on Saturday May 15, 2021 @05:10AM (#27163625)
If you don't need that "complexity" (I wouldn't call it that), you can use a pure FP or a pure OOP language that will be simpler, smaller, but more restrictive and less expressive. That's a matter of preference of course.

But Scala's syntax and language features are great when you actually make use of them to accomplish your goals, especially so with Scala 3. The syntax isn't excessive or frivolous or nonintuitive. It's a pretty straightforward encoding of the desired feature set of the language.

Re:Scala 3.0 by patrickthebold on Friday May 14, 2021 @08:47PM (#27161207)
Why do you consider it fundamental? Are there examples where it fundamentally does more than saving you from typing out the canonical method name? (This is for `apply`, I agree that match with unapply is actually language syntax and not sugar.)
Re:Scala 3.0 by nikitaga on Saturday May 15, 2021 @12:54AM (#27162496)
Because it enables an equivalence between functions and objects. Not a technical one that's hidden deep in the implementation, but a practical one that's apparent to library authors and users.

If you want to make any object `foo` callable with first-class application syntax, i.e. `foo(bar)`, you add an `apply` method to that `foo`. You don't need to bother extending Function, you don't need to come up with a method name and call that. When you call `foo()`, you don't know if `foo` is a function or an object, and you don't care. You can find out easily with a half decent editor of course, but the point is, you're free to mix objects and functions as you wish, the language does not get in your way.

And for all that it provides, it's a complete non-issue in terms of learning curve. It's a basic language feature that you learn once and are never impeded by thereafter.

Re:Scala 3.0 by yawaramin on Saturday May 15, 2021 @02:47AM (#27163013)
> Some parenthesis are optional: Some(1,2,3) is Some((1,2,3))

There's a compiler warning against this syntax that everyone should really enable.

Re:Scala 3.0 by valenterry on Friday May 14, 2021 @12:25PM (#27156052)
I agree. But Scala still does certain things different, so to a Java or python dev it _looks_ as if there is a lot of syntax. Just like Haskell looks strange when you look at it for the first time.
Re:Scala 3.0 by tormeh on Friday May 14, 2021 @07:52PM (#27160905)
I don't think people object to the language syntax itself, but rather the unfamiliarity and randomness of language conventions. Haskell/Perl/K/Scalaz is full of line noise I can't be bothered to learn, for example