I don't really understand what the point of all this is, and why anyone would consider using this in a real-world application they're developing. There's already a C-like language which lets you write type-safe generic programs: it's called C++! And if for some reason you really want or need to restrict yourself to using C language features (almost) exclusively, you can disable RTTI, exceptions, and use a technique t…
Generics in C without void* or macros – enabled by psychec
31–40 of 74 posts
Re: Generics in C without void* or macros – enabled by psychec
#32Earlier quoted context omitted.
...my compile times rarely take more than a minute, so I can't really relate to that, but exceptions will slow down execution and add an overhead to the binary's file-size.
Exceptions don't generally slow down execution -- they usually have zero runtime cost if they're not thrown making them better than error returns for performance. However, the exchange is, as you said, that they do add a lot of overhead to the file-size.
There's cost to transfer it through memory and cache hierarchies and there's cost when it causes the CPU to drop some other L1C cache line.
Re: Generics in C without void* or macros – enabled by psychec
#33You should never typedef a pointer to an object. That’s common knowledge amongst experienced C developers and an immediate red flag, even for myself normally welcoming of anything built with Haskell.
Re: Generics in C without void* or macros – enabled by psychec
#34Re: Generics in C without void* or macros – enabled by psychec
#35Earlier quoted context omitted.
Exceptions don't generally slow down execution -- they usually have zero runtime cost if they're not thrown making them better than error returns for performance. However, the exchange is, as you said, that they do add a lot of overhead to the file-size.
Something that generates extra code that ends up in the instruction cache during execution is not zero cost. There's cost to transfer it through memory and cache hierarchies and there's cost when it causes the CPU to drop some other L1C cache line.
Re: Generics in C without void* or macros – enabled by psychec
#36Earlier quoted context omitted.
Yes, that was confusing. "Look, you don't need to use these C-features if you use another language than C."
C++ 14, Haskell and Python. One of the reasons I'm actually going for pure C in this modern day and age, is that I can just write a small program, without having any other dependency. I'm sure the same could be said for C++, too, but for some reason, with my setup (GCC 5.1.0 with MinGW on Windows 7), I'm averaging around 800KB on C++ vs 80KB on C, for the (mostly) same code. EDIT: It appears that exception-handling i…
Re: Generics in C without void* or macros – enabled by psychec
#37Earlier quoted context omitted.
C++ 14, Haskell and Python. One of the reasons I'm actually going for pure C in this modern day and age, is that I can just write a small program, without having any other dependency. I'm sure the same could be said for C++, too, but for some reason, with my setup (GCC 5.1.0 with MinGW on Windows 7), I'm averaging around 800KB on C++ vs 80KB on C, for the (mostly) same code. EDIT: It appears that exception-handling i…
Are you sure it isn't debugging information that bloats the executable? Try a strip --strip-all your.exe and see if it is still that big.
...I guarantee that it is nothing short of humongous xD
Joking aside, maybe, I don't know, it's been a while since I used some C++ code, but I'll have a look into it the next time around.
...though it's probably unlikely, I use Code::Blocks and exclusively use the "Release" candidate, and uncheck the "Debug" version, and I'm quite confident the CB authors know what they are doing.
Re: Generics in C without void* or macros – enabled by psychec
#38No void* or macros, but requires a special compiler frontend.
Re: Generics in C without void* or macros – enabled by psychec
#39Earlier quoted context omitted.
Exceptions don't generally slow down execution -- they usually have zero runtime cost if they're not thrown making them better than error returns for performance. However, the exchange is, as you said, that they do add a lot of overhead to the file-size.
Something that generates extra code that ends up in the instruction cache during execution is not zero cost. There's cost to transfer it through memory and cache hierarchies and there's cost when it causes the CPU to drop some other L1C cache line.
Re: Generics in C without void* or macros – enabled by psychec
#40Interesting link, but if anybody is interested in making real practical use of generics in a C-style language, then it's best to take a look at Zig.
[1] https://ziglang.org/download/0.1.1/release-notes.html [2] https://andrewkelley.me/post/intro-to-zig.html