28 comments

[ 2.0 ms ] story [ 67.8 ms ] thread
...why?

I get it if this is someone's project just for fun, but relevance to the HN crowd seems a bit iffy.

> SubC is a simple subset of C originally written by Nils Holms for teaching newcomers how to write a compiler.

I assume it's for fun and to learn

The original headline said C89, not SubC. It makes more sense as a SubC compiler.
Writing compilers for fun is not relevant to HN? Get off your high horse, this project is really cool!
Why not? Have you never coded something for fun and wanted to show it off? HN seems like just the place to do that, full of like minded people who just code for the sake of coding.
You are joking right? This is the most HN sounding title I've seen in a while.
Judging from their account age I hope so.
It's (1) a side project that involves (2) writing code to implement (3) a compiler for a subset of C.

I don't really see where your issue is, but I do see 3 reasons for it being on HN.

You can do a lot more with compiler infrastructure than simply building programs. C89 is a useful starting point.
Not even remotely C89. Whoever submitted it incorrectly put C89 in the title.
That's what confused me. Building a C89 compiler is a lot of work, but aggressively useless in 2016. You would be hitting edge cases on most modern code.
It is called "HackerNews", not "PracticalAndEfficientNews
It would have been even more fun(and useful) to write a safer C.
I'm not sure where the C89 in the submitted title came from. This is for SubC, "a simple subset of C." This README describes the many differences:

http://www.t3x.org/subc/README-current.html

Wow, that's a lot of features removed. No double, float, short, long, signed, unsigned, or typedef? There goes 99% of the C programs ever written.
Sounds like they're trying to make it more like B.
Charlie Stross should put the language Z in his books. It's another language of that heritage, but writing a working compiler in it would constitute a thaumaturgic formula so powerful, the universe would end.
You talking about the specification language? If so, I can give you the compiler you asked for written using it.
Is "thaumaturgic" related to "demiurge" etymologically?
Yes. The "urge" part means "work:" Thaumaturgy is using magic to do work, and a demiurge was just a craftsman or artisan until Plato borrowed the term for theological purposes.
Huh, that's cool. I wonder if there's any way I can expand my etymology-fu apart from just picking stuff up randomly or learning Latin/Ancient Greek. (I did read Word Power Made Easy as a kid. It kicked off my interest in these things.)
One thing you can do is, if you come across a word you're curious about, plug it into Wiktionary and see what comes up. Wiktionary tends to be pretty good with etymology.

For example, thaumaturgy: https://en.wiktionary.org/wiki/thaumaturgy

Clicking on one of the links provided gives this: https://en.wiktionary.org/wiki/ἔργον which lists a number of derived forms. Did you know that the words "energy" and "lethargy" and the prefix "ergo-" come from a derivative the Greek root of "urge"? Neither did I until I started writing this comment.

And looking up "demiurge" leads me to this: https://en.wiktionary.org/wiki/Δημιουργός where it comes from the Greek for "public worker". So that probably means the "demi" in "demiurge" comes from the same root as "democratic"! And going to the lowercase form gives https://en.wiktionary.org/wiki/δημιουργός

And I just realized that referring to a divine entity as "the Demiurge" is just a fancy way of saying "the Creator" or "the Maker".

That's very similar to what I do now. I was looking for something more systematic than "hope you stumble across cool words" :)

I did not know that energy and lethargy come from the same Greek root, though, thanks!

SubC was designed for demonstrating how a compiler works, not as a drop-in replacement for C. It's more like the Small C compilers of the 1980's, but without bending the rules (i.e. it compiles with little or no warnings).

(I'm the author of SubC, which is the language implemented by Gosubc.)

Thanks, we've updated the title from the submitted “Gosubc: a C89 compiler written in Go”.
So? Is it shorter? How much shorter? How does Go improve over C? Just curious.