News for hackers. Stuff that matters.
Re:Primeval C: two very early compilers by gwern on Friday March 01, 2013 @09:50PM (#5308238)
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?
Re:Primeval C: two very early compilers by kragen on Saturday March 02, 2013 @01:29AM (#5308729)
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!
Re:Primeval C: two very early compilers by vanderZwan on Saturday March 02, 2013 @01:00PM (#5310311)
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?
Re:Primeval C: two very early compilers by kragen on Sunday March 03, 2013 @01:21PM (#5314626)
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.

Re:Primeval C: two very early compilers by 1337p337 on Saturday March 02, 2013 @05:17PM (#5311328)
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.

Re:Primeval C: two very early compilers by jacquesm on Friday March 01, 2013 @05:36PM (#5307411)
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.

Re:Primeval C: two very early compilers by jrajav on Friday March 01, 2013 @06:06PM (#5307549)
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.

Re:Primeval C: two very early compilers by zerohp on Friday March 01, 2013 @06:22PM (#5307614)
Your browser has awful defaults. There's no CSS, so your browser is responsible for presenting it in a readable form.
Re:Primeval C: two very early compilers by derefr on Friday March 01, 2013 @07:55PM (#5307923)
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).

Re:Primeval C: two very early compilers by aaronblohowiak on Saturday March 02, 2013 @10:24AM (#5309721)
>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.

Re:Primeval C: two very early compilers by nawitus on Friday March 01, 2013 @07:46PM (#5307887)
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?
Re:Primeval C: two very early compilers by 1337p337 on Friday March 01, 2013 @08:08PM (#5307974)
Firefox and Webkit both allow a user-specified stylesheet, although it is buried a bit in Firefox.
Re:Primeval C: two very early compilers by waterhouse on Saturday March 02, 2013 @09:18AM (#5309518)
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

Re:Primeval C: two very early compilers by jamesgeck0 on Saturday March 02, 2013 @02:45AM (#5308878)
That's not by default. User-specified CSS is even less usable by most end users than a 3rd party "make readable" bookmarklet.
Re:Primeval C: two very early compilers by ihateloggingin on Saturday March 02, 2013 @03:28AM (#5308955)
What about resizing the browser window? Is that usable by most end users?
Re:Primeval C: two very early compilers by onli on Saturday March 02, 2013 @10:40AM (#5309772)
A website forcing the user to resize the browser window (or use a readable-bookmarklet/plugin) is broken.
Re:Primeval C: two very early compilers by 1337p337 on Friday March 01, 2013 @07:30PM (#5307846)
> 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.

Re:Primeval C: two very early compilers by jrajav on Friday March 01, 2013 @09:53PM (#5308245)
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.
Re:Primeval C: two very early compilers by cmccabe on Saturday March 02, 2013 @05:42AM (#5309160)
It's really depressing to see so many comments about HTML in this thread. Seriously... who cares?
Re:Primeval C: two very early compilers by DaveInTucson on Saturday March 02, 2013 @12:52AM (#5308637)
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 :-(
Re:Primeval C: two very early compilers by stormbrew on Friday March 01, 2013 @04:31PM (#5307065)
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.
Re:Primeval C: two very early compilers by xymostech on Friday March 01, 2013 @10:10PM (#5308286)
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.
Re:Primeval C: two very early compilers by coldtea on Saturday March 02, 2013 @06:21AM (#5309225)
>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.

Re:Primeval C: two very early compilers by stormbrew on Friday March 01, 2013 @10:57PM (#5308395)
True. But it really could have been anything suffix, including probably *, and it would have still resolved that ambiguity.
Re:Primeval C: two very early compilers by leothekim on Friday March 01, 2013 @05:09PM (#5307263)
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?

Re:Primeval C: two very early compilers by leothekim on Friday March 01, 2013 @05:09PM (#5307264)
Oh never mind, RTFA
Re:Primeval C: two very early compilers by limmeau on Friday March 01, 2013 @03:45PM (#5306849)
No "entry" keyword. I looked.
Re:Primeval C: two very early compilers by mortdeus on Friday March 01, 2013 @04:43PM (#5307123)
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
Re:Primeval C: two very early compilers by asveikau on Friday March 01, 2013 @06:30PM (#5307637)
Is it me or is it weird to say "thanks for the cross-post" for something written by Dennis Ritchie?
Re:Primeval C: two very early compilers by coldtea on Saturday March 02, 2013 @06:23AM (#5309229)
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.

Re:Primeval C: two very early compilers by mortdeus on Saturday March 02, 2013 @01:47AM (#5308775)
As in thanks for linking it to hacker news, because I didnt after finding the article last night.
Re:Primeval C: two very early compilers by asveikau on Saturday March 02, 2013 @12:38PM (#5310245)
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.
Re:Primeval C: two very early compilers by mortdeus on Monday March 04, 2013 @11:21PM (#5322890)
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.