logoalt Hacker News

MrMcCall11/08/20242 repliesview on HN

(OCaml Question Ahead)

I agree on F#. It changed my C && OO perspective in fantastic ways, but I too can't support anything Microsoft anymore.

But, seeing as OCaml was the basis for F#, I have a question, though:

Does OCaml allow the use of specifically sized integer types?

I seem to remember in my various explorations that OCaml just has a kind of "number" type. If I want a floating point variable, I want a specific 32- or 64- or 128-bit version; same with my ints. I did very much like F# having the ability to specify the size and signedness of my int vars.

Thanks in advance, OCaml folks.


Replies

neonsunset11/08/2024

F# is a far better option from a practical standpoint when compared to alternatives. By simple virtue of using .NET and having access to very wide selection of libraries that make it a non-issue when deciding to solve a particular business case. It also has an alternate compiler Fable which can target JS allowing the use of F# in front-end.

Other options have worse support and weaker tooling, and often not even more open development process (e.g. you can see and contribute to ongoing F# work on Github).

This tired opinion ".net bad because microsoft bad" has zero practical relevance to actually using C# itself and even more so F# and it honestly needs to die out because it borders on mental illness. You can hate microsoft products, I do so too, and still judge a particular piece of techology and the people that work on it on their merits.

show 1 reply
throw1618033911/11/2024

I'm a novice OCaml user, but AFAIK here's how it works.

int is pointer-sized minus one bit, e.g. 31 on 32-bit, 63 on 64-bit

nativeint is pointer-sized, but boxed.

float is 64-bit and boxed.

There's limited support for different number sizes or specifying signedness.

show 1 reply