https://github.com/dspinellis/unix-history-repo/blob/Researc...
Is this B, or is it BCPL? What would have compiled this code back in the day?
https://github.com/dspinellis/unix-history-repo/blob/Researc...
Is this B, or is it BCPL? What would have compiled this code back in the day?
Running B was a challenge on the PDP-7 but easier on the PDP-11, apparently, because of the increase of memory size. The linked document has an interesting history about compiling B to threaded code, a form of interpreted code, and then to machine language. B never really made the jump to a full-fledged citizen because it quickly got replaced by C, although BCPL was popular for a long time.
That’s poetry. Nice find.
Reminds me a lot of writing my own compiler/assembler in university, where it’s expected that all this happens automatically nowadays.
main()
{
int ch;
while ((ch = read()) != 4) {
if (ch > 0100 && ch < 0133)
ch = ch + 040;
if (ch == 015) continue;
if (ch == 014) continue;
if (ch == 011) {
ch = 040040;
write(040040);
write(040040);
}
write(ch);
}
}
A more modern C version would look like: #include <stdio.h>
int
main(void)
{
int ch;
while ((ch = getchar()) != -1) {
if (ch > 0100 && ch < 0133)
ch = ch + 040;
if (ch == 015) continue;
if (ch == 014) continue;
// No need to handle tabstop specially
putchar(ch);
}
}EDIT: ops, the "auto" here means automatic allocation.
did old keyboards not have curly braces or what?
int main() <%
printf("hello, world\n");
return 0;
%>