3 ms·
> let num : u8 = 5; <-- auto converts to u8; Can we please knock it off with reinventing different ways to declare a variable? This also irritates me about Rus
by janalsncm 3y ago
> let num : u8 = 5; <-- auto converts to u8;
Can we please knock it off with reinventing different ways to declare a variable? This also irritates me about Rust. There’s nothing wrong with having syntax that looks like languages that have existed before. How about
[modifiers] [type] [variable name] = [initial value];
What I want in a programming language is not arbitrary new grammars, I want drop-in improvements to languages that already exist. C++ but with better dependency management. Python but statically typed (Mojo where you at?). PHP but standardize all the weirdness.
(Some or all of these rants could be out of date as my knowledge cutoff for languages ends at various times in the last 15 years.)
- dllthomas 3y ago"let bindings" were present in ML in the 70s; I'm not sure whether they originated there or go back further. They've been used in many languages since, particularly those drawing on ML as a significant inspiration. It's not new, it's just borrowing from something you're unfamiliar with.
- xigoi 3y agoTypes before the name have several problems. And "let" is, like, one of the most common ways to declare variables.
- gavinhoward 3y agoAs another commenter said, types before the variable has problems. I don't like `let` because it's an extra four characters every time. But the [variable name]: [modifiers] [type] = [initial value]; only has one extra character and avoids all of the problems.