this post was submitted on 30 Aug 2023
103 points (94.0% liked)

Programming

17008 readers
448 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

I have been reading about this new language for a while. It's a C competitor, very slim language with very interesting choices, like supporting cross platform compilation out of the box, supports compiling C/C++ code (and can be used as a drop in replacement for C) to the point in can be used as replacement of (c)make and executables are very small.

But, like all languages, adoption is what makes the difference. And we don't know how it goes.

Is anyone actually using Zig right now? Any thoughts?

you are viewing a single comment's thread
view the rest of the comments
[–] CameronDev@programming.dev 18 points 1 year ago (16 children)

I've heard of it, and don't know what the point is.

In zigs defence, I felt the same way about rust a few years back as well.

I wonder what the killer feature for zig is. At least rust promises safer code, what does zig promise?

[–] jeffhykin@lemm.ee 12 points 1 year ago* (last edited 1 year ago) (5 children)

The killer feature (IMO) is automatic conversion of C code to Zig code (transpiling). E.g. take a C project, convert it all to Zig, and even if you don't transpile, you still get really nice compat (include C headers just like a normal input without converting). Getting a medium sized C project converted to Zig in 1 day or 1 week, then incrementally improving from there, is really enticing IMO especially considering the alternative of rewriting in Rust could be months of very hard conversion work. Transpiling isn't perfect but it seems to be a 97% soltuion.

The second advantage seems to be easy unsafe work.

BTW I don't really use Zig, and I still prefer Rust, but those are the reasons I think it has a niche of its own.

[–] CameronDev@programming.dev 6 points 1 year ago (4 children)

I wonder if owners of large C projects are that keen to move off C to zip though? I guess time will tell. I do a fair bit of C, and I can't see us risking switching to Zig, unless there was something else that made it really worth it. I should probably have a look at Zig if I have spare time, maybe there is a killer feature we aren't seeing yet.

Easy interop with legacy code is how kotlin took off, so maybe it will work out?

[–] Blackthorn@programming.dev 5 points 1 year ago (1 children)

My understanding is that this is possible: you should be able to take a C project, add a build.zig file and under the hood the system is calling clang to compile the C project. HOWEVER, you can now add a .zig source file, compile that in zig and link together with the output of the C compiler into an executable. If this is actually true, I can definitely see the attractiveness of the language.

[–] CameronDev@programming.dev 1 points 1 year ago

Definitely sounds like a well thought out upgrade path. But I don't feel like an upgrade path is a killer feature in of itself. I think I'd have to have a play with it to see if there is something to make transitioning worthwhile.

load more comments (2 replies)
load more comments (2 replies)
load more comments (12 replies)