zlacker

[return to "My fast zero-allocation webserver using OxCaml"]
1. smartm+tq[view] [source] 2026-02-02 14:06:19
>>noelwe+(OP)
From the article:

> I am also deeply sick and tired of maintaining large Python scripts recently, and crave the modularity and type safety of OCaml.

I can totally relate. Switching from Python to a purely functional language can feel like a rebirth.

◧◩
2. voidUp+6s[view] [source] 2026-02-02 14:15:13
>>smartm+tq
While python isn't type safe, you can use Pylance or similar in combination with type hinting to get your editor to yell at you if you do something bad type-wise. I've had it turned on for a while in a large web project and it's been very helpful, and almost feels type-safe again
◧◩◪
3. Vorpal+2N[view] [source] 2026-02-02 16:06:01
>>voidUp+6s
> I've had it turned on for a while in a large web project and it's been very helpful, and almost feels type-safe again

In my experience "almost" is doing a lot of heavy lifting here. Typing in python certainly helps, but you can never quite trust it (or that the checker detects things correctly). And you can't trust that another developer didn't just write `dict` instead of `dict[int, string]` somewhere, which thus defaults to Any for both key and value. And that will type check (at least with mypy) and now you lost safety.

Using a statically typed language like C++ is way better, and moving to a language with an advanced type system like that of Rust is yet another massive improvement.

◧◩◪◨
4. voidUp+kv3[view] [source] 2026-02-03 08:07:06
>>Vorpal+2N
dict types to dict[Unknown, Unknown], not dict[Any, Any]. I'm the main developer on this code right now, so I've been pretty much ensuring its all typed reasonably well myself, but I don't just blindly trust it. I check what types it thinks it is, reason why they aren't as narrow as they could be, and fix that to make them more narrow, sometimes introducing extra classes so I don't have to type them as dict[dict[dict...]]. This is also an established codebase that does server-side processing that flask makes easy, and most of the developers working on it don't know C++ or Rust
[go to top]