| ▲ | Capture Checking in Scala(nrinaudo.github.io) |
| 62 points by nrinaudo 4 days ago | 18 comments |
| |
|
| ▲ | noelwelsh 3 days ago | parent | next [-] |
| Nice article. It reminds me of another post a little while ago about OCaml. Like OCaml, Scala is getting more systems programming capabilities. Capture checking can, for example, be used to implement safe memory arenas (aka slab allocation or memory pools.) If you can prove that no code has captured anything from the arena, you can prove it is safe to deallocate the arena. This is less fine-grained than Rust's approach, but I think it is much more usable. I think of it as similiar to Zig's approach but with safety guarantees. The other part, doing away with monads, is also exciting for FP nerds like me, but probably less generally exciting as it doesn't add new capabilities to the language so much as make existing capabilities easier to use (puns intended, of course!) |
| |
| ▲ | brabel 3 days ago | parent [-] | | Flix has regions which also restrict the scope of certain values. Seems like a similar concept. And D has “scope” and “return scope” to describe when variables are intended to not escape (unless returned in the latter case). | | |
| ▲ | pjmlp 3 days ago | parent [-] | | As does C#, after they decided to incorporate Midori learnings, and C++/CLI wasn't going to be cross-platform, so C# needed to improve its low level capabilities. |
|
|
|
| ▲ | ndriscoll 2 days ago | parent | prev | next [-] |
| Does the capture check on Secret prevent you from just using `_.value` as your extractor now? I'm not seeing how this approach could ever be made to work without tracking primitives, and even with that it's not clear that you can actually use this to prevent a leak. You're always going to have to serialize the secret somehow (unless the capability is entirely used as a token within your same process, and then you don't need to wrap anything and can just pass an opaque object around), so you can always get at it. |
|
| ▲ | edem 3 days ago | parent | prev | next [-] |
| Oh, Scala...I thought the language was practically dead. |
| |
| ▲ | nikitaga 2 days ago | parent | next [-] | | Scala is very much alive, it's just past the initial hype stage, well into the slope of enlightenment / plateau of productivity depending on which style of Scala one is into. It's now growing slower but based on more sustainable pragmatism instead of just hype. | |
| ▲ | erikvanoosten 2 days ago | parent | prev | next [-] | | Scala (with ZIO) is still the only language I know that lets me write a fairly complex program with a few unit tests, and then run it without any bugs. | |
| ▲ | apwell23 2 days ago | parent | prev [-] | | still have to use it at work for some datapipeline stuff |
|
|
| ▲ | lmm 3 days ago | parent | prev [-] |
| Meh. Scala's great strength used to be a simple, consistent model instead of zillions of ad-hoc features (e.g. implicits replace maybe 5 or 6 special-case features in other languages). But Scala 3 seems to be determined to destroy that elegance and turn into a pile of special cases. If I wanted that I'd use Kotlin. |
| |
| ▲ | pjmlp 3 days ago | parent | next [-] | | I would say that having lost the adoption wave, especially since Google got cozy with JetBrains, thus making Kotlin unavoidable on Android, and all big data solutions that were powered by Scala going into modern C++/Go/Rust, eventually the only thing left to keep Scala relevant is to be Haskell on the JVM. Still, F# could only dream to have half as much adoption as Scala. | | |
| ▲ | blandflakes 2 days ago | parent [-] | | My job has been making a tactical retreat from Scala, and it's really fascinating to look to alternatives like F# and see that they're even less "successful", from an adoption point of view. I'm surprised at how little success even marginally higher-level languages than C# or Java are having. As you say though, really we've seen a shift in a direction I didn't expect as much, more toward languages that aren't bringing a virtual machine. Even the dialog at work talks about elastic computing where the JVM is less of a dominant player than something that uses fewer resources and starts fast. Go has really become the poster child for a lot of this momentum in my circles... intentionally not an elaborate language, good ecosystem, good runtime characteristics. I personally don't really want to be moving to Go, but the gulf between status quo and "moves the needle" languages has grown, not shrunk, these last few years, it feels. | | |
| ▲ | pjmlp 2 days ago | parent [-] | | I am usually a big critic of Go's design, but if the option is between C or Go, I would rather put up with Go. F# has suffered from Microsoft not really caring that much, it almost feels that management has repented to have added into Visual Studio 2010, and now mostly carries it around, based on the work of volunteers, with a rather small team. Even the release notes aren't part of .NET proper, While VB folks document directly what is changing, https://github.com/dotnet/core/blob/main/release-notes/10.0/... F# notes tell readers to click into yet another link to the F# repo, https://github.com/dotnet/core/blob/main/release-notes/10.0/... https://fsharp.github.io/fsharp-compiler-docs/release-notes/... | | |
| ▲ | blandflakes 2 days ago | parent [-] | | No disagreement on my part. I largely hope not to be in a world where I'm choosing between C or Go, though! |
|
|
| |
| ▲ | halfmatthalfcat 3 days ago | parent | prev [-] | | Strange since Scala’s huge standard library and FP/OO choose-your-own-adventure garnered a ton of criticism as being “too unopinionated” leading to many ways to accomplish the same thing and confusion on what was “blessed”. If anything Scala 3 was an attempt to standardize and reduce some of the existing complexity to make it more widely appealing. | | |
| ▲ | lmm 3 days ago | parent | next [-] | | > If anything Scala 3 was an attempt to standardize and reduce some of the existing complexity to make it more widely appealing. I know that's the argument, but I think it ends up the opposite. Splitting one consistent feature into three overlapping subsets is not a simplification in my book - it might make the easy cases slightly easier, but it makes the hard cases much harder. | |
| ▲ | brabel 3 days ago | parent | prev [-] | | What’s the preferred syntax in Scala 3? Python-like indentation based or C-like curly braces? Is FP the “default“ or OOP? | | |
| ▲ | nikitaga 2 days ago | parent | next [-] | | Preferred syntax is whatever looks nicer to you. It's not really two different syntaxes, just one more flexible syntax where if you choose to go full braceless, it ends up looking like python. I personally like the new braceless python-like syntax. Scala has two main camps, one is purist FP (cats / zio / etc.), another is plain Scala, banking on ergonomic OOP+FP fusion. Neither of those is the default. FP advocates are more vocal online but that's because they need a bunch of libraries (thus more OSS work) to make that approach work, whereas the other camp just uses plain Scala and simpler libraries that aren't reinvented every 5 years, so their online presence is not as apparent. | |
| ▲ | pjmlp 3 days ago | parent | prev [-] | | It seems Python-like indentation based is the one being pushed, due to way Python was own mindshare around learning to programm language, and AI DSL. I would assume FP is the one being pushed with stuff like Cats and ZIO, anyone that wants OOP with good enough FP has already moved back into modern Java, or Kotlin. |
|
|
|