Hacker News new | ask | show | jobs
by PaulHoule 661 days ago
It’s part of the shambolic world of Unix and C. But “worse is better!”

A good language spec is laid out in a way that reads from front to back with minimized circularity. See Common Lisp, Java, Python, etc.

As a kid in high school checking out Unix manuals and implementing many Unix tools in

https://subethasoftware.com/2022/09/27/exploring-1984-os-9-o...

I struggled with K&R because of the circularity of the book, which was really an anomaly built into C, the culture of C, or both because C++ books still read this way. C had so many half-baked things, such as an otherwise clean parser that required access to the symbol table. And of course a general fast and looseness which lead to the buffer overflow problem.

There were other languages which failed to solve the systems programming problem like PL/I and Ada, not to mention ISO Pascal which could have tried but didn’t. (Turbo Pascal proved it could have been done.)

People took until 1990 or so to be able to write good language specs consistently, so we can forgive Unix but boy is it awful if you look closely at it. On the other hand, IBM never did make a universal OS for the “universal” 360, yet Unix proved to be adaptable for almost everything.

1 comments

i may have missed it, but where does the C Standard say anything about access to a symbol table? or even if such a thing exists.

and as for IBM i managed to use all sorts of OSs in VMs on IBM hardware back in the 1980s. Which did you have problems with?

The parser in C has to keep track of the symbol table to handle cases like

   typdef int myint;
   myint x;
which is unusual among programming languages. Sure I used VM on IBM hardware in the 1980s and it was great. I also used timesharing systems on the PDP-8 (what atrocious hardware!), the PDP-11 and the PDP-10/20 in the 1970s. Although the 360 was superior in so many respects (except for the slow interrupt handling) it failed to break into the huge market for general-purpose timesharing to support software development and such (learning BASIC) until the time microcomputers came along and crushed the timesharing market. (PDP-10 was famously used to develop microcomputer software such as the original Microsoft BASIC and Infocom's z-machine games)

Fred Brooks' project to develop an OS for the 360 was notoriously troubled and IBM belatedly turned to VM as a dark horse. Today it looks ahead of its time (as virtualization became mainstream on x86 in the 00's) but back then IBM was flailing and they wound up with a good software story by accident. It was not really their fault, people just didn't know how to make an OS and the most advanced thinking back then was monstrosities like MULTICS. It was Unix and VAX/VMS that pointed to what a general purpose OS would look like a few years later and there has been relatively little innovation since then because nobody can afford to rearchitect the user space. (e.g. no way you can take out the "bloat" because you'll have to put it back in to run the software you want)

IBM's z-architecture (the other z) has a great software story today (even runs Linux) but it was not the Plan A or even the Plan B.

I don’t know that ‘<identifier><space><identifier>;’ is ambiguous in C. (For this expression it seems the parser could be confident the left is a type name, and raise an error later if not.) I’d be interested in seeing a counter-example for that simple of an expression. There are more obvious examples IMO here: https://eli.thegreenplace.net/2007/11/24/the-context-sensiti...
well, that's like saying the compiler when it sees something like:

   int x;
   x = 1;
it has to keep track of "x". of course it does. what programming languages don't?
The weird thing about C is the syntax does not clearly identify which tokens refer to types and which tokens refer to other things. A statement like `myint x` is only a variable declaration if `myint` is a type, which means in order to identify a variable declaration, you have to know the complete set of named types, so constructing an AST requires keeping track of types.
Yeah, it's a really weird thing when you look into the yacc grammar of a C compiler.