Better HN
topnewbestaskshowjobs
Log inSign up

sideeffffect

318 karma · joined Jan 5, 2019 (7y ago) · 168 submissions

Submissions

comment 4y ago · link · parent

> JDK 17 has most of the good features of Scala and Kotlin.

I'd be sooo happy if that were the case, but sadly, it's not. From the point of view of Scala, I still see many features missing. Roughly in the order of importance:

* Immutable persistent collections in the standard library (and thus lingua franca in the libraries). Just so much better than mutable collections. Way less headache. Once you start using them, you realize how rarely you actually need mutable ones.

* Pattern matching. Java will surely improve on what is currently available. But why wait? It may take a long time.

* Sophisticated string interpolation. It's powerful, and yet is still easy to read. Again, Java is on its way to get it, but with Scala you can have it right now.

* Type Classes. Sometimes it is very good design to separate data from functionality. Java designers (Brian Goetz IIRC) mention they would like to get this eventually. Scala has an interesting design of Type Classes -- "givens" -- which is also modular (in contrast to Haskell). Scala also has an elegant mechanism for Type Class derivation using the "derives" clause. https://docs.scala-lang.org/scala3/reference/contextual/deri...

* for-comprehension syntax and IO/Task/ZIO for async programming. Project Loom still hasn't delivered. But Scala has you covered. It gives you for-comprehension syntax, so that you don't have to suffer from nested callback hell. And there are many great libraries for async programming, like ZIO or Cats Effect. These are easier to work with, compared to other Futures from various Java libraries, because they're lazy, not eager. for-comprehension syntax is also useful for other things, it's just that async is the typical usecase.

Higher-kinded types. Not everything has to be super fancy higher-kinded type-level craziness. And very often one gets away without needing to use higher-kinded types and that's good (just as often a solution without parametric polymorphism aka generics is enough). But other times it's awesome to have this power of abstractions. Typically, but not only in libraries.

* Object. Sometimes you just need to have an object (which might implement an interface/class/trait). But Scala doesn't force you to create a whole class, if you only even want just one instance anyway. A small thing, but way more elegant.

But I'm really happy to see Java/JVM improve. The 17 release has brought some great features, but in the language level (records, embryonic pattern-matching, ...) and the VM level (GCs in particular). We all benefit more or less directly, one way or the other.

comment 4y ago · link · parent

Since you mentioned using IntelliJ, I can't resist asking the question: Have you played with Scala too? If yes, how would you compare OCaml to it?

comment 4y ago · link · parent

I don't know much about OCaml, only Scala and Cats Effect/ZIO/Monix, but would appreciate if I could get a gist of what Multicore OCaml brings to the table.

Is there somebody who's familiar with both worlds and could compare them and explain how Multicore OCaml (and possibly the new effect system) work?

Thanks in advance!

comment 4y ago · link · parent

Could you explain why you wanted to avoid the term (excuse the pun :) ) "type" so much?

comment 4y ago · link · parent

> Empirical is the only system I know of that can infer types while staying static.

F#'s Type Providers can do that too.

https://docs.microsoft.com/en-us/dotnet/fsharp/tutorials/typ...

comment 5y ago · link · parent

Can you please compare to 11 or even 8?

comment 5y ago · link · parent

If I contribute a code under the new CLA, is Grafana Labs allowed to relicense that contribution under a non-copyleft license, like Apache Public License 2.0, without my further permission?

If yes, than it's a really bad bad thing and I hope they change it.

CLAs that permit relicensing for a project that already uses permissive license is fine and fair. But doing that on a project with a copyleft license is a bad taste. It would enable Grafana Labs to give Grafana to a party X which can then give it to party Y, where X isn't required to give all the necessary freedoms to Y.

https://opensource.com/article/19/2/cla-problems

https://sfconservancy.org/blog/2014/jun/09/do-not-need-cla/

comment 5y ago · link · parent

> I think Scala will always suffer from its choice to make implicits so fundamental.

Thankfully it won't. Scala 3 deconstructs implicits and discourages (or outright discards) the bad parts: http://dotty.epfl.ch/docs/reference/contextual/motivation.ht...

"Implicits" are useful for the Type class pattern and is available in Scala 3 with an improved syntax.

"Implicits" for implicit conversions is an ugly hack that should be avoided as much as possible and Scala 3 restricts it.

"Implicits" for extension methods is a clever hack, and Scala 3 provides a dedicated syntax for defining extension methods.

comment 5y ago · link · parent

> the compiler has no way of suggesting to you

Of course it does. And since Scala 3, it does suggest to you the imports you need for implicits. And IntelliJ does recommend imports even for Scala 2.

Regarding cats, the codebase has been restructured, so that you won't need the implicit imports (or not as much at least): https://meta.plasm.us/posts/2019/09/30/implicit-scope-and-ca... The trick there is that the Type class instances were moved to appropriate companion objects which are searched by the compiler by default and thus the used doesn't need to do any manual imports.

comment 5y ago · link · parent

AFAIK Credit Suisse have their quant library written in F#.

comment 5y ago · link · parent

> Isn't F# pretty much OCaml.NET?

Kinda yes, kinda no. There's a whole interesting story to it:

https://dl.acm.org/doi/pdf/10.1145/3386325

comment 5y ago · link · parent

Oh yes it does count. Scala can be a nice functional language, with a powerful module system.

Although I miss type providers, enforced lack of cycles and other nice things, like syntax:

https://contributors.scala-lang.org/t/scala-3-very-impressiv...

comment 5y ago · link · parent

> GPL doesn't permit commercial use

That is alarmingly false. Do you have a source that McNealy indeed has said that? I couldn't find anything by googling.

comment 5y ago · link · parent

AFAIUI _monomorphisation_ and reification are interchangable.

That means, that if I have a polymorphic (generic) class `MyClassA<T>`, the compiler (regardless if it is JIT in the runtime as in C#, or AOT as in Rust) monomorphises (reifies) `MyClassA` for each instantiation of `T`. So `MyClassA<MyClassB>` and `MyClassA<MyClassC>` are distinct classes.

For this reason, co-/contra-variance in C# works only for interfaces. Type parameters in classes are invariant. `MyClassA<MyClassB>` and `MyClassA<MyClassC>` are distinct classes, neither sub-/super-class of the other, even if `MyClassB` were a subclass of `MyClassC`.

comment 5y ago · link · parent

It it possible to use this with F#?

comment 5y ago · link · parent

"Generics" in Haskell are real, but they're not what is in the .NET lingo called reified. Just like Java does not monomorphise.

On the other hand, C#, F# or Rust monomorphise (have reified generics).

comment 5y ago · link · parent

Has anyone tried to combine Zig with Cosmopolitan libc yet?

https://justine.lol/cosmopolitan/index.html

comment 5y ago · link · parent

> that is what killed F# effectively

F# has been an unwanted child of Microsoft, it actually adopted the language from Microsoft Research. As a language, F# is _very_ good (although not as good as the original OCaml, whose features had to be cut to be able to run on CLR). It's just not first-class citizen, so not everything may work with F#. And F#'s own development and features are blocked on CLR -- instead of F# charting its own path, each feature first has to be available for C#/CLR and only then will F# developers implement it (higher-kinded types are just one example).

But it's still much more pleasant "syntactic sugar to write the CIL bytecode" than C# can ever be.

> even Scala is dead

I beg to differ! Thankfully, Scala is very much not dead. Scala 3 is around the corner, with many more features and, even more importantly, several simplifications. And the community is also much larger compared to F# (or any other ML language, like Haskell). Innovation also takes place in the realm of libraries, like ZIO for example.

comment 5y ago · link · parent

> Algorithms are not simply math, in the same way mechanical engineering is not simply math.

Algorithms are _literally_ mathematical objects. C.f. Church-Turing thesis.

> And if it were simply math, then there would be no way to work around those patents, which plenty of open source codecs have done in various directions.

Show me an H.264 codec that works around the patents in the MPEG LA pool. Also software patents are orthogonal to the question of "open source" (which is about copyright). That there is very often no way to work around the patents in an otherwise independent implementation is precisely the problem with Software patents.

> Unfortunately, most open source codecs are not as good at compression, mostly since the patented ones have a massively bigger pool of engineering behind them from dozens of companies banding together their work to develop best of breed solutions.

Show me the numbers. Because the numbers I know (for example the chart in the blogpost itself) show that x265 is the best codec (or encoder, if it's not a decoder too) for H.265, it self being "open source", better than proprietary alternatives.

> And eventually the patents expire, and the world gets these codecs free to use.

Even after patents expire, copyright expires in 90 years.

comment 5y ago · link · parent

> Scala has its own drawbacks wrt. Haskell: lack of typed effects is a big one for me.

There are libraries like ZIO, Cats Effect or Monix. Give them a try! Some people might even say that for example ZIO is even better than Haskell's IO.

comment 5y ago · link · parent

But F# doesn't have async/await. As you write, it has "computation expressions", which are inspired by Haskell's "do-notation", but are more generalised and powerful (than both Haskell's "do-notation" or Scala's "for-comprehension", let alone async/await).

One of the things I liked best about F#.

comment 5y ago · link · parent

I'm not a C++ developer, but AFAIK the fact that C++ is not 100% "you don't pay for what you don't use" is commonly acknowledged. Exceptions are an example of that.

There are ideas/proposals how to fix that: https://www.youtube.com/watch?v=ARYP83yNAWk

comment 5y ago · link · parent

Really amazing cast: Dana Scott, Phil Wadler, Barry Jay, last student of Curry (whose name I don't remember)... it's really interesting to see all these people together.

comment 5y ago · link · parent

Why not F#? :)

comment 5y ago · link · parent

I've posted above how Scala's IO/Task is different from C#/Kotlin async-await.

https://news.ycombinator.com/item?id=25305574

I hope you will find it helpful.

comment 5y ago · link · parent

> Scala/Haskell's IO type

Since you've brought out Haskell's IO and Scala libraries' IOs (Monix, ZIO, Cats Effect), or F#'s Async, I think it's worthwhile to point out how they're different from the async-await approach that's in C#/Kotlin/Rust/etc.

They both require "special" handling -- in C# it's the `async`/`await` syntax, in Scala it's the flatMap function or for-comprehension -- there they are similar. But their meaning is different. IO/Task in Scala doesn't represent a possibly started and under-way computation; it represents a "dead" program, yet to be started, a mere value. And it has all the advantages that mere values have, like refactoring (extract variable, ...) or restarting in case or failure and so on. Pass it into a method, return it from a method, store it in a data structure/collection, create `IO[IO[X]]`, whatever you want, just like you would with `Option[X]` or `List[X]`. In Scala, you have to differentiate between `A => B` and `A => IO[B]`, because `B` and `IO[B]` are different, but both are still values. Your program then ends up being this one big IO/Task value, which is then executed "at the end of the world". These pictures illustrate it quite well:

https://twitter.com/impurepics/status/1182946618280153094

https://twitter.com/impurepics/status/1180064851219144704

On the other hand, async-await has none of the benefits, only downsides. You get functions of two colors, but no benefit in return. It's justifiable in Rust, because Rust aims for zero-cost abstractions. But for Kotlin/C#, it's a sad choice.

The Loom approach for Java is a reasonable one. No async-await shenanigans, no funny FP/Haskell/IO business. You just use threads for concurrency as God intended them and you can have gazillions of them, because they are M:N. And I respect that, even though I'm partial to IO/Task for the reasons outlined above.

comment 6y ago · link · parent

There is an answer to the perceived bad UX of Git: Gitless.

https://gitless.com/

Is has already been mentioned a couple of time in this thread, but it deserves a more prominent mention, because IMHO it's a really interesting project.

The author(s) analysed git UX shortcomings and tried to learn from them. For example, Gitless aims to align well its concepts with user's intentions. There have been written research papers (and a talk is available online) about their methodology and Gitless design:

https://spderosso.github.io/oopsla16.pdf

https://www.youtube.com/watch?v=31XZYMjg93o

comment 6y ago · link · parent

Interestingly, just recently, Neil Mitchell has published an article claiming that this is a fallacy and in practice, people are forced to back-pedal on it.

    Ban recursion and unbounded loops. Proclaim the language is "Turing incomplete" and that all programs terminate.
    Declare that Turing incomplete programs are simpler. Have non-technical people conflate terminate quickly with terminate eventually.
    Realise lacking recursion makes things incredibly clunky to express, turning simple problems into brain teasers.
    Add recursion.
    Realise that the everything is better.
https://neilmitchell.blogspot.com/2020/11/turing-incomplete-...

comment 6y ago · link · parent

The Free software movement hasn't gone anywhere. Copyleft licenses still exist, so does the Free Software Foundation.

There are now more people who care about these things and more quality Free software available than ever before in human history! It's just that the complacent open-source idea, as well as proprietary software (biggest offenders are locked smartphones, etc), have spread even faster :(

I don't think the movement has weak foundations nor that it is politically naive. In my eyes it goes directly to the problem it cares about, which is human freedom in the context of using a computer. It doesn't oppose commerce, but it is aware of the current socio-political order's (i.e. capitalism's) tendency to turn anything into a sellable commodity.

comment 6y ago · link · parent

Yes, "copyleft licenses force or encourage devs to contribute back to the community" is a ridiculous cliche (or misguided, or misleading, to be more charitable), but for different reasons than you talk about.

The point of Copyleft (and the Free software movement in general) is to ensure that the user of a computer (and the software in it), a human being, is free -- meaning she can do with it what she pleases. Use if for whatever, study what it does, change it, share the original or modified version -- those are the four freedoms https://www.gnu.org/philosophy/free-sw.en.html . Humans can't be free, if they're not in control of the computers/software that they use.

The Free software community considers it unethical, if a cellphone owner or an automobile owner can't do with her device (including the software it runs) what she wants, even though she bought it with her hard earned money.

123456