355 points · by gaws · 1y ago · 210 comments
> I must not segfault. Uncertainty is the mind-killer. Exceptions are the little-death that brings total obliteration. I will fully express my cases. Execution will pass over me and through me. And when it has gone past, I will unwind the stack along its path. Where the cases are handled there will be nothing. Only I will remain.
¥https://signalsandthreads.com/build-systems/
(Hard to present glyphs that would actually be used in print - I've chosen what I think is close - but they are not that close because wrong font)
I still occasionally hear things about how the more academic-styled functional languages can't work in production, but Ocaml shows that it absolutely can work, even with high performance requirements.
Mercury also uses Haskell for their backend https://mercury.com/
I was fortunate enough to work at Jet.com before Walmart completely destroyed it, which was an F# shop. I really liked it, and I never really felt "limited" by it.
The stuff I was working on didn't have nearly the same requirements as high-frequency trading like Jane Street does though. I never did any super low-latency stuff with F#, so it's tough for me to say how well it fair with that kind of environment.
Would honestly be a lot more interesting than Haskell.
But I think what OP meant was more about the "functional programming" side of things than the "HM-typed" side of things. Naively, anyway, you might think that "the FP-style" of avoiding mutation and preferring recursion would require lots of garbage and high-latency garbage collection, copying, function call overhead...of course, that's not the whole story, but having Jane Street to point to as a crushing counter-example is nice.
It feels like the trend right now is to bolt on one or two "functional libraries" into your "normal" language and pretend that that's the same as writing Haskell or Ocaml. People have actually expressed such sentiments to me because Java has the optional type and a "map" function for the Streams API. When I suggest writing something in a functional language, the response is always "it's too hard" or "we won't be able to hire for that", as if engineers are somehow unable to learn new things.
I think it's purity that actually is a big difference, but OCaml isn't pure.
It complicates things that are simple to express in an imperative language
There are a ton more people working in tech in finance that don’t quite have it as fun (or lucrative) as Jane Street let alone your average tech company.
Many jobs in finance are updating 20 year old Java code, or figuring out new ways to load data in and out of Excel files for custom reporting.
I wonder if they disable all the fancy exploit mitigation protection in linux kernel just for a tiny performance hit
Processes reading and writing directly to FPGA/NIC ring buffers.
Shunning TCP in favour of UDP based protocols that are easy to optimize for your particular usecas in userspace.
Removing cores from the Linux scheduler entirely and pinning processes to those cores.
This stuff isn't even novel, it's been standard practice for a couple of decades.
A lot of jobs are extremely mundane though, compliance, regulations, legacy code bases, etc.
Yes, all mitigations get disabled
go fish
Also, it's apparently significantly harder to land a position at JS than at a Google/Meta.
Actually, I applied there a while ago, the interviewer was actually pretty unpleasant, which hasn't happened to me at big tech. Didn't leave a really good impression.
It was probably the first and only time I would have rather have been ghosted lol
I still rank it above making people click on ads though.
Let's see if they last at least a couple of centuries.
"How do you live with yourself making high 6 fig / 7 figs a yr?"
Quite easily in fact.
Work on real problems. Try to make real people's lives better and happier. There are real problems in finance but my feeling was it's all very simple and solved decades ago, now it's just pointless complexity that isn't solving anyone's problems. I recommend John Kay's Other People's Money for a primer on what finance is actually good for and where it's gone wrong.
The real big problem in finance IMO is digital cash. Bitcoin started out trying to solve that problem, and there are still some people in the community interested in it, but it's mostly of interest to the finance guys now. Just another "instrument" in their "portfolios".
He also claims they're full of elitists from top universities and are not receptive to ideas outside that bubble.
>> With nowhere to go, it has to roam everywhere in your system, both in your code and in people's heads. And as people shift around and leave, our understanding of it erodes.
>> Complexity has to live somewhere. If you embrace it, give it the place it deserves, design your system and organisation knowing it exists, and focus on adapting, it might just become a strength.
- Fred Hebert, https://ferd.ca/complexity-has-to-live-somewhere.html
And even when the complexity is essential, IMO it's better off not in the build system. I'll gladly accept more complex code for the sake of a simpler build (even though that theoretically means worse performance). Worst case if I need to do something complex at build time I'd rather model that as "the build system invokes a program that does something complex" than try to express the complex thing in some Turing Tarpit "configuration" language.
I am painfully aware of bitbake. I’ve probably written 3-400 recipes.
Most of them are about 20-30 lines long, because I refused to hide the compilation mess inside a recipe. I fixed the problem _before_ getting to the bitbake part. Most of my recipes at this point need only a repo name, the recipes are identical after that.
"go learn this awful new language"
I don’t mean that as an insult to Lua’s creators. They seem like really smart fellows. It’s just that the language is (to my eyes, with my background) viciously ugly. And 1-based arrays, of course, are evil.
It has some neat ideas, though, and it is supposed to be very easy to integrate into a project. But man, that syntax …
I'll eat at least a bit of shit if it means I can get more than one platform's-worth of build process out of a single set of human-editable configuration files.
The world does not work like this though. CMake is weird but once you've learned some non-intuitive stuff, it works very well and there's a reason why pretty much everyone is using it.
(And two minor annoyances that people determined to hate CMake will never shut up about. But then, if you're determined to hate something, there are worse things than CMake to do it to! So I can't be too critical.)
Sounds like the perfect match for C++.
Ocaml never clicked for me, I have a rare form of semicolon allergy and Haskell just looked a lot nicer to me.
But then I recently tried Reason and enjoyed it A LOT, so everything Ocaml is suddenly interesting.
https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
https://reasonml.github.io/ looks cool, OCaml with javascript.
The Javascript-oriented part of ReasonML got forked to be its own language: Rescript. https://rescript-lang.org/
I'm sure once you get the zen of it, it's fine. Like Lisp, I guess, you learn to think in its structure. But looking at a screenful of Haskell to me is intimidating.
Of the bunch I found SML/NJ to be the most readable.
But in any case, you can use curly braces and semicolons in Haskell just fine. You can also write your Haskell like Lisp, and add lots of parens everywhere, and use all operators in prefix-form.
I took a brief look at these things, and my impression is that their stuff isn't "ready" for anyone outside Jane Street, even though they put a lot of effort in building the ecosystem and open source their code.
I've used some of their other libraries too, their logging and unit test ppx are common maybe even de facto standards as much as the ocaml world has such a thing. I've also used, off the top of my head, their code formatter, one of their test frameworks, their implementations of some advanced data structures.
Sometimes you do run into one like the other commenter said, where that shit just does not work. It depends on an undocumented something they shipped separately, or needs a secret bit of config or whatever. These aren't malicious, I open a ticket and come back in a year or two often they'll be working.
It's not zero frustration but I appreciate their approach of just throwing everything over rather than spending more resources testing and polishing fewer releases. Their code quality is generally very high and even if I can't get something working directly, it provides a rigorous & vetted example implementation.
How is the design of the APIs? How stable are they?
Does Jane Street respond to bug reports/pull requests (if any) quickly?
I worked on Bloomberg DLIB which is basically an implementation of https://www.cs.tufts.edu/~nr/cs257/archive/simon-peyton-jone...
I love Lean 4, but good luck getting help with it from AI. Today's project-in-progress is digesting their reference manual to fit well within a 200K context window. We'll see if that helps.
JS does have a bit of a NIH culture, but I'm not sure if that was really at play here. There just...weren't very many good build tools available at the time, particularly for a company using an unorthodox tech stack.
But Dune started (according to this blog post) in 2016 and JS started seriously improving and adopting it last year. So to me Jenga sounds like a reasonable step in 2012, but pouring significant effort into migrating from Jenga to Dune (and improving Dune) in 2024 sounds more weird
In particular I was under the impression one needed to be able to run ocamldep before hand (or compile twice) - buck2 can do this, bazel needs hacks iirc.
The major pain point is LSP integration, which has to be closely tied to the build system, since it's only by building that the LSP server can know a file's dependencies. Everything is all neatly available with dune. We've cobbled something together a bit with buck2 but it's not as nice.
The lsp requires you to run "dune build" first, bad already.
If you add a new file, the lsp wont pick it up until you dune build it again.
The compiler errors arent there too.
But i loved writing OCaml, its just thats a bit more painful to learn than due to the tooling, since i didn't use many functional langs before.
Cmake mostly
(This rant more or less equally applies to other language-specific build systems.)
"Familiar" is not a property of any system. It's a relation between a system and a user.
Some Linux build systems maybe be more familiar to some users, but will be less familiar to others. When picking a build system, you can't just look at the system itself and declare it familiar or not.
It's not even enough to look at the total number of users familiar with some thing. Hindi is one of the most familiar languages in the world, but you're probably gonna have a bad time if you use it for the menu in a cafe in rural Texas.
You have to look at your actual cohort of users (and potential future users) and see what's familiar to them. This is one of the key reasons why usability is actually a deeply hard problem. So much of usability hinges on familiarity, but familiarity is a human-specific highly variable property.
(this rant more or less equally applies to all os-or-distro-specific build systems)
---
This rant is only semi-serious. I do see some value in the Linux distribution style packaging. In particular, I do sympathise with the need to do cross-language builds. But goodness are they a pain to work with, and probably the biggest barrier to me shipping software on Linux.
My hope is that eventually an evolution on build systems like bazel/buck2 will lead to a truly universal build system that is both cross-platform and cross-language. But unfortunately it doesn't look like it's coming soon.
Don’t[1]. Ship source tarballs (or VCS tags).
I’ll grant that most distros’ build systems are antiquated and, in places, silly. (That includes Nixpkgs, first released 2006.) We could really use some fresh ideas there.
But they’re also not for you (or me) in your (or my) capacity as a software author. They’re there for a person who works on packaging software for, most of the time, a single distro, and their balance of complexity and flexibility is calibrated accordingly. One of the functions of that person is also to keep you honest and represent the interests of users before you, because they have more expertise than the users but not as much of an attachment to your software as you. The ecosystem is less healthy when the author tries to fill in for the packager.
“But then the users will come to my bugtracker to complain about bugs in patched versions!” Pre-Google, we used to have a solution for that: a configure option to set the bug reporting email, present in all GNU software. Nowadays it’s not clear what a good solution could be, but it does seem like, unfortunately, the author will have to maintain a table of packager contact information for the end users.
[1] https://drewdevault.com/2021/09/27/Let-distros-do-their-job....
Less popular apps or closed source apps don't work. Things with old dependencies won't work. Other language with package manager which depend on dependencies and dependency versions that may not be in distro packages may have trouble.
For the core the distro model might work. For the rest maybe something like flatpack from the devs might scale
What's a 'familiar Linux build system'? make?
But I'm a new OCaml user, and actively starter using ocamlbuild because dune added layers of indirection really tripped me up at first.
And yet those language-specific build systems are overwhelmingly winning, in pretty much every language.
> As Fedora packager for OCaml packages,...
I honestly think traditional Linux packaging is in the wrong here and the problems are essentially self-inflicted (not in the sense that individual maintainers are doing something wrong, but in the sense that the policy that traditional Linux distributions are following is inherently unsustainable. It's designed for a pre-CPAN world)
> As an upstream OCaml developer, the whole thing falls down the minute you need to integrate other programming languages into your build (or OCaml code into a code base written in another language).
True up to a point, but frankly the worst case is falling back to a terrible C-style build, and "always do terrible C-style builds in case you need to integrate with C code" is not a proposition that has much appeal.
Much as I wish the whole world would standardise on Maven or Cargo, I can't see a realistic path to there without first eliminating C, because the C people are never going to agree to follow a standard for package repositories.
The issue is there. Not you or your fellow packagers of course, but in the idea that every linux distribution needs it's own packaging system, and each version of a distribution it's own packages.