Live data from Hacker News

Generic dynamic array in 60 lines of C

gist.github.com

11–20 of 110 posts

Re: Generic dynamic array in 60 lines of C

#11

Heavy use of macros to do metaprogramming is a strong sign it's time to move to a more powerful language.

I don't have this luxury if I want to learn about ffmpeg libraries, its all written in c, almost all media and hardware accelerator libraries are written in c, you go to another language they just bind to c. its soo frustrating but I've no choice but to stick with c.

Re: Generic dynamic array in 60 lines of C

#15

Heavy use of macros to do metaprogramming is a strong sign it's time to move to a more powerful language.

I don't have this luxury if I want to learn about ffmpeg libraries, its all written in c, almost all media and hardware accelerator libraries are written in c, you go to another language they just bind to c. its soo frustrating but I've no choice but to stick with c.

huh? What's wrong with using the higher level languages if they take care of binding to the C parts for you.

(I know these are far an in-between for ffmpeg, too many leaky abstractions.)

Re: Generic dynamic array in 60 lines of C

#16

Heavy use of macros to do metaprogramming is a strong sign it's time to move to a more powerful language.

I don't have this luxury if I want to learn about ffmpeg libraries, its all written in c, almost all media and hardware accelerator libraries are written in c, you go to another language they just bind to c. its soo frustrating but I've no choice but to stick with c.

Most languages have the ability to call C functions. Use the language that helps you write your code and convert to call the third party API.

For example, a C++ Vector provides a generic container and the code can still call C functions with the underlying array.

This is in the "Doctor it hurts if I do X" bucket.

https://stackoverflow.com/questions/2923272/how-to-convert-v...

Re: Generic dynamic array in 60 lines of C

#18

Heavy use of macros to do metaprogramming is a strong sign it's time to move to a more powerful language.

On one hand that's obviously true, on the other hand it's just 60 lines of code, which is easier to check and audit than (for instance) a typical std::vector implementation - I don't know what the equivalent is in D, please forgive my ignorance :)

Re: Generic dynamic array in 60 lines of C

#19

Earlier quoted context omitted.

I don't have this luxury if I want to learn about ffmpeg libraries, its all written in c, almost all media and hardware accelerator libraries are written in c, you go to another language they just bind to c. its soo frustrating but I've no choice but to stick with c.

Most languages have the ability to call C functions. Use the language that helps you write your code and convert to call the third party API. For example, a C++ Vector provides a generic container and the code can still call C functions with the underlying array. This is in the "Doctor it hurts if I do X" bucket. https://stackoverflow.com/questions/2923272/how-to-convert-v...

Mixing high level C++ stdlib classes with low level C APIs is often not exactly trivial, for instance most C++ containers expect that their items are RAII compatibel, and the resulting memory corruption errors will be harder to debug than plain old C code because the shit hits the fan deep inside some completely unreadable C++ stdlib implementation code.
Post reply on HN