News for hackers. Stuff that matters.

sekao

Re:Partially Matching Zig Enums on Saturday August 09, 2025 @10:06AM (#44846560)
The code example will work even if `u` is only known at runtime. That's because the inner switch is not matching on `u`, it's matching on `ab`, which is known at compile time due to the use of `inline`.

That may be confusing, but basically `inline` is generating different code for the branches .a and .b, so in those cases the value of `ab` is known at compile time. So, the inner switch is running at compile time too. In the .a branch it just turns into a call to handle_a(), and in the .b branch it turns into a call to handle_b().

Re:Things Zig Comptime Won't Do on Monday April 21, 2025 @04:45PM (#43756271)
Agreed. Zig's approach re-uses the existing machinery of the language far more than C++ templates do. Another example of this is that Zig has almost no restrictions on what kinds of values can be `comptime` parameters. In C++, "non-type template parameters" are restricted to a small subset of types (integers, enums, and a few others). Rust's "const generics" are even more restrictive: only integers for now.

In Zig I can pass an entire struct instance full of config values as a single comptime parameter and thread it anywhere in my program. The big difference here is that when you treat compile-time programming as a "special" thing that is supported completely differently in the language, you need to add these features in a painfully piecemeal way. Whereas if it's just re-using the machinery already in place in your language, these restrictions don't exist and your users don't need to look up what values can be comptime values...they're just another kind of thing I pass to functions, so "of course" I can pass a struct instance.

Re:Zig: What to Expect from Release Month on Friday January 17, 2025 @08:01PM (#42744824)
I noticed you used scare quotes...is that because you and your team don't think simplicity is valuable?
Re:Zig Goals on Friday June 07, 2024 @03:46PM (#40612219)
The ability to export a zig project to a single C header file would be really nice. Is that still a planned feature?
Re:The Flix Programming Language on Sunday November 26, 2023 @11:49AM (#38422990)
I can't imagine why they would be argumentative with a gentle diplomat like yourself.
Re:The Flix Programming Language on Sunday November 26, 2023 @11:21AM (#38422755)
You know, I used to think that design was a nuanced grappling of complex tradeoffs, but you convinced me: those you disagree with are just "brain-dead" "idiots". I think there is a relevant quote by Charles Bukowski about confidence, but it escapes me...
Re:The Flix Programming Language on Sunday November 26, 2023 @06:03AM (#38420729)
Zig and Go both let you silence the error with `_ = myvar`. It can still be annoying, but it avoids the recursive problem you mentioned. Language design is hard, and it's best to not just assume that people are "idiotic" for not thinking the way you do. Turn the volume down a bit, and maybe find a synonym for "literally" for the sake of variety.
I'm running NixOS + KDE on the AMD framework and surprisingly it worked perfectly out of the box. All I had to do was disable secure boot to get it running, and after install I had to configure the global scale in display settings to 200% so it looked right. No weird hacks needed at all -- the 23.05 installer just worked, including wifi, which apparently isn't true for Windows 11.
Re:Bcachefs Merged into the Linux 6.7 Kernel on Tuesday October 31, 2023 @08:47AM (#38083970)
As I said in the last thread, the author could use support: https://www.patreon.com/join/bcachefs

This has been a solitary and largely self-financed effort by Kent over many years. He must feel pretty great to finally see this happen!

Re:Bcachefs Pull Request Submitted for Linux 6.7 on Monday October 30, 2023 @02:23PM (#38073527)
The author lost corporate funding recently and is asking for donations. I just started giving 20/mo. I don't care about kernel drama; I just want a good COW filesystem for Linux and this guy is doing a thankless service.

https://www.patreon.com/join/bcachefs

You can do a smaller pledge via the custom pledge button if you want.

Re:Local-First Web Development on Sunday February 19, 2023 @11:06AM (#34858714)
Think about longevity. Whether I'm writing, drawing, making music, or anything else important to my life, will I still be able to view/edit that data in 20 years? Granted, even with offline-friendly software I may need to port it to new platforms and make sure I back up the data, but at least I have a chance. The data I still have from 20 years ago is far more precious to me than I thought it would be back then. Data that can only be accessed through an external party is ephemeral and it will inevitably disappear one day.
Richard is a great contrarian thinker. I remember him from GET LAMP, a documentary about text adventures, and his take on the power of text in games was really memorable: https://www.youtube.com/watch?v=Zctp972y_Eg
Re:A Year of Building for the Terminal on Thursday December 22, 2022 @10:09AM (#34094016)
The browser target sounds neat. Do you plan on running the python in web assembly, or would it be a client/server design?
Re:A Year of Building for the Terminal on Thursday December 22, 2022 @09:53AM (#34093844)
I think we will need new standards here, because terminal emulators currently don't have any semantic information about what TUI programs are rendering. Browsers have the benefit of HTML to know this is a button, and that is a paragraph. A terminal is an unstructured grid of characters. The best we can hope for is for terminal emulators to use heuristics or AI to make sense of what TUI programs are rendering.
It doesn't detract from that at all, chief. What a weird thing to say. Particularly in the case of Nim -- it doesn't "throw away" C or C++, it compiles to them!
Re:Bun v0.2.0 on Friday October 14, 2022 @01:37PM (#33206558)
I believe cyclic imports are coming. And Nim does supports wasm...you can target it with `--cpu:wasm32`. You most likely want to pair that with emscripten as in https://github.com/treeform/nim_emscripten_tutorial
Re:Revisiting the design approach to Zig on Tuesday September 06, 2022 @08:43AM (#32736336)
Andrew argues that zig can produce faster programs than c or rust towards the end of the video: https://youtu.be/gn3YsZ6HUHw?t=3566
Re:Git’s database internals I: packed object store on Monday August 29, 2022 @10:57AM (#32639092)
Binary files are also delta'd in git.
Re:Zig is now self–hosted by default on Saturday August 20, 2022 @01:27PM (#32533704)
I didn't even know about it until today, very impressive. Generic SoA in less than 500 lines of userland code...

https://github.com/ziglang/zig/blob/master/lib/std/multi_arr...

Re:Photos of trains in the American West (2017) on Sunday August 14, 2022 @09:49AM (#32459227)
> the big tragedy it's that is focused on freight transport

I don't see the tragedy in that. Tracks in the US are privately owned and freight makes them more money than passenger rail. Don't think we'd gain anything by artifically changing that. Even in Europe planes are usually faster and cheaper than rail when traveling between countries.

Re:Ideas for DataScript 2 on Sunday August 14, 2022 @07:03AM (#32458270)
Reactive updates is the big one, in my opinion. DataScript is a triumph and arguably is the reason why so many note-taking tools (Roam, Athens, Logseq, etc) are written in Clojure. But there are so many cases where it would be nice to react when some set of entities is changed.

I think what we need is to figure out how to combine DataScript with a rules engine. I wrote a rules engine and made a writeup that compares the two together: "Using O'Doyle Rules as a poor man's DataScript" https://github.com/oakes/odoyle-rules/blob/master/bench-src/...

Subscribing to individual entities is nice but with a rules engine you have so much more fine-grained control over your reactions. And with the RETE algorithm this can be done efficiently. Most libraries in this space just ignore it and make their own ad-hoc solution -- an informally-specified, bug-ridden, slow implementation of half of a rules engine.

Re:Ask HN: How to make a native GUI with a modern language? on Tuesday August 09, 2022 @10:44AM (#32398716)
That is the case with JavaFX as well. It's not part of the JRE anymore. Also there really isn't any such thing as the JRE anymore, only the JDK. If you want to distribute a desktop Java app you must embed the entire runtime via javapackager. They have correctly realized that end users cannot be expected to install and update a language runtime separately...
Re:Some Thoughts on Zig on Saturday August 06, 2022 @04:07AM (#32366049)
Nim supports wasm. You can target it with `--cpu:wasm32`. You most likely want to pair that with emscripten. Here's an example: https://github.com/paranim/parakeet
Re:ANSIArt on Friday August 05, 2022 @10:32AM (#32356643)
See also https://github.com/hpjansson/chafa which is an image -> unicode library written in C. I built it into my BBS so users can embed images in their posts. Some turn out better than others but it gives the board a unique feel at least.
Right now not good but I have a plan for the web version. I'm going to overlay text fields, buttons and other things on top of the cells where they're being rendered. This is doable because nimwave has all the semantic information.

For terminals there is no way to do this. I think we need a new standard to represent terminal interfaces that preserves this info. I have some ideas on how to do this in a backwards compatible way but I'm on my phone at a BBQ right now so I can elaborate later :P

Re:Don't contribute anything relevant in web forums (2020) on Monday February 14, 2022 @01:26AM (#30328936)
Good points but the suggested alternatives are ignoring the most important piece of tech we have for synchronizing content: git. My problem with ActivityPub is that when you export your content, you get a big binary file that can't be incrementally updated. I'm exploring the idea of using git to clone a completely offline version of a message board in my BBS: https://ansiwave.net/
Re:Most websites are implicitly designed with a short lifetime on Tuesday February 01, 2022 @04:21AM (#30160287)
The reason websites aren't designed to last is not due to ever-changing design trends; it's because the web is inherently ephemeral. For a website to continue to be available requires continuous effort and expense to run a web server, update SSL certs, etc. This automatically shortens the time horizon when you're developing for it.

I think the way to get more "timeless" software is to build a platform where the code and the data can be brought offline. PWAs do the first but not the second. The data needs to be in an enduring format like SQLite that can be queried offline. With that kind of system, an app or game (and the accompanying data) could remain usable 20 years from now, long after its author stopped distributing it.

Re:Ask HN: Where do you hang out virtually online? on Monday January 31, 2022 @12:36PM (#30150955)
I'm building my own hang out spot: https://ansiwave.net/ Strictly a BBS right now, but i'm considering adding chat as well.
Out of context, you won't necessarily be able to glean meaning from either an arbitrary SQLite database or arbitrary RDF tuples. Both are equally meaningful or meaningless depending on the observer...at the end of the day, they are just structured data with labels that (hopefully) the observer understands. One doesn't have inherently more semantic meaning than the other.

Older »