Live data from Hacker News

Object-Oriented Programming in C (2019) [pdf]

state-machine.com

11–20 of 95 posts

Re: Object-Oriented Programming in C (2019) [pdf]

#12
post #11

If you need to do OOP in C, it's time to move to a more powerful language.

"If you need to do OOP in C, it's time to move to a more powerful language." As long as is not C++...

C++ has plenty of issues, but it's really not that bad, especially modern C++. It's a huge language with tons of features, many of which you'll never use, but as far as writing C++, really not that bad. I've written a lot of C++ over the years, and I've also written a lot of vanilla C. I can tell you that you can definitely get a new project up and running much faster in C++ than in C.

Re: Object-Oriented Programming in C (2019) [pdf]

#13
post #11

Earlier quoted context omitted.

"If you need to do OOP in C, it's time to move to a more powerful language." As long as is not C++...

C++ has plenty of issues, but it's really not that bad, especially modern C++. It's a huge language with tons of features, many of which you'll never use, but as far as writing C++, really not that bad. I've written a lot of C++ over the years, and I've also written a lot of vanilla C. I can tell you that you can definitely get a new project up and running much faster in C++ than in C.

I'm an OO programmer, and I avoid using classes in C++. The happy path seems to be to treat at C with STL + smart pointers, not C with classes.

Re: Object-Oriented Programming in C (2019) [pdf]

#17

I think this approach is working too hard to realize Virtual Tables and Virtual Pointers. Another, different implementation is to define an array of function pointers, one function per method implemented, and then extend the array per subclass; each child class fills in its own or parents function pointers at init time.

Or perhaps go the more novel way of Piumarta's and Warth's Open, extensible object models? http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.121...

Re: Object-Oriented Programming in C (2019) [pdf]

#18
post #11

If you need to do OOP in C, it's time to move to a more powerful language.

"If you need to do OOP in C, it's time to move to a more powerful language." As long as is not C++...

C++ is fantastic if you need a more powerful language than C because of the "You don't pay for what you don't use" philosophy.

Of course, so is D...

Re: Object-Oriented Programming in C (2019) [pdf]

#19
post #11

Earlier quoted context omitted.

"If you need to do OOP in C, it's time to move to a more powerful language." As long as is not C++...

C++ has plenty of issues, but it's really not that bad, especially modern C++. It's a huge language with tons of features, many of which you'll never use, but as far as writing C++, really not that bad. I've written a lot of C++ over the years, and I've also written a lot of vanilla C. I can tell you that you can definitely get a new project up and running much faster in C++ than in C.

It is not that bad... Compared to c

Throwing Rust into the pool

Re: Object-Oriented Programming in C (2019) [pdf]

#20
This is a good example of how a good programmer is more important than a a complex language with complex features. C lets you use OO if you want it ,and it doesn't require many more lines to do it, but it doesn't push you to always do it. Ive used this a number of times, but its always because its the right approach for the problem, not to be object oriented because the language is.
Post reply on HN