Live data from Hacker News

OCaml as my primary language

xvw.lol

281–290 of 296 posts

Re: OCaml as my primary language

#281

Earlier quoted context omitted.

From the gedcom wiki page it doesnt seem that bad. At least the data format itself. But it seems like its very easy to screw up working with it.

GEDCOM was developed by the Mormons and was not really designed to encompass the rich diversity of human relationships. You can seriously overload the notes fields! Genealogy is really hard but it is important to not get too bogged down with formality and get the data stashed in one form or another. Genealogy "facts" decay with a horribly short half life. It is also important to accept all "facts" as is and not try t…

> How on earth do you go about genealogy data?

My extremely naive approach would a scheme where you have a header containing a list of used types of information fields, then a list of entries for people, then relationships (genealogical descendants, familial relationships with a start and end date (optional, YMD format, that you only fill in with as far as you know, so if you only know the year, you just set that.)) then a list of various events, then a list of supporting documents with a confidence value, where each document has a list of people and a list of events they are relevant to. then a list of basically freeform fields, that can link to events, documents, people, etc. where the types are defined in the header.

typing this out at 2 in the morning, so sorry for the incoherence.

Re: OCaml as my primary language

#282

Earlier quoted context omitted.

Anyone have a link to the Android talk? I wonder if it was backend code or on-device code. On device you could probably justify the compromises of a no-GC language better.

I tracked it down: https://www.youtube.com/watch?v=QrrH2lcl9ew I don't think it was on-device code, as they talked about porting Python projects. But you can watch the talk to see if I'm misremembering.

Thanks!

In the transcript I found more talk about porting C++ and Go to Rust, without Python rewrite references... still interesting tidbits, like

"when we've rewritten systems from go into rust we've found that it takes about the same size team about the same amount of time to build it that is there's no loss in productivity when moving from go to rust "

Re: OCaml as my primary language

#283
post #170

Earlier quoted context omitted.

Maybe it's good it died? Now we have moonbit lang.

Moonbit the fast, compact and user friendly language for WebAssembly? Or Moonbit the language for industrial usage? Or Moonbit the AI-native general-purpose programming language? (They are the same language) Reason at least was an active collaboration between several projects in the OCaml space with some feedback into OCaml proper (even though there was a lot of initial resistance IIRC).

It's not only for wasm, compiles to native code as well [0].

[0] https://www.moonbitlang.com/blog/llvm-backend

Re: OCaml as my primary language

#284
post #225

Earlier quoted context omitted.

Haskeller here! > The idea that the example program could use pattern matching to bind to either test values or production ones is interesting, but I can’t conceptualize what that would look like with the verbal description alone. The article appears to have described the free monad + interpreter pattern, that is, each business-logic statement doesn't execute the action (as a verb), but instead constructs it as a nou…

Thanks for the detailed reply, that’s very cool! This looks great, very usable way to do DI. Do you use Haskell professionally? If so, is this sort of DI style common?

No idea how common it is. It's never been my main work language but I've been using it at work for prototyping/scripting/automation/analysis etc for at least ten years now.

It looks like what I've done is most similar to https://www.parsonsmatt.org/2018/03/22/three_layer_haskell_c...

And I think this was the post that proposed tagless-final over free-monads: https://markkarpov.com/post/free-monad-considered-harmful.ht...

Re: OCaml as my primary language

#285
post #23

I migrated from OCaml to Rust around 2020, haven't looked back. Although Rust is quite a lot less elegant and has some unpleasant deficiencies (lambdas, closures, currying)... and I end up having to close one one eye sometimes and clone some large data-structure to make my life easier... But regardless, its huge ecosystem and great tooling allows me to build things comparatively so easily, that OCaml has no chance. A…

Your comment makes me think the kind of people who favor OCaml over Rust wouldn't necessarily value a huge ecosystem or the most advanced tooling. They're the kind who value the elegance aspect above almost all else, and prefer to build things from the ground up, using no more than a handful of libraries and a very basic build procedure.

Yeah, I was that kind of person, then I wrote a real tool that does real work in OCaml... and then I discovered than I am no longer such a person and went to Rust.

Re: OCaml as my primary language

#286
post #23

I migrated from OCaml to Rust around 2020, haven't looked back. Although Rust is quite a lot less elegant and has some unpleasant deficiencies (lambdas, closures, currying)... and I end up having to close one one eye sometimes and clone some large data-structure to make my life easier... But regardless, its huge ecosystem and great tooling allows me to build things comparatively so easily, that OCaml has no chance. A…

> the end result is seriously faster Do you have a ballpark value of how much faster Rust is? Also I wonder if OxCaml will be roughly as fast with less effort.

Just the straight/naive rewrite was ~3 times faster for my benchmark (which was running the program on the real dataset) and then I went down the rabbit hole and optimized it further and ended up ~5 times faster. Then slapped Rayon on top and got another ~2-3x depending on the number of cores and disk speed (the problem wasn't embarrassingly parallel, but still got a nice speedup).

Of course, all of this was mostly unneeded, but I just wanted to find out what am I getting myself into, and I was very happy with the result. My move to Rust was mostly not because of speed, but I still needed a fast language (where OCaml qualifies). This was also before the days of multicore OCaml, so nowadays it would matter even less.

Re: OCaml as my primary language

#287
post #23

I migrated from OCaml to Rust around 2020, haven't looked back. Although Rust is quite a lot less elegant and has some unpleasant deficiencies (lambdas, closures, currying)... and I end up having to close one one eye sometimes and clone some large data-structure to make my life easier... But regardless, its huge ecosystem and great tooling allows me to build things comparatively so easily, that OCaml has no chance. A…

Were you using the ocamlopt compiler? By default, ocaml runs in a VM, but few people figure that out because it is not screaming its name all the time like a pokemon (looking at you JVM/CLR). But ocaml can be compiled to machine code with significant performance improvements.

Yeah, I just checked in my repository, it was ocamlopt

Re: OCaml as my primary language

#288
post #180

I saw a talk by someone from Google about their experiences using Rust in the Android team. Two points stuck out: they migrated many projects from Python, so performance can't have been that much of a concern, and in their surveys the features people liked most were basics like pattern matching and ADTs. My conclusion is that for a lot of tasks the benefit from Rust came from ML cicra 1990, not lifetimes etc. I feel…

That is why if I feel like doing ML style programing I rather reach out for Kotlin, Scala or F# than Rust, and even then Java and C# have gotten enough inspiration that I can also feel at home while using them. I am no strage to ML type systems, my first one was Caml Light, OCaml was still known as Objective Caml, and Mirada was still something being discussed on programming language lectures on my university. From w…

> too many people rush out for Rust

Yes

> thinking that ML type systems is something new introduced by Rust

This feels off to me. Of the hype-train that Rust has been for a while now, a _type_ of type system it has hasn't been any of the cars, as it were.

At least in my readings; I'm sure we travel in different circles, but even the few academic oriented things have been other language features and memory safety through and through.

Re: OCaml as my primary language

#289
post #97

Earlier quoted context omitted.

> bool -> bool has 2^2=4 values Not the best example since 2*2=4 also. How about this bit of Haskell: f :: Bool -> Maybe Bool That's 3 ^ 2 = 9, right? f False = Nothing f False = Just True f False = Just False f True = Nothing f True = Just True f True = Just False Those are 6. What would be the other 3? or should it actually be a*b=6? EDIT: Nevermind, I counted wrong. Here are the 9: f x = case x of True -> Nothing…

Good point, well there's Ordering type built-in in Haskell (LT | EQ | GT). Ordering -> bool has 2^3=8 values (const true, const false, == LT, == EQ, == GT, is_lte, is_gte, ne) EDIT: now you see why I used the smallest type possible to make my point. Exponentials get big FAST (duh).

> now you see why I used the smallest type possible

I think the length's worth it for the sake of a crystal clear enumeration.

Re: OCaml as my primary language

#290
post #158

Earlier quoted context omitted.

While at it: what was / is holding Ada back? I haven't seen a single open-source project built in Ada, nor did I hear about any closed-source corporate project that uses Ada's superpowers. (Most likely these exist! But I did not see any available, or at least well-publicized.) People agree to go to great lengths to use a tool that has some kind of superpower, despite syntactic weirdness or tooling deficiencies. Peopl…

Ada has been held back primary by an image problem that traces back to the high cost and poor performance of a lot of early Ada 83 compilers. Ada adoption has never really recovered from that despite its many technical advantages, and despite the low cost and good performance of several current compilers. The GNAT Ada compiler, always open source and quite good, has been freely available since the 1990's. It has been…

> early Ada 83 compilers

IIRC, in response, DARPA (et al) did invest in compiler research.

> adoption has never really recovered

Ya. Timing. There's a brief window of opportunity for new languages (ideas) to catch on before the horde of "worse is better" solutions overwhelm the field.

Post reply on HN