There are many amazing GNU projects. Just yesterday I found out about GNU radio. I also remember reading the initial commit for Gneural and thinking "wow, this code is really nice".
I think GNU deserves much more support then it's getting.
There are so many awesome projects, but one that I recently learned about is GNU Taler. Basically it's an attempt to make "socially responsible digital cash", where all customers' transactions are private (you cannot tell who bought what or link their purchase history) but you can audit vendors and mints to verify that they pay taxes.
It's quite an elegant system and strikes the right balance (in my mind) between privacy and accountability for corporations. Also it piggy-backs on existing systems (operating through exchanges) and doesn't require proof-of-work. And the browser extensions are super easy to use (even easier than Flattr in some ways).
> I think GNU deserves much more support then it's getting.
I would recommend donating money to the FSF (if you have the means) and becoming a member. They are an incredible project doing awesome work and deserve the support. You also get free access to LibrePlanet conferences and a few other perks.
How does something become an official project under the umbrella of GNU, other than adopting a GPL? I'm guessing the FSF somehow curates and leads the individual efforts, before it can be called "GNU $THING"?
As others have said, you have to apply to the FSF to become a GNU project. And while being under GPLv3-or-later is one of the requirements, I just want to clarify something on this point:
> other than adopting a GPL
Despite it's name, the GNU General Public License is a license for any software written by anyone. Licensing something under the GPL doesn't make your project a member of the GNU project, any more than licensing something with the MIT/X11 license make your project part of FreeDesktop, or BSD making your project one of Berkley's projects.
They're keyword arguments, I suspect the #: prefix was chose precisely because it is ugly so it'll almost never conflict with a name a programmer might actually want to give as an argument, Racket uses it too. http://docs.racket-lang.org/guide/keywords.html
The # is extensible reader syntax. You can install your own readers for characters following the #. #\ is for the character reader, #: for keywords, etc.
Thanks for providing the link to the documentation in Racket. For people like me who don't know how to program in Scheme, this quote from the documentation might make it click (it is at the end of the page):
Despite their similarities, keywords are used in a different way than identifiers or symbols. Keywords are intended for use (unquoted) as special markers in argument lists and in certain syntactic forms. For run-time flags and enumerations, use symbols instead of keywords. The example below illustrates the distinct roles of keywords and symbols.
Examples:
> (define dir (find-system-path 'temp-dir)) ; not '#:temp-dir
> (with-output-to-file (build-path dir "stuff.txt")
(lambda () (printf "example\n"))
; optional #:mode argument can be 'text or 'binary
#:mode 'text
; optional #:exists argument can be 'replace, 'truncate, ...
#:exists 'replace)
reminds me of emacs config file, john wiegley made a tiny dsl called use-package that made everything cuter by a few simplification here and there. A few iteration it became extremely nice to write and read.
Remember the Emacs config file is not a configuration file: it is actually a program that's run as Emacs starts. You can do all sorts of interesting stuff (like installing missing packages, setting font size according to the screen, etc) on it.
Well config vs program is a deep debate. Now J.Wiegley extension brings some resemblance of semantics because it has a few concepts and steps instead of free form imperative (setq ...)
(actually i use org mode to compile all of my dot files based on predicates, i'm double plus weird here >.<)
I really rather like this way of working with things as it just sticks stuff into ~/.emacs.d/elpa. I can rsync that around if i need/want. And it even bootstraps itself if i'm opening things on a new system. I just like keeping each package in its own use-package declaration so I can have config+setup all in one spot.
Go for it, its mostly inspired from nix in how I set it up. I can just run make and create dot files for whatever I need then rsync it over to where I need it.
Aka I can customize my dot files based on if i'm going to a bsd/mac/linux box with(out)/nix/perl/haskell/git/whatever and have an easy way to copy things over the top of things or not.
I declared dot file bankruptcy a few years ago and this is my "perpetual penultimate dot file solution" (yes I'm making a joke at my own expense with penultimate here).
But this new setup is easily the most sane I've found so far. Most dot file management uses softlinks which sucks for rsyncing, or some hokey templating language.
All mine amounts to is just a stupid .el file that holds predicate definitions that just controls via stupid elisp when an org babel block gets tangled out into a file. Its pretty simple and straightforward. Wonder if I should do some sort of show and tell for it or not.
Good luck! Hope it helps or inspires something better.
My first thought is how I'd parse, modify and write it back without losing user's comments, formatting, changes and suchlike. Is this some well understood format with libraries for common programming languages? If not, it is just likely to proliferate more crappy config management with chunks of regexes and suchlike
Elsewhere people are saying it's just Scheme. I'm sure I could find a parser for that in Python, and maybe if I'm really lucky that parser will record whitespace and comment nodes, and have a reverse transformation, but do I really want to be writing error prone 20-line AST visitors just to tweak an integer setting? (No, I most certainly do not, and I consider design decisions like this a massive code smell that'd ward me off any further investigation of a system)
edit: downvotes? Is this really such a difficult concept?
edit 2: so apparently the big whoopsie was insulting the religion that is LISP. Yes, using a turing complete language for config syntax causes pain. Nobody does this stuff in the real world for a reason. Deal with it, meanwhile go back to obsessing over novelty code-is-data academic exercises on your obsolete Symbolics machines, you'll cause less damage that way.
So, since nobody mentioned that, i'll ignore your edits and try to answer your original concern. Generally speaking, this is S-Expressions (as others have said) and S-Expressions are trivial to parse and edit - you can write a parser in C that converts this to a tree easily. Note that the comments and such are a problem regardless of the config syntax used but the solution is the same: instead of rewriting the file, edit it in-place (to do that a simple way is store the index range of each node's value in the code buffer when parsing it and when you modify the node's value update the buffer's contents - make sure you also update the other nodes' ranges if the value changes length in characters).
All these assuming you want to implement the thing yourself. Which is fine, S-Expressions are one of the easiest tree syntaxes to parse. But there are already libraries that can do this for you (including full Lisp/Scheme interpreters) and some of them can even 'pretty format' the code like the quoted snipped above.
So generally speaking this wont be a problem in practice.
It's Scheme s-expressions. Parsers for it have existed for it longer than C or Unix have existed (Scheme came out in 1970, First Edition Unix in 1971), let alone Lisp parsers which have existed for even longer.
EDIT: Complaining about downvotes and then going on a tirade about how Lisp users are cave-dwellers is not constructive. Personally I think your argument was a valid concern (and I just went to try to find a Scheme parser in Python to help you), but you're not helping your case.
Also, like it or not, but both of the most widely-used editors (emacs and vim) both have turing-complete "configuration" languages. By your statements, that would make the majority of programmers academic cave-dwellers (oh wait... :P).
If you include full-blown IDEs in your definition of editor (which I think you should), Visual Studio was the most widely used editor among all the 19,772 people that responded to this question in the Stack Overflow Developer survey 2017.
Notepad++ was the second-most popular editor.
Sublime Text was the third-most popular editor.
Vim was the fourth-most popular editor.
Visual Studio Code, IntelliJ, Atom, Eclipse, Android Studio, PHPStorm, Xcode, NetBeans and PyCharm followed.
The point still stands if you substitute "both" with "two". I admit that I assumed Emacs and Vim were higher in the "leaderboard" (and I'm not sure StackOverflow is the best place to sample developers) but the point stands regardless.
> using a turing complete language for config syntax causes pain
That may sometimes be so, but only as a general consequence of "programming computers causes pain". You can do something complicated, which can have a bug; then someone comes along with a half-conceived thought like, "that solution shouldn't have been doble in the config language; therefore config language caused pain".
A non-computational config language also causes pain. Sometimes to the point that a Turing-complete language is used to generate a configuration. Then you have pains like "# this was generated ... don't touch!".
As others have pointed out, it's s-expressions (and possibly simply scheme) so reading and writing shouldn't be difficult. If it uses scheme comments, those will be a problem just as when transforming any programming language. I the other hand, if they syntax supports doc-strings, you're all set.
Add far as AST visitors, you're probably better off with XPath/XSLT tree transformations. (Anyone know of a suitable library?)
On the other hand, the don't-swim-upstream approach would be to use one of the best programming languages in existence, Scheme, you do your config management tasks directly, rather than an arm's-length parse, modify, write approach.
So you want to programmatically edit a config file, preserving formatting and comments, without using regexes, AST visitors, or XSLT? What's left? I seriously don't know of any other ways to manipulate data while preserving formatting and comments.
This isn't applicable to scheme as a config format, but some config formats are line based and have programmatic tools to manipulate them, e.g. the .ini-like format Git uses, try adding some comments to ~/.gitconfig and manipulating it with `git config --global <...>`, it'll all be preserved.
You will lose any comments like this though:
[user]
name = My Name ; that's my name!
Programming is hard in the face of arbitrary user data.
$ cat my-config.xml
<root>
<!-- i am a comment -->
<thing attr="foo">
<!-- i am another comment -->
<setting>value</setting>
</thing>
</root>
$ cat c.py
import lxml.etree
doc = lxml.etree.fromstring(file('my-config.xml').read())
for setting in doc.xpath('.//thing/setting'):
setting.text = 'set without screwing up the file'
print lxml.etree.tostring(doc)
$ python c.py
<root>
<!-- i am a comment -->
<thing attr="foo">
<!-- i am another comment -->
<setting>set without screwing up the file</setting>
</thing>
</root>
... but you just chewed someone out for suggesting XML. And you are doing tree walking here, you're just reducing some of the boilerplate with XPath. You can do the same thing with Scheme using car, cdr, cadr and friends.
My mistake then. You can still use car, cdr, cadr etc. to accomplish more or less the same thing as XPath. S-expressions are a completely valid serialization format. You can't easily manipulate JSON or YAML data while preserving formatting and comments with any library I've used (though it is possible), that doesn't mean JSON and YAML are invalid.
>> downvotes are because you're sort of insulting Lisp (which is older than you and all your "best practices") with an ignorant complaint.
I recognized it as lisp right away, but I share the complaint about the format. If you want to write a lisp program then do so. If you want to format something for human readability it's probably a good idea to do it differently. This is just a opinion of course, but I suspect it's not an uncommon one.
So all I asked is whether it was possible to roundtrip an edit to one of these files from Python without writing an AST visitor, and without losing formatting and comments. I have absolutely no idea how this could be considered ignorant.
Ignorant of the cave-dwelling depths some would go to ensure the practicality of the arcane religious icon that is LISP as a massively overgeneral solution to a problem, at the cost of all downstream users who must now "just switch to Guile" or link against chunks of a C compiler just to introspect a config? Maybe, but I'm content with that.
So the example you showed with XML uses XPath, what do you think that does? I am sure something similar can be created in python for editing lisp code as easily as this.
> My first thought is how I'd parse, modify and write it back without losing user's comments, formatting, changes and suchlike. Is this some well understood format with libraries for common programming languages? If not, it is just likely to proliferate more crappy config management with chunks of regexes and suchlike
> Elsewhere people are saying it's just Scheme. I'm sure I could find a parser for that in Python, and maybe if I'm really lucky that parser will record whitespace and comment nodes, and have a reverse transformation, but do I really want to be writing error prone 20-line AST visitors just to tweak an integer setting? (No, I most certainly do not, and I consider design decisions like this a massive code smell that'd ward me off any further investigation of a system)
XML satisfies all the above: no AST visitors, no custom parsing routines, no attempting to solve the halting problem in order to introspect a simple scalar value.
What you're saying is that the same is "possible" with Scheme. At least one followup comment (finally) described an algorithm that would actually allow machine-driven file changes, but we're still left with rather than a working out of the box solution, a description of an algorithm that "might someday work" and that's not the sort of thing I want to be dealing with while building business solutions on somebody else's dime, which drives my conclusion above: this config file syntax is not for me, and my original comment explained precisely why.
You're complaining that there isn't good tooling around the config file format for a project that is described as "in its early development stages" and provides "alpha releases". If you're talking about using this "while building business solutions on somebody else's dime" your getting way ahead of yourself. I'm sure they will expose a library for parsing and editing the config format before a general release.
You're right, I can't find a python library with the exact functionality you want. But a solution does exist, you would just have to write it yourself. It takes about 200 lines of python, less if you use a parser generator. But if you don't want to do that (nothing wrong with that! Why do work when you don't have to, after all), well then you'll have to either ask someone else to do it for you or just not use this project, assuming this functionality is critical for you. Or you could use sed or a templating system, up to you.
I have little doubt it could be written, but at risk of going blue in the face, this was irrelevant to the original question ("what do you dislike about this syntax?"). Never mind, 'truth' has won out in the end regardless, and I note for future that the presence of Lisp on a CV is fair reason to pause and reconsider.
"My first thought is how I'd parse, modify and write it back without losing user's comments, formatting, changes and suchlike. Is this some well understood format with libraries for common programming languages?"
Regarding edit 2: Using a non turing complete language results in hacks to attain the flexibility that would have been provided by the more powerful language.
And that was kind of the whole point with GuixSD and Shepard.
Nix has limited "Nix-expressions" which resulted in a bunch of bash scripts to get around the limitations, and Systemd ends up requiring C services or bash scripts because it has a limited INI-like syntax. On the opposite end, GuixSD is entirely configured, packaged, and maintained with Guile.
My first question would be in what use case do you require the ability to alter via a program the same config file that you expect the user to be able to hand edit and never have a conflict?
It was my understanding that issue was best handled by having multiple files and having one take precedence over the other. Like having a global config that is pushed to the machine and allowing the user to locally override values set globally in the local config.
Another solution to multiple parties needing to define configuration for the same area without stomping all over each other would be to have a directory wherein all files contained therein are applicable. That way multiple people can maintain their own particular files but some precedence has to be established.
Even if you do need to do this I wouldn't think it would be that hard to modify lisp with lisp.
A single quote is actually shorthand for the quote special form
'foo
(quote foo)
'(1 2 3)
(quote (1 2 3))
It basically does not evaluate its arguments but returns whatever it is. So instead of the value of foo, it the symbol foo. The list example does not evaluate it either, it would normally try to apply the first element as a function, but instead we get the list of numbers.
While I don't write Scheme, I believe it is Scheme -- one of the goals of the GNU project is to have every GNU tool be configurable with Scheme (which is why GNU has a Scheme implementation as opposed to a Common LISP implementation).
Rust's usage of single quotes comes from CS language theory (lifetimes are denoted using quotes) which I believe comes from the normal usage of quotes in possessive words (James', Amanda's). I don't think LISP's usage comes from the same place (it means something very different semantically).
Lisp's quote (or ') comes from the word quote and the context:
(quote something)
Meaning: take whatever follows and leave it alone. Do not interpret it. If it's a list it stays a list (one of the main uses for this). The single quote ' is shorthand for that. It's meant to be an easier way to create a literal list (and other things) without escaping all the parts of a list that might be misinterpreted as symbols to evaluate (to values or functions).
I can appreciate how holistic the GNU ecosystem seems to be. I'm a lover and user of Nix, so whenever something about Guix comes up, I draw the contrast. In this case, GuixSD is using Shepherd, which uses Guile for configuration and feels like natural continuity within the system. NixOS, on the other hand, provides systemd (and only systemd). In the case of nix, it's smart to leverage existing technologies, for velocity, yes, but also as a sort of proof that the core principles behind nix can apply even over systems and tools that are completely unaware of nix concepts; on the other hand, GNU really makes me a believer in the fact that Guix is very pure.
GNU Shepherd works on GNU/Linux as well as GNU/Hurd. The problem is that Linux doesn't really have any sane way of tracking double-forked processes. A misuse of the cgroup API is to do that (and I do mean misuse, reading cgroups.proc is not atomic and will cause repetitions and dropped entries if you read more than a single page of data). But that's still better than using ptrace's POSIX-breaking pseudo-parent semantics (see Upstart, though they apparently switched to using the proc connector API which is sort of like ptrace-lite).
I would presume they'd separate out that particular detail into separate modules.
In what way don't they use namespaces? It's object oriented using a lisp system (hence arbitrary macro support for lexical and dynamic scoping). Each service object would track its own processes.
> The GNU Daemon Shepherd or GNU Shepherd, formerly known as GNU dmd
dmd was short for "daemon management daemon". Basically, it's what powers all services running on GNU Guix instead of something else, like systemd.
I think this new name may sound "friendlier", but at the cost of precision. I immediately realized what dmd would be, but I had no idea what GNU Shepherd would be about.
The difference between Guix and GuixSD isn't about alternative names for the same thing (like whether e.g. Ubuntu is "Linux" or "GNU/Linux"). Instead these names describe two distinct, but related, software projects.
Guix is a collection of programs for building, installing and distributing software (or other digital artefacts). It is specifically designed to work alongside alternatives, like apt, yum, etc. on many operating systems.
GuixSD is a particular OS distro, which uses Guix for all of its packaging, etc. If you use GuixSD, you're going all-in on Guix for everything.
The distinction between these projects is important, since Guix might be a good engineering choice for some project (say, a Web site backend, requiring particular versions of Apache, Python, various modules, etc.), whilst it may be a bad idea to switch the whole underlying OS to GuixSD.
As a concrete example, I've not used Guix or GuixSD myself, but exactly the same distinction exists between Nix and NixOS. I personally use NixOS, and I include Nix configurations in my own projects, so others can use Nix to install them with all of the right dependencies, etc. They don't need to switch distro to NixOS though; Nix will work on whatever system they already use (e.g. Ubuntu, OSX, etc. Though not yet Windows).
You call your OS Linux, RMS calls it GNU, I call it Bash, my wife calls it XFCE, her granma calls it "that one with the blue mouse" (and uses it without a problem).
But I really think that the name should be Bash, because that's what holds it all together.
This is init, with the exceptional property that you write your scripts in Guile Scheme (an implementation of a standardised Lisp dialect). That should allow for a more robust and debuggable way to write init scripts.
GuixSD is kind of immature at the moment, and I have driver issues with linux-libre, but in the coming weeks I'll have the time to try to run it with a custom kernel that supports my hardware. If I succeed, as an Emacs user it'll become turtles all the way for me, which is very exciting (GuixSD is Guix + Shepherd + GNU + Linux Libre).
"kind of immature" is a bit vague, but I disagree. I'm using GuixSD on almost all of my machines (a server, two laptops, an audio workstation) without problems.
It is quite easy to overwrite the kernel package to use in a system configuration (e.g. to use a kernel with the RT patches applied), but I should say that I use the default kernel on all but one machine.
That's because the D language people asked for a name change then. The Shepherd was actually a dormant project for many years until it was revived for GuixSD.
Most likely. It can even run as an unprivileged user (and users can manage their own daemons with it).
Though in most cases I find that people just want the "zombie problem" to go away. I wrote a simple init[1] that implements all of the key pieces of an init and signal forwarder.
I see you mentioned tini (another such init) in the README as being "not as simple as it should be". We're using https://github.com/Yelp/dumb-init at work; if you know it, what do you think of it?
dumb-init is better, but they don't use socketfd which means they might drop signals in certain cases (in the race between consecutive sigwaits). I will concede this is a minor point, and I still have to finish implementing all of the necessary signal semantics in initrs, but it is kinda important.
Also I'm learning Rust and it was a good opportunity to practice by implementing something I already knew how to easily do in C.
Sadly it doesn't seem to play well when run under Python 3. Not a big deal now, but hopefully one of these years, desktop Linux distributions will have a 3.x release of Python as the default.
XSLT has nothing to do with either Scheme or Shepard (which I have nothing to do with, either). XSLT is a very good tree-transformation language, once you look past the atrocious XML syntax, and tree transformations are a much better alternative to writing visitors.
Name-calling and trashing others is not part of the kind of discussions we're trying to have here, and it violates the guidelines. Please stop doing this.
I'd suggest that you remove all the name-calling and sarcasm because it seriously undermines what seems to be a good argument. It's only programming syntax, there's no reason to get personal.
I think GNU deserves much more support then it's getting.