Hacker Newsnew | past | comments | ask | show | jobs | submit | alurm's commentslogin

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!


You could at least use Hujson[0], which adds comments and trailing commas; makes for a more convenient editing experience, at the price of an additional parsing step.

[0]: https://github.com/tailscale/hujson


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.


I 100% have been inspired plan9, not actually a tangent at all!

I never spent much time in Acme. I did use wmii as a daily driver window manager for a number of years, which was also 9p based! I wasn't great at scripting it, and the docs have always been basically non-existent for it's 9p interfaces... but I did poke around and look at things, which was super easy to do because it was just a filesystem! I did find this short example of some wmii examples, inside a Chicken Scheme 9p write-up, which is lovely to see online: https://wiki.call-cc.org/eggref/5/9p#utility-procedures

It's a fine distinction, but I do like json2dir and my own work a bit more than 9p because with apps that expose 9p, if the app goes away, so does the filesystem! 9p is an interface to talk to some process state. But if you just keep state on the regular filesystem, it will stick around & persist beyond the life of the process. The downside is your app needs to watch for that state changing, needs to be able to reconcile changes as they happen. On the upside though, now you can use a lot of great filesystem utilities: for example btrfs or zfs snapshots or incremental-backups are going to work as usual!

Being able to easily script your world is-I think- a missing key to unlocking personal computing. Different technologies discussed, but another serendipitous thread on personal computing from today: https://news.ycombinator.com/item?id=44837783


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!


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)


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

    ...
  }


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


I keep intending to give nushell a serious try, but I'm too set in my ways :(


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.


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.


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.


Thanks, fixed.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: