3 ms·
Well, I've tried plain C in one project. The compiler didn't complain when I did some invalid casts, didn't complain when I forgot to return values from functio
by self_awareness 9y ago
Well, I've tried plain C in one project. The compiler didn't complain when I did some invalid casts, didn't complain when I forgot to return values from functions, provided some warnings against using some undefined functions, but compiled the units anyway (failing on linking stage), I had to write my own implementation of vector (probably buggy and slow), and probably I've forgot to free memory in some situations because C doesn't support smart pointers and automatic cleanup through RAII. Lots of times I felt I'm programming in some dynamic language that doesn't support types, because types are so weak in C. This means that lots of bugs were caught in runtime, not compilation step. Trying to use a hashmap meant I had to pull additional dependencies.
Disclaimer: I don't love C++, I think it has lots of problems, but saying C++ is wrong, while C is right suggests to me that lots of people didn't take time to actually learn C++ but have strong opinions on it.
- dllthomas 9y ago> because types are so weak in C You can get nominal typing in C by wrapping your primitives in single-element structs. Slight syntactic overhead, no runtime overhead. In my C code, I try to avoid passing primitives between functions. It worked out well on my last large C project.