Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

51–60 of 527 posts

Re: Why is Zig so cool?

#51
post #7

> I can’t think of any other language in my 45 years long career that surprised more than Zig. I can easily say that Zig is not only a new programming language, but it’s a totally new way to write programs, in my opinion. To say it’s merely a language to replace C or C++, it’s a huge understatement. I don't understand how the things presented in this article are surprising. Zig has several nice features shared by man…

> One may wonder how the compiler discovers the variable type. The type in this case is *inferred* by the initialization. That the author feels the need to emphasize this means either that they haven't paid attention to modern languages for a very long time, or this article is for people who haven't paid attention to modern languages for a very long time. Type inference has left academy and proliferated into mainstre…

> Type inference has left academy and proliferated into mainstream languages for so many years that I almost forgot that it's a worth mentioning feature.

It’s not common in lower level languages without garbage collectors or languages focused on compilation speed.

Re: Why is Zig so cool?

#52
To author -- code sample as images is great for syntax highlight but I wanted to play with the examples and.. got stuck trying to copy the content.

(also expected tesseract to do a bit better than this:

  $ wl-paste -t image/png | tesseract -l eng - -
  Estimating resolution as 199
  const std = @import("std");
  const expect = std.testing.expect;
  
  const Point = struct {x: i32, y: i32};
  
  test "anonymous struct literal" {
  const pt: Point = .{
  x = 13,
  -y = 67,
  33
  try expect (pt.x
  try expect(pt.y
  
  13);
  67);

)

Re: Why is Zig so cool?

#53
post #46

There's at least 1 thing that Zig is better than Rust is that Zig compiler for Windows can be downloaded, unzipped then used without admin right. Rust needs msvc, which cannot be installed without admin right. It is said that Rust on Windows can use cygwin but I cannot make it work even with AI help.

You should check out cargo-zigbuild which makes use of zig for cross compiling rust projects. https://github.com/rust-cross/cargo-zigbuild

Re: Why is Zig so cool?

#55
post #7

Earlier quoted context omitted.

> One may wonder how the compiler discovers the variable type. The type in this case is *inferred* by the initialization. That the author feels the need to emphasize this means either that they haven't paid attention to modern languages for a very long time, or this article is for people who haven't paid attention to modern languages for a very long time. Type inference has left academy and proliferated into mainstre…

> Type inference has left academy and proliferated into mainstream languages for so many years that I almost forgot that it's a worth mentioning feature. It’s not common in lower level languages without garbage collectors or languages focused on compilation speed.

C++ added auto 14 years ago. Swift had it since day 1 back in 2014 if I remember right. What else is there?

Re: Why is Zig so cool?

#56

Earlier quoted context omitted.

That's really cool actually. Now that AI is a little more commonly available for developer tooling I feel like its easier than ever to learn any programming language since you can braindrain the model.

The standard models are pretty bad a zig right now since the language is so new and changes so fast. The entire language spec is available in one html file though so you can have a little better success feeding that for context.

> The entire language spec is available in one html file though so you can have a little better success feeding that for context.

This is what I've started doing for every library I use. I go to their Github, download their docs, and drop the whole thing into my project. Then whenever the AI gets confused, I say "consult docs/somelib/"

Re: Why is Zig so cool?

#57
post #7

Earlier quoted context omitted.

> One may wonder how the compiler discovers the variable type. The type in this case is *inferred* by the initialization. That the author feels the need to emphasize this means either that they haven't paid attention to modern languages for a very long time, or this article is for people who haven't paid attention to modern languages for a very long time. Type inference has left academy and proliferated into mainstre…

> Type inference has left academy and proliferated into mainstream languages for so many years that I almost forgot that it's a worth mentioning feature. It’s not common in lower level languages without garbage collectors or languages focused on compilation speed.

Compilation speed — OCaml, Go, D, C#, Java

“Low-level” languages — Rust, C++, D

Re: Why is Zig so cool?

#58
post #20

Is it cool? It seems to be in nether land between Rust and Go. Not sure what is the unique use case for Zig.

Well, it's insanely simple, insanely fast, often more performant than Rust with lower resource usage, with first class C-interop and cross-compiling out of the box. It's easily my favorite language now, with Go being a close second. Both are opinionated and have a standard formatter that makes Zig code instantly readable when you see it, similar to Go. Rust was once interesting, but it's firmly in macro hell territory now, just like Swift, with concealed execution paths aplenty and neither cross-compiling out of the box.

Re: Why is Zig so cool?

#59
post #7

Earlier quoted context omitted.

> One may wonder how the compiler discovers the variable type. The type in this case is *inferred* by the initialization. That the author feels the need to emphasize this means either that they haven't paid attention to modern languages for a very long time, or this article is for people who haven't paid attention to modern languages for a very long time. Type inference has left academy and proliferated into mainstre…

> Type inference has left academy and proliferated into mainstream languages for so many years that I almost forgot that it's a worth mentioning feature. It’s not common in lower level languages without garbage collectors or languages focused on compilation speed.

The only popular language I can think of is C (prior to C23). If you want to include Fortran and Ada, that would be three, but these are all very old languages. All modern system languages have type deduction for variable declarations.

Re: Why is Zig so cool?

#60
post #39

Earlier quoted context omitted.

> Isn't cross compilation very, very ordinary? Working cross compilation out of the box any-to-any still isn't.

Yes, very rare and there is a strong cartel of companies ensuring it doesn't happen in more mainstream langs through multiple avenues to protect their interests! From helicoptering folks onto steering committee and indoctrination of young CS majors.

If I had the ability to downvote a comment yet, I'd downvote you. If you're going to spout conspiracy-theory-sounding stuff, at least provide some evidence for your claims!
Post reply on HN