Live data from Hacker News

Scala 3.0

github.com

261–270 of 292 posts

Re: Scala 3.0

#261
post #220
post #97

Scala 3 + VS code + worksheets is my favourite exploratory programming environment. Its has: * Powerful functional features * Powerful OO features * Imperative features * Powerful type system * Great stdlib * Great syntax * Very fast write/test cycle with worksheets, way better than a REPL * Great IDE features such as autocomplete Scala may not be the best on any one axis, but the combination is unparalleled.

I don't know what worksheets are, but does Scala3 work with vscode now? Previously the plugins didn't do much, especially if you didn't use SBT.

The Scala/vscode story is pretty good now. [0]

[0] https://scalameta.org/metals/

Re: Scala 3.0

#264
post #230

Earlier quoted context omitted.

> Java misses the syntactic sugar to define ADT in one place like in Standard ML, OCaml or F#. I don't think so. > I was not able to define a classical list with cons and nil in Java. If you want to restrict Nil to a single instance, don't make it a record class: sealed interface List { static List cons(T car, List cdr) { return new Cons (car, cdr); } static List nil() { return (List )Nil.INSTANCE; } record Cons (T c…

Pattern matching does not work if you use an enum List list = cons("a", nil()); switch(list) { case Cons (var car, var cdr) -> ... case Nil -> ... } Nil is typed List which is not compatible with List . You may be able to use extractors as the inverse of the static methods cons() and nil() but that adds more boilerplate. Disjunctive enums like in Rust or Scala 3 is a simpler way to define ADT.

Pattern matching will work fine with an additional explicit nil() pattern. I agree that in this particular case it's not quite as succinct as in more functional languages, but virtually all cases in ordinary business applications are not like that, and the additional code, if any, is O(1).

Of course, Java could add rules for the special case of zero-argument records, making them more enum-like, but I really think the value in doing that is negative. Other than being able to directly translate ML examples, it would add complexity that isn't worth it.

In fact, in this particular case I'd do it like so:

    record List(T car, List cdr) {
      public List { if (car == null) throw new IllegalArgumentException("null element"); } 
    }
Which would give you:

    switch(list) {
      case List(var car, var cdr) -> ...
      case null -> ...
    }
It might not be exactly what people who like Scala might prefer, but it is very much a good representation of ADTs for those who prefer Java.

Re: Scala 3.0

#265
post #232

Earlier quoted context omitted.

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.

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 el…

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

#266
post #218
post #97

Scala 3 + VS code + worksheets is my favourite exploratory programming environment. Its has: * Powerful functional features * Powerful OO features * Imperative features * Powerful type system * Great stdlib * Great syntax * Very fast write/test cycle with worksheets, way better than a REPL * Great IDE features such as autocomplete Scala may not be the best on any one axis, but the combination is unparalleled.

Can you talk a little more about worksheets? I'm not familiar with scala worsheets at all. Follow-up: How do you transition to productionizing your code after iterating in them?

Worksheets are a simple concept: you write lines of code in them, and the IDE runs the code automatically as you type, and displays the return value of each line. If you're familiar with the concept of Jupyter notebooks, it's a bit like that.

I tend to not view it as a replacement for an ordinary code file, but as a replacement for a REPL session. It has several advantages:

* Keeping track of your previous commands in a file is much more convenient than keeping track of it in your input history of the REPL.

* You can keep re-editing previous lines easily, and you can see the output of all lines.

* There is no hidden state (unlike a REPL). Everything is run from scratch every time.

* It's easier to define helper functions than in a REPL.

* It's easier to turn a worksheet into a unit test than it is to turn a REPL session into a unit test.

That said, it's also possible to start writing a module in a worksheet, and then turn it into an ordinary code file later.

Worksheets aren't perfect yet; I can think of many improvements, but they're already very useful to me. I think the end game will be to merge the concept of worksheet, unit test, debugger, printf debugging, and ordinary code file into one system, like Sean McDirmid's usable live programming research work (which in my opinion remains one of the most underrated research projects).

https://www.youtube.com/watch?v=01Xyoh-G6DE

Re: Scala 3.0

#267
post #220
post #97

Scala 3 + VS code + worksheets is my favourite exploratory programming environment. Its has: * Powerful functional features * Powerful OO features * Imperative features * Powerful type system * Great stdlib * Great syntax * Very fast write/test cycle with worksheets, way better than a REPL * Great IDE features such as autocomplete Scala may not be the best on any one axis, but the combination is unparalleled.

I don't know what worksheets are, but does Scala3 work with vscode now? Previously the plugins didn't do much, especially if you didn't use SBT.

It does work quite well with Scala 3.

Re: Scala 3.0

#268
post #197
post #97

Scala 3 + VS code + worksheets is my favourite exploratory programming environment. Its has: * Powerful functional features * Powerful OO features * Imperative features * Powerful type system * Great stdlib * Great syntax * Very fast write/test cycle with worksheets, way better than a REPL * Great IDE features such as autocomplete Scala may not be the best on any one axis, but the combination is unparalleled.

I've been extremely happy with IntelliJ plugin for Scala. I do use Visual Studio Code for Python,JS,web, etc. What would be advantage of using VS Code over IntelliJ for Scala?

I'm familiar with VS code and have a set up that I'm familiar with (shortcuts & settings) and I've only briefly looked at IntelliJ, so I'm not qualified to answer this question. What is the reason you're using IntelliJ rather than VS code?

Re: Scala 3.0

#269

Earlier quoted context omitted.

Looks like many libs already support Scala3: https://index.scala-lang.org/search?targetTypes=jvm&scalaVer...

Not sure what Play Framework is doing at the top of the list, will most likely be many months before a Scala 3 supported version is released. Same for Spark, DB libraries, Akka, etc. Basically everything with large dependency graphs that depend on macros or removed Scala 2 features (e.g. abstract type projections, arghhhh) will take significant time to port over to Scala 3. What has had Scala 3 support from early on…

Is Play Framework still used/developed? Haven't seen any progress from performance in the last years. Happy to get corrected, though.

Re: Scala 3.0

#270

Personally I'm looking forward to scala native 1.0 more than anything else. We'll have a strong Haskell competitor. I dont like jvm.

Scala native is not at all needed, you can already leverage graalVM native

Yeah, not at all easy though. Spent two days at work and didn't managed to get it done.
Post reply on HN