C++ funnies

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

C++ funnies

Postposted on Wed Dec 25, 2002 7:36 pm

i remember one day in Computer Science II class (C++) ... we were discussing classes..
the professor was talking about the benefits of ojects and making functions private.. we were also discussing "friend" functions and how they can access the private functions.. in the objects...
so then the professor went off talking about friend functions... to emphasize the importance of good programming.

"make every function private if possible"
"friend functions can be used ....but remember.. friends have access to your private parts."

we all cracked up laughing.
You don't have to feel safe to feel unafraid.
danny e.
Maximum Gerbil
Gold subscriber
 
 
Posts: 4374
Joined: Thu Apr 25, 2002 3:09 pm
Location: Indonesia/Nebraska/Wisconsin

Postposted on Wed Dec 25, 2002 7:38 pm

it was actually more funny than that...... but i cant remember everything that was said.. i just remember the ENTIRE class laughing for like 5 straight minutes.

shoulda taken notes that day. :D
You don't have to feel safe to feel unafraid.
danny e.
Maximum Gerbil
Gold subscriber
 
 
Posts: 4374
Joined: Thu Apr 25, 2002 3:09 pm
Location: Indonesia/Nebraska/Wisconsin

Postposted on Wed Dec 25, 2002 9:13 pm

:lol: That is pretty funny there. Most of the time I just sleep through my classes though, so any potentially funny things are lost to me. :)
"God created man. Samuel Colt made them equal."

"Government does not tax to get the money it needs; government finds a need for the money it gets." - Ronald Reagan
eckslax
Gerbil Elder
 
Posts: 5332
Joined: Sat Oct 05, 2002 4:22 pm
Location: Vast Right Wing Conspiracy HQ

Postposted on Sat Jan 04, 2003 4:10 pm

#include <iostream.h>

void main()
{
for (int x=0; x<3000; x++)
cout<<"All work and no play make Jack a dull boy"<<endl;
}
Last edited by mac_h8r1 on Mon Mar 03, 2003 9:16 am, edited 1 time in total.
mac_h8r1
Minister of Gerbil Affairs
 
Posts: 2962
Joined: Tue Sep 24, 2002 6:57 pm
Location: Alpha Epsilon Pi for life

Postposted on Sat Jan 04, 2003 4:59 pm

Same errors as in the favorite language thread.
Craig P.
Gerbil Team Leader
 
Posts: 285
Joined: Tue Dec 31, 2002 3:12 am
Location: South Bend, IN

Postposted on Mon Mar 03, 2003 5:53 am

Original: "Let It Be" (Beatles)

Write in C

When I find my code in tons of touble,
Friends and colleages come to me,
Speaking words of wisdom:
"Write in C."

As the deadline fast approaches,
And bugs are all that I can see,
Somewhere, someone whispers:
"Write in C."

Write in C, write in C,
Write in C, oh, write in C.
LISP is dead and buried,
Write in C.

I used to write a lot of FORTRAN,
For science it worked flawlessly.
Try using it for graphics!
Write in C.

If you've just spent nearly 30 hours
Debugging some assembly,
Soon you will be glad to
Write in C.

Write in C, write in C,
Write in C, yeah, write in C.
Only wimps use BASIC.
Write in C.

Write in C, write in C,
Write in C, oh, write in C.
Pascal won't quite cut it.
Write in C.

{
guitar solo
}

Write in C, write in C,
Write in C, yeah, write in C.
Don't even mention COBOL.
Write in C.

And when the screen is fuzzy,
And the editor is bugging me.
I'm sick of ones and zeros,
Write in C.

A thousand people sware that T.P.
Seven is the one for me.
I hate the word PROCEDURE,
Write in C.

Write in C, write in C,
Write in C, yeah, write in C.
PL1 is '80s,
Write in C.

Write in C, write in C,
Write in C, yeah, write in C.
The government loves ADA,
Write in C
no sig
muyuubyou
Grand Gerbil Poohbah
 
Posts: 3231
Joined: Wed Aug 28, 2002 6:19 am
Location: London, UK or Tokyo/Yokohama, Japan or Madrid, Spain

Postposted on Mon Mar 03, 2003 7:11 am

Hehe, all our CS lecturers usually manage to tell us at least once per lecture to avoid C. (Languages we're using this - first - year are ML and Java, though I've done some C myself anyway.)
BigMadDrongo
Gerbil Elite
 
Posts: 913
Joined: Mon Apr 29, 2002 12:57 pm
Location: London, UK

Postposted on Mon Mar 03, 2003 7:29 am

And they're right. You have to learn something more "theoretical" first. See Pascal, Java, ML, Smalltalk...

C is somewhat "dirtier" but maybe better in practice.

edit: theoretic for theoretical. Thanks IntelMole ;) Grammar Shammar...
BTW isn't theoretic right too?? http://www.yourdictionary.com/ahd/t/t0151500.html
Last edited by muyuubyou on Mon May 12, 2003 8:56 am, edited 2 times in total.
no sig
muyuubyou
Grand Gerbil Poohbah
 
Posts: 3231
Joined: Wed Aug 28, 2002 6:19 am
Location: London, UK or Tokyo/Yokohama, Japan or Madrid, Spain

Postposted on Mon May 12, 2003 8:28 am

muyuubyou wrote:And they're right. You have to learn something more "theoretic" first. See Pascal, Java, ML, Smalltalk...

C is somewhat "dirtier" but maybe better in practice.


And here's me just trying to learn C straight from doing a bit of VBA :-D

BTW, you was close, "theoretical" was the word you was searching so elegantly for...
IntelMole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Mon May 12, 2003 8:46 am

I would recommend Python as an introductory language. Has a lot of functionality, forces legibility and is great for interfacing with C.
no sig
muyuubyou
Grand Gerbil Poohbah
 
Posts: 3231
Joined: Wed Aug 28, 2002 6:19 am
Location: London, UK or Tokyo/Yokohama, Japan or Madrid, Spain

Postposted on Mon May 12, 2003 12:23 pm

Start with C++, hop into advanced Java, and get a 5 on next years AP CompSci AB test!
mac_h8r1.postCount++;
Chaos reigns within. Reflect, repent, and reboot. Order shall return.
Slivovitz owns you.
mac_h8r1
Minister of Gerbil Affairs
 
Posts: 2962
Joined: Tue Sep 24, 2002 6:57 pm
Location: Alpha Epsilon Pi for life

Postposted on Tue May 13, 2003 6:09 am

shouldnt you start with a BASIC language like VB?
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
fc34
Minister of Gerbil Affairs
 
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Postposted on Tue May 13, 2003 6:11 am

VB?? NOOOOOOOOOOOOOOOOOOO
no sig
muyuubyou
Grand Gerbil Poohbah
 
Posts: 3231
Joined: Wed Aug 28, 2002 6:19 am
Location: London, UK or Tokyo/Yokohama, Japan or Madrid, Spain

Postposted on Tue May 13, 2003 9:51 am

I'd think starting with a BASIC would be a great way of learning bad programming habits. But I may be wrong :)
BigMadDrongo
Gerbil Elite
 
Posts: 913
Joined: Mon Apr 29, 2002 12:57 pm
Location: London, UK

Postposted on Tue May 13, 2003 10:01 am

Most University boffins I know say Basic mangles your mind and you can never become into a really good programmer after that.

I think that's a bit exaggerated, but Basic hurts more than help IMO. Whatever you do, take something open and standard you can use in several platforms and get free documentation to get you started (or a good book, but get advice first).

If possible, DON'T USE AN IDE at first. Knowing the compilation steps helps a lot (assuming you're using a compiled language). If compiling steps scare you, try an scripting/interpreted language first.
no sig
muyuubyou
Grand Gerbil Poohbah
 
Posts: 3231
Joined: Wed Aug 28, 2002 6:19 am
Location: London, UK or Tokyo/Yokohama, Japan or Madrid, Spain

Postposted on Tue May 13, 2003 12:47 pm

fc34 wrote:shouldnt you start with a BASIC language like VB?


Does fiddling with VBA (GCSE/A-Level projects, prime number generator for a friend) count?

That's about my programming experience..

Oh, and have played with using html as well :lol:,
IntelMole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Mon May 19, 2003 6:01 pm

I remember seeing a quote some years back, to the effect that "Programmers who learn BASIC as their first language become brain-damaged beyond all possible hope of redemption." :D

Here's a funny link I found:

http://noncorporeal.com/people/pathfind ... _foot.html
just brew it!
Administrator
Gold subscriber
 
 
Posts: 37834
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Postposted on Mon May 19, 2003 11:26 pm

just brew it! wrote:I remember seeing a quote some years back, to the effect that "Programmers who learn BASIC as their first language become brain-damaged beyond all possible hope of redemption."


That quote is straight from the Jargon File, hosted here:

http://catb.org/esr/jargon/html/B/BASIC.html

If it's in the Jargon File, it must be right.
Life is hard; but it's harder if you're stupid. Big Al.
Captain Ned
Global Moderator
Gold subscriber
 
 
Posts: 20426
Joined: Wed Jan 16, 2002 7:00 pm
Location: Vermont, USA

Postposted on Tue May 20, 2003 4:56 am

Whats wrong with learning BASIC as the first language?
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
fc34
Minister of Gerbil Affairs
 
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Re: C++ funnies

Postposted on Tue May 20, 2003 5:23 am

danny e. wrote:i remember one day in Computer Science II class (C++) ... we were discussing classes..
the professor was talking about the benefits of ojects and making functions private.. we were also discussing "friend" functions and how they can access the private functions.. in the objects...
so then the professor went off talking about friend functions... to emphasize the importance of good programming.

"make every function private if possible"
"friend functions can be used ....but remember.. friends have access to your private parts."

we all cracked up laughing.



:lol: Hahahahhah i can see why you guys were laughing :lol:
Shake it to the limit!
PING
YBK
Minister of Gerbil Affairs
 
Posts: 2859
Joined: Fri Jul 26, 2002 2:38 am
Location: Sydney

Postposted on Tue May 20, 2003 7:43 am

Whats wrong with learning BASIC as the first language?

Well... VB in its current incarnation is actually quite a bit better than what passed for BASIC back when people originally came up with those quotes. It really isn't that terrible any more.

Historically, BASIC had no concept of data structures, and all but required you to use unconditional branches (GOTOs) all over the place. This resulted in what is commonly called "spaghetti code".

Also, some of the very characteristics that make BASIC easy to learn can be a liability. The fact that you can just jump in and start banging away encourages programmers to not plan out a project properly, resulting in difficult to maintain code.

My take on VB today --

It's actually not a bad introduction to programming. And for many Microsoft-specific scripting tasks, it is in fact the best (or even the only) tool for the job, for the simple reason that many Microsoft products are designed to work with it (e.g. MS Word macros are actually VB subroutines).

However... if you are serious about learning programming, you need to keep the following points in mind:

- It isn't portable. Languages like Perl, Python, C++ and Java will work across Windows and UNIX platforms; VB will not.

- Most OSes are written in C/C++. This typically means that programming in these languages will provide you with the most efficient and flexible interface to all of the capabilities of the underlying OS.

- "Object oriented" languages like C++ and Java provide better data abstraction and modularity. While this is no guarantee of good programming (it is certainly possible to write unmaintainable code in these languages as well), they provide a better framework for writing large complex applications in a logical, modular fashion.
just brew it!
Administrator
Gold subscriber
 
 
Posts: 37834
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Postposted on Tue May 20, 2003 12:12 pm

just brew it! wrote:Here's a funny link I found:

http://noncorporeal.com/people/pathfind ... _foot.html

I love those, they're just so true! (Those I know about anyway, some of them are funny even when I've no idea what they're on about.)
HTML 1 You shoot yourself in the foot, only to find out that no matter how gory the result looks, your foot keeps working. Your foot finally stops working when you stub your toe kicking the box the gun came in.
2 <a href="http://www.body.org/lower-half/left/foot.html">Shoot here</a>

Perl 1 !($foot =-/left/) # ! read as "Bang!"
2 You Separate the bullet from the gun with a hyperoptimized regexp, and then you transport it to your foot using an array of arrays of arrays. However, the program fails to run and you can't correct it since you don't understand what the heck it is you've written.

This page has some more variants - I love the one on Standard ML (one of the two languages they teach us for first-year CS here).
Standard ML
By the time you get your code to typecheck, you're using a shoot to foot yourself in the gun.

So true!

Wow, that was a [quote]fest. Apologies.
BigMadDrongo
Gerbil Elite
 
Posts: 913
Joined: Mon Apr 29, 2002 12:57 pm
Location: London, UK

Postposted on Wed May 21, 2003 3:29 am

The "shoot in the foot" one is quite old. I see it has evolved a lot anyway. BTW some of those are actually MINE. w00t!! :D
no sig
muyuubyou
Grand Gerbil Poohbah
 
Posts: 3231
Joined: Wed Aug 28, 2002 6:19 am
Location: London, UK or Tokyo/Yokohama, Japan or Madrid, Spain

Postposted on Wed May 21, 2003 4:21 pm

muyuubyou wrote:BTW some of those are actually MINE. w00t!! :D

I am in the presence of a god. I stand in awe.
;)
BigMadDrongo
Gerbil Elite
 
Posts: 913
Joined: Mon Apr 29, 2002 12:57 pm
Location: London, UK

Postposted on Wed May 21, 2003 4:27 pm

BigMadDrongo wrote:
muyuubyou wrote:BTW some of those are actually MINE. w00t!! :D

I am in the presence of a god. I stand in awe.
;)


Pray for a chair :-P,
IntelMole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Re: C++ funnies

Postposted on Wed May 21, 2003 4:32 pm

danny e. wrote:i remember one day in Computer Science II class (C++) ... we were discussing classes..
the professor was talking about the benefits of ojects and making functions private.. we were also discussing "friend" functions and how they can access the private functions.. in the objects...
so then the professor went off talking about friend functions... to emphasize the importance of good programming.

"make every function private if possible"
"friend functions can be used ....but remember.. friends have access to your private parts."

we all cracked up laughing.

Did you ask your professor about all of the disadvantages of combining the paradigms of non object oriented languages and object oriented languages and why C++ is bad because of it?
Hehe, all our CS lecturers usually manage to tell us at least once per lecture to avoid C.

There is nothing wrong with C, they're probably telling you to avoid C++.
Whats wrong with learning BASIC as the first language?

Most languages exist to serve a specific purpose. C exists to solve large project performance programming--C++ exists to give you the benefits of object oriented language with only slightly more overhead than C (there are disadvantages that i won't go into). Java exists to be an incredibly well structured high performing interpreted objecting oriented language. Perl and Python exist to extend shell scripting, mostly, and are never used when performance is an issue but you generally use them to make quick "hack" fixes or make a small script to do something. A lot of people really misuse python lately--they like to pretend it's a real language and make programs out of it.

Then there is vB. vB exists for no other purpose than to be easy (although it's probably not eaiser than perl/python). It's inefficient, it can encourage poor programming practices, and programs produced through it alway seem to be very slow. Now, perhaps the programmers using it don't understand programming complexity theory or perhaps the language just underperforms. It's not an issue for me but people will still continue to use it because they know it and there not interested in learnign the correct tool for the job. When you are a hammer, every problem looks like a nail.
LJ
Gerbil Elite
 
Posts: 883
Joined: Wed Apr 10, 2002 2:24 am

Postposted on Thu May 22, 2003 4:05 am

I beg to differ.

I WILL always recommend ANY person to begin with BASIC. It is easy to learn, and is more likely to arouse interest than some cryptic low level lenguage like assembly or C.

To give a few examples, take functions.

C requires at least one function. QB only requires functions if you want them to exist, you could sit down to write a QB program without thinking about functions. This makes a beginner's much easier when he has alot of other things on his mind like variable types, and all those commands to remember.

Also, generally speaking, BASIC functions are easier to remember

QB:

If x = 1 Then
Print "Hello World!"
End If

C:

If (x == 1)
{
printf("Hello World!");
}

And y the heck would you need a ; after each line? Many times when writing a few hundred lines of code and miss 1 ;, the compiler spits junk at me, it can take hours to find the error

I agree with you that BASIC could cultivate some bad programming practices, like QB not requiring you to declare all variables before using them. However, you CAN still declare them in QB, you just are not required to. So long are you teach them to write a declare statement for every variable used, it becomes virtually the same as C.

I also agree with you that other programming languages offer more functions and ranges than BASIC, but I think there are several advantages of BASIC.

-Simple commands, for newbies means more time devoted to programming, rather than learning the language. (For the longest time, I couldnt figure out y C had to use == when testing, and = when assigning. Till this day, it still pisses me off)
-When writing simple programs, sometimes I just want it to so something simple, like repeat a menial task, I dont like to go through the complex process of making, compiling and testing a complex cryptic program, for simple 1 time use programs, I still prefer BASIC
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
fc34
Minister of Gerbil Affairs
 
Posts: 2816
Joined: Wed May 08, 2002 8:39 am
Location: Somewhere

Postposted on Thu May 22, 2003 4:56 am

No way fc34.

Believe it or not, there are other languages much more suitable than BASIC. In fact BASIC was a good alternative (along with Fortran) during the eighties, since it was available for "microcomputers" (personal computers of the time).

Pascal has always been a better alternative and still is.

Right now, you'd better begin with a scripting language like Python, which interfaces nicely with C. C isn't a bad alternative to start with if you have a teacher. You should have a teacher anyway.

All the good programmers (not amateurs) I know have studied at least some programming at the University (E-Eng, CompSci, Maths, and even Physics). A good, qualified teacher is always a good thing.


A strong background in mathematics is necessary for a professional Computer Scientist or Electrical Engineer (of course other scientists apply too).

You don't figure out complex algorithms without reinventing the wheel if you're not good at maths. I don't mean 'pro' level in the sense of hacking pages together in PHP or coding a flashy demo in assembler. But rather things figuring out quasi-optimal algorithms for space partitioning (like Carmack did for Quake) or applying n-dimensional packing algorithms for fast transmission over copper lines, in modern modem firmware.

QB:

If x = 1 Then
Print "Hello World!"
End If

C:

If (x == 1)
{
printf("Hello World!");
}

And y the heck would you need a ; after each line? Many times when writing a few hundred lines of code and miss 1 ;, the compiler spits junk at me, it can take hours to find the error


With any half-way decent compiler you should get your error just pointing to the next sentence after the lack occured.

BTW you don't need a semicolon after each line. You use semicolons to separate sentences in C . Some knowledge about parsers is very clarifying, but that doesn't come in "H4x0rz J0hnny's C HOW-TO". You can put several sentences in the same line in C (but it's often frowned upon to do so).

That shows pretty well what we're talking about. If you think the need of ; to separate sentences is a big language difference [or '==' as 'equal' ('=' as 'assignment')] you're a bit off-topic.

Visual Basic is not good examples of BASIC. It's quite different to most old'skool BASICs (lack of standarization is yet another problem with BASIC). Probably QB is a bit better example. Old 8bit computers' BASIC and QB are what those boffins were probably talking abut.
no sig
muyuubyou
Grand Gerbil Poohbah
 
Posts: 3231
Joined: Wed Aug 28, 2002 6:19 am
Location: London, UK or Tokyo/Yokohama, Japan or Madrid, Spain

Postposted on Thu May 22, 2003 7:34 am

All the good programmers (not amateurs) I know have studied at least some programming at the University (E-Eng, CompSci, Maths, and even Physics). A good, qualified teacher is always a good thing.

Hmm... while I did study Comp Sci (and a little bit of EE as well) at UofI, I'd say that the vast majority of my practical programming knowledge has been self-taught. I did (and still do) a lot of reading about programming-related topics though, so I suppose you could say that the authors of all those books I've read have been my teachers. :wink:

A strong background in mathematics is necessary for a professional Computer Scientist or Electrical Engineer (of course other scientists apply too).

Agreed. But the reality of today's job market is that not all software developers need to be Computer Scientists.

I do wish there was some sort of minimum standard for understanding the underlying technology before one is allowed to write software professionally though. I've encountered developers who don't have the vaguest notion of what it is that goes on inside the computer... and IMO you can't design efficient software if you don't have a clue what is going on "under the hood".
just brew it!
Administrator
Gold subscriber
 
 
Posts: 37834
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Re: C++ funnies

Postposted on Thu May 22, 2003 7:54 am

LJ wrote:There is nothing wrong with C, they're probably telling you to avoid C++.

Nuh-uh, 'twas C. I think they were mainly talking about pointer arithmetic, weak typing, lack of proper strings or arrays, that sort of thing. (The things that make it a good language if you're interested in performance, or so I assume, but a bad one from a number-severity-and-untrackdownability-of-possible-bugs standpoint.) And then, of course, there's this: http://www-users.cs.york.ac.uk/~susan/joke/c.htm
We stopped when we got a clean compile on the following syntax:

for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);

To think that modern programmers would try to use a language that allowed such a statement was beyond our comprehension!
BigMadDrongo
Gerbil Elite
 
Posts: 913
Joined: Mon Apr 29, 2002 12:57 pm
Location: London, UK

Next

Return to Developer's Den

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests