Live data from Hacker News

Why is Zig so cool?

nilostolte.github.io

341–350 of 527 posts

Re: Why is Zig so cool?

#341
post #324

Zig is so cool, but C is cooler. I like how Zig feels clear and simple to start with. I like that it gives one toolchain and makes cross compilation easy. I like that it helps people see how systems programming can feel approachable again. I also like that C has done these things for many years. I can use different tools, link libraries, and trust that it will still work. I can depend on standards that keep improving…

I've used for well oven a year now, and I identify with this comment... well no, but I used to. In between Zig, and another language I enjoy was Python, and it was breath of fresh air to come back to the C style that I know and love within Zig. I would have said exactly this, when I first started writing Zig. Today, Zig is so much better than C. I used to refer to Zig as an improved version of C. But I don't anymore.…

Have you tried C23, especially its new Unicode support? It really surprised me after returning to C more than ten years later.

You can now write wide and UTF-8 string literals directly:

    char8_t* s = u8"こんにちは";
    char16_t* t = u"Привет";
    char32_t* ustr = U"你好";

It just works across compilers, no special libraries or hacks needed.

C still feels like C, but cleaner, safer, and more consistent.

Re: Why is Zig so cool?

#342
post #193

Earlier quoted context omitted.

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.

"Computing is a fashion show"

-- Alan Kay

Re: Why is Zig so cool?

#343
post #328

Earlier quoted context omitted.

I mostly write C, but yes even a simple call to e.g. malloc has different semantics in C++ (you need to cast).

Proper C++ should use new , delete , custom allocators, and standard collection types. Even better, all heap allocations should be done via ownership types. Calling into malloc () is writing C in C++, and should only be used for backwards compatibility with existing C code. Additionally there is no requirement on the C++ standard that new and delete call into malloc() / free() , that is usually done as a matter of co…

[deleted]

Re: Why is Zig so cool?

#344
post #275

Earlier quoted context omitted.

Perl 6 = Raku.

Please, stop deadnaming the Raku Programming Language :-)

I thought it was useful information for people who did not know this. Of course Wikipedia would have sufficed, too: "Raku, formerly known as Perl 6 [...]".

Re: Why is Zig so cool?

#345

Earlier quoted context omitted.

As much as I dislike Rust, I gotta give it credit where it's due. It has something unique: a borrow checker. What is so unique in Zig?

> It has something unique: a borrow checker. Rust's borrow checker isn't unique either but was inspired by Cylone: https://en.wikipedia.org/wiki/Cyclone_(programming_language) IMHO a programming language doesn't need a single USP, it just needs to include good existing ideas and (more importantly) exclude bad existing ideas (of course what's actually a good and bad idea is highly subjective, that's why we need many p…

I don't necessarily disagree, of course. That is why I like Odin the most so far, and perhaps C3.

Re: Why is Zig so cool?

#346
post #341

Earlier quoted context omitted.

I've used for well oven a year now, and I identify with this comment... well no, but I used to. In between Zig, and another language I enjoy was Python, and it was breath of fresh air to come back to the C style that I know and love within Zig. I would have said exactly this, when I first started writing Zig. Today, Zig is so much better than C. I used to refer to Zig as an improved version of C. But I don't anymore.…

Have you tried C23, especially its new Unicode support? It really surprised me after returning to C more than ten years later. You can now write wide and UTF-8 string literals directly: char8_t* s = u8"こんにちは"; char16_t* t = u"Привет"; char32_t* ustr = U"你好"; It just works across compilers, no special libraries or hacks needed. C still feels like C, but cleaner, safer, and more consistent.

I abandoned the goal of investing More time into C when they couldn't get defer into their latest version.

2 years later, already enjoying it in Zig `defer` is a lot less important to me now. But I still view it as a symptom of the death of the language. C isn't dead, by any stretch of the imagination, but it's no longer learning from it's mistakes, where as I still am.

Re: Why is Zig so cool?

#347

Earlier quoted context omitted.

I was also curious what direction the article was going to take. The showcase is cool, and the features you mentioned are cool. But for me, Zig is cool is because all the pieces simply fit together with essentially no redundancy or overloading. You learn the constructs and they just compose as you expect. There's one feature I'd personally like added, but there's nothing actually _missing_. Coding in it quickly felt…

Having spend a year tinkering in zig and it's absence of features has made me want to drop c#/java professionally and pick up Golang. Its quiet annoying when you see a codebases written in C#/java and you can tell in which year/era it was written because of the language features. The way of writing things in C# changes like every 4 years or so. There's a certain beauty in only having to know 1~2 loops/iteration conce…

You already have have Go, before and after modules, before and after generics, before and after ranges over function types.

Skipping other minor changes.

However I do agree C# is adding too much stuff, the team seems trying to justify their existence.

Re: Why is Zig so cool?

#348
post #79

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…

I think this is a major mistake for Zig's target adoption market - low level programmers trying to use a better C. Julia is phenomenally great for solo/small projects, but as soon as you have complex dependencies that _you_ can't update - all the overloading makes it an absolute nightmare to debug.

Ada has them, and I guess we all agree on its systems programming nature.

Re: Why is Zig so cool?

#349
post #317

Earlier quoted context omitted.

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 c…

BEGIN blocks execute at compile-time. require is just a wrapper to load a module at compile-time. When you want to use state, like openening a file for run-time, use INIT blocks instead. These are executed first before runtime, after compile-time. My perl compiler dumps the state of the program after compile-time. So everything executed in BEGIN blocks is already evaluated. Opening a file in BEGIN would not open it l…

I think we’re using different definitions of “compile time”.

I know who you are, and am sure everything you say about the mechanisms of BEGIN is correct, but when I refer to “compile time”, I’m referring to something that happens before my program runs. Perl5’s compilation happens the first time a module is required, which may happen at runtime.

Perhaps there’s a different word for what we’re discussing here: one of the primary benefits of comptime and similar tools is that they are completed before the program starts. Scripting languages like perl5 “compile” (really: load code into in-memory intermediate data structures to be interpreted) at arbitrary points during runtime (require/use, eval, do-on-code).

On the other hand, while code in C/Zig/etc. is sometimes loaded at runtime (e.g. via dlopen(3)), it’s compile-time evaluation is always done before program start.

That “it completed before my code runs at all” property is really important for locality of behavior/reasoning. If the comptime/evaluation step is included in the runtime-code-load step, then your comptime code needs to be vastly more concerned with its environment, and code loading your modules has to be vastly more concerned with the side effects of the import system.

(I guess that doesn’t hold if you’re shelling out to compile code generated dynamically from runtime inputs and then dlopen-ing that, but that’s objectively insane and hopefully incredibly rare.)

Re: Why is Zig so cool?

#350
post #322

While some of the features the author references are really interesting, personally I don't see how any of that would justify creating a new memory unsafe language in 2016. I thought it was pretty obvious by now [1][2][3] memory safety is best left to tooling / compilers and not to programmers. [1] https://research.google/pubs/secure-by-design-googles-perspe... [2] https://www.microsoft.com/en-us/msrc/blog/2019/07/we…

I think even in the year of our lord 2016 there's room for a language with safe defaults but seamless interoperability with existing unsafe code. It's certainly an improvement on the status quo and provides an alternative to rewriting the world in Rust or a GC language.

Except Zig defaults could be found on the year of our Lord in 1976, 1978, 1983 and 1986.

Exercise from other posts of mine which languages those might be.

Post reply on HN