|
C with structs or C++ with classes... Your choice and why. |
_Dante
Member #7,398
June 2006
|
Shawn Hargreaves said: How on earth did we end up talking about snake fetishes? I can think of a lot of things you could do with a snake, with or without weak and/or shared pointers, but I don't think I'd particularly enjoy any of them... Leather, on the other hand, now that's something I can relate to. Sheesh, no imagination - what's wrong with snakeskin leather? ----------------------------- |
Andrei Ellman
Member #3,434
April 2003
|
Steve++ said:
Quote: Unless you're working on an existing C project. Converting an entire project from C to C++ (even if it's object-oriented C) can take so much time that it would be more productive to use OO C. So you spend half a man hour renaming everything from .c to .cpp and compiling everything, casting any void pointers that the compiler may complain about. Is that half a man hour such a big price to pay for having language supported OOP at your disposal instead of doing it the hard way in pure C? Argh!" I should have made myself clearer. I meant to say converting a C project to use C++'s fancy new features. If I were to add some polymorphic virtual abstract base classes and all that, I'd either have to write C++ wrappers for my C 'classes' (and hope that the compiler optimises it away), or convert any code that resembles what I posted previously in this thread to use a more C++ like approach ( = major rewrite). Or I could just hope that the new C++-ish stuff only interacts minimally with the existing code. _Dante said: what's wrong with snakeskin leather? It can't be cast into anything. AE. -- |
23yrold3yrold
Member #1,134
March 2001
|
Quote: I'll pay you $100 to port Allegro to C++. As I'm generous I'll give you a whole day to do it Reread his post. By his argument, Allegro is already C++. I mean, I've been using it with C++ for years ... BTW, this should be common knowledge, but my goatee owns all your beards, reigning supreme on these forums for a year .... mua ha ha! -- |
Onewing
Member #6,152
August 2005
|
The problem with beards is there are too many ways of going about them, making them hard to maintain in the work environment. Plus, you have to rely on lowlevel methods of testosterone to produce proficient scruffs. Some people end up with mixed patches that just plain look ugly, not an impressing office factor. ------------ |
Steve++
Member #1,816
January 2002
|
Quote: Some/Most times the Nookie interface itself incurs huge costs all by itself. My Nookie Provider suggested I apply the useGillette() method to her Nookie interface. |
_Dante
Member #7,398
June 2006
|
Quote:
Quote: Some/Most times the Nookie interface itself incurs huge costs all by itself. My Nookie Provider suggested I apply the useGillette() method to her Nookie interface. That's a brave Provider you've got there, as the useGillette() method is generally considered "unsafe" as it does no bounds checking, and can actually damage the underlying hardware. Might I suggest a Wax pattern, and in particular the latest version coming out of Brazil. ----------------------------- |
Steve++
Member #1,816
January 2002
|
Back on topic... Lately I discovered that table-driven programming is a great 'alternative' to procedural or OOP programming. I used quotes around alternative because it can be used in a procedural or OOP environment. I recently started to develop an asynchronous version of MooServer (server for a Multimedia Fusion plugin that allows online play) using Java. There are sockets, channels, connections, sessions, servers, players, etc. that can each be modelled with a class. So I started writing a class for each one, then the methods to make them interact. I actually found that all this OOP was getting in the way. My code was becoming spaghetti-like. So I stepped back and thought, what would all this information look like in a relational database? So I designed some tables on paper and for the first time, I completely understood the relationships between all the data. So I coded everything in one class (MooServer) using tables to map all the data. The whole thing became so much simpler. The only reason I didn't finish this project (which would have taken about three full days) is that all this mundane life stuff came up that needed my attention - the same reason every project dies, but that's another story... Here's a tiny snippet:
The moral of the story is that if you have a clue about how to model information in a relational database and you have mapping data structures available, you should use OOP only to serve table-driven programming because table-driven programming absolutely rocks. EDIT: I suppose table-driven programming could be (and probably has been) implemented in plain old C quite effectively. |
HoHo
Member #4,534
April 2004
|
Quote: Reread his post. By his argument, Allegro is already C++. I mean, I've been using it with C++ for years ... Not exactly. Allegro doesn't compile with C++ compiler and I understood that he meant making a C project compile as C++ one. __________ |
nonnus29
Member #2,606
August 2002
|
Quote: you should use OOP only to serve table-driven programming because table-driven programming absolutely rocks. Your formulation of 'table driven programming' is a bit beardless, err weak. Real table oriented programming requires that the executable code also live in tables. That could be done in java or c# using dynamic class loading but I've not seen anyone do that. I completely agree with you that oop is unsuited for many problems, for example my problem of easily creating a web application of 500 forms with simple to complex business logic. I think it was Paul Graham in on of his lisp articles who made the observation that business appiclations are basically a series of a arbitrary exceptions to general rules. Sure some things like customer management (name, address, account information) can be easily implemented in with oop or whatever, but when you get to bizarre stuff like handling the record keeping for variable rate annuities or tax regulations, oop falls flat on its face. Which is why in 2006 cobol is thriving. |
BrknPhoenix
Member #7,304
June 2006
|
C++, and here's why: 1) I find the code to be more readable. Done correctly, it's nigh impossible to not be able to easily locate the 'hooks' in your program. |
Steve++
Member #1,816
January 2002
|
Quote: Real table oriented programming requires that the executable code also live in tables. I don't think table oriented/driven programming has been formalised to the extent that you can say what is real and what isn't, except that it should make heavy use of tables. My personal flavour of TDP involves storing all the data in tables and programming the relationships between them in a procedural manner. The Java collections API supports that rather nicely. To me, putting code in tables sounds like it could me a nice trick, but it would probably obstruct code readability and it seems like a way of using tables to achieve OOP (sounds like Lua). Quote: That could be done in java or c# using dynamic class loading but I've not seen anyone do that. Interestingly, I've done some dynamic class loading in Java. The purpose was to use Java as a scripting language in a Java MMORPG. I had it working so NPCs could be hot-swapped without changing their class names. |
axilmar
Member #1,204
April 2001
|
Quote: I suppose table-driven programming could be (and probably has been) implemented in plain old C quite effectively. Here is a constructive critisism about OO and tables. |
Lucid Nightmare
Member #5,982
July 2005
|
Well, its more of an individual likingness and comfortability factor with the two languages... I like C++ over C and normally code only in C++ whenever I have to. It actually depends from a person to person... Its not necessary for anyone of them them being better or superior but just a matter of choice... Well, its just an opinion of mine and I might be wrong... Two Golden Rules of life- Firstly, I'm always right and secondly, if you think otherwise, slap your face and read rule number one again! |
Neil Walker
Member #210
April 2000
|
I'm still wondering what shared pointers has to do with beards. However, the mystery that troubles me is why women in IT are so ugly. It's as if, in order to embrace technology you have to be a man or a minger. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
_Dante
Member #7,398
June 2006
|
Quote: I'm still wondering what shared pointers has to do with beards. It's pretty simple, really. I have a beard and shared pointers don't. See how that works? Quote: However, the mystery that troubles me is why women in IT are so ugly. I'm curious as to why you think the men in IT aren't. Attractive people work in sales and marketing... ----------------------------- |
Richard Phipps
Member #1,632
November 2001
|
I use C with some extras provided by C++ (i.e. use of bools, and the STL library). |
Neil Walker
Member #210
April 2000
|
Quote: I'm curious as to why you think the men in IT aren't. Attractive people work in sales and marketing... I work in IT and (non-IT) women adore me. However I've seen Richard Phipps, which seems to correlate your statement Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Richard Phipps
Member #1,632
November 2001
|
Quote: I work in IT and (non-IT) women adore me. I almost choked on my dinner! Sniff.. I was having a bad hair day (or two) when those pictures were taken. |
_Dante
Member #7,398
June 2006
|
Quote: I work in IT and (non-IT) women adore me. Your mom telling you how handsome you look in your tux on prom night doesn't count. ----------------------------- |
23yrold3yrold
Member #1,134
March 2001
|
I work at a tech support center. Dunno if that counts as IT, but a lot of the more knowledgable girls on the floor are really cute. Most of the guys are fat and ugly and we outnumber the girls 5 to 1; dunno how that fits into your theory though. -- |
_Dante
Member #7,398
June 2006
|
Pretty much confirms mine ----------------------------- |
ReyBrujo
Moderator
January 2001
|
Quote: And why anyone would want to use/have a weak_pointer<> is beyond me. Ah, I miss that innocence That is the bad thing about programming under Windows -- |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: Ah, I miss that innocence Oh I love "technical" weak pointers, but I think a few people have missed the not so hidden joke -- |
ReyBrujo
Moderator
January 2001
|
-- |
Samuel Henderson
Member #3,757
August 2003
|
23 said: I work at a tech support center. Dunno if that counts as IT, but a lot of the more knowledgable girls on the floor are really cute. Most of the guys are fat and ugly and we outnumber the girls 5 to 1; dunno how that fits into your theory though. Wow. Where I work (also tech support), all the tech saavy women are simple technicians, and all the beautiful (but technically challenged) women have cushy overloard type supervisor jobs. Anyways, back on topic. I prefer C++ because that was all we learned in college thus far (aside from JavaScript, Java, MySQL, and VB.NET). ================================================= |
|
|