pouët.net

C++ a wicked language

category: code [glöplog]
Optimus, Optimus, Optimus... XDDDDDDDDDDDDDDDD
added on the 2003-05-17 00:42:01 by texel texel
wicked.
added on the 2003-05-17 01:41:26 by abuze abuze
c/c++: good for your pc since you don't have to speedoptimise anyway. c allows some fast development. c++ allows that too but also gives a user the ability todo the same stuff in about a million different ways. good for freedom but a disaster for readability. OOP is nice for companies, but imho useless for optimised demo coding (esp on older machines). that it works for ryg and chaos in teamwork is prolly cos these guys code more or less the same style. that can happen in any language. OO is a good thing to sort things out. but thinking it's the magic tool to solve everything for you is idiocy.

paradigm, proactive and synergy and such words suck. who invented that shit anyway?
optimus: you seem to be some writer. why not devote some of those writing skills to demomaking stuff ;)

added on the 2003-05-17 10:42:48 by earx earx
This is all too cromulent for me.
added on the 2003-05-17 14:06:17 by sagacity sagacity
TeXel, when you told me to go in the irc, I was already in bed. If you join frequently in one irc, you might find me sometimes..
added on the 2003-05-17 17:17:43 by Optimus Optimus
Optimus: If you mean evil, why not just use evil? Either that or get a more thorough dictionary which includes slang and such. (Bearing in mind that English has more words than another language on the planet.)

Now you know why many English speaking people don't bother learning a second language, they're too burnt out!!
earx, please stop talking till you actually comply with one of the following guidelines 1) you have something to say or 2) you actually know what you're talking about.

Thanks in advance.
Isn't the word 'wicked' used like 'excellent' or 'cool' or similar?
No, the work evil can't describe it, it is something very diferrent. Like the evil tangled in a chaotic web..
added on the 2003-05-18 11:08:49 by Optimus Optimus
So, go O'Caml? =)

(No, seriously, C++ definitely has its sides, but it's terribly big and complex. It isn't exactly learned in a week, but even though there are still lots of things I miss in it, it can be very powerful at times too. :-) )
added on the 2003-05-18 16:26:58 by Sesse Sesse
(from the RedBook Glossary:)

C
God's programming language

C++
The object-oriented programming language of a pagan deity

...
added on the 2003-05-18 17:36:59 by psyche psyche
ugh, oop can be done with any language almost, not just c++. imho c++ is a very good language and it doesn't stop you from being accessing low level things on the platform.

__asm{} is just great for such things alltho it's not portable for obvious reasons.

I don't believe many demos today are coded in pure asm, not because people don't know it but because people don't have the time to write in asm and you really don't gain that much speed increase either.

Ofcourse there are alot of pitfalls of using classes and such but that's just a matter of knowing your language...
added on the 2003-05-19 08:03:13 by pantaloon pantaloon
there are still people out there that think C++ is slower than C.

that's not true. you need to look at the disassembling of your compiled C++ and learn what code the compiler generates.

you should disassemble exceptions and virtual function calls, for a start. you will see that exceptions are not acceptable and virtual function calls are slower than normal function calls, but faster than large switch statements (which they replace). even exceptions are good for what they were designed (things that happen just before displaying an error message), but you shurely want to have that in an intro.

my private rule is: never use a language feature where you can't predict what's happening on assembly level. following this rule, and carefully choosing what features to use in which situation, C++ programms should never slower than C programms, but are usually easier to read and faster to write. and maybe you even sacrifice performance for clarity, but in C++ this is a programmers decision, not forced by the language.
added on the 2003-05-19 11:32:38 by chaos chaos
Isn't this pretty clear then?-)

struct substr { int l; char *s; };
#define MAP_TAG wordmap
#define MAP_CLS Wordmap
#define MAP_KEY struct substr
#define MAP_VAL Intvec
#define MAP_KEY_HASH(x) x.l^x.s[0]
#define MAP_KEY_EQUALS(x, y) x.l==y.l && strncmp(x.s, y.s, x.l)==0
#include "map.tl.c"
added on the 2003-05-19 12:12:41 by 216 216
"Which all kinda proves that people who really have no clue about what they're talking should just STFU. I think I've never seen such a huge pile of bullshit in such a short thread."

word ryg =)

added on the 2003-05-19 13:30:18 by superplek superplek
OOP in C

typedef struct {
void (*blabla)();
int x;
} ClassX;

void ClassX_blabla( ClassX *this ) {
this->x = 10;
/* blabla */
}

ClassX *ClassX_new() {
ClassX *c = malloc(sizeof(ClassX));
c->blabla = ClassX_blabla;
return c;
}
---
ClassX *cx = ClassX_new();
cx->blabla(x);

now image how easy this would be in C++ ;)

however, C++ has lots of gotchas. Try to read "Exceptional C++" to confuse yourself :)
added on the 2003-05-19 15:11:14 by faor faor
Haha
No no no ... no!

You're all wrong: you obviosly can't write OO code in C. For example, the code above isn't OO - I mean for god's sake - there are usually a couple of fundamental things necessary for a language being "OO". First of all: classes. Are telling me a C struct is equal to a class? There has to be support for data-encapsulation. How are you going to achieve that in C? How are you going to achieve interheritance and virtual functions in C? Implement a vtable yourself?

PLEASE!
added on the 2003-05-19 15:49:01 by sofokles sofokles
Ook. Ook. Ook! Ook? Ook. Ook? Ook. Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook! Ook? Ook. Ook. Ook! Ook. Ook? Ook. Ook! Ook! Ook? Ook!
added on the 2003-05-19 15:55:21 by skrebbel skrebbel

As long as I read these sources on this thread, I think I will get stick on 6510 this Summer ;P

They are like complex mathematic writtings, full of symbol meanings, where everything could be really written and explained in a much easier way..
added on the 2003-05-19 16:00:50 by Optimus Optimus
>They are like complex mathematic writtings, full of symbol meanings,
>where everything could be really written and explained in a much easier way..

Yep. Pascal looks much more intuitional IMO...
added on the 2003-05-19 16:10:07 by ie ie
taking the bait...

/*fubar.h*/
typedef struct fubar *Fubar;
struct fubar_class {
void (*dofoo)(Fubar);
};
#define fubar_dofoo(fubar) ((*(Fubar_class**)(fubar))->dofoo(fubar))

/*fubar_protected.h*/
struct fubar {
struct fubar_class *classptr;
int x;
};
extern struct fubar_class fubar_class;

/*fubar.c*/
#include "fubar.h"
#include "fubar_protected.h"

struct fubar_class fubar_class={
dofoo
};
Fubar fubar() {
Fubar f=malloc(sizeof *f);
f->classptr=&fubar_class;
f->x=666;
if (!f) die("horribly");
return f;
}
static int dofoo(Fubar f) {
return f->x*f->x;
}

a) Is there something visible to an outsider that shouldn't?
b) Implement Quuxnightclub as a subclass to Fubar
added on the 2003-05-19 17:44:56 by 216 216
f->blah .. if (!f) ... oops. blame input type=textarea:)
added on the 2003-05-19 17:48:35 by 216 216
Quote:
First of all: classes. Are telling me a C struct is equal to a class? There has to be support for data-encapsulation. How are you going to achieve that in C? How are you going to achieve interheritance and virtual functions in C? Implement a vtable yourself?


no sir, you can do much of this. c++ encapsulation creates lots of dependencies (#includes), and to remove them you need that pimpl idiom anyway, and this is what _216_ showed in c here (ok, forward declarations do it also, but then you need more pointers). inheritance and virtual functions are also easy to implement. interfaces even more easy. to make it all readable you can use macros. hey, but you dont want this anyway, wont you ? ;)

i like coding in pure c (c++ has too much gotchas for me). but sometimes a clean interface with common members and that stuff is needed, so i use something like the code above then, and it works fine.
added on the 2003-05-19 18:07:28 by faor faor
_216_: Hahah *LOL* :D

Ok, ok, ok, ok, ok, you got me :)

I shouldn't have used the word "can't". Of course you can fake it as seen above but since there aren't any *language constructs* to do it, claiming that it's OO is pretty absurd still - don't you think? It's like saying "yeah sure you can do functional programming in C" only because in it's possible to create code that behaves that way. And there's exception support too right? I mean it's only longjmp's after all.... :)

It was a nifty way to hide the private data, though :)
added on the 2003-05-19 18:37:21 by sofokles sofokles
hehe. you can even do oo in asm =)
added on the 2003-05-19 19:38:44 by faor faor

login