Why are UNIX/POSIX system call namings so illegible?

What is the reason to use such untelling system call names like time and creat instead of getCurrentTimeSecs and createFile or, maybe more suitable on Unix get_current_time_secs and create_file. Which brings me to the next point: why should someone want something like cfsetospeed without camel case or at least underscores to make it readable? Of course the calls would have more characters but we all know that readability of code is more important right?

Asked By: Benjoyo

||

It’s due to the technical constraints of the time. The POSIX standard was created in the 1980s and referred to UNIX, which was born in the 1970. Several C compilers at that time were limited to identifiers that were 6 or 8 characters long, so that settled the standard for the length of variable and function names.

Related questions:

Answered By: dr_

dr_ is right, but there’s also another reason – usability. Back in the day, you didn’t have something as comfortable as a keyboard to type on. If you were lucky, you had something akin to an old-school typewriter. If you were unlucky, you had to deal with systems that required actual physical work to operate (as in, it took a lot of force to press the "key"), or you manually punched holes in a card.

This meant that even within the 6-8 character limit, you tried to keep your commands as short as possible. That’s why you have ls instead of list, and creat instead of create. Code from that era is full of variables like a, x and i – and of course, x2 and friends. Typing was a lot of work – today, you’re less exerted from typing listIndex than you used to be from "typing" i – and it isn’t even all that slower anymore (especially with additional technologies like auto-completion).

The real question is – why do so many Unix idioms persist even though they’re no longer desirable?

Answered By: Luaan

In addition to the other answers, I would like to point out that Unix was developed as a reaction to Multics, CTSS, and other contemporary operating systems, which were significantly more verbose about their naming conventions. You can get a feel for these OSes at http://www.multicians.org/devdoc.html. For example, http://www.multicians.org/mspm-bx-1-00.html gives change_name as the command for renaming a file; compare Unix mv.

Also, the principal reason why the very short system call names persist is backward compatibility. You will notice that newer APIs tend to be more explicit; e.g. gettimeofday and clock_gettime instead of just time.

(Even today, using whateverIndex instead of i for a loop index is an automatic code-review failure in my book 😉

Answered By: zwol

Dennis Ritchie set himself a constraint with C that it wouldn’t rely on any linker features that weren’t also required by Fortran. Hence the 6 character limit on external names.

Answered By: user207421
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.