Hacker News new | past | comments | ask | show | jobs | submit login
Primeval C: two very early compilers (bell-labs.com)
108 points by tchalla on March 1, 2013 | hide | past | favorite | 33 comments



These are very early compilers indeed, but it makes me wonder: a HN comment today reminded me of 'Proebsting's law' that compilers double program speed every 18 years. He got this by comparing a -O0 run with a -02 run and then dividing, but the obvious problem with this is that even if a modern compiler is run with -O0 it's probably going to be in effect optimizing a lot just by all the architectural choices and default code generation. It would be interesting to see if one could take a more recent C compiler, say late '70s and compare it to a heavily optimizing GCC run, and answer the question: how much have C compilers improved over the last 30-40 years?


I am pleasantly surprised to see that current GCC seems to be able to generate code for a PDP-11 target. I think there may actually even be cycle-accurate PDP-11 simulators around, which would enable you to do the benchmarking. If you do get around to it, I'd love to hear your results!


Aren't most optimisations hardware dependant, and if so: wouldn't it make sense that the work put into these optimisations depends largely on how much the hardware is used? Is the PDP-11 still a useful target in that sense? Wouldn't the original x86 instruction set be more useful for example?


Well, if you want to compare a 1970s compiler to a modern compiler, the x86 instruction set will not be a useful target, since no 1970s compilers target it. These particular ancient compilers target the PDP-11.

The larger question of whether optimizations are hardware-dependent is interesting. In some sense, sure. But there are a lot of optimizations in modern compilers that apply equally well to the PDP-11 and to the AMD64; they're just not that different.

My homework assignment for you: write a C function of three or four lines which loops over an array of structs and does some computation for each one, including some conditional and a call to a one-line static function; compile it with -c -O0 -Wa,-adhlns=unoptimized.lst and with -c -O5 -fomit-frame-pointer -Wa,-adhlns=optimized.lst; list the optimizations you notice in the difference between unoptimized.lst, and hazard a guess at which of them are applicable on a PDP-11.


The situation with x86 specifically is a little weirder than that: http://www.emulators.com/docs/nx06_rmw.htm . It's a bit of a long read, but the summary is that on some x86s, single-instruction adds to memory are faster, and on others, load/increment/store in three instructions is faster.

Compiler optimization be a harsh mistress.


No css, no javascript, loads in a flash (pun intended), the way a web page should be.

On top of that it contains mostly information rather than mark-up and eye candy.


Um, yes, and this kind of unstyled webpage is also the kind that makes me twitch straight to my "Make Readable" CSS-forcing bookmarklet so that I can read it in a legible size, line spacing, and line width, rather than having it trawl all the way across my widescreen monitor in 12pt serif.

It can get exhausting keeping up with all of the silly CSS/JS web trends, I realize, but there is a good reason for a lot of it.


Your browser has awful defaults. There's no CSS, so your browser is responsible for presenting it in a readable form.


I wonder if a popular web browser could get away with changing all its default CSS rules to resemble modern readability guidelines, without breaking a large majority of the web?

People who use CSS resets would be fine; people who use things like normalize.css might have to go get a new version; but the rest of the internet (which is implicitly relying on things like the line-height of <p>s and the padding of <body>) might just spontaneously combust.

Then again, it might be fine to apply an alternate "default theme" if and only if there are literally no non-user-agent CSS styles defined on the page (either by stylesheets or DOM-manipulating Javascript).


>Then again, it might be fine to apply an alternate "default theme" if and only if there are literally no non-user-agent CSS styles defined on the page (either by stylesheets or DOM-manipulating Javascript).

That might be the way to go.


Firefox doesn't present it in a readable form (the page width is so large that reading the text is annoying). Which browsers handle this well?


Firefox and Webkit both allow a user-specified stylesheet, although it is buried a bit in Firefox.


Hey, you're right. As it says at this URL,

  resource:///defaults/profile/chrome/userContent-example.css
the file goes in <profile directory>/chrome/userContent.css. On a conventionally installed Firefox on OS X, the profile directory is:

  ~/Library/Application Support/Firefox/Profiles/<random characters>.default/
You may have to create your own "chrome" subfolder in there. (I did.) Some poking around reveals that the essays on Paul Graham's website achieve their indentation by sticking all the text in a <td width=455>. 455 pixels, then. So I tried this CSS file, having spent all of three or so minutes looking at a CSS reference:

  ~ $ cat heh.css
  p {max-width:455px}
And installed that as <profile-dir>/chrome/userContent.css. ... This seems to have far-reaching implications. It does make all the paragraphs on this website, except for the first one, fit in what is presumably a 455px box. This also goes for Hacker News comments, and it also constricts the paragraphs on a website that pretty certainly has its own CSS. I suspect the only thing that would override this is a CSS that specifically changed the max-width property of <p> objects. (I expect a CSS expert would have been able to predict all of the above, except possibly the fact that it seems common for the first paragraph to not be in a <p> tag.) Oh, and I had to restart Firefox for the effects to be visible; and, editing that CSS file, it seems I'll have to restart Firefox again to see changes.

For those who don't want to go to the above effort to see the results: http://imgur.com/F1MHng3 http://imgur.com/jYly4fX


That's not by default. User-specified CSS is even less usable by most end users than a 3rd party "make readable" bookmarklet.


What about resizing the browser window? Is that usable by most end users?


A website forcing the user to resize the browser window (or use a readable-bookmarklet/plugin) is broken.


> It can get exhausting keeping up with all of the silly CSS/JS web trends

This is DMR's website. Good job criticizing a dead man on not "keeping up" or writing CSS so that you don't have to customize your default styles.


That was in response to (and in empathy of) jacquesm' implication that this was preferable to other styles on the web, it wasn't meant to criticize this link's WM.


It's really depressing to see so many comments about HTML in this thread. Seriously... who cares?


Here's a bookmarklet I keep handy. I call it "Sane Margins":

  javascript:var style=document.getElementsByTagName('body')[0].style;style.marginLeft=style.marginRight='1in';style.maxWidth='7in';void(0)
Ninja update: oops, reply fail :-(


The fact that early pointer notation was just suffix [] is interesting. If they'd stuck with that it would have avoided the a*b ambiguity.


And if they hadn't, people would be confused about whether something's supposed to be a pointer or an array. I think I like the current syntax much better.


>And if they hadn't, people would be confused about whether something's supposed to be a pointer or an array.

Not that they aren' confused between pointers and arrays now.


True. But it really could have been anything suffix, including probably *, and it would have still resolved that ambiguity.


I just glanced at this: http://cm.bell-labs.com/cm/cs/who/dmr/last1120c/c10.c

What is/was the purpose of the ospace() and waste() functions?


Oh never mind, RTFA


No "entry" keyword. I looked.


yeah, I found this last night and posted it on Reddit. Thanks for the cross post. I have a github repo open for it I if anybody wants to fork. I won't merge pull requests. github.com/mortdeus/legacy-cc


Is it me or is it weird to say "thanks for the cross-post" for something written by Dennis Ritchie?


You are the second person bringing up DR in this post for reasons having nothing to do with DR himself.

The "post" part is about who posted it to HN, not about who wrote the article.


As in thanks for linking it to hacker news, because I didnt after finding the article last night.


I read this article a few years ago, does that entitle me to recognition? Obviously not. It just struck me as taking credit for non-accomplishments.


What are you even talking about? I was thanking the poster for doing something I didnt do myself. This is the x-post I was talking about.

http://www.reddit.com/r/programming/comments/19gnki/legacycc...

I am not seeking any sort of recognition for the post whatsoever.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: