Live data from Hacker News

A header-only C implementation of C++

github.com

51–60 of 94 posts

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

#51
post #8

Ah, one of those "generic" libraries back from MS-DOS days.

> Ah, one of those "generic" libraries back from MS-DOS days. Nothing about this screams "MS-DOS".[1] Why the disparagement? [1] I know, I was programming at that time.

pjmlp is a C++ fan who consistently criticizes C.

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

#52
post #22

Earlier quoted context omitted.

God I wish everything was done in this way. Even the C standards committee moves too fast and adds features that have no place in the standard.

Well, there are people who choose to stay away from social and technical progress. I totally respect that desire.

I have nothing against progress itself (although I'm not sure why you brought social progress into this), but not everything has to be everything. XML parsers are useful, but surely you wouldn't want one included in libstdc++.

And I'm not saying there isn't room for improvement. There are lots of genuinely useful features C is missing, especially regarding static analysis. I would love to have a proof assistant that can integrate with a C/C++ compiler to prove equivalence of functions, so you could write an obvious version and then transform it step by step to an optimized version, which is guaranteed to have the same observable behaviour.

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

#54
post #16

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

I think our projects are completely different and don't have the same goals. 1. You don't implement the most important algorithms. For example `stable_sort` for arrays. So right there, it's not even a substitute. One of my motivations from the start was simply to have `stable_sort` in C (to implement database queries). 2. Yours is a clever implementation of C++ features using macros. But it's not idiomatic C. If some…

Well, you do support only vector containers, by having the limitation of first++ as only iter increment. Your name "array" clashes with the C++ array, which is a compile-time sized vector. And your array is unsafe sized, as last is the only size provision, even unsafer than C++ with its unsafe iterators. With C++ you can it least still bounds check against the vector size.

Your variant being static is indeed nice, the STL, CTL cannot do that, just MTL exists for that. Which supports all containers. E.g. Non-vector types allow for much faster inserts.

You can only replace insitu, which is the opposite of functional. No backtracking. Manual copying needed. The spirit of the STL algorithms is to allocate, not overwrite.

Re hash-map: this is not even finished. For now it's just a pointer-stable unordered_map with optimizations for all types, primitives or strings. optimized Swisstable (string) and Stanford hashes (u64) are in work (no time for that), and are indeed multiple times faster.

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

#55
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.

> It also ended serfdom.

Hardly.

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

#56

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.

> 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.

KISS is a feature indeed. I like to think that I can drive my tooling, and I do appreciate not having my choice of build system being affected by this library.

I understand that some libraries are themselves so big and complex that they need a build system. Each library I want to use that doesn’t is a blessing.

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

#57
post #33

Earlier quoted context omitted.

> Ah, one of those "generic" libraries back from MS-DOS days. Nothing about this screams "MS-DOS".[1] Why the disparagement? [1] I know, I was programming at that time.

Common C libraries in MS-DOS, before Borland C++ and Watcom C++ took over.

> Common C libraries in MS-DOS,

Honestly, never came across those in the C compilers I used back then.

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

#58
post #16

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

Honestly, who cares? On a more constructive side, I think adding some value by giving the poster some feedback or engaging in a conversation about the topic would be nice, otherwise it just sounds as an attempt to show off. I'm not a fan of these "header only" projects nor am I a fan of overly clever code because even though it's fun and rewarding to write it's not a great fit for larger or collaborative projects whe…

> attempt to show off

Why not? rurban's work is solid and should be shown off.

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

#59
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

I personally love that. Sometimes you'll find gems among all that information.
Post reply on HN