4 ms·
As someone who dove deep into Rust at the end of 2022, I always find it interesting to read these stories from people who went through the harder times it was b
by vascocosta 1y ago
As someone who dove deep into Rust at the end of 2022, I always find it interesting to read these stories from people who went through the harder times it was back in 2015. I feel lucky to have learnt the language when it was much more developed, as it certainly made the already steep learning curve a bit more comfortable.
In a way I feel like I'm going through what is described in the article but for Zig. I guess Zig is more or less in a similar place now to where Rust was back then. Still I enjoy very much using it already.
- tonyhart7 1y agowhenever programming language adopted into big tech (MSFT,Google etc) or Big OSS (Linux etc) is already prove its mature ecosystem but I cant say the same to Zig because I dont see it as (big) update compared to what we have
- vascocosta 1y agoFor me the value in Zig is its simplicity as a language (in a way similar to go's simplicity) and the explicit and very fine grained control over memory allocation. On top of that, I really appreciate tagged unions and error handling. It adds enough value on top of something like C to make it worth for me. Still wherever I need absolute code correctness and production grade quality, I use Rust, my favourite language, at the expense of more code and spending more time doing it "the right way".
- throwawaymaths 1y ago> For me the value in Zig is its simplicity as a language I was reading an article about rust posted here yesterday and i realized: i have no clue what is going on in this code (also i presume "templage" is a typo): #[derive(Debug, Default)] pub struct Context { authed: bool, } #[derive(Template)] #[templage = "layout.jinja"] struct HomeTemplate { ctx: Context }; pub async fn home() -> impl IntoResponse { HtmlTemplate( HomeTemplate { ctx: Context::default() } ).into_response() }
- Narew 1y agoI personally think that the discovery of rust API is awfully as soon as macro is involve. It's impossible to know what argument is taken by macro. For example the "simple" `println!`, without example in the docstring it's impossible to guess what are the argument even when we have an IDE that show you the implementation.
- techjamie 1y agoLooks like a small request handler for an HTTP framework using a page written with the jinja templating engine. I'm a bit rusty (pun intended) so I can't immediately place which HTTP framework that is though.
- dsff3f3f3f 1y agoYou're correct and the HTTP framework looks like Axum.
- throwawaymaths 1y agoi mean i got that part :). my best guess is that the async function is some sort of factory? why you would need a factory to be async i have no idea.
- vascocosta 1y agoYes, while macros simplify some tasks, they also make it harder to really understand the code. Well, technically they hide the code in most languages as they're metaprogramming done in a separate language. I love Rust and do some advanced code sometimes, but very rarely have I created a macro. I still see it more or less like "magic" that "super-human" library developers master to make their life easier. Typically not my use case. This is another advantage of Zig. As you may know, metaprogramming in Zig doesn't use any special syntax, but rather the Zig language itself. This is often known as comptime and while not necessarily easy to grasp, as you're reasoning about compile time stuff, at least it's done in pure Zig.
- throwawaymaths 1y ago
- cogogo 1y agoI know nothing about zig so just looked it up on wikipedia. Apropos of nothing it’s the first wikipedia article I’ve read that I’m convinced was written by/using an LLM. https://en.m.wikipedia.org/wiki/Zig_(programming_language) https://en.m.wikipedia.org/wiki/Zig_(programming_language)
- Hasnep 1y agoHaving skimmed it, I had the opposite reaction, the wording is clunky in a way that I haven't seen LLMs do, it feels very human to me. Stuff like > Also the learning curve for Zig can be steep, especially for those unfamiliar with low-level programming concepts. I don't think an LLM would start a sentence with "also" like that > The small and simple syntax is an important part of the maintenance, as it is a goal of the language to allow maintainers to debug the code without having to learn the intricacies of a language they might not be familiar with. The wording here feels like someone who's a fan of Zig taking a sentence praising Zig's design and trying to rework it into a slightly more neutral encyclopedia style.
- cogogo 1y ago> Other challenges mentioned by the reviewers are interoperability with other languages… This sounds exactly how llms have made comparisons for me. What reviewers?
- metaltyphoon 1y ago> value in Zig is its simplicity IMO, there are things Zig just don’t care about, which in the surface makes it simple but its annoying and burdensome later on. * Manual interface implementation * Internals of a struct is public * No string types * anytype requires reading code * Error can’t carry information * The iteration abstraction in the std is all over the place * Unused declarations is compilation error
- vascocosta 1y agoI resonate with you about interfaces and a String type. At least these two are so prevalent even on the simplest of programs to warrant some proper language and std lib support.
- estebank 1y agoThere's a strong culture of "leave things better than you found them". When a user gets confused by the tooling/language, it's not the user's fault. If you got confused, chances are that others will too, so fixing/improving things when we encounter them has unbounded benefit. Second best time to plant a tree being today and all that. One benefit of this is that if someone tries and bounces, when they try again a year later their experience might be improved enough that they don't bounce again. For a while I was of the thought that the best piece of advice I could give someone wanting to learn Rust was "wait 6 months" :)
- jvanderbot 1y agoThis is such a great attitude. I know LLMs are becoming the new Godwin's law, but I really wish this attitude was pervasive in LLM-based tooling. "If it's not working you're prompting wrong" is all we have. But I guess "wait 6 months" still applies (except then you're "NGMI").
- vascocosta 1y agoI very much agree with this and that's one of the reasons I keep using Zig as it is now. I try to provide feedback on what isn't very obvious to me.