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

Programmer Humor

24709 readers
326 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
 

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
[โ€“] barsoap@lemm.ee 27 points 2 weeks ago* (last edited 2 weeks ago) (5 children)

The actual reason why let ... in syntax tends to not use C-style "type var" like syntax is because it's derived from the syntax type theory uses, and type theorists know about parameterised types. Generics, in C++ parlance, excuse my Haskell:

let foo :: Map Int String = mempty

We have an empty map, and it maps integers to Strings. We call it foo. Compare:

Map Int String foo = mempty

If nothing else, that's just awkward to read and while it may be grammatically unambiguous (a token is a name if it sits directly in front of =) parser error messages are going to suck. Map<Int,String> is also awkward but alas that's what we're stuck with in Rust because they reasoned that it would be cruel to put folks coming from C++ on angle bracket withdrawal. Also Rust has ML ancestry don't get me started on their type syntax.

[โ€“] weird@sub.wetshaving.social 7 points 2 weeks ago

There is also the thing where the compiler might mistake your c++ style variable declaration for a function, e.g.

String myfunction():

String myvariable();

load more comments (4 replies)