Hacker News new | past | comments | ask | show | jobs | submit login

I don't know anything about cars and don't understand your metaphor at all, sorry.



I know a little about cars and I'm still confused - I think I just have a very different view of the relative "it factors" between each pair of languages. De gustibus...


Yeah I mean that's fair too. My impressions are poorly formed but the analogy is that both F# and OCaml are based on functional programming, which to my mind takes a step back from the "imperative programming -> OOP -> shared state multithreading" history into an alternative history, I'm phrasing this as them being "electric cars" for the first half. OCaml is not really the swankiest of swank in the alt-languages community, so I chose a Prius to be like "what's a car that folks know as eco-friendly but it's not very prestigious?" ... meanwhile F# is like "we are THE functional programming of the .NET world, come over here we're cool and slick and all-electric" hence the Tesla comparison.

Pony is like the far-off "ah maybe someday I'll be able to use that at work, maybe for some little experiment" thing and it reminded me of going to a dealer and being like "let me drive the Caddy, you know I'm not gonna buy it, I know I'm not gonna buy it, but I just wanted to live a little today." I don't have any particular experience with Chevy SUVs so I just chose one at random, the point was that Rust is like a "look we're just trying to be C with explicit contracts between parts that allow for memory safety" type of language, very practical and chunky and like people love it don't get me wrong... just, it's an SUV. It's less opinionated and more just "let's get from point A to point B safely."


I think it's one of those cases where using metaphors doesn't help clarify the thought, and instead obscure it. Rust shares a lot with OCaml, and so with F#. F# is "the" functional programming language of the .NET world, but it's also because it's the only one, and it's a second class citizen.

I will also add that Rust is not trying to be C (and neither trying to "replace C"). It's here to offer an alternative, that in some cases makes more sense than sticking with C. C code means a lot of thing. For example, some people code in C89 because they find some kind of purity in it. You're never going to get that from Rust. For some people, it means fast and secure code, like with Python's cryptography. That's a place where Rust can be used. For some other people, it's C because that's the only thing that's allowed by some authority. Again, Rust isn't going to fit here until/if it's allowed. I think in general, trying to reason in terms of use case leads to better comprehension than trying to think in languages.

But outside of that, the move was basically the same. They found another language that's very similar, but that has a way bigger ecosystem.


> Rust shares a lot with OCaml, and so with F#. F# is "the" functional programming language of the .NET world, but it's also because it's the only one, and it's a second class citizen.

I thought F# was OCaml?


They're both ML family languages, and both add OO, so they're not quite that closely related but they're definitely part of the same family tree.


F# at its heart is OCaml without functors, and with its original structurally typed OO model replaced by .NET's.


No, F# has a lot more OO than OCaml, and there’s a significant difference in features (ex active patterns in F#, functors OCaml). I liked what I used of F#, but for any serious program it’s more Multi-paradigm than functional, since you’ll end up doing a lot of OO.


In my experience that isn't quite true. You usually OO for IO/interop if a C# library is being used, then its module code for the most part all the way down (e.g. ASP NET Core define a class for the controller, then have it interop to F# FP code for the most parts). With some newer F# frameworks you don't even have to do that these days.

Having some experience with large scale F# codebases its rare you define a class compared to records, unions and functions. 100's of functions, 50-100 small types, 1-2 classes approx is usually the ratio I've seen for a typical microservice (YMMV).


I have a very different perception of OCaml compared to you (compared to most people?)

When I think of OCaml, the concepts that come to mind are brilliant French computer scientists and hedge funds. A practical Haskell. When I think of F#, I think of... .NET, bright enterprise programmers who want to work with a tolerable language, and that's about it. If forced to name a user of it, I'd say "uhh, no idea... Maybe Stack Overflow?"

(That's entirely aside from the relative merits of both languages, which are leaps and bounds ahead of both most OOP and functional languages.)


I've seen both being used by hedge funds and finance/banks actually. A lot of F# use anecdotally is closed source finance (this has changed now I think) which is why IMO it didn't have as much open source visibility or people showing its use. OcAML is probably in a similar boat. Having hidden use cases however means breaking changes in the language are harder to judge.


Except the O in OCaml stands for Objective Caml, and F# has plenty of OOP features to interoperate with .NET ecosystem.


While it is true that OCaml does support a kind of OOP, even the OCaml manual outright states that it isn’t used much: https://ocaml.org/manual/objectexamples.html

I think the biggest use for objects is to have a kind of row polymorphism? I don’t know too much because I haven’t used them at all.


OCaml object system is better than what .NET offers, IMO. On one hand, it enforces clear interface/implementation separation ("classes aren't types"), while structured typing for objects makes this arrangement easy to use in practice. But then there are also powerful features such as multiple inheritance.

The biggest quirk coming from something like Java or C# is that you can't downcast. But classes can still opt into this ability (by using virtual methods + extensible variants) where it makes sense; and in most cases, the presence of downcasts means that a discriminated union is probably a better fit to model something than a class.


It's things like that that makes OCaml what it is. It supports OO even if you don't use it all the time, it supports imperative constructs. I remember reading in "Le langage Caml", by Xavier Leroy, that you should use an imperative loop over recursion if the loop is simple, and keep recursion for complex use cases, where it makes sense. That's not something you often hear from functional programmers, probably because the ones we hear are more obsessed with purity than practicality. But it's a great way to show OCaml's values.


tldr: Elm is a Cybertruck


More like a golf cart to Haskell’s Cybertruck.




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

Search: