212 points by simonpure 6 days ago | 142 comments | View on ycombinator
Joker_vD 5 days ago |
Lucasoato 5 days ago |
> By default, variables are mutable. You can enable Immutable by Default mode using a directive.
> //> immutable-by-default
> var x = 10; > // x = 20; // Error: x is immutable
> var mut y = 10; > y = 20; // OK
Wait, but this means that if I’m reading somebody’s code, I won’t know if variables are mutable or not unless I read the whole file looking for such directive. Imagine if someone even defined custom directives, that doesn’t make it readable.
seabrookmx 5 days ago |
giancarlostoro 5 days ago |
Gys 5 days ago |
morcus 5 days ago |
I am not too familiar with C - is the idea that it's easier to incrementally have some parts of your codebase in this language, with other parts being in regular C?
forgotpwd16 5 days ago |
v_iter 5 days ago |
undefined 5 days ago |
stevefolta 5 days ago |
AIn0n 4 days ago |
saidnooneever 5 days ago |
first your write 'tutorial C'. then after enough segfaults and double frees you start every project with a custom allocator because you've become obsessed with not having that again..., then you implement a library with a custom more generic one as you learn how to implement them, and add primitives you commonly build that lean on that allocator, it will have your refcouters, maybe ctors, dtors etc etc.. (this atleast is my learning path i guess? still have a loooong way to go as always!)
i dont see myself going for a language like this, but i think its inspirational to see where your code can evolve to with enough experience and care
Kapendev 4 days ago |
This is so nice. It's crazy how other low-level langs don't have it. I know Dlang and Rust have it. Maybe Swift too? The way Dlang does it is nice because you can do a lot of stuff with them at compile time.
keyle 5 days ago |
A lot of the ideas in there are worth being inspired by.
Dwedit 5 days ago |
The Beef programming language was used to write Penny's Big Breakaway.
alfonsodev 5 days ago |
taolson 5 days ago |
t4eh0 5 days ago |
p0w3n3d 5 days ago |
KUDOS
kreco 5 days ago |
List of remarks:
> var ints: int[5] = {1, 2, 3, 4, 5};
> var zeros: [int; 5]; // Zero-initialized
The zero initialized array is not intuitive IMO.
> // Bitfields
If it's deterministically packed.
> Tagged unions
Same, is the memory layout deterministic (and optimized)?
> 2 | 3 => print("Two or Three")
Any reason not to use "2 || 3"?
> Traits
What if I want to remove or override the "trait Drawing for Circle" because the original implementation doesn't fit my constraints? As long as traits are not required to be in a totally different module than the struct I will likely never welcome them in a programming language.
t4eh0 5 days ago |
ramses0 5 days ago |
repeat 3 {
try { curl(...) && break }
except { continue }
}
...obviously not trying to start any holy wars around exceptions (which don't seem supported) or exponential backoff (or whatever), but I guess I'm kindof shocked that I haven't seen any other languages support what seems like an obvious syntax feature.I guess you could easily emulate it with `for x in range(3): ...break`, but `repeat 3: ...break` feels a bit more like that `print("-"*80)` feature but for loops.
undefined 5 days ago |
Archit3ch 5 days ago |
Zambyte 5 days ago |
blacksqr 5 days ago |
alexpadula 5 days ago |
rurban 5 days ago |
aappleby 5 days ago |
ethin 5 days ago |
Panzerschrek 5 days ago |
RockieYang 5 days ago |
undefined 5 days ago |
sebastianconcpt 5 days ago |
Panzerschrek 5 days ago |
GrowingSideways 5 days ago |
In fact why not simply write rust to begin with?