Live data from Hacker News

A header-only C implementation of C++

github.com

41–50 of 94 posts

Re: A header-only C implementation of C++ <algorithm>

#41

Why header only? Jesus christ, we have a linker.

I assume you are not familiar with modern C, but I think it's a good opportunity to explain.

A single header style allows you to customize the library with the preprocessor before `#include`. I use this ability to implement generics. Otherwise, you're stuck with void* or code generation (want my python script instead?).

However, you don't have to forgo the benefits of separate compilation units. You can include the declarations in a header, and the implementation in a separate C file. No other parts of the code base will be impacted.

Re: A header-only C implementation of C++ <algorithm>

#42

Why header only? Jesus christ, we have a linker.

I assume you are not familiar with modern C, but I think it's a good opportunity to explain. A single header style allows you to customize the library with the preprocessor before `#include`. I use this ability to implement generics. Otherwise, you're stuck with void* or code generation (want my python script instead?). However, you don't have to forgo the benefits of separate compilation units. You can include the d…

That isn't modern C. It's the cool kids backporting a misfeature from C++ because that's what all the game devs do. Header only serves no purpose in C other than to demonstrate that you can't drive your tooling. Plus you've created a new burden to keep track of the magic define that activates the definitions in the code and the one file where it's invoked.

Re: A header-only C implementation of C++ <algorithm>

#44
post #36
post #32

Earlier quoted context omitted.

"Social progress" got us the holocaust and tens of millions killed by communism, though. It's perfectly reasonable to be wary of it.

It also ended serfdom. Being wary of change is usually the excuse to perpetuate awful systems in both technology and society.

> Being wary of change is usually the excuse to perpetuate awful systems in both technology and society.

Do you have any evidence to back that "usually" claim? I'm from a country that went through the horrors of malicious forced social change (under Communism), and most people who warm against it just don't want it ever to return.

Re: A header-only C implementation of C++ <algorithm>

#45

Earlier quoted context omitted.

I assume you are not familiar with modern C, but I think it's a good opportunity to explain. A single header style allows you to customize the library with the preprocessor before `#include`. I use this ability to implement generics. Otherwise, you're stuck with void* or code generation (want my python script instead?). However, you don't have to forgo the benefits of separate compilation units. You can include the d…

That isn't modern C. It's the cool kids backporting a misfeature from C++ because that's what all the game devs do. Header only serves no purpose in C other than to demonstrate that you can't drive your tooling. Plus you've created a new burden to keep track of the magic define that activates the definitions in the code and the one file where it's invoked.

[deleted]

Re: A header-only C implementation of C++ <algorithm>

#46

Earlier quoted context omitted.

I assume you are not familiar with modern C, but I think it's a good opportunity to explain. A single header style allows you to customize the library with the preprocessor before `#include`. I use this ability to implement generics. Otherwise, you're stuck with void* or code generation (want my python script instead?). However, you don't have to forgo the benefits of separate compilation units. You can include the d…

That isn't modern C. It's the cool kids backporting a misfeature from C++ because that's what all the game devs do. Header only serves no purpose in C other than to demonstrate that you can't drive your tooling. Plus you've created a new burden to keep track of the magic define that activates the definitions in the code and the one file where it's invoked.

> you can't drive your tooling

Can you suggest what tooling actually can help to implement algorithms and data structures libraries with generic types in a clean way?

Re: A header-only C implementation of C++ <algorithm>

#47

Earlier quoted context omitted.

I assume you are not familiar with modern C, but I think it's a good opportunity to explain. A single header style allows you to customize the library with the preprocessor before `#include`. I use this ability to implement generics. Otherwise, you're stuck with void* or code generation (want my python script instead?). However, you don't have to forgo the benefits of separate compilation units. You can include the d…

That isn't modern C. It's the cool kids backporting a misfeature from C++ because that's what all the game devs do. Header only serves no purpose in C other than to demonstrate that you can't drive your tooling. Plus you've created a new burden to keep track of the magic define that activates the definitions in the code and the one file where it's invoked.

> demonstrate that you can't drive your tooling

Apparently few can. How many image libraries came before `stb_image`? KISS is a feature.

Also, tooling changes between platforms and build systems.

Re: A header-only C implementation of C++ <algorithm>

#48
post #46

Earlier quoted context omitted.

That isn't modern C. It's the cool kids backporting a misfeature from C++ because that's what all the game devs do. Header only serves no purpose in C other than to demonstrate that you can't drive your tooling. Plus you've created a new burden to keep track of the magic define that activates the definitions in the code and the one file where it's invoked.

> you can't drive your tooling Can you suggest what tooling actually can help to implement algorithms and data structures libraries with generic types in a clean way?

The issue here is people too lazy to tell their compiler where to find a header file so instead they cook up a bespoke system that is specific to every library using this approach.

Re: A header-only C implementation of C++ <algorithm>

#49
post #46

Earlier quoted context omitted.

> you can't drive your tooling Can you suggest what tooling actually can help to implement algorithms and data structures libraries with generic types in a clean way?

The issue here is people too lazy to tell their compiler where to find a header file so instead they cook up a bespoke system that is specific to every library using this approach.

[deleted]

Re: A header-only C implementation of C++ <algorithm>

#50
post #16

Well, I do like mine better, which is closer to the STL, and for all containers. https://github.com/rurban/ctl/

I wonder why it's a so common pattern here that everytime someone shows their product, someone in the comments will show their own version in a not-so-implicit patronizing tone

Possibly because rurban is very consistent about showing up to C topic threads, mentioning his own work, and using that kind of tone.
Post reply on HN