Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> but when thinking of Scala I can't help but think "Well, it's not quite Haskell, is it?". (The poor type inference, the whole OOP thing, the lack of TCO means that any Monadic abstraction must be trampolined and that's just cruel.

Some good news:

- Better type inference at the place were it was sorely needed landed in 2.12 (use -Ypartial-unification to enable) or use it on 2.11 with a compiler plugin.

- Even if you are not a fan of OO (I'm not), I still love that I get a great module system for free. Haskell's module system is a completely mess.

- Scala-Native already supports all kinds of TCO, including mutually recursive ones.



Oh yeah, definitely looking forward to 2.12. Don't get me wrong Scala is still good, just not great. (Hence the scare quotes around "trapped")

> - Better type inference at the place were it was sorely needed landed in 2.12 (use -Ypartial-unification to enable) or use it on 2.11 with a compiler plugin.

I was actually thinking of things like local definitions not needing type signatures. It's really easy to underestimate how much more fluent this makes the language feel. (Think of functions defined in 'where' clauses and things like that. Entirely subjective, but there's this feeling of fluency when you don't need any type signatures for non-top-level things.)

I don't think Scala is ever going to move away from requiring all functions to have an explicit type signature.

> - Even if you are not a fan of OO (I'm not), I still love that I get a great module system for free. Haskell's module system is a completely mess.

Not so much "mess", I think... more completely underpowered? It's really just a namespacing mechanism.

Hopefully we'll get Backpack at some point...

> - Scala-Native already supports all kinds of TCO, including mutually recursive ones.

Really? This is surprising to me, but perhaps they've gone with the Pascal(?) calling convention so as to make it trivially supportable?

It's still sad it can't be relied upon per language spec. :/


> It's still sad it can't be relied upon per language spec. :/

There is a @tailrec annotation which ensures that a method was optimized. It probably needs to be updated to understand Scala-Native's new abilities, but the infrastructure is there!


Yes, but IIRC it doesn't work for mutually recursive methods or dynamic(!) tail calls.


Yes, because Scala-Native only exists for a month at this point in time.


Hm? Not sure why you're bringing up Scala-Native again... @tailrec has existed since 2.8(?).

The limitations of @tailrec are obviously due to the JVM, but I was thinking (given your mention) that maybe Scala-Native had done away with the problem -- if you use the "Pascal" calling convention I believe it's mostly completely trivial to do TCO. (Just omit the "push/pop things onto/off stack" bit in the caller and use "goto".)


> Not sure why you're bringing up Scala-Native again

Weren't talking about that?

> @tailrec has existed since 2.8

Yes?

> I was thinking (given your mention) that maybe Scala-Native had done away with the problem

It uses fastcc, and yes it does. I don't understand the issue.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: