Zig programming language as First-class citizen

Some days ago i published posts with the same title on

OpenWRT is

  • open source Linux Embedded system
  • 99.99% of application code is written on C
  • relative big(r/openwrt has 34K members vs 18K of r/zig) and active community

Looks like a suitable environment

Posts were kind of ping - just check the reaction to “foreign body

Oh god no

C is going to stay around forever.
Programming language of the week is not going to change that.

Nothing new. This was expected reaction.

We can improve Zig “happily ever after”, but it’s unllikely change the situation.

Looks like a problem of marketing department and not R&D

And maybe it’s too early to think about it?

Don’t click !!!

In my opinion, Zig doesn’t need to worry about how it’s perceived externally. Programming languages are tools, ultimately, their purpose is simply to help us accomplish tasks. While we’re not purely rational beings, there is a strong pragmatic bias in a capitalistic market.

If Zig, as a tool, can match C’s functionality within a specific context while lowering operational costs, public opinion on whether Zig is a viable C replacement will be irrelevant. Over time, a company using C will struggle to compete with one using Zig if Zig genuinely reduces operational costs by improving developer experience, safety, product quality, and the time to market for new features. If the C company refuses to adapt, it risks losing market shares, and potentially even fading out.

Therefore, Zig’s focus should be on becoming an exceptional tool (useful, reliable, and enjoyable to work with). This alone will naturally generate traction.

From my personal experience, I’ve spoken with recruiters in embedded software development for the French defense industry, as well as with senior engineers and product managers from those companies. From what I can tell they don’t display a strong bias toward C, sure it’s the natural goto because of the current state of the ecosystem and the culture in embedded, but they’re open to new tools as long as these tools are demonstrably useful. For instance, one engineer I talked to rewrote part of a networking stack in Rust, and no one objected to it not being in C, they simply cared that it was reliable and effective. I expect Zig to receive a similar reception in most companies.

12 Likes

I am not ready to hold everyone else to this standard, but for me personally, I would be hesitant to actively advocate for “production usage” of a language which is still under construction and which still hasn’t reached 1.0 and doesn’t have stability guarantees. To clarify, I work at TigerBeetle, and we are using Zig in production, but we know very well what we are doing. While I’d be happy to extol benefits of Zig to anyone who actively asks, I would avoid actively pushing it onto someone for now.

EDIT: but don’t take this too seriously, I still have a laptop with “Rust evangelism strike force” sticker on it :stuck_out_tongue:

17 Likes

Why? Even if someone froze at a particular version of Zig for 5 years, they’d probably have a better developer experience than using certain other languages. If people can advocate for languages that I would never want to touch, why can’t someone advocate for Zig?

3 Likes

Good questions!

If people can advocate for languages that I would never want to touch, why can’t someone advocate for Zig?

They certainly can advocate for Zig! I am not saying they can’t, I am saying only that I wouldn’t, and why. This is to help others make their mind on the topic!

And, to clarify, I am talking about a very specific narrow subclass of advocation here, “pushing the language”. I am certainly happy to advocate for Zig by writing Zig code, by writing about Zig on my blog, and by speaking about Zig when I am invited. What I am avoiding is going to someone else’s space without invitation and starting speaking about Zig, instead of what that place is nominally about. In a pinch, that kind of thing can actually be useful sometimes, but I think Zig is not there yet at the moment.

Separately, I’d maybe caution against the logic of “if other people can do this on the Internet, why I can’t?” — some people say all kinds of crazy things, and the nature of Internet is that it tends to amplify the most controversial opinions. So, again, for myself, I just don’t care what the others say, I try to reason from the first principles about what’s the right thing (so, don’t listen to me either, lol :slight_smile: ).

Even if someone froze at a particular version of Zig for 5 years, they’d probably have a better developer experience than using certain other languages

The way I see it, the two major forces that shape the ever growing body of software are:

  • uncertainty about the future
  • path dependence on the past

Decisions made today tend to reverberate decades into the future, often in unexpected way. Circa 1995, Unicode was all the rage, and so all of JavaScript, Java, C++, and windows jumped onto the wchar bandwagon, declaring that a “character” is 16 bits. As a result, most prominent APIs of today are basically impossible to use correctly: String.prototype.charAt() - JavaScript | MDN.

So I am very wary of decisions which are simultaneously hard to undo and carry a lot of uncertainty! And picking a pre-1.0 language is one of the central examples here! A doom scenario here would be, for example, that in five years:

  • something happens to Zig (hostile takeover of the foundation, something happening to Andrew, Rust fully eating the world, etc)
  • Apple releases a new CPU, O-90, which uses a new architecture yet again (RISCV)
  • A new LLVM version supports riscv-apple target tuple
  • But there’s no one to upgrade five-year-old Zig to it

And there’s also more mundane issues like Andrew liking to break the build system in every release :smiley:

There are contexts where these can be viewed not as unacceptable risks, but rather as smart bets to make, but I expect those context to be rare, specific, and requiring case-by-case reasoning at the moment.

13 Likes

I meant that even 1.0 won’t improve the situation.

In the answers no one even mentioned the language version as a reason not to use it, but current zig version was in the first line of the post

On discrouse, the first (and most :+1:uped ) reply there was about path dependence, the exact thing I have described above. It is the same concern, just not expressed in terms of version numbers.

This is the correct reaction for OpenWRT to have. Especially “programming language of the week”.

Why Zig? Why not Odin, why not Nim? Jai will be coming out someday (probably…) why not hold out for that? Why not Ada, for that matter? Carbon? It’s backed by Google. Or, may I introduce you to our Lord and Savior the Crab

Are the advantages of Zig compelling? I think the answer is “yes of course”, but why would a 20 year old project written in a 50 year old language see that?

The language isn’t stable, there’s no specification. Does it even target everything which uses OpenWRT (I would be surprised by that)?

The way to get Zig a seat at the table is to keep writing compelling software in it. Ghostty is going to be a real boon to the ecosystem once it’s public. Joran Dirk Greef’s TigerStyle presentation has been visibly influential, I see it referenced a lot now, it’s contributing to the conversation in a way which reminds me of early Rich Hickey.

Just to cite one fact about the state of the language: there’s an open issue for a complete audit of the standard library, where any and all changes are on the table. If OpenWRT started merging Zig code, in addition to being stuck with the language forever, come what may, it would be taking on the maintenance burden of updating all of that code to use the new standard library, which might include needing to vendor things which didn’t make the cut. That’s a big ask.

There are surely some more adventurous C codebases which are interested in adopting Zig, the build system alone is quite attractive. But the best thing we can do for language adoption right now is use it to write great software.

8 Likes

Some interesting facts regarding OpenWRT:

  • since 2015 OpenWRT is based on musl libc
  • Andrew Kelley is individual musl libc project sponsor
  • The Zig Programming Language is musl libc project sponsor
  • x86_64-linux-musl - one of the zig build targets
1 Like

G. Steele and P. Gabriel presented a theory at 1993 ACM History of Programming Languages II Conference. After 30 years, their programming languages theory still holds.

You can find a description of the theory at page 111 (chapter: The End of History and the Last Programming Language) of the P. Gabriel book: Patterns of Software (Tales from the Software Community).

There are four parts to the theory:
• Languages are accepted and evolve by a social process, not a technical or technological one.
• Successful languages must have modest or minimal computer resource requirements.
• Successful languages must have a simple performance model.
• Successful languages must not require users have “mathematical sophistication.”

Let’s look at how languages are accepted and evolve. My theory, which Steele seems to accept, is that a number of factors enable a language to flourish:
• The language must be available on a wide variety of hardware.
• It helps to have local wizards or gurus for the language.
• It must be a minimally acceptable language.
• It must be similar to existing popular languages.

5 Likes

Zig doesn’t need to worry about how it’s perceived externally

I agree. Zig inherits a lot of C’s reputation as far as it’s positive, because it has the same interfaces or abstractions.

Comptime adds a whole universe of potential advantages to that.

Where I perceive all modern languages as weak is where library contributions seem to inevitably lead to some kind or npm-ish dependency hell.

I believe Zig could greatly benefit from a more consolidated approach. I am thinking of how C and UNIX have been a great development environment (re. POSIX functionality) including most OS functionality until the time when innovation ceased in UNIX world and Linux took the lead.

I see two projects that would synergize well with Zig. One would be a server development platform, let’s call it a distribution. That should include the scope of POSIX and Linux functionality, but not necessarily the aged API standards, maybe with a side eye towards macos and windows. This could be the basis for minimal container images, server deployments and maybe even a desktop (though that’s not my focus).

A similar project would be something resembling Ansible. Ansible has a powerful set of modules and it’s extremely easy to use, but it fails to scale because of some design flaws, Python on targets and all kinds of barriers making reuse very hard. Having this kind of functionality available as a comprehensive and curated “core” library would make build.zig a viable alternative to Ansible and provide a whole lot of funcitonality allowing Zig to encroach on use cases that are currently reserved for Go and Python.

These would probably be new projects rather than existing ones adopting Zig, but I believe that they would uniquely benefit from Zigs particular features.

The Zig/Linux distribution would benefit hugely from comptime, especially if parts of it would also work on mac and windows. The cooperation between musl and zig would also play very well into that. And either way, Zig is already doing a lot to wrap OS functionality into a standard library. The limited scope is however preventing that library from covering enough ground to make a difference in how easy it is to get things done fast (imho).

Zig-Ansible would greatly benefit from Zigs cross platform compilation. It could preserve Ansible’s agent-less architecture (one big plus of Ansible in my eyes) and also remove the need for a Python interpreter and these horrible Ansibalz (python-tars) that get shuffled over the network for each task.

If the scope of either or both of such projects would extend to cloud technology, then zig could include a “deploy” command in addition to “build” and “monitor” or “debug”.

I think that could help Zig a lot, considering that all of these topics are still hot (because of the cloud and a possible future in which the cloud migrate back to the edge - to use all the buzz words) and there is are tons of community contribution in all of of these fields.

If anybody here finds this attractive, I reserved a domain “zensible.dev”, proposing this as name for such a project - A sensible Ansible with a little bit of Zig zen :wink:

2 Likes

Don’t give up!!!
We are moving forward!!

ANNOUNCEMENT:

Zigsters are looking for:

  • development project/platform
  • relative new
  • posix api
  • c based

We are going to ensure “peaceful coexistance” of two languages and two dev groups:

  • Zig developers are part of platform community
  • Zig toolchain is the part of platform toolchain
  • Zig binding for platform APIs or Zig native libraries
  • Build - based on build.zig
  • Enchancement or new features - developed mostly on Zig
  • etc.

So which project/platform will suffer from Zig intervention?

Welcome to Ziggit @mutech!

You may be interested in a recent thread on advanced Zig projects.

2 Likes

Thanks for the pointer, I’m going to make a pitch there. :slight_smile:

2 Likes

Hey, they are starting to mock us, which I take as a good sign:
https://www.reddit.com/r/ProgrammerHumor/comments/1gqhu5e/averagezigdeveloper/

I really need a hoodie with Zig logo…

7 Likes