DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th December 2009
tetrodozombie tetrodozombie is offline
Real Name: bill slusser
Banned
 
Join Date: Dec 2009
Location: atlanta, ga
Posts: 82
Default Is anyone doing Object Oriented Programming with Plain Ol' C?

The very idea of using something as fast as C for OOP makes me very excited. I'm not talking about objective-c or C++. You can google "object oriented C" and there will be a pdf that pops up of a book, an article someone wrote explaining how to write C in an OOP way.

Since I'm basically an Action Script 3.0 programmer, I'm wondering have any one who programms in C tried using the OOP methods described?

And, how do you like it?
Reply With Quote
  #2   (View Single Post)  
Old 18th December 2009
Beastie Beastie is offline
Daemonology student
 
Join Date: Jan 2009
Location: /dev/earth0
Posts: 335
Default

I never liked OOP languages and all their overly complex concepts. They're too abstract and "detached" from the machine, if you see what I mean.

I feel at home with C and assembly.

Uh, sorry for the totally useless post.
__________________
May the source be with you!
Reply With Quote
  #3   (View Single Post)  
Old 19th December 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

Most of the things that people tout as the advantages of OOP, are exactly the things you should be doing with or without it.

Programming in C with a more `object oriented` nature generally applies to making wiser use of data structures and pointers then the newbie will often first consider. You might consider a look at LibWWW or GTK+ (C bindings, not C++).



On a side note:

Typical game implementations that I've seen, either build their control handling as a massive switch over key events (I believe even vi did this), or create a input management class that invokes a method on a registered objects descended from abstract base class XYZ after looking up the binding. Registering callbacks some times even saves a pointer to some special object rather then a function pointer. This generally sucks up costs for (several) vtable operations, numerous method resolutions, will likely incur dynamic memory allocations in the data structures, and some people will even process the controls in a O(n) like fashion every frame.

The system I've been piecing together for Stargella, polls input events and uses the key that was pressed to index into a table of function pointers: which is effectively a sniper shot compared to using std::map or related bits of C++ voodoo. Making my system more of a simple matter of pointer arithmetic to trigger the call backs, then would be the cost of hunting it down through an STL map, vector, or list (etc).


That is a fair difference between `typical C++` and `typical C` was of implementing the same thing.


A more objectual change, will be making the game register structures instead of funcptrs with the input system, allowing one to more easily change the concept of a keybinding without complicating the input system. The main reason for the change, being to bundle the question of whether input handling for control XYZ is supposed to be buffered or unbuffered, etc.


and without having to deal with the hell they call C++ OOP :-P.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #4   (View Single Post)  
Old 19th December 2009
tetrodozombie tetrodozombie is offline
Real Name: bill slusser
Banned
 
Join Date: Dec 2009
Location: atlanta, ga
Posts: 82
Default

I like what I've been hearing about C. I like that it is fast and simple. It's like a tank or cannon. Simple, reliable, and ubiquitous. It runs everything above it, which is everything most people use the computer for. Then only thing beneath it is assembly and machine code. It like feeding bullets into a machine gun and shooting the gun at the same time. You are right in the middle of the power a computer has, not the being shot at if you can understand my analogy.

C can do anything and do it better than any other language today and doesn't consume the overhead they do.

I'm definitely going punch away at writing more C code and nailing those graphics frameworks down like Cairo and Gtk+.
Reply With Quote
  #5   (View Single Post)  
Old 19th December 2009
Beastie Beastie is offline
Daemonology student
 
Join Date: Jan 2009
Location: /dev/earth0
Posts: 335
Default

There are many bindings for using Cairo and GTK from HLL and OOP languages. But they're both written in C.
__________________
May the source be with you!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delphi or Object Pascal In OpenBSD? SunSpyda Programming 14 28th November 2009 11:21 AM
Shared object not found 'libwrap.so.4' magic FreeBSD General 3 22nd July 2009 09:36 PM
Java and AI-programming idefix Programming 4 7th February 2009 01:41 PM
GUI Programming bsdnewbie999 Programming 6 17th August 2008 12:19 AM
link: `libtheora_la-common.lo' is not a valid libtool object error during compilation pax FreeBSD Ports and Packages 2 29th July 2008 11:30 AM


All times are GMT. The time now is 08:28 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick