HackerTrans
TopNewTrendsCommentsPastAskShowJobs

alurm

no profile record

Submissions

Nix Taco Sprint 2026

jrdsgl.com
6 points·by alurm·17 gün önce·0 comments

A generic dynamic array in C that stores no capacity and needs no struct

gist.github.com
27 points·by alurm·geçen ay·33 comments

[untitled]

1 points·by alurm·2 ay önce·0 comments

[untitled]

1 points·by alurm·11 ay önce·0 comments

Json2dir: a JSON-to-directory converter, a fast alternative to home-manager

github.com
51 points·by alurm·11 ay önce·20 comments

Moreshell tricks: first class lists, jq, and the es shell

alurm.github.io
41 points·by alurm·11 ay önce·14 comments

I made a tiny library for switches and sum types in Lua

github.com
83 points·by alurm·2 yıl önce·7 comments

comments

alurm
·28 gün önce·discuss
Yeah, I've added macros `vec_len` and `vec_ptr` (or, enums, actually), which help somewhat.

`arr[3]` should be flagged by the compiler it is known to the compiler that you're operating on an array.

You can pass `arr` as `&arr` to functions, then compiler will know the length of the array since the type would be `T ()[2]`.

And you can then use it like this:

  void f(int *(*ints)[2]) {
      for (size_t i = 0; i < (size_t)vec_len[*ints]; i++) printf("f: %d\n", vec_ptr[*ints][i]);
  }
Curiously, this is a rare case where the "inverted" `a[b]` requires less typing compared to `(b)[a]`.

A compiler will not be able to flag `vec_len[ints]` though, which is unfortunate.
alurm
·28 gün önce·discuss
Thank you! I implemented this pattern initially about a year ago, but decided to write about it now. Since you liked it, it wasn't for nothing. :)
alurm
·28 gün önce·discuss
You're right, I added some more clarity in the README.

Interestingly, I think my approach will work fine on CHERI, since the pointer is never dereferenced, but I didn't test this. But yeah, there are some architectures where it would fail.
alurm
·28 gün önce·discuss
Good point! Added `vec_ptr[vec]` and `vec_len[vec]` helpers to mitigate this somewhat.
alurm
·28 gün önce·discuss
Thanks for mentioning it, I've heard about stb, but this time around I actually looked at the code. Their approach is very nice.
alurm
·4 ay önce·discuss
Making a strict subset of some existing language (Go) be a "better C" is quite an interesting idea compared to others (D, Zig, Hare, C3, D, ...), haven't seen it elsewhere. No new syntax. And Go seems to be a pretty good choice for this. Not sure if it's gonna fly though.
alurm
·11 ay önce·discuss
Yes, but you can generate JSON with other tools easily. home.md describes how you can do it with Nix, but just as easily you can use Cue or something else.

Edit: mentioned this in the README explicitly. Thanks!
alurm
·11 ay önce·discuss
Yeah, in general (a bit of a tangent), ideas from Plan 9 are really powerful. For example, the Acme text editor exposes it's API as a file system (it's represented via Unix sockets in plan9port, but FUSE is available as well there). It's easy to write scripts to manipulate the editor, and quite fun.
alurm
·11 ay önce·discuss
Well, if you're generating JSON with Nix, you don't have to put everything inside of one file. It would be a better idea to split it up into multiple. You can also use builtins.readFile for reading config files which don't have to be generated in a complex manner. It's up to you to choose, I just kept everything inside of one file since it makes for a simpler example.

Edit: I have updated the documentation to mention this explicitly, thanks!
alurm
·11 ay önce·discuss
YSH looks very nice here, thanks. I thought to mention YSH, but have no experience with it, so I hoped you would comment.

(I guess we're duplicating threads at this point :D)
alurm
·11 ay önce·discuss
Sure.

I have tried Bash namerefs. I found them to be kinda awkward, since you need to name them uniquely. So, you have to pretend that they are global variables, even though they are declared inside a function, which makes their usage verbose.

Here, this could look like:

  split_by_double_dash() {
    declare -n split_by_double_dash_before=$1
    declare -n split_by_double_dash_after=$2
    
    split_by_double_dash_before=()
    split_by_double_dash_after=()

    ...
  }
alurm
·11 ay önce·discuss
Yeah, PowerShell and nushell are pretty cool, I hope they gain more adoption.
alurm
·12 ay önce·discuss
Location: Yerevan, Armenia.

Remote: yes.

Willing to relocate: yes.

Technologies: Rust, C/C++, Bash, Go, Linux, Nix.

Résumé/CV: https://alurm.github.io/resume/alan-urmancheev.html (or .pdf for a PDF).

Email: [email protected].

A systems programmer. Prefer US opportunities.
alurm
·2 yıl önce·discuss
I like your approach.

(Implicitly) using [1] instead of [false] as a default is less typing for sure (but maybe a bit more confusing?).

Also, objects being switched on really have to be tables in my version anyway (since overriding __call for builtin types seems harsh to me), so having a tag field right in them as opposed to creating a metatable should be more efficient.

For my version I'll add a value-weak map of metatables to dedup them, should work as well.

In terms of functions, yeah, I don't think you can get rid of them, but (in the example) you can avoid (r) and (s) params if you assume that the functions lexically close over shape.
alurm
·2 yıl önce·discuss
Honestly, not much.

I found it nice how it's possible to emulate switches in Lua with so little code, without the result looking too ugly. You may find this pattern useful. That's it.

The catch is that, unlike with normal switches or with a series of "if"s, there's a whole bunch of indirection added via functions, so it's not very efficient.

Perhaps LuaJIT can inline these functions, but I haven't tested it.
alurm
·2 yıl önce·discuss
Thanks, fixed.
alurm
·2 yıl önce·discuss
https doesn't make content trust worthy.
alurm
·2 yıl önce·discuss
In this case it doesn't matter much I think. I suppose the api existed for ages.

But I prefer openbsd or man7 pages, sure.
alurm
·2 yıl önce·discuss
Pretty sure it's fake.
alurm
·2 yıl önce·discuss
As I understand, Bittorrent is not a persistent data structure. Git and IPFS are. Radicle is another interesting approach. They used IPFS but switched to a custom protocol, as I understand, for performance.