Better HN
topnewbestaskshowjobs
Log inSign up

alurm

103 karma · joined Feb 11, 2023 (3y ago) · 32 submissions

Submissions

comment 2mo ago · link · parent

  Location: Tbilisi, Georgia
  Remote: Yes
  Willing to relocate: Yes
  Technologies: Rust, Nix
  Résumé/CV: https://alurm.github.io/cv.pdf
  Email: alan.urman@gmail.com
Software engineer, open source maintainer. Systems programming, developer tools, Unix.

2.

Nix Taco Sprint 2026(jrdsgl.com ↗)

6 points · by alurm · 5mo ago · discuss

comment 5mo ago · link · parent

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.

comment 5mo ago · link · parent

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. :)

comment 5mo ago · link · parent

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.

comment 5mo ago · link · parent

Good point! Added `vec_ptr[vec]` and `vec_len[vec]` helpers to mitigate this somewhat.

comment 5mo ago · link · parent

Thanks for mentioning it, I've heard about stb, but this time around I actually looked at the code. Their approach is very nice.

8.

A generic dynamic array in C that stores no capacity and needs no struct(gist.github.com ↗)

27 points · by alurm · 5mo ago · 33 comments

comment 8mo ago · link · parent

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.

comment 1y ago · link · parent

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!

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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!

13.

Json2dir: a JSON-to-directory converter, a fast alternative to home-manager(github.com ↗)

51 points · by alurm · 1y ago · 20 comments

comment 1y ago · link · parent

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)

comment 1y ago · link · parent

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=()

    ...
  }

comment 1y ago · link · parent

Yeah, PowerShell and nushell are pretty cool, I hope they gain more adoption.

17.

Moreshell tricks: first class lists, jq, and the es shell(alurm.github.io ↗)

41 points · by alurm · 1y ago · 14 comments

comment 1y ago · link · parent

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: alan.urman@gmail.com.

A systems programmer. Prefer US opportunities.

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

Thanks, fixed.

22.

I made a tiny library for switches and sum types in Lua(github.com ↗)

83 points · by alurm · 1y ago · 7 comments

comment 1y ago · link · parent

https doesn't make content trust worthy.

comment 2y ago · link · parent

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.

comment 2y ago · link · parent

Pretty sure it's fake.

comment 2y ago · link · parent

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.

comment 2y ago · link · parent

This is very funny.

comment 2y ago · link · parent

Click bait hacker news title.
12