Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The C preprocessor was an easy and compact way to extend C back when memory was really really tight. You can't even fit a C++98 compiler into DOS's memory space, but you can fit a C compiler in 64K. (Well, an earlier version of C.)

C has been adding generics anyway, like _Generic.



>C has been adding generics anyway, like _Generic.

"_Generic" added function overloads to c, not generics. The naming is exceptionally poor.

The submission is an example of generic programming. It an implementatin of something that works on all types that fullfill certain constrains. In this case comparable and swapable. "All types" include user defined types.

"_Generic" does something completely different. The C++ equvivalent would be std::conditional_v<std::is_same<T, int>, myIntFunc, std::conditional<std::is_same<T, double>, myDoubleFunc ............ The exact opposite of a generic, I'd argue, as myIntFunc and myDoubleFunc do depend on the type. You might use the preprocessor to create these functions that differ only in type, but then again, you might do what OP did.


About a year ago I had a look at a C compiler for 16bit computers, featured in disk form on I think Adrian's digital basement YT channel.

The compiler was very basic, nothing like you'd expect from a compiler even from the dragon book.

So simple and it was a production compiler too!

Sadly I can't remember the name of it to reference here.


I wrote one back in 1983 or so for 16 bit DOS, too!

A few years later, I was at a C++ conference where they asked me to sit on an "Ask us anything" panel. I was there along with the developers of Microsoft C, Borland C, etc.

The first question was "do you still ship a version of your compiler that will run on a floppy disk system?"

Vendor 1 said sure, and launched into a long description of how the files could be shuffled about on the floppy to make it work.

Vendor 2 said sure, and launched into ...

My turn. I said sure, and said the floppy disk version costs $200 and comes with a hard disk drive. (That was the price of a hard disk in those days.)

That was the end of that, I never heard that question again from anybody.

Progress...


What versions did you offer otherwise? I don't recall CD becoming popular on computers until the 90s.


Wow, in 1983 I hadn’t even seen a hard disk in person!


I had one back then, but I did say "a few years later...".




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: