328
submitted 2 days ago* (last edited 2 days ago) by HiddenLayer555@lemmy.ml to c/programmer_humor@programming.dev

Made with KolourPaint and screenshots from Kate (with the GitHub theme).

you are viewing a single comment's thread
view the rest of the comments
[-] pivot_root@lemmy.world 2 points 2 days ago* (last edited 2 days ago)

std::string doesn't have a template type for the allocator. You are stuck using the verbose basic_string type if you need a special allocator.

But, of course, nobody sane would write that by hand every time. They would use a typedef, like how std::string is just a typedef for std::basic_string<char, std::char_traits<char>, std::allocator<char>>. Regardless, the C++ standard library is insanely verbose when you start dropping down into template types and using features at an intermediate level. SFINAE in older versions of C++ was mindfuck on the best of days, for example.

Don't get me wrong, though. I'm not saying Rust is much better. Its saving grace is its type inference in let expressions. Without it, chaining functional operations on iterators would be an unfathomable hellscape of Collect<Skip<Map<vec::Iter<Item = &'a str>>>>

[-] calcopiritus@lemmy.world 2 points 2 days ago

As long as you call .collect() on it at the end, don't need to write the entire type as it is a method with a generic parameter, and returns that generic.

The intermediate iterators though, those are hell. Especially if you pass it to a lambda and for some reason rust can't infer the type.

I once came across a parsing library that did the parsing with basically just the type system. It was absolute hell to debug and build. Types of parsers would be hundreds of characters long. It would take tens of minutes to build a simple parser.

I don't know much much time it would take to build a complex parser, since it was unable to. it reached the max type generic depth of the rust compiler, and would just refuse to compile.

I believe it was called Chomsky or Chumsky or something like that. Discovering nom was a blessing.

[-] Ajen@sh.itjust.works 4 points 2 days ago

Yeah, I missed the custom allocator at first. I thought I deleted my comment fast enough, but I guess you were faster. :)

this post was submitted on 19 Jun 2025
328 points (90.4% liked)

Programmer Humor

24374 readers
916 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS