News for hackers. Stuff that matters.
Re:Zig is becoming more production-worthy by verdagon on Tuesday July 05, 2022 @12:20AM (#31984273)
I love how Zig is pushing the state of the art forward. I have some expertise in the area, and I think the future is in languages that prioritize simplicity and developer velocity like Zig is doing.

> The core team will then be able to begin thinking about: ... Exploring hot-code-swapping

Hot code swapping, plus Zig's ability to cross-compile, plus release-safe's memory assistance without mental overhead, all seem to come from one underlying drive: support and empower the programmer without getting in their way.

When designing a language, it's important to keep the user's ultimate goal in mind: making useful software. For some domains that might mean adding restrictions, but for other domains it means getting out of the programmer's way and making language mechanisms and tooling so they can iterate, experiment, and build faster.

I'm particularly excited about Zig's future in webassembly, where many safety concerns are already handled by sandboxing. It's amazing to read that someone ported an entire game to webassembly with Zig.

Re:Zig is becoming more production-worthy by danielscrubs on Tuesday July 05, 2022 @12:35AM (#31984352)
Looks like it has nice syntax but it seems very very far from pushing state of the art, and that is totally fine.
Re:Zig is becoming more production-worthy by verdagon on Tuesday July 05, 2022 @12:45AM (#31984405)
It can seem like that on the surface, but a closer look reveals a lot of very interesting new features. Here's a few off the top of my head:

* Comptime, which can serve the purpose of generics without a new sub-language [1]

* Colorblind async-await, basically parameterizing async-ness to avoid the downsides of async's infectious nature [2]

* Hot-code swapping proof-of-concept [3] (Edit: specifically, new to low-level languages, AFAICT)

Pretty cool stuff!

[1] https://kristoff.it/blog/what-is-zig-comptime/

[2] https://kristoff.it/blog/zig-colorblind-async-await/

[3] https://www.reddit.com/r/Zig/comments/s9toy1/we_have_a_worki...

Re:Zig is becoming more production-worthy by ghoward on Tuesday July 05, 2022 @01:34AM (#31984676)
Zig's async/await isn't actually colorblind. [1] It just seems that way at first.

[1]: https://gavinhoward.com/2022/04/i-believe-zig-has-function-c...

Re:Zig is becoming more production-worthy by pornel on Tuesday July 05, 2022 @09:19AM (#31987878)
"Colorblind" is an arbitrary goalpost made to satisfy an imprecisely defined term of one blog post.

The original color article is soo annoying, because it presents two things as one: a JS-specific limitation, and author's arbitrary opinion on how async syntax should (not) look like. Since then even languages that don't have JS's limitation still keep chasing the other point, because otherwise they're shamed for having "color".

Re:Zig is becoming more production-worthy by kristoff_it on Tuesday July 05, 2022 @12:07PM (#31989987)
"having colors" is an unfortunate property of async/await, not of JS. C# has the same exact set of problems, made even worse by Microsoft's love for horrid APIs and inconsistent runtimes.
Re:Zig is becoming more production-worthy by anonymoushn on Tuesday July 05, 2022 @09:34AM (#31988021)
Is it a JS-specific limitation? Python works quite similarly.
Re:Zig is becoming more production-worthy by pornel on Tuesday July 05, 2022 @09:37AM (#31988055)
Make that JS+Python then. OTOH languages that can spawn threads and use synchronization primitives are able to bridge sync and async.
Re:Zig is becoming more production-worthy by anonymoushn on Tuesday July 05, 2022 @09:50AM (#31988174)
You can spawn threads in Python. Async/await is (among other things) a control-flow primitive for single-threaded programs. C# also includes more or less the same async/await as these languages, as far as I know.

Not only do threads not really do the thing (in part because of the high cost of threads compared to alternatives), the alternative isn't only threads. Users of Lua, Greenlet, ucontext_t, libco, etc. have been able to write single-threaded code that's generic over the async-ness of its callees for decades. Recently there's a trend toward preferring needing to change 99 call sites and function signatures when adding a single piece of I/O to a single function though, needing to write two versions of each library, etc.

Re:Zig is becoming more production-worthy by pornel on Tuesday July 05, 2022 @11:14AM (#31989196)
I'm not talking about trade-offs of async vs sync. I'm talking about the color article saying languages have "color" when one type of functions (sync) can't use results of another type of functions (async). If you have threads and mutexes, then one type can use the other, regardless of whether that's a good idea or not. The point is that there either is a hard unsolvable api-infecting limitation (like in JS) or there isn't.
Re:Zig is becoming more production-worthy by anonymoushn on Tuesday July 05, 2022 @01:38AM (#31984704)
Hello, have you had a chance to check out the successful implementation of the program you attempted to write in that blog post? https://gist.github.com/sharpobject/49bd88416e68606d7812d609...
Re:Zig is becoming more production-worthy by ghoward on Tuesday July 05, 2022 @02:22AM (#31984977)
Yes, why does that matter? It still shows that Zig's async/await is not colorblind.
Re:Zig is becoming more production-worthy by anonymoushn on Tuesday July 05, 2022 @02:29AM (#31985023)
It seemed like most of your post was about not being able to use the two functions through pointers of the same type, but you can use the two functions through pointers of the same type, so maybe now you can delete a majority of your post and submit a retraction to Hacker News or something.

I'm not sure you are using the same notion of "colorblind" as most people. All that is claimed is that much application code can be *compile time generic* over the async-ness of the I/O functions it calls. Stepping up the requirements to being runtime generic introduces some difficult concerns about the different error sets of different I/O functions, but async vs. non-async can be handled as in the above gist or by writing like one switch statement.

Re:Zig is becoming more production-worthy by dantillberg on Tuesday July 05, 2022 @12:05PM (#31989964)
I'm new to Zig this year, and I'll share my own learning experience. ziglang.org's overview[0] says, "Zig functions avoid colors." I interpreted that as similar to Go's lack of function colors. Given the rest of the language design, I didn't think it really possible.

Months later I read Gavin's post (linked above). I found that post immensely helpful to understand Zig's design around sync/async function colors (thanks Gavin!). Gavin's post helped to illuminate for me that Zig functions do have colors, but that the compiler can infer the color in most usual cases. This is still very exciting!

As I see it, it's not to Zig's detriment whether it "has" function colors or not, I don't really care. I'm really excited about Zig either way. But I personally (coming from a decade+ of JS/Python/Go) found the verbiage I found used to describe Zig's behavior here confusing.

[0]: https://ziglang.org/learn/overview/

Re:Zig is becoming more production-worthy by ghoward on Tuesday July 05, 2022 @10:09AM (#31988371)
My post has three quotes where people claim Zig is completely colorblind, not just at compile-time. My point stands, especially because of the hoops that gist had to jump through to get it to work.
Re:Zig is becoming more production-worthy by qaq on Tuesday July 05, 2022 @01:34AM (#31984678)
Erlang has had Hot-code swapping for decades
Re:Zig is becoming more production-worthy by brabel on Tuesday July 05, 2022 @02:00AM (#31984839)
Dart is one of the only compiled languages that also does that (see Flutter).
Re:Zig is becoming more production-worthy by freilanzer on Tuesday July 05, 2022 @07:39AM (#31986989)
Common Lisp as well.
Re:Zig is becoming more production-worthy by pjmlp on Tuesday July 05, 2022 @05:32PM (#31994005)
If we ignore Java, .NET, Common Lisp and C++.
Re:Zig is becoming more production-worthy by brabel on Wednesday July 06, 2022 @01:56AM (#31997265)
Those are not compiled to native code (C++ has hot swapping?), which is the obvious meaning of hot-swapping we're discussing here.
Re:Zig is becoming more production-worthy by pjmlp on Wednesday July 06, 2022 @02:24AM (#31997418)
They surely are,you apparently aren't aware of the available toolchains for such purpose.

Plenty of coments of mine where I list what exists since their early days.

Yes, C++ compilers like Visual C++ support it. Or Unreal tooling like Live++.

Re:Zig is becoming more production-worthy by brabel on Wednesday July 06, 2022 @03:24PM (#32005573)
But you claim Java can hot swap... I happen to know all about hot-swapping in Java, and it's only good for very simple debugging reloads... not at all at the same level as Dart VM. No one who knows Java would claim that.

Common Lisp is only hot-swappable when you're not running a binary, at least from what I know of SBCL.

So, it's hard to take your comment seriously. I am unfamiliar with Visual C++'s hot-swapping capabilities, but to claim the language itself can do it seems pretty ridiculous to me, as all you've got is machine code at runtime, C++ has no hot-swapping runtime and could never have one... which makes me think you're just confused about what we're talking about... I am not talking about debuggers here.

Re:Zig is becoming more production-worthy by pjmlp on Wednesday July 06, 2022 @04:43PM (#32006561)
Yes I claim, there are multiple implementation of Java, like JRebel.

Maybe spend some time using proper Lisps like LispWorks and Allegro Common Lisp.

Language and implementation aren't the same thing.

There is so much to learn about compilers, young padawan.

Re:Zig is becoming more production-worthy by lispm on Wednesday July 06, 2022 @05:29PM (#32007060)
> Common Lisp is only hot-swappable when you're not running a binary, at least from what I know of SBCL.

Which is false.

Re:Zig is becoming more production-worthy by kstenerud on Tuesday July 05, 2022 @02:06AM (#31984882)
For every feature X, there is a programming language Y that has had it for decades.

It's not a question of inventing it, but rather of making it mainstream popular.

Re:Zig is becoming more production-worthy by kjeetgill on Tuesday July 05, 2022 @07:39AM (#31986990)
It's extremely common in plenty of popular languages: Java's a big one, and if you count dynamic languages most do.
Re:Zig is becoming more production-worthy by catach on Tuesday July 05, 2022 @02:38AM (#31985075)
I expect that erlang is still significantly more popular than zig.
Re:Zig is becoming more production-worthy by kstenerud on Tuesday July 05, 2022 @02:45AM (#31985115)
Of course it is. Zig is an up-and-comer, so most established languages will be more popular at this stage. But Zig aims to be a mostly general purpose language (which is what the majority of mainstream languages are), whereas Erlang does not.
Re:Zig is becoming more production-worthy by pjmlp on Tuesday July 05, 2022 @05:36PM (#31994036)
Lisp has had it for decades, full blown graphical workstations were written in it.

Oberon used hot code reload for OS modules.

Visual C++ has had edit-and-continue for years, and hot reload as improvement since the last two years.

Re:Zig is becoming more production-worthy by muth02446 on Tuesday July 05, 2022 @01:05AM (#31984516)
RE 3:

Hot-code swapping seems to require a lot of tricky code. Are there compelling use cases that justify the implementation effort?

The examples seem to be mostly focused on swapping out functions but I dot see how it could handle structural changes to data structures.

Re:Zig is becoming more production-worthy by Cloudef on Tuesday July 05, 2022 @01:28AM (#31984647)
Hot-code swapping would guarantee a really fast compile times and maybe even "hot reload" of program while it's running. Do not underestimate how much this helps with developer productivity. I'm so tired of the compile times with large C++ codebases...
Re:Zig is becoming more production-worthy by cturtle on Tuesday July 05, 2022 @01:34AM (#31984680)
Exactly! The idea is during development you use the super fast backend that supports hot code swapping. Then when you want to make a release build you use llvm and get all the optimization benefits of a longer compilation.
Re:Zig is becoming more production-worthy by giancarlostoro on Tuesday July 05, 2022 @12:23AM (#31984291)
> I think the future is in languages that prioritize simplicity and developer velocity like Zig is doing.

I kind of dont like Zig because of the syntax its just a little out of the norm from what I'm used to. I like D more if I want to go the C-like route, just hate that its not quite as popular as Go or Rust seem to be. Currently I'm diving into Nim more than anything though, it feels like the sweet spot for me.

Re:Zig is becoming more production-worthy by NinoScript on Tuesday July 05, 2022 @12:52AM (#31984440)
One gets used to syntax, don’t let that be the reason you don’t like a language.
Re:Zig is becoming more production-worthy by giancarlostoro on Tuesday July 05, 2022 @11:12AM (#31989183)
It's not just syntax, it is obviously C-like which I like, but it is the way programs look, I think Zig is maybe more low level than I care for.
Re:Zig is becoming more production-worthy by sam0x17 on Tuesday July 05, 2022 @01:28AM (#31984646)
I wish I had known about D like a decade ago. I swear it was just too ahead of its time.
Re:Zig is becoming more production-worthy by pornel on Tuesday July 05, 2022 @09:31AM (#31987992)
I've tried it a decade ago, and it wasn't ready back then. It was split between D1 and D2, and Tango and Phobos. That was super annoying, because whatever documentation or library you'd find, it was most likely for a different combination of D+std than you had.

Enjoy D now when it's more mature. The betterC switch is especially interesting.

Re:Zig is becoming more production-worthy by ArrayBoundCheck on Tuesday July 05, 2022 @01:55AM (#31984804)
Its a great language. I suspect the problem was it tried to out java java (GC!) and it kind of tried to out C++ C++
Re:Zig is becoming more production-worthy by rowanG077 on Tuesday July 05, 2022 @12:42PM (#31990516)
To me simple and not getting in the way are complete opposites of one another. C and go are prime examples. The simplistic nature of the languages mean you can't express many obviously wanted things.
Re:Zig is becoming more production-worthy by OtomotO on Tuesday July 05, 2022 @01:44AM (#31984747)
Useful software is good.

But it shouldn't be easy to program in memory errors.

Re:Zig is becoming more production-worthy by ArrayBoundCheck on Tuesday July 05, 2022 @01:53AM (#31984793)
You mean rust shouldn't allow easy to write out of bounds errors?

I'm still waiting for a flag to disable runtime bound checks

Re:Zig is becoming more production-worthy by OtomotO on Tuesday July 05, 2022 @01:56AM (#31984810)
I haven't mentioned Rust.

I love KISS and Zig's simplicity especially but there is two sides to programming.

The engineers perspective and the user perspective.

I am both and prefer to have more paid hours and safer software ;)

Re:Zig is becoming more production-worthy by jorangreef on Tuesday July 05, 2022 @03:28AM (#31985379)
Zig takes a different approach to safety. For example, Zig has checked arithmetic enabled by default in safe builds, can guarantee static allocation, and can recover from memory allocation failure. It depends on the definition of “safer software”, but for many domains where safety is a field [1], these are also important design decisions.

[1] https://spinroot.com/gerard/pdf/P10.pdf