Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Object Oriented Programming in C (2006) (cern.ch)
15 points by tyranocyte on Aug 16, 2023 | hide | past | favorite | 6 comments


You can also use GObject[1]. It was created for the GTK[2] GUI library and therefore underpins all of the GNOME desktop environment, but can also be utilised independently.

[1]: https://docs.gtk.org/gobject/

[2]: https://www.gtk.org/


Apologies to Greenspun:

“Any sufficiently complicated C program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of C++.”


I used to do it by hand.


Me too friend


There was that time I was finishing up my PhD thesis and had written a Monte Carlo integration that computed the volume of an energy surface in a 6-dimensional phase space.

I wrote the first draft of the program in Java, it wasn't really fast enough, so I wrote a second draft in C that used a bunch of performance optimizations, most notably it applied a coordinate transformation to the phase space that meant the probability of a point being inside the surface was much higher than it was before.

The program was really a lot faster but most of the gain came from using better algorithms, the factor I got from C might not really have been worth it. I wrote that program in my own dialect of object-oriented C.


It's amusing how the times have changed.

Back in 2002, you couldn't get a job unless you wrote "object oriented code" in your resume.

Nowadays, state is evil (pun intented) and OO is the naughty child - "Bro, do you even write functional?", yet no one writes haskell (neither do I).

Seeing articles like these for 2006 trying to shoe-horn Objects in C is amusing!

This is not a nostalgic post about the gool ol' days, today we know so much more about what works and what doesn't in large applications. State _is_ bad and should be encapsulated. Pure functions are your friend. Objects... egh. We don't talk about objects, we refer to them as "this guy".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: