this post was submitted on 19 Sep 2023
27 points (100.0% liked)

Linux

48212 readers
692 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

Most applications provide you configuration files that are data / text based. Whether it is toml, JSON, yaml or some other format, you are usually defining values for pre-determined keys and that's all.

This makes sense for many applications, but involved applications have explored configurations that make use of scripting. For example, vim uses VimScript, neovim uses Lua, but vscode uses json (as far as I remember), and Helix (vim inspired editor) argues editor configurations must be data, not scripting, and uses toml.

many tiling window managers use various programming languages (Qtile uses python, xmonad uses Haskell, Awesome uses Lua) while others stick to data configuration (i3).

Do you think that scriptable configuration is over-engineered and brings weaknesses, or is it warranted and grants the user power in these big applications? What are the benefits of scriptable configurations?

top 15 comments
sorted by: hot top controversial new old
[–] [email protected] 9 points 1 year ago* (last edited 1 year ago)

Turing Complete Configuration

  • more extensible
  • tend to be heavier
  • harder to provide detailed error messages
  • more difficult for new users

Data Based Configuration

  • easier to use
  • easier to provide documentation
  • lighter to embed
  • more limited usecases
[–] [email protected] 8 points 1 year ago (1 children)

For stuff like, say, configuring all of your systems and programs in one file, actual programming languages are really useful. coughnixcough

[–] [email protected] 2 points 1 year ago

Just started going down the Nix rabbit hole and, yeah, it's kinda annoying

[–] [email protected] 7 points 1 year ago (1 children)

I've become addicted to script-configured window managers. I won't even try ones that aren't, anymore.

Bash is a scripting language, so it qualifies per your description, but the main advantage is that anything you can do in the config, you can do on the CLI: these WMs also have first-class CLI tooling, a consequence of CLI-first design. All configuration is runtime adaptable, and although auto config reloading can get you there, it's fantastic to be able to change a configuration without it having to be persisted in a file.

Seriously, next to tiling, scripted configuration is the most important feature of a WM. I haven't encountered it outside of WMs very often, but for long running processes, it's a great design.

[–] [email protected] 2 points 1 year ago

Same here! I used to use BSPWM, but I since switched to RiverWM. It's a lot like BSPWM, but for Wayland. Highly recommend

[–] [email protected] 5 points 1 year ago

Apart from text editors/IDEs I don't really see the use for it. I think it is not practical unless all your users are both power users and programmers, which basically boils down to developer tools.

[–] [email protected] 4 points 1 year ago

I think the primary difference is that data based configuration is easier for software to modify and store.

[–] [email protected] 3 points 1 year ago (1 children)

You can also get the best of both worlds: https://cuelang.org/

[–] [email protected] 4 points 1 year ago

People like you are why I love online spaces like this.

Yes, it's obscure. Yes, nobody uses it. Yes, nobody ever heard of it before. No, that won't stop me from using it.

[–] [email protected] 3 points 1 year ago

scriptable configuration makes sense if you want to be able to extend or modify the program like with vim while data based configuration makes sense if your program is already extendable/configurable enough like with i3

[–] [email protected] 3 points 1 year ago (1 children)

I think data configuration is fine until you get to a point where you need functions. This is one of my pet peeves: data configuration formats that get creative to work around the format limitation when they should switch to scripting. My example is Home Assistant.

Home Assistant is a home/smart device automation server. It uses Yaml for automation scripts. But you often need functions. So they use jinja2 templates to emulate functions in Yaml. Then you have to manage copying variable values to make them available in the runtime context who where jinja2 templates are evaluated. There is no static validation for templates. And it takes a lot of detective work to figure out what variables and helpers are available. It's very frustrating. I really wish Home Assistant would use a type-checked scripting language instead. And it's not the only system out there that uses Yaml with string templates!

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

Same here, I avoid using Jinja if at all possible because I just hate blindly poking at stuff like that. I wish the YAML portion had schemas available for autocompletion when editing, at the very least.
Ansible comes to mind as something in a similar vein, I've been messing with it pretty often these days. At least here you do get robust autocomplete support and whatnot that eliminates a lot of the guesswork, although Jinja is always a bit painful lol.

[–] [email protected] 2 points 1 year ago

Oh yeah, and with Ansible there is an alternative to point to, Nix, which does configuration better IMO using a scripting language. It's still not typed so editor LSP support is limited. At least with NixOS modules and with Home Manager modules runtime validation is pretty good.

[–] [email protected] 2 points 1 year ago

it’s not just a json config file, it’s a schema that can be used to validate its input, and a library to load, validate based on said schema, and convert to-in memory representation with no extra code.

[–] [email protected] 1 points 1 year ago

As long as it's not configured by GUI I'm grateful 🙏😔