Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

281–290 of 527 posts

Re: Why is Zig so cool?

#281
post #133

Earlier quoted context omitted.

I meant for focused on compilation speed to apply only to lower level languages. And when I say lower level I don’t really include D because it has a garbage collector (I know it’s optional but much of the standard library uses it I believe).

That a language has a garbage collector is completely orthogonal to whether it has type inference ... what the heck does it matter what "much of the standard library uses" to this issue? It's pure sophism. Even C now has type inference. The plain fact is that the claim is wrong.

The x axis is orthogonal to the y axis, so I can’t be interested in the area where x > what the heck does it matter what "much of the standard library uses" to this issue?

It matters in that most people looking for a low level manually memory managed language won’t likely choose D, so for the purposes of “is this relatively novel among lower level, memory managed languages” D doesn’t fit my criteria.

> Even C now has type inference. The plain fact is that the claim is wrong.

Almost no one is using C23 yet.

Re: Why is Zig so cool?

#282
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…

Dev celebs makes blogposts and videos on how Zig is awesome and unique, so the herd repeats.

Re: Why is Zig so cool?

#283

Earlier quoted context omitted.

For quite a long time, I have been wondering why I like to code in Raku so much … in a round about way you set me thinking. Perhaps it’s because, in Raku, precision, performance and determinism take a back seat to expediency. (Sorry for the tangent).

Wow, Raku looks like a really interesting language, I'd never heard of it before! Have you used it in any large projects?

I love it. My largest project is about 20k lines … so nothing too big. But if you need to be expedient (just quickly make a data extract/load/transform or a command line thingy) it is great fun. The LLMs seem to be pretty good too, just the usual hallucination here and there.

Re: Why is Zig so cool?

#285

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…

As a c++ developer who's heard of Zig but never dived into it, I was reading this article scratching my head wondering what is it actually so unique about it. Why the blog has a section on how it install it on the path is also very puzzling.

[deleted]

Re: Why is Zig so cool?

#287

Earlier quoted context omitted.

People are working on this. std.zon is generally considered to be a good example of how to handle errors and diagnostics, though it's an area of active exploration. The plan is to eventually collect all the good patterns people have come up with and (1) publish them in a collection, and (2) update std to actually use them.

> how to handle errors and diagnostics, though it's an area of active exploration I am flabbergasted and exasperated by this sentiment. Zig is over 9 years old at this point. This feels this same kind of circular arguments from Golang "defenders" about generics and error handling.

Go gets a lot of flack for getting some things wrong but it was a stable and productive language within a couple of years.

If you look at the current Zig website the hello world example doesn’t compile because they changed the IO interface. Something as simple as writing to the console.

It’s easier to get things right if you have no issues breaking backward compatibility for a decade. It feels it’ll be well over 10 years before Zig is “1.0”.

Re: Why is Zig so cool?

#288

Earlier quoted context omitted.

The feature I want is multimethods -- function overloading based on the runtime (not compile time) type of all the arguments. Programming with it is magical, and its a huge drag to go back to languages without it. Just so much better than common OOP that depends only on the type of one special argument (self, this etc). Common Lisp has had it forever, and Dylan transferred that to a language with more conventional sy…

>The feature I want is multimethods -- function overloading based on the runtime (not compile time) type of all the arguments. >Programming with it is magical, and its a huge drag to go back to languages without it. Just so much better than common OOP that depends only on the type of one special argument (self, this etc). Can you give one or two examples? And why is programming with it magical?

For a start it means you can much more naturally define arithmetic operators for a variety of built in and user-defined types, and this can all be done with libraries not the core language.

Because methods aren't "inside" objects, but just look like functions taking (references to) structs, you can add your own methods to someone else's types.

It's really hard to give a concise example that doesn't look artificial, because it's really a feature for large code bases.

Here's a tutorial example for Julia

https://scientificcoder.com/the-art-of-multiple-dispatch

Re: Why is Zig so cool?

#290
post #181

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.

Perl5 had it before. Either by constant-folding, or by BEGIN blocks. Constant-folding just got watered down by the many dynamic evangelists in the decades after, that even C or C++ didn't enforce it properly. In perl5 is was watered down on add (+) by some hilariously wrong argumentation then. So you could precompute mult const expressions, but not add.

How are perl5’s BEGIN blocks equivalent to comptime? It’s been awhile, but I recall BEGIN blocks executing at require time—which, in complicated pre-forking setups that had to be careful about only requiring certain modules later during program execution because they did dumb things like opening connections when loaded, meant that reasoning about BEGIN blocks required a lot more careful thought than reasoning about comptime.

The same is true for templates, or macros—all of which are distinguished by being computed in a single pass (you don’t have to think about them later, or worry about their execution being interleaved with the rest of the program), before runtime start (meaning that certain language capabilities like IO aren’t available, simplifying reasoning). Those two properties are key to comptime’s value and are not provided by perl5’s BEGIN blocks—or probably even possible at all in the language, given that it has eval and runtime require.

Post reply on HN