←back to thread

Things Zig comptime won't do

(matklad.github.io)
458 points JadedBlueEyes | 8 comments | | HN request time: 0.001s | source | bottom
Show context
no_wizard ◴[] No.43744932[source]
I like the Zig language and tooling. I do wish there was a safety mode that give the same guarantees as Rust, but it’s a huge step above C/C++. I am also extremely impressed with the Zig compiler.

Perhaps the safety is the tradeoff with the comparative ease of using the language compared to Rust, but I’d love the best of both worlds if it were possible

replies(5): >>43744960 #>>43745201 #>>43745418 #>>43745573 #>>43749228 #
ksec ◴[] No.43745418[source]
>but I’d love the best of both worlds if it were possible

I am just going to quote what pcwalton said the other day that perhaps answer your question.

>> I’d be much more excited about that promise [memory safety in Rust] if the compiler provided that safety, rather than asking the programmer to do an extraordinary amount of extra work to conform to syntactically enforced safety rules. Put the complexity in the compiler, dudes.

> That exists; it's called garbage collection.

>If you don't want the performance characteristics of garbage collection, something has to give. Either you sacrifice memory safety or you accept a more restrictive paradigm than GC'd languages give you. For some reason, programming language enthusiasts think that if you think really hard, every issue has some solution out there without any drawbacks at all just waiting to be found. But in fact, creating a system that has zero runtime overhead and unlimited aliasing with a mutable heap is as impossible as finding two even numbers whose sum is odd.

[1] https://news.ycombinator.com/item?id=43726315

replies(4): >>43745462 #>>43745760 #>>43745791 #>>43746930 #
1. skybrian ◴[] No.43745462[source]
Yes, but I’m not hoping for that. I’m hoping for something like a scripting language with simpler lifetime annotations. Is Rust going to be the last popular language to be invented that explores that space? I hope not.
replies(3): >>43745665 #>>43745858 #>>43745947 #
2. hyperbrainer ◴[] No.43745665[source]
I was quite impressed with Austral[0], which used Linear Types and avoids the whole Rust-like implementation in favour of a more easily understandable system, albeit slightly more verbose.

[0]https://borretti.me/article/introducing-austral

replies(1): >>43746855 #
3. Philpax ◴[] No.43745858[source]
You may be interested in https://dada-lang.org/, which is not ready for public consumption, but is a language by one of Rust's designers that aims to be higher-level while still keeping much of the goodness from Rust.
replies(1): >>43745902 #
4. skybrian ◴[] No.43745902[source]
The first and last blog post was in 2021. Looks like it’s still active on Github, though?
5. Ygg2 ◴[] No.43745947[source]
> Is Rust going to be the last popular language to be invented that explores that space? I hope not.

Seeing how most people hate the lifetime annotations, yes. For the foreseeable future.

People want unlimited freedom. Unlimited freedom rhymes with unlimited footguns.

replies(1): >>43746350 #
6. xmorse ◴[] No.43746350[source]
There is Mojo and Vale (which was created by a now Mojo core contributor)
7. renox ◴[] No.43746855[source]
Austra's concept are interesting but the introduction doesn't show how to handle correctly errors in this language..
replies(1): >>43748794 #
8. hyperbrainer ◴[] No.43748794{3}[source]
Austral's specification is one of the most beautiful and well-written pieces of documentation I have ever found. It's section on error handling in Austral[0] cover everything from rationale and alternatives to concrete examples of how exceptions should be handled in conjunction with linear types.

https://austral-lang.org/spec/spec.html#rationale-errors