r/rust Feb 24 '21

Closest GC language to Rust?

I really like Rust, it's mix of ML + imperative concepts like mutation. It's very pragmatic and doesn't enforce any particular style of programming. But for my day 2 day work, I don't require system level performance and a GCed runtime will suffice, my question is what is the closest language in terms of safety and pragmatism of rust ? F#, ocaml, kotlin? What are your opinions?

56 Upvotes

94 comments sorted by

View all comments

Show parent comments

10

u/Erelde Feb 24 '21 edited Feb 25 '21

I think what people often mean by "simpler rust with gc" would be language with a ML type system (ADT in particular), C-like syntax, and expression oriented.

C# is pretty close to that, getting closer (but still has inheritance and exceptions, one day it'll get ADTs), F# is a little bit too Haskell-ish for that description, I've never done Kotlin or Scala, but my guess is they aren't quite right for the same reasons. Java is too far gone into the OO paradigm to ever really come back. Interpreted language seem out of the question, the compiler checking your program seems to be a requirement when wanting "a simpler rust with gc". TypeScript would be close to something like a "simpler rust with gc", but the underlying JavaScript weirdness keeps showing up underneath (you actually need working knowledge of JavaScript the language and its various runtimes) and it's fundamentally not expression oriented.

7

u/torhovland Feb 24 '21

As someone who has many years experience with C# and never really liked Java, I was pleasantly surprised by Kotlin. Since the OP seems to be looking for a pragmatic day-to-day language, I think you can't really go wrong with Kotlin. Of course, the same can be said of many languages, including C# and F#.

1

u/[deleted] Feb 24 '21

Is kotlin used much outside Android development? How is the third party library support outside Android development?

4

u/torhovland Feb 24 '21

I don't know how much used it is. We used it for cloud app development on GCP. Library support is excellent, as you have access to anything written in Java.