Live data from Hacker News

Scala 3.0.0-M1

github.com

101–110 of 148 posts

Re: Scala 3.0.0-M1

#101

Earlier quoted context omitted.

How is that a bad thing? It's the same in other languages and it is nice to have some flexibility. E.g. lisp: use whichever type of parentheses you want Or Kotlin: use short syntax lambdas fruits.filter(it == apple) or long syntax fruits.filter(fruit -> fruit == apple) or with annotated types: fruits.filter{fruit: Fruit -> fruit == apple} Sometimes brevity is good for the reader, sometimes more details are good for t…

The flexibility is perfectly fine when you're programming something on your own. But when you're in a team, or worse, in a large company, it starts to be a problem that everyone can use their own style. It's much easier to read someone else's code when you have a common code style. And in Scala there are not only many different ways to use the standard libraries or to structure your code, there is a pure FP vs OOP-st…

> But when you're in a team, or worse, in a large company, it starts to be a problem that everyone can use their own style

I was in many failed or semi-failed projects and code style was never the problem. Yes, people do use slightly different styles, but style is really easy to enforce - there are tools to do it automatically. And even if somebody misplaces a brace or writes `map(_.length)` instead of `map(x => x.length)` this doesn't impact the readability as long people in your team know the language. If a project fails to meet the deadline because of the code style it is not because of people using different styles but because of developers bikeshedding about the code style in code reviews instead of doing real work.

Re: Scala 3.0.0-M1

#102

Earlier quoted context omitted.

How is that a bad thing? It's the same in other languages and it is nice to have some flexibility. E.g. lisp: use whichever type of parentheses you want Or Kotlin: use short syntax lambdas fruits.filter(it == apple) or long syntax fruits.filter(fruit -> fruit == apple) or with annotated types: fruits.filter{fruit: Fruit -> fruit == apple} Sometimes brevity is good for the reader, sometimes more details are good for t…

> How is that a bad thing? This doesn't quite answer your question, but, the Python community takes seriously the idea of There's Only One Way To Do It , as part of their philosophy on complexity. https://wiki.python.org/moin/TOOWTDI https://www.python.org/dev/peps/pep-0020/

Seriously?

How to do data structures:

1. just put everything ad-hoc into a dict or a list (the "PHP" way :D) 2. use a namedtuple 3. define a class 4. define a dataclass (preferred) but works only if your Python version is recent enough

In Scala? Just use case classes and this is the only recommended way (#1 is very impractical so noone does that, #2 doesn't exist, #3 possible, but impractical when you have #4 in all versions).

How to map a collection in Python? - Start from an empty one and add mapped items in a loop - Use map + lambda - Use list comprehension - Update all items in place with a loop

Is it really any better than in Scala?

Re: Scala 3.0.0-M1

#103
post #2

Scala 3 is a huge change. As someone who used Scala for years, but always wondered whether they can retain their users with competition from Kotlin, I'm extremely curious what this will mean for Scala in the long run. I'm skeptical, because the cost to migrate is big. But I'm hopeful, because Scala is a language I like to write code in. Edit: why am I skeptical? I know scala 3 is largely meant to be backwards compati…

Scala 3 supports braceless syntax, aka significant indentation, aka "YAML is to JSON as Scala 3 is to Scala 2" https://dotty.epfl.ch/docs/reference/other-new-features/inde... There was quite some debate on this, going on strong.

Yuck... personally I'd want a Lint that would disallow many such syntax differences from Java: - force use of () - force use of ; - etc...

Re: Scala 3.0.0-M1

#104

Earlier quoted context omitted.

> Rust which simply has a wider applicability area Rust is a great language but that's a pretty insane statement. The ecosystem is still tiny compared to the JVM.

Rust is a great language, and Scala is a great language, but they are different. They optimize for a different thing. Rust definitely rocks at high-performance, resource management, fine grained control over all the aspects of the program, at the expense of developer's time. Scala rocks at developer productivity and building abstractions, sacrificing a bit of performance. However, I must say that Rust is also a very…

> Scala is limited mostly to JVM...

No, it's not. You can call native (C) functions from the JVM.

Re: Scala 3.0.0-M1

#105

Earlier quoted context omitted.

There are no "special" methods in Scala. If you see something like "arr.map(_.nonEmpty).filter(a => a % 2)" in the standard library, you can use that syntax yourself too. E.g. "arr.customlyFiltered()" is easy to do. Or even easier "arr.filter(myCustomFilter)". If something doesn't work out for you, please feel free to use e.g. scalafiddle.io and make it example, then you will be helped! :) Scala is indeed not a high…

There is no straighforward elegant way of doing "obj.scalaMethod.myCustomMethod.scalaMethod.myCustomMethod" in Scala. I want to create a method and just inject it into the chain, no fiddling or ducktaping or using some black Scala magic. "def myFun(a: String, b: Double): Boolean = {...}" and then "obj.mapValues.myFun.forall(_)" or just anything similar. And yes, Scala is exactly the language when you need safe and ma…

In the Scala 2.x this can be done with an implicit class.

It's a bit cumbersome and not very use-case oriented (mechanism over intention) and so Scala 3 has introduced extension methods[0].

This gives you exactly what you want.

Since Scala 3 is pretty much completely backwards compatible (and with the use of Tasty you can use Scala 3 code in Scala 2.x projects), so I don't see the migration as a big problem. The Scala team has spent a lot of work to make the transition as painless as possible.

[0] https://dotty.epfl.ch/docs/reference/contextual/extension-me...

Re: Scala 3.0.0-M1

#107

Earlier quoted context omitted.

> Rust which simply has a wider applicability area Rust is a great language but that's a pretty insane statement. The ecosystem is still tiny compared to the JVM.

Rust is a great language, and Scala is a great language, but they are different. They optimize for a different thing. Rust definitely rocks at high-performance, resource management, fine grained control over all the aspects of the program, at the expense of developer's time. Scala rocks at developer productivity and building abstractions, sacrificing a bit of performance. However, I must say that Rust is also a very…

Of course, general purpose languages have their limits and I'm not arguing that Scala can do everything. But it certainly can do a lot more than Rust (and its C/C++ interop) at the moment.

And I have no problem with the JVM interop. As long as you don't try to write Scala libraries that need to be consumed by Java applications, everything just works really.

Re: Scala 3.0.0-M1

#108
post #93

Earlier quoted context omitted.

Ah, I understand what you mean now. You are looking indeed for the thrush operator. I think it should be built into Scala's standard library, but until that happens, you can use the mouse library or build it yourself. Here is an example: // Need to define this once somewhere in your project implicit class TrushExtension[A](anything: A) { def |>[B](function: A => B) = function(anything) } // Your application code def…

If you would call it pipe operator, like it's called in many (Elm, Elixir, F#, OCaml) other languages that have it, people would understand you faster IMHO. It is even discussed for inclusion into JavaScript.

https://www.scala-lang.org/api/current/scala/util/ChainingOp...

Re: Scala 3.0.0-M1

#109
The most important thing that no one seems to mention is that Scala 3 is not compatible with Scala 2. This means that they are creating competition for themselves. It is the Python 2 vs 3 problem all over again.

Re: Scala 3.0.0-M1

#110

In my company (10k+ devs) Scala seems to be losing steam. All the enthusiasts have moved to Go/Rust, while the pragmatics are staying in (moving back) in Java. No new major project is being built in Scala. Does anyone share this experience?

What I'm seeing is that Scala devs I know have started using Kotlin (including me). It is a much more pragmatic language that doesn't try to reinvent the wheel, like Scala does.
Post reply on HN