> I have been interested in pure C lately, and I really need to level up my experience.
> I wanted to use a object oriented style with constructors and polymorphism. Since it isn’t supported directly, you are free to implement it as you feel like.
I've been there in the "pure C" land some time ago. I drank all the 'C++ is shit' koolaid that was spread some time ago all over the net. And I hacked away quite a few projects in C - with my own implementation of polymorphism, strings, etc.
But then I got really really tired of it. It's all extra work you don't have to do in C++. Yes, C++ can be a horrendous mess if you use all features. But it also offers awesome syntactic sugar for "structs with methods" style programming.
std::string and vector alone save you so much time. And RAII + shared_ptr will free up another huge chunk of time you otherwise would have spent thinking about memory and resource management issues.
I think everyone who's doing C++ work should go C-only for some time just to appreciate what the lovely monster called C++ actually did for programmer productivity.
* This is no flame against C. It has its place and I appreciate its existence.
Honestly, the only real reason to use C was because I simply wanted to get some more experience writing C. I was also curious how OO would be done in C.
I just got a new job, and one of the positions I was interviewed for would involve developing a Bluetooth stack for embedded devices. I ultimately wasn't offered that particular job, because I didn't have the experience in C they were looking for. Too bad, it could have been fun.
I have nothing against C++ really. It's just that if I would do a hobby project in C++, I would like to focus on the modern features like smart pointers and write really clean, idiomatic C++. The old code for the renderer was neither.
I actually find it more interesting that you had to postscript which says an indifferent discourse on your experience on C and C++ was not a flame against C.
While I agree with your remark wholeheartedly(Yes, C++ has a lot of toolchain, but no one decreed that you have to use everything in your toolbox), I think had I written this response, I would've added that defence somewhere. I guess it's telling how far the C vs C++ discussion went and how long it raged on...
C++ advocate here. It doesn't seem to be a strongly represented opinion here, so I think it's actually worth me chiming in.
All the criticisms are valid. Yes, C++ is like "making an octopus by nailing 4 extra legs onto a dog". None of us like having to remember that we need virtual destructors if we have derived classes, because otherwise deleting a class through the wrong derived pointer type would cause complicated problems. There's a bunch of crap there.
But I spent years coding C and I hate going back.
I miss smart pointers when I'm stuck with C. I miss containers that don't suck. I miss lame stuff like log4cpp and boost::asio.
If you're willing to accept a bunch of dependencies and can handle serious (sometimes grevious) conceptual overheads, you can write native code with an expressiveness approaching Python. To me, that makes it all worth it.
Note that I'm not a very good programmer, don't know very much about Java and math and didn't even know how to program a camera. But Jeffrey Ventrella helped me with some basics and also his document "Intuitive Computer Graphics Camera" helped me a lot: http://www.ventrella.com/Ideas/index.html
If you're really interested in Raytracing, get hold of the Book "Physically-based Rendering" by Matt Pharr and Greg Humphreys.
It's pretty-much the bible for raytracing theory at close to production level rendering, and has pbrt - an open source raytracer - which ships with it which is a relatively capable renderer, and an excellent example of how to design a renderer in an object-orientated way.
The BRDF functions I implemented are supposed to be energy conservative. However, the most important part is the photon importance sampled bouncing, which is by definition energy conservative.
> I wanted to use a object oriented style with constructors and polymorphism. Since it isn’t supported directly, you are free to implement it as you feel like.
I've been there in the "pure C" land some time ago. I drank all the 'C++ is shit' koolaid that was spread some time ago all over the net. And I hacked away quite a few projects in C - with my own implementation of polymorphism, strings, etc.
But then I got really really tired of it. It's all extra work you don't have to do in C++. Yes, C++ can be a horrendous mess if you use all features. But it also offers awesome syntactic sugar for "structs with methods" style programming.
std::string and vector alone save you so much time. And RAII + shared_ptr will free up another huge chunk of time you otherwise would have spent thinking about memory and resource management issues.
I think everyone who's doing C++ work should go C-only for some time just to appreciate what the lovely monster called C++ actually did for programmer productivity.
* This is no flame against C. It has its place and I appreciate its existence.