LWN.net Logo

Fast boot

Fast boot

Posted Nov 9, 2012 11:55 UTC (Fri) by gb (subscriber, #58328)
In reply to: Fast boot by Eckhart
Parent article: LCE: Systemd two years on

> You are implying that the classic base system is so badly written that it needs frequent edits – and your conclusion is to *not* rewrite it in a maintainable programming language? Seriously?

There is big difference between flexibility and problem solving. There are many reasons to change the scripts: learning, configuring, debugging unrelated issues, making a copy. The ability to use system in ways not expected ways is highly valuable thing.

So, ability to easily read and change the scripts has not relation to be "badly written".

And scripts written in bash are significantly more "maintainable" than written in C.


(Log in to post comments)

Fast boot

Posted Nov 9, 2012 13:42 UTC (Fri) by intgr (subscriber, #39733) [Link]

> And scripts written in bash are significantly more "maintainable" than written in C.

Init "scripts" in systemd aren't written in C either. They're written in a custom declarative language, which is straightforward and well documented. It's very easy to customize these configuration files -- infinitely easier than 100+ line bash scripts dealing with PID files, exit statuses, "sleep" hacks to work around race conditions and distro-specific process management commands that were designed to help write init scripts, but are each inadequate their own way.

But as for maintainability of bash, I still disagree. I'm no fan of C, but when you read a C program, it's usually clear what's happening and how it happens. bash scripts, in comparison, typically consist of some commands duct-taped together with grep, awk, cut, tr etc. There's no way to know what they're doing other than running the command and then reverse engineer which bits of the output it is trying to extract.

Fast boot

Posted Nov 9, 2012 16:43 UTC (Fri) by marcH (subscriber, #57642) [Link]

Scripts are not easier to understand than C code because the language is clearer - you are right the Bourne shell is too old and sucks.

Scripts are easier to understand than C code because they're using a higher level language which means comparable things are done in code several times smaller. They are also "faster" to understand because you don't need to find and download the right source code version. They are also faster to understand because, when you are not sure, you can add traces and more generally hack and experiment with them in the blink of an eye with a simple editor (everyone around my cube is able to do that while few people can do similar things in C).

Yes system V init scripts suck in so many ways, yes Bourne shell is the oldest and ugliest of scripting languages, but as a high-level and interpreted language it has a number of desirable features that C - a fantastic but extremely low level language - will never have.

I can't believe I have to explain the most basic characteristics of scripting languages in a forum like this...

Fast boot

Posted Nov 9, 2012 17:21 UTC (Fri) by intgr (subscriber, #39733) [Link]

Let me say it again: systemd services are NOT written in C. systemd replaces bash with a new declarative language, which does not have the downsides of bash. If you want to change the way that a service is launched, you change this config file -- you don't have to download or write or compile any C code, making your rant irrelevant to the systemd debate.

> Scripts are easier to understand than C code because they're using a higher level language

You're stating this as if it were a fact, but it's not -- it depends on the task. I won't take this further because it's a red herring to direct attention away from the real argument.

> I can't believe I have to explain the most basic characteristics of scripting languages in a forum like this...

Wow, that's a nice way to say "I'm right and you're stupid because you disagree with me"

Fast boot

Posted Nov 9, 2012 21:33 UTC (Fri) by boklm (subscriber, #34568) [Link]

> Scripts are easier to understand than C code because they're using a higher level language which means comparable things are done in code several times smaller.

And domain specific language (such as what systemd uses for its unit files) are also several times smaller and easier to understand than the same things done in a general purpose language like bash.

Fast boot

Posted Nov 9, 2012 22:50 UTC (Fri) by dlang (✭ supporter ✭, #313) [Link]

If it eliminated the need to learn Bash you might have a point. However it doesn't eliminate the need to learn Bash, so it's 'yet another language to learn'

At that point, you have to question if the new language is valuable enough to have to exist instead of re-using one that's already required.

Fast boot

Posted Nov 9, 2012 23:09 UTC (Fri) by boklm (subscriber, #34568) [Link]

Actually this is not really a new language, just simple configuration files, so there is no new language to learn.

You need to understand what the options mean, but it is usually obvious with the name, and fully documented in man pages.

When looking at a bash init script, you also need to understand what the variables mean. You do this by looking at the code to find what it is doing. In systemd you look at the man page instead. But only the first time, because the same options are used in all unit files so it's easy to remember, while sysv init script always re-implement the same things in a different way so you need to read everything.

Fast boot

Posted Nov 15, 2012 9:47 UTC (Thu) by HelloWorld (guest, #56129) [Link]

There's no new language to learn, systemd's configuration file use the same ini-style format as freedesktop's .desktop files.

Fast boot

Posted Nov 15, 2012 9:46 UTC (Thu) by HelloWorld (guest, #56129) [Link]

Scripts are easier to understand than C code because they're using a higher level language which means comparable things are done in code several times smaller.

Brevity alone doesn't help. intgr's point is that every time you read a command such as foo | awk '{ print $4 }', you need to know what foo prints in its fourth column, so it forces you to keep lots of things in mind, which certainly isn't maintainable.

And by the way, that's not just a limitation of the bash language but of UNIX shells in general, as their primary means of communication is an unstructured byte stream.

Fast boot

Posted Nov 10, 2012 7:50 UTC (Sat) by Eckhart (guest, #74500) [Link]

> There is big difference between flexibility and problem solving. There are many reasons to change the scripts: learning […]

Nothing prevents you from doing that with C files: http://www.freedesktop.org/software/systemd/

> […] configuring […]

You see, this is the main problem with "hackers" (compared to actual programmers): they fail to understand that code and configuration are two different things. "gcc config.c && ./a.out" is *not* a great audio player with a rather complex configuration file.

> […] debugging unrelated issues […]

If you need to change the internals of one component to debug unrelated issues, then your encapsulation is probably wrong.

> […] making a copy

There is no DRM, feel free to copy.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds