Top
Best
New

Posted by ksec 3 days ago

What Zig felt like, coming from Rust(besok.github.io)
276 points | 346 commentspage 2
truth_seeker 3 days ago|
Detailed in depth look at Zig Vs Rust (also ... Vs Go)

https://gist.github.com/corporatepiyush/5382d79192be9737cf3b...

elendilm 3 days ago||
> It turns out I’d simply forgotten how straightforward it can be to rely on bare CLI tooling.

Happy for you.

CLI tooling counter intuitively makes for very less friction especially when you are moving very fast.

spider-mario 3 days ago||
> The first thing that caught me off guard — and honestly, who would’ve expected this to be the memorable part — was IDE support, or the near-total lack of it.

I would have completely expected that.

ozgrakkurt 3 days ago||
Would recommend learning how to use arena allocation. You would have patterns like:

fn run_query(alloc) {

   arena = init_arena(alloc);

   defer arena.deinit();

}
simonask 3 days ago|
Step zero of using arena allocation is to build realistic benchmarks so you can measure if it's worth the trouble in the first place. Standard allocators are incredibly good these days, and even plugging in mimalloc or jemalloc will be much less work, and much less error prone.
boomlinde 3 days ago|||
I don't know about more error prone. Benchmarks completely aside, freeing a batch of stuff you've allocated in a single place makes it easier to manage memory. I think it should be preferred wherever it's an option for that reason most of all. The "killer app" is something like an arena allocator that lives for the duration of an HTTP request.
simonask 3 days ago||
I respectfully disagree. The technique has its place, and I use it once in a while, but whether it makes a positive difference for performance is highly sensitive to a number of factors.

For example, bump style allocators allocate very quickly, but at the cost of higher memory usage and therefore sometimes worse cache locality.

The only way to know is to actually measure.

boomlinde 3 days ago||
You disagree with a point I never made. My point is that they enable easier memory management, regardless of whether they're more performant. I really don't understand how that point didn't get across. You must simply not have read what you responded to.
simonask 2 days ago||
You said

> I think it should be preferred wherever it's an option for that reason most of all.

And that’s far too broad in my opinion.

Sure, if you’re writing in a language that makes memory management difficult, like C or Zig, that might be worth it, but arena allocators apply to many other languages too.

boomlinde 1 day ago|||
> You said

Yes, which you didn't respond to until now.

> And that’s far too broad in my opinion.

Similarly, it's far too broad to say that it's "much less error prone" to use a more general allocation strategy. Clearly we both make unspoken assumptions, but in the context of this discussion on Zig, where you initially responded to an example written in Zig, I think you actually understood what I meant.

slopinthebag 3 days ago||||
i think the reason is more that arena's let you manage lifetimes in groups instead of pointer chasing. if you have to manually manage memory, it's eaiser to manage a small number of arena objects instead of a large number of individual objects.

eg https://www.dgtlgrove.com/p/untangling-lifetimes-the-arena-a...

that being said, it's even easier to not manage any lifetimes at all :)

although i suppose some will say that you still manage lifetimes in rust, you just have full support from the compiler to make sure you do it right. that seems better to me than relying on simplification to ensure you don't make mistakes.

ozgrakkurt 3 days ago|||
I meant to suggest using arena allocation for everything and not even using a malloc style allocator. Just getting memory via memmap at program start and then using arenas for everything after that.

It makes it much easier to avoid lifetime mistakes in my experience.

Using arena allocation also makes me think more about how much memory I am using and how much memory I should be using etc.

It is hard to benchmark it against just using a global allocator because it is a structural change to the whole codebase.

simonask 3 days ago||
If this works for the programs you write, that’s great. It does preclude you from using many great data structures with potentially better performance - especially hash maps. Rehashing is pretty detrimental to most arena allocators you can think of.
ozgrakkurt 2 days ago||
It is pretty tough to figure out how to structure it and I’m not 100% on it.

But, you can use hashmaps fine. Just need to think about it and structure the program well for it.

It becomes clear once you do it a couple of times

jauco 3 days ago||
Given that the author mentions both using helix and zig encouraging larger files with more content I’d be curious to know how they navigate these files in helix. The thing that keeps me from using it is lack of code folding, which I notice I use a lot when navigating larger files to zoom out.
karmakurtisaani 3 days ago||
Off topic, but I remember fondly the pre-LLM days when I used to love reading about programming languages. I never got a chance to professionally work with Rust, but made some cool hobby projects with it. Would have eventually tried out zig too.

Now it all feels so pointless though. Like memorizing rules to do mental arithmetic. Sure, there is still use for language expertise, but not enough to get excited over new concepts and ideas.

alembic_fumes 3 days ago||
I relate to this.

For years I used Rust as my hobby-programming language and loved it greatly. I never managed to land a job working with it full-time, because either the work was too niche or it didn't pay enough, or I was simply too comfortable where I was to change. And now that I finally have enough discretion over my technology choices to run a "proper" project using whatever tools and languages I want, it is not me but the AI that writes all of the code.

There's a part of me that feels a quite sad about all this. It's almost as if there actually all along existed a real final deadline on finding that "dream job". And I missed it. And while I expect this one miss to be just a small piece in the grand picture of things that we're going to lose or have already lost to the zeitgeist of agentic SWE, it feels big to me. It was my professional dream, while I still had professional dreams.

NetMageSCW 3 days ago|||
I seemed to have been through this pattern in my interests multiple times and just wait in the between times for something of interest. For hobby/interests I started with programming languages and then moved into understanding hardware and then mobile devices. I wrote HP 41 s/w, HP 48 s/w, the first public dethreader for HP 48 ROMs, Newton s/w, Windows CE s/w, jailbreak s/w and on device iPhone 1.0 s/w (pre App Store), but have been waiting for the next thing since iPhone 5 or so. In languages I went through a lot as well and now am waiting on C# to be improved.
karmakurtisaani 3 days ago||||
Yeah, this is exactly it. Not earth-shattering, but personally depressing. My solution has been to start a career switch.
asp_hornet 2 days ago|||
I relate to this comment so much. Like you said, just the first in many things we will lose. Gratitude I can still support my family and build cool stuff at all now.
ratorx 3 days ago|||
I think (for now), it is still relevant. A language is an abstraction, and a good abstraction, like a good LLM harness, can be quite valuable.

Let’s say I’m writing some concurrent code with an LLM. I’d probably feel much safer having it write Rust, rather than C. So even in a post-LLM world, languages will continue to evolve as long as abstractions can be improved.

karmakurtisaani 3 days ago||
But do you still have enthusiasm for finding out about new language features or concepts? I'll do what it takes to get the job done, but the passion for it is totally gone.
frje1400 3 days ago|||
Yes, as an example structured concurrency in Java (final release in Java 28 perhaps). I think that could totally change how we write concurrent code in that language.

I just upgraded a less important service to Java 27, a few days after its release (several nice features). It's cool how easy it is to upgrade nowadays.

That an agent writes most of the code doesn't mean anything to me here.

My examples are Java because that is the main language where I work.

karmakurtisaani 3 days ago||
Thanks for the perspective.
frje1400 3 days ago||
You're welcome. I now feel inspired to try to change your mind, if you don't mind.

I would argue that "concepts" actually are more important than ever. Let's take my structured concurrency example. It doesn't matter here exactly what is, but if it ends up being as important as I think it will be, I likely want to write most concurrent code that way going forward.

However, it will likely be years until agents go to it unless deliberately steered in that direction. And if I want to make agents write it, I need to review it, and if I'm going to review, I need to understand it.

I think this is why I'm not pessimistic about the profession, it still feels like what I'm doing and learning matters.

slopinthebag 3 days ago||
just chiming in to say that i agree with you. i initially felt demotivated and passionless but the more i use llms to generate code the more i feel like knowledge of the concepts are crucial to generating useful code.

eg. you dont need to memorise sorting algorithms or be able to write them, but you do need to understand the concept of sorting, and the concept of time complexity, etc etc. knowing what data structures to use and when to use them. knowing how to structure concurrency for your problem space. many many concepts.

system design is becoming the most important thing, and to me it's also the most interesting part of creating software. and there will always be more to know.

za3faran 3 days ago||||
There's a couple of languages I follow their roadmap and I find exciting, including Java and C#. I don't feel there's proper justification of writing backend services in something like python or ruby anymore, for example.
karmakurtisaani 3 days ago|||
Yeah, I also try to follow what's new. But it's more like "Ok, that's good I guess." Rather than "Cool! Looking forward to applying this in my next project!"
NetMageSCW 3 days ago||||
I found C# exciting when it was new and adding features that were important to me, but now it feels like it has become bogged down with chunks just abandoned on the alter of backwards compatibility (Expression, anyone?) and adding features I couldn’t care less about (null safe code, pattern matching, etc).
Quothling 2 days ago||
I worked with C# for a decade around the transition from .net to .net core to .net. I've come to really dislike it as a language because of it's implicity and abstractions but I'm surprised that you're not finding the new features intereting. All the work on immutability seems pretty awesome to me at least. Sure it's still this bastard version where you build "readonly" objects and put them into immutable collections, but I assume they'll work on this going forward.

I'm never going back to it, but I do think it's the best it's ever been.

pjmlp 3 days ago|||
Never was really, at least if performance matters.
tonyhart7 3 days ago|||
nothing stopping you to code manually
karmakurtisaani 3 days ago||
Nothing stopping me from doing a lot of things. But is there any point to it?
layer8 3 days ago||
Meaningfulness comes from what you care about. I wonder why you were interested in programming-language concepts before but now (apparently) stopped caring about the code. The code still remains the language that communicates the actual program logic.
karmakurtisaani 3 days ago||
I guess a large part of my motivation was that it makes me a more effective and skilled programmer. There are countless of interesting things out there, and the motivation to focus on one comes from what you do with it later on.
rgoulter 3 days ago|||
> Sure, there is still use for language expertise, but not enough to get excited over new concepts and ideas.

Programming and learning new things can still be fun in the era of agentic coding.

With LLMs, I get to quicky ask: what would this look like? Why do it that way? If you suspect that the LLM isn't doing it the right way, you can still investigate that yourself.

e.g. the other day, https://rhombus-lang.org/ was mentioned on HN. With LLMs, the cost for trying this out is practically much lower.

karmakurtisaani 3 days ago||
Yep, learning new things is amazing now. Just today I went through some really crappy slides, just dropped them to gemini and asked for elaboration. It saved me hours of figuring the shit out the old fashioned way.
eddythompson80 3 days ago|||
I was thinking about that too recently. We have a new service that we’re trying to publish an SDK for. I don’t like the SDK that was created and kept nitpicking about how verbose certain things are and how “unergonomic” it feels (long tedious type names, annoying redundant constructs, etc) But then I was wondering if for a brand new service/SDK if anyone cares anymore and how much fuss i should be making about that.
skhameneh 3 days ago|||
This is a bit nuanced, because if there’s redundant constructs then that does impact maintainability and efficiency with both runtime and LLMs working with the code.

I’d push this more towards personal preference of how code is expressed matters much less now than how maintainable it is.

There is the aspect of long type names, they often don’t have much impact when tokenized. The character count of words is nearly negligible - they often become one or two tokens anyways. But, the choice of words may have a greater impact on how the word choice weights an LLMs contextual processing of that word (a human may be able to ignore an inaccuracy in naming a bit more flexibly than some LLMs).

karmakurtisaani 3 days ago|||
Exactly, hard to see why any of this matters anymore.
echelon 3 days ago|||
I used Rust extensively pre-LLM, and I'm much happier to serialize my thoughts to Rust than any other language.

I prefer to prototype in Golang since it compiles fast and makes for quick iteration, but at the end I ask the LLM to port the Golang to Rust.

Nice Rust enums for APIs are the chef's kiss.

I absolutely will not write anything in Python or scripting languages anymore. They're too brittle and don't have great devex or deployment stories. Especially when you can just as easily build in a typesafe language with good error handling that compiles down to a single static binary.

boredatoms 3 days ago|||
It still boggles my mind that golang hasnt introduced rust-style enums
za3faran 3 days ago||
After reading many comments from its original authors, it's not surprising.
karmakurtisaani 3 days ago|||
Yep, my point tho is more sentimental than technical. Let the LLM figure out the language details and just manage the output and deployment. It's ... not fun
computerfriend 2 days ago|||
> the pre-LLM days when I used to love reading about programming languages.

The main thing to change this feeling for me is the large number of articles on programming languages written by an LLM.

bigstrat2003 3 days ago|||
It isn't like LLMs are actually good at programming, so there's no reason to give up on your interest in it. The hype around LLMs is not sustainable, the quality simply is not there.
wannabe44 3 days ago|||
> Sure, there is still use for language expertise, but not enough to get excited over new concepts and ideas.

In 5-10 years, the people who have paid attention to these will be needed to bail us out of the mess that the rest of the slop-addled monke brains have created.

karmakurtisaani 3 days ago|||
I'm skeptical, most human written code was and still is garbage and survives without major rewrites.
wannabe44 3 days ago||
We will imprison these slop addicted monke brains and start new academic regime, only hand written OCaml code allowed.

Jokes aside, have you watched 2001 - a space Odyssey?

Havoc 2 days ago|||
That seems about as probable as translator jobs coming back in 5 years time
layer8 3 days ago||
> I remember fondly the pre-LLM days when I used to love reading about programming languages.

First I thought you were going to comment about the grating LLM-isms in the article, which made me end up not enjoying reading it.

janden 2 days ago||
Articles like this make it clear that I have no idea what I'm doing. And I probably never will.
waffletower 1 day ago||
I found the statement "I found the resulting Zig code less readable than its Rust counterpart" absolutely hilarious, especially if you look at the code example comparison just above the statement.
AlienRobot 3 days ago||
In the example of Rust:

    items.iter().enumerate().filter(|(_, i)| cond(i)).map(|(idx, i)| Pointer::idx(i, path, idx)).collect()
vs. Zig:

    while (i < cursors.len) {
        if (actual_index < arr.items.len) { cursors[i] = .{...}; i += 1; }
        else iteration.remove(i);
    }
I think you have to be a special kind of person to call Rust "more readable."

The thing about Rust is that if you can appreciate zero-cost abstractions on iterators then the language feels like the only right way to program. But many programmers either don't use this sort of programming at all, or don't care if it has a cost in languages like JS, Python, Java, etc.

Personally I like Zig a lot because it feels like you're doing low-level programming but without having to program C which is... well, https://xkcd.com/918/

sgarland 3 days ago||
THANK YOU. I feel exactly the same way.

https://news.ycombinator.com/item?id=49769812

metaltyphoon 2 days ago||
You realize you can write the Rust version in the same way the Zig one too right?
AlienRobot 2 days ago||
I don't understand what you mean. The examples come from the article.
More comments...