Live data from Hacker News

Zig is becoming more production-worthy

zigmonthly.org

61–70 of 73 posts

Re: Zig is becoming more production-worthy

#61
post #52

I used Zig for a couple of Advent of Code problems last year. I decided that Zig is not a language I’m going to be using. Here’s why: - If you ever want to allocate memory, you have to pass in an allocator to the function doing the allocating. You also have to explicitly allocate and deallocate. - Zig has no concept of a string - it’s just a slice of bytes. This also means Zig has no support for string concatenation,…

>t’s very much the next C

And that is great, once Zig is fully settled down we need something like Objective-Zig, or may be call it Zag.

Re: Zig is becoming more production-worthy

#63
post #7

Earlier quoted context omitted.

Looks like it has nice syntax but it seems very very far from pushing state of the art, and that is totally fine.

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…

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

#64
post #62
post #22

Earlier quoted context omitted.

Dart is one of the only compiled languages that also does that (see Flutter).

If we ignore Java, .NET, Common Lisp and C++.

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

#65
post #64
post #62

Earlier quoted context omitted.

If we ignore Java, .NET, Common Lisp and C++.

Those are not compiled to native code (C++ has hot swapping?), which is the obvious meaning of hot-swapping we're discussing here.

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

#66
post #65
post #64

Earlier quoted context omitted.

Those are not compiled to native code (C++ has hot swapping?), which is the obvious meaning of hot-swapping we're discussing here.

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++.

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

#67
post #66
post #65

Earlier quoted context omitted.

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++.

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

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

#68
post #66
post #65

Earlier quoted context omitted.

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++.

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

> 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

#69
post #29

Earlier quoted context omitted.

I’m excited for Zig’s possible future in embedded, too. I currently use Nim for our firmware at work, because at the end of the day —compileOnly means it’s just C. It’s been excellent for ESP-IDF/FreeRTOS, but I’d love to see Zig tackle it as well. One lovely side effect of using Nim is our “business logic” code is remarkably simple in the firmware, as I got PPPoS working nicely with our Cat-M1/LTE NB-IoT modem, so m…

I've been diving into Nim in my free time after experimenting with Zig and Rust. I really appreciate how clearly I can layout business logic in code without needing to qualify what the compiler should do (my biggest issue with rust is all the stuff you need to do to satisfy the borrow checker I feel obfuscates your intention). Getting to use Nim for your day job sounds like a dream! I'm particularly keen on Nim's UFC…

> I'm particularly keen on Nim's UFCS

One of my favourite parts about UFCS is how it can turn C libraries that I've had to bind into nice clean looking interfaces!

    esp_err_t sw_enableRx(SwSerial *self, bool State)
Becomes

    proc sw_enableRx*(self: ptr SwSerial, State: bool): esp_err_t {.importc: "$1", header: "".}
Which when called is super lovely!

    var port = sw_open(params, etc)
    port.enableRx(true)

Re: Zig is becoming more production-worthy

#70
post #69

Earlier quoted context omitted.

I've been diving into Nim in my free time after experimenting with Zig and Rust. I really appreciate how clearly I can layout business logic in code without needing to qualify what the compiler should do (my biggest issue with rust is all the stuff you need to do to satisfy the borrow checker I feel obfuscates your intention). Getting to use Nim for your day job sounds like a dream! I'm particularly keen on Nim's UFC…

> I'm particularly keen on Nim's UFCS One of my favourite parts about UFCS is how it can turn C libraries that I've had to bind into nice clean looking interfaces! esp_err_t sw_enableRx(SwSerial *self, bool State) Becomes proc sw_enableRx*(self: ptr SwSerial, State: bool): esp_err_t {.importc: "$1", header: " ".} Which when called is super lovely! var port = sw_open(params, etc) port.enableRx(true)

The end result doesn't look anything like C! Really nice.

Nim almost feels like I'm writing a dynamic scripting language, except that I've worked with a typed python code base and it sucked because typing always felt taped on. With generics in Nim I feel like I'm duck typing, but my ducks are compile time checked!

I'm keen on experimenting with protocol oriented programming and as far as I understand, UFCS provides this really neatly to the language. I really like the idea of being able to define my own types and have them seamlessly work with functionality of other libs (and vice-versa) without needing to resort to a language feature like traits.

Post reply on HN