Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

231–240 of 527 posts

Re: Why is Zig so cool?

#231

Earlier quoted context omitted.

D has had compile time function execution since 2007 or so. https://dlang.org/spec/function.html#interpretation It doesn't need a keyword to trigger it. Any expression that is a const-expression in the grammar triggers it.

Maybe I don't understand, in D, how do I write a function which makes a new type? For example Zig has a function ArrayHashMapWithAllocator which returns well, a hash table type in a fairly modern style, no separate chaining and so on Not an instance of that type, it returns the type itself, the type didn't exist, we called the function, now it does exist, at compile time (because clearly we can't go around making new…

You use templates and string mixins alongside each other.

The issue with mixins is that using string concatenation to build types on the fly isn't the greatest debugging experience, as there is only printf debugging available for them.

Re: Why is Zig so cool?

#232
post #211

I'm afraid this article kinda fails at at its job. It starts out with a very bold claim ("Zig is not only a new programming language, but it’s a totally new way to write programs"), but ends up listing a bunch of features that are not unique to Zig or even introduced by Zig: type inference (Invented in the late 60s, first practically implemented in the 80s), anonymous structs (C#, Go, Typescript, many ML-style langua…

> C/C++ It has been several decades since putting a slash between these two made sense, lumping them together like this. It would be similar to saying something like Java/Scala or ObjectiveC/Swift. These are completely different languages.

Nope, that is a English grammar construct that is a shortcut for "and" and "or", as any good English grammar book will explain.

Indeed you see those for Java/Scala and Objective-C/Swift in technical books and job adverts.

Any search on the careers sites, or documentation, on companies that have seats at ISO, sell/develop C and C++ compilers, have such C/C++ references in a couple of places.

Do you need any example?

Re: Why is Zig so cool?

#233
post #153

Some days ago I decided to look at Zig a bit more in detail. So I skipped the usual marketing and I checked why it could be an alternative to C or Rust. Could it be? It seems that (debug) allocators are a nice idea, however, it seems that they exist "somehow" already for C, so I wonder: why would you pick this language for your next low level program? They provide runtime checks, so you need thorough testing before y…

> So the question I have for hardcore low level programmers: why don't they invest more on the memory allocators A partial answer is that part of low-level programmers avoid memory allocation and threads like plague. In some cases they are not even an option (small embedded programming, it's nearly as low-level as you can get before going hardcore for real with assembly programming), but when they can the keywords ar…

Indeed, and if someone wants to help work on C, this is very much possible both on the compiler side or on the standards side.

Re: Why is Zig so cool?

#236

In my opinion the biggest issue of Zig is that it doesn't allow attaching data to error. The error can only be passed via side channel, which is inconvenient and ENOURAGES TOOL DEVELOPERS TO NOT PASS ERROR DATA, which greatly increase debugging difficulty. Somethings there are 100 things that possibly go wrong. With error data you can easily know which exact thing is wrong. But with error code you just know "somethin…

There are plans in Zig to allow to include custom information into error stack trace https://github.com/ziglang/zig/issues/14446 . But that is not implemented. In any case, when debugging annotating error with extra context often is not enough. One often needs a detailed trace of what happens before. So what I would like to see in any programming language is ability to do a structured logging with extra context from…

closed as not planned :)

Re: Why is Zig so cool?

#237
post #118

Earlier quoted context omitted.

I agree. I look forward to a future high-level language that uses something like comptime for metaprogramming/interfaces/etc, is strongly typed, but lets you write scripts as easily as python or javascript.

D and Nim both offer that. D has a tool, rdmd, that compiles (with caching) and runs a script written in D, so you write #!/usr/bin/env rdmd D code ... and run it as if it were an executable.

If you want to write a code example on HN you can just indent it by 2 spaces and it'll work like you'd expect. For example:

  #!/usr/bin/env rdmd
  D code...

Re: Why is Zig so cool?

#239
post #193

I'm afraid this article kinda fails at at its job. It starts out with a very bold claim ("Zig is not only a new programming language, but it’s a totally new way to write programs"), but ends up listing a bunch of features that are not unique to Zig or even introduced by Zig: type inference (Invented in the late 60s, first practically implemented in the 80s), anonymous structs (C#, Go, Typescript, many ML-style langua…

When I read "I can easily say that Zig is not only a new programming language, but it’s a totally new way to write programs" I expected to see something as shocking as LISP/Smalltalk/Realtalk/EVE/FORTH/Prolog... A whole new paradigm, a whole new way to program. Or at least a new concept like the pure functionalism of Haskell, or Prototyping like in Lua/JS/Io. And I was so damn shocked how I must have missed something…

The idea of modern society is "get hyped for the new thing". Tech crowd did not escape that unfortunately, and keeps rediscovering techniques that were already possible more that 50 years ago. Because they don't want to learn the history of the technology they are using.

Re: Why is Zig so cool?

#240
zig is not cool at all, its ugly as sin, and has zero use case other than mingling with legacy c code, and who in their right mind wants to be doing that

its a hipster language, absolute insanity to use it when rust exists unless you have that very specific c related slave work to do

Post reply on HN