737 karma · joined Jul 19, 2018 (8y ago) · 115 submissions
comment 3y ago · link · parent
An alternative is to allow an additional parameter which optionally points to a diagnostics object to be updated upon error. Returning an error here signals that the object contains additional information while not harming composition as much and giving the choice of where to store such information. This is arguably a better pattern in a language where resource allocation is explicit.
2.
Simula One Compute Is Being Upgraded to Raptor Lake(simulavr.com ↗)
3 points · by nyberg · 3y ago · discuss
3.
The Upcoming Release Postponed Two More Weeks and Lacks Async Functions(ziglang.org ↗)
6 points · by nyberg · 3y ago · discuss
comment 3y ago · link · parent
It's also difficult to update such devices in the field so even if they do fix such issues it's only for new units or a new product line which most customers won't bother with until forced to by regulations / incidents as it's expensive to replace them (you have to send someone out on the field as there are pretty much no OTA updates).
comment 3y ago · link · parent
Needing channels for non-free is a feature as the system will be pure by default and can make progress towards fully reproducible builds for all packages rather than having several blessed non-free blobs around that drain maintainance time.
For the record, I use linux-nonfree, amdgpu, iwlwifi, firefox, and steam.
comment 3y ago · link · parent
prompt injection is the way to go
comment 3y ago · link · parent
One-shot programs also don't always need it as they're often fine with a less sophisticated scheme of arena allocation or reusing memory by resetting temporary buffers.
You also have the option to classify pointers if you absolutely must pass them with similar techniques as https://dinfuehr.github.io/blog/a-first-look-into-zgc.
comment 3y ago · link · parent
comment 3y ago · link · parent
13.
Deep Neural Networks from Scratch in Zig(monadmonkey.com ↗)
235 points · by nyberg · 3y ago · 32 comments
comment 3y ago · link · parent
Web Assembly might be a way to provide web app support in addition to native but it should never replace native.
Also, energy efficiency is starting to play a greater role here in the EU where hopefully it encourages less use of energy hungry frameworks and more native applications given their better resource use.
17.
Resource Efficient Thread Pools with Zig(zig.news ↗)
2 points · by nyberg · 3y ago · discuss
19.
Implement Multi-Object for Loops(github.com ↗)
3 points · by nyberg · 3y ago · discuss
comment 3y ago · link · parent
comment 3y ago · link · parent
If it's a comptime constant by "mistake" then it would have resulted in the same wrong behaviour at runtime.
comment 3y ago · link · parent
There's support for invoking with qemu, wine, etc in the build system which allows you to run tests for other platforms.
A case where I've taken advantage if this is to have data structures and code adjust based on the expected page size and cache-line. There are also cases where things may be both comptime and runtime known depending on which platform that you target which is easy to handle by having the maybe comptime value be first in conditional branches.
comment 3y ago · link · parent
It's on the project to convince the user to turn on telemetry rather than the user having to remember to turn it off. Excuses such as "nobody would turn it on" don't apply.
comment 3y ago · link · parent
You have copy-paste operators like `inline for`, `inline while`, and `switch (x) { inline else => {} }` that focus on generating code given a value known at compile-time (think of it like running a C program to print out the code within a `for` loop then inlining that in your code) and are great when you need to unroll a loop or loop over the fields of a struct (e.g when printing it). If you find those difficult then try printing the code they inline to get a feel for how it changes your program or writing what they'd inline manually.
For the more template style `ArrayList(T)` style you can follow the logic yourself by writing the struct it would result in when you substitute the parameters (again a copy paste but with slightly more going on) and any more calls with the same parameters will always return the same struct back.
Branching at compile-time is like having a smarter `#ifdef` for the most part where you use `if`, `switch`, and other control-flow to decide which code should remain in the program as long as the condition is known at compile-time. This logic can be applied to the copy-paste operators too depending on the condition.
Async is very experimental and not complete so it's currently difficult for most. It can be thought of as a fancy way of creating a state machine with `.nextState()` being the `resume` keyword making it not a function but by having the compiler perform a little magic at compile-time it's possible to write code which doesn't care about this until you get to function pointers as then the difference starts to matter. If you want a C equivalent have a look at https://c9x.me/articles/gthreads/intro.html which covers it pretty well and it's almost what zig does for you with the `suspend` and `resume` keywords. `async` and `await` should be understood in terms of `suspend` and `resume` as they exist at a much higher level and can be a bit tricky. Another way to get a quick overview of what it's doing is to have a look at generators in python with `yield` and their equivalent with writing the state machine yourself as a class as it's equivalent.
If you feel like trying it again, don't be afraid to reach out on the zig room on matrix. I'll be happy to help with comptime and related things as it can be a bit difficult to grasp.
Oh and don't give up! The best parts about learning is the rewarding feeling when it finally clicks after all the hard work.
26.
Git 2.39.1 (and more) released (CVE-2022-41903, CVE-2022-23521)(lwn.net ↗)
7 points · by nyberg · 3y ago · 1 comment
comment 3y ago · link · parent
You'd want faster compilation so that you can test your changes without it breaking your flow where having to wait a 1-5 minutes means you'll end up reading HN or checking chat for 10 or so minutes. That's also why there's interest in hot-code reloading and incremental linking to make it faster as it will further reduce compilation to just the changes you've made and nothing more.