Live data from Hacker News

Zig: programming language designed for robustness optimality and clarity [video]

youtube.com

41–50 of 73 posts

Re: Zig: programming language designed for robustness optimality and clarity [video]

#41
post #40

Every time there is news about a language, the first thing I am interested in is reading the syntax, I don't really care about anything else. Unfortunately it's often hard to find code examples. Zig doesn't fail that rule, I browsed 3 or 4 pages or so on the website, and could not find decent code examples. It's frustrating. You should be proud of the syntax choices you're making and it should be the first thing you…

I just clicked on "documentation" and found examples:

https://ziglang.org/documentation/master/

Re: Zig: programming language designed for robustness optimality and clarity [video]

#42
post #31

Earlier quoted context omitted.

Ok, got it. Apparently, espeed was using an unusual definition of "memory safety", which made their comment a bit odd :)

What was unusual about that? Here is Wikipedia: "Memory safety is the state of being protected from various software bugs and security vulnerabilities when dealing with memory access, such as buffer overflows and dangling pointers.[1] For example, Java is said to be memory-safe because its runtime error detection checks array bounds and pointer dereferences." This is the mainstream definition. Do you think Zig doesn'…

Rust does no have freedom from race conditions. It does have freedom from data races. They’re different things.

Re: Zig: programming language designed for robustness optimality and clarity [video]

#43
I've been advised to a write a preprocessor so that I can make a language that compiles to C. I'm mostly fine with C, except I want to make it more readable and with a 'sweeter' syntax.

Features I want are: * pythonic indent * no trailing semicolon * vector, hashmap and map containers * immutable strings

Re: Zig: programming language designed for robustness optimality and clarity [video]

#44
post #20

Earlier quoted context omitted.

I may be wrong, but if I read the documentation correctly, Rust looks more memory-safe than Zig. What am I missing?

Rust has lifetimes and ownership as language concepts so that you have to be explicit about who owns a resource, for example memory, but it does not give you a lot of control about what to do when an allocation fails. Zig is designed so that you can still peogrammatically deal with a failing allocation, as does well-written C, but it does not have a ownership system like Rust.

Rust’s standard library types do not give you that control. The language doesn’t know abou allocation, and you can build whatever you want on top of it.

Re: Zig: programming language designed for robustness optimality and clarity [video]

#45
post #15

Personal taste, not factual One-True-Way™ It looks on the surface like almost Rust meets JS with a sprinkling of Ruby/Smalltalk. Semicolons in 2018, really? Indentation and line-oriented parsing makes code more beautiful. Heck, in general, enums, arrays and dictionary literals shouldn’t even need commas if there’s one tuple per line. Extra typing is a waste of time and clutters-up code with distracting, Christmas orn…

That's just your personal opinion, obviously. You need some sort of separators for putting several statements on the same line anyway, and requiring them everywhere is better than Javascript's or python's optional semicolons. Also I guess zig's main audience is C programmers, and semicolons are not one of the problems that need fixing in a "better C" language.

Re: Zig: programming language designed for robustness optimality and clarity [video]

#47
post #46

Where are the generative capabilities? It seems there is no macro-like thing in Zig, though there are comptime parameters (and I guess: monomorphized templates).

https://ziglang.org/documentation/master/#Case-Study-printf-...

Re: Zig: programming language designed for robustness optimality and clarity [video]

#48
post #18

I have read quickly through the tutorial, and this looks interesting. Objectives are similar to Rust, with a few twists. A few differences that I can see: - At first glance, Rust's `enum` looks safer and more powerful than Zig's `union` + `enum`, while Zig's `union` + `enum` appears more interoperable with C. - Zig's `comptime` is quite intriguing. In particular, types are (compile-time) values and can be introspecte…

Rust does support varargs in extern functions (FWIW): https://play.rust-lang.org/?gist=92fbdf9bdc95c09d16e30c03ffa...

Re: Zig: programming language designed for robustness optimality and clarity [video]

#49
post #19

Earlier quoted context omitted.

Do nullable types and maybe types add much over checked dereferences (a la Java)? I imagine they might be good for performance (fewer checks), but does it really help with correctness/convenience/elegance/readability/etc?

In my experience from Rust & co, yep, this improves correctness a lot. Elegance, not so much.

Swift’s syntax sugar for Optionals makes working with nullable types much more elegant, too.

Re: Zig: programming language designed for robustness optimality and clarity [video]

#50
post #27
post #24

Earlier quoted context omitted.

There was a HN discussion ~4 months ago that touched on some of this: "Unsafe Zig Is Safer Than Unsafe Rust" https://news.ycombinator.com/item?id=16226235 Also see this previous thread on Rust's stdlib OutOfMemory errors: "Containers should provide some way to not panic on failed allocations" https://github.com/rust-lang/rust/issues/29802

> "Unsafe Zig Is Safer Than Unsafe Rust" Yes, I've seen that blog post. Definitely a useful analysis, but it doesn't strike me as a fundamental difference, i.e. adding this check (as a warning) to rustc doesn't look too hard and wouldn't break existing code. Also, as pointed out in the title, that's code explicitly marked as `unsafe` in Rust, so it might not be an entirely fair comparison :) > "Containers should prov…

Just to clarify, allocation is entirely implemented in the Rust standard library, not the language/compiler.
Post reply on HN