Server Help

Trash Talk - Taking the plunge? Java to C++

Jason - Tue Feb 10, 2004 9:28 pm
Post subject: Taking the plunge? Java to C++
First of all, I apologize if this is in the wrong forum. I wasn't quite sure where else to put it. That being said, it's high time I moved on to learning the language that everybody and their brother's brother is using to code their apps with these days. I feel as though I'm very comfortable in Java, and I'm ready to take the plunge into C++. My question is, where to start? Being that there are quite a few resident developers in here with mucho experience in C++ I figured this would be a good place to ask. I don't need to start out with one of those tutorials directed at someone who's never programmed a day in their life. However, I also don't want to start with something that's over my head. So what do you think? Are there any reccomendations as far as docs I should read? I don't mind spending oodles of time reading this and that as long as I'm going to learn something. I've searched around and found lots of C++ tutorials here and there, but I'm not sure of which to actually sit down and go through. And I can't seem to find any tutorials tailored to someone who already knows Java and wants to move over into C++.

Long story short, help me out oh wonderful gurus! :]
Mine GO BOOM - Tue Feb 10, 2004 11:57 pm
Post subject:
Since you already know a language, it isn't too hard to move over to another one. My recommendation: Get a good IDE (Visual Studios from Microsoft or if you don't have access to that, something free like Dev-C or Borland C++ Builder) in which you can use debuggers with. Helps a lot.

Start with some basic programs that you know work. Such as a bot for SubSpace. Load it up, and compile it without any changes. Look at how some of the parts work (such as the !help command), and try changing a bit. It shouldn't look too much different than how Java works for you. After a bit of playing with just simple parts, try figuring out how all of the dlls or the exe works.

Read some tutorials. As I don't/havn't in a while, I cannot recommend much more than what googling for c++ tutorial would return.
Jason - Wed Feb 11, 2004 2:05 am
Post subject:
Thanks for the info. I didn't think this was Trash Talk worthy? No big deal though, they're your forums so you can move shit wherever you please.

That episode of The Simpsons is fucking great, by the way. :]
50% Packetloss - Wed Feb 11, 2004 2:07 am
Post subject:
Pick up a good book. Find a book with the least amout of decorations on the front cover, take a look to see if it looks solid and then buy it. Online tutorials are nice, but a book is worth the money and will be handy for a reference.
Mine GO BOOM - Wed Feb 11, 2004 10:17 am
Post subject:
Jason wrote:
I didn't think this was Trash Talk worthy?


Everything is Trash Talk worthy. I just try to keep the other forums more subspace related, while all the non-subspace stuff usually ends up here.

For books, I'd recommend some of the O'Reilly stuff, as I've heard they are good. Go to a bookstore and check them out, but check online prices before you buy. I forget the name of the official Microsoft ones (published by Microsoft Press atleast), but those have always been good in the past.

Just make sure you do not get books based on Windows programming only, or ones based on MFC, as they won't teach you much about C, or atleast very well.

If you'd like some samples of books, I could offer you a couple of pdf's of pages of some. Like maybe 100meg worth?
Gravitron - Wed Feb 11, 2004 2:32 pm
Post subject:
If you wish I could fix you up with a nice small book - converted html that'll teach you most of the basics in C++.
Helicon - Wed Feb 11, 2004 4:09 pm
Post subject:
i have done this as well, though i didn't do it with a clear nkowledge of either language.

A few pointers to get you started:

Pointers:
Almost everything in java is By Reference (IE pointer-like), which most of C and C++ by value unless otherwise notated with a pointer
Jason - Wed Feb 11, 2004 4:12 pm
Post subject:
MGB, thanks for the offer about the PDFs, but unfortunately I'm on dialup so 100megs is out of the question.

Gravitron, that sounds great! Whenever you get the chance, either PM me or send me an e-mail with more details.

Helicon, thanks!
Cyan~Fire - Wed Feb 11, 2004 5:14 pm
Post subject:
http://www.cplusplus.com/doc/tutorial/

There's your basic C++ tutorial. Helicon's pdf, though, is really better if you're already comfortable with Java.
The only main difference between C++ and Java, as Helicon said something about, is memory management. Java will do everything for you there, but C++ you have to do everything yet it's much more flexible. The two major things to know are.
Declaring a variable with a * after the datatype declares that as a pointer. An & preceding a variable name returns the pointer to it's memory address. A * preceding a (pointer) variable name returns the value in that memory address.
A sample:
Code: Show/Hide
int value;
int *pointer = &value; //Now pointer is the memory address of value.

value = 15;
printf("Using value: %d\n", value); //printf() is like System.out.println() in Java.
printf("Using pointer: %d\n"", *pointer); //%d in printf tells the program to display the value after the comma as a decimal (replacing the %d)

That should output:
"Using value: 15"
"Using pointer: 15"

OK, hope you understood that, I jumped around a little. icon_razz.gif
Your major resource here will be the MSDN library, which will either come with Visual Studio or you can get it on the web. I'd say first look up printf() in the library, as it's use is rather complex to most functions.
Helicon - Wed Feb 11, 2004 6:42 pm
Post subject:
oh yes, and java has a garbage collector. Once your vars go out of scope, they are deleted automagically.

in c++ , you have to trash your objects manually with delete.

if anybody has 100 megs (or less) of good material, please let me in on it. I do this often, and literature is always welcome on my hard drive.
Helicon - Wed Feb 11, 2004 6:49 pm
Post subject:
more junk:
this is not all 100% accurate, but it should help you find the floor to stand on

package == namespace

IE
Code: Show/Hide
System.out.println("test");

~equals
Code: Show/Hide
std::cout << "test" << std::endl;

note that std::endl is the end of line character and that
std is a namespace:
std::cout == System.out

header files might be a bit tougher to explain.
anyone up to it?

Blurb:
The fact is that C++ is often more lenient in how you get something done, and how it looks in text.
Stick to as many of your java habits as you can as far as syntax is concerned. Purists may look down on you, but the fact is that 50% more people can read code that looks like java, even if it is C++
Helicon - Wed Feb 11, 2004 6:54 pm
Post subject:
50% Packetloss wrote:
Pick up a good book. Find a book with the least amout of decorations on the front cover, take a look to see if it looks solid and then buy it. Online tutorials are nice, but a book is worth the money and will be handy for a reference.


decorations... two words, squirrel and snake:

Practical C++
Learning C++

buy them used, or get them in pdf. They aer expensive, and they are worth it
Cyan~Fire - Wed Feb 11, 2004 8:40 pm
Post subject:
Well namespaces and header files kind of combine to form packages.

In C++, to use built in functions, you include what are called 'header files'. It's like importing packages in Java. For example, printf() which I was talking about before is included in 'stdio.h'. You can include a file with: #include <headerfile>. For example, to include stdio.h, you'd use "#include <stdio.h>".

When you look up functions you want in the MSDN library (or any other one), it'll usually tell you which header file the function is included in.

Another word about dynamic memory:
Although C++ does make dynamic memory more complex, you have to use it a lot less. Classes in C++ are declared just like variables, without using the new operator.
Jason - Thu Feb 12, 2004 12:27 am
Post subject:
I absolutely fucking love garbage collection. Memory management is what's kept me from picking up C++ for so long, although it's probably not that difficult at all and I just haven't bothered reading up on it enough.

Thanks Helicon and Cyan. I really appreciate all the various tidbits of info. Now I just have to start writing some of those basic, boring and generally useless programs one writes whilst learning a language!
CypherJF - Thu Feb 12, 2004 3:06 am
Post subject:
i love c++, but ive begun to love java more because of the statements before, about how java handles memory much nicer, ie: garbage collection; it has a string class by default where in class we didnt need to write one up :X lol.. and in java we were taught how to make visual forms w/ it...

i know its possible w/ c++ but i guess im just biased on what i've been taught knowledge wise.. but in the long run c++, good stuff..
Dr Brain - Thu Feb 12, 2004 9:28 am
Post subject:
C++ has garbage collectors too, they just aren't built in.
50% Packetloss - Thu Feb 12, 2004 2:27 pm
Post subject:
just deallocate the memory you allocate. No need to have something do it for you, its simple

int *bob=new int;
delete bob;
CypherJF - Thu Feb 12, 2004 3:59 pm
Post subject:
yeah what about setting up a pointer to a variable; and if you delete the pointer and not the actual memory variable it was pointing too, it creates a memory leak that way?
Cyan~Fire - Thu Feb 12, 2004 5:02 pm
Post subject:
It's really just bad programming habits that cause memory leaks. As 50% said, if you delete your allocations, you're fine.

I personally like C++'s pointers better than Java's because it gives you more flexibility. (I know, I'm weird icon_razz.gif)
Helicon - Thu Feb 12, 2004 5:15 pm
Post subject:
Cyan~Fire wrote:
I personally like C++'s pointers better than Java's because it gives you more flexibility. (I know, I'm weird icon_razz.gif)


i like pointers, too
and i like linux
i guess i'm just a control freak
CypherJF - Thu Feb 12, 2004 5:48 pm
Post subject:
i love pointers also; makes life a lot easier icon_smile.gif just its a pain sometimes when ur brain dies on ya and you are thinking it made a copy instead of a pointer :/ lol.. yea im just strange like that.. cause yea biggrin.gif
ExplodyThingy - Thu Feb 12, 2004 7:28 pm
Post subject:
Java makes lazy coders, way too much possibility for failure. For example:
Bleh.toString().charAt(Bleh.toString().length()-1);

What if toString, charAt, or length() returned null? It would die, poor coding. In C, this is invalid icon_smile.gif
Helicon - Thu Feb 12, 2004 8:12 pm
Post subject:
ExplodyThingy wrote:
Java makes lazy coders, way too much possibility for failure. For example:
Bleh.toString().charAt(Bleh.toString().length()-1);

What if toString, charAt, or length() returned null? It would die, poor coding. In C, this is invalid icon_smile.gif


there are great C programmers and great Java programmers.
This is the work of neither.

Unfortunate for your argument, the capacity to fuck up is so much more powerful in C and C++ than in java, that, despite the fact that java programmers may be "lazy" as you say, they tend to produce solutions faster with fewer damages.

And by the way, many great programmers don't confine themselves to one language!!!!
Languages aren't cults, they are tools!
ExplodyThingy - Thu Feb 12, 2004 8:48 pm
Post subject:
Well, that was just an absurd example. Fro my experiences in the world, you can tell who learned to programe from what. For the most part:
Lazy methods are done by those who learned on Java. Absurd methods are done by those who learned on PERL. Unnecessarily streamlined methods are done by those who learned on low level languages. Fast but often unexportable methods are written by those who learned on C/C++.
Cyan~Fire - Thu Feb 12, 2004 10:05 pm
Post subject:
Explody wrote:
Absurd methods are done by those who learned on PERL.

So true.

Lol, but yeah, I always tell all my Java-freak friends that Java is for lazy people, and they don't understand. :'(
Mine GO BOOM - Thu Feb 12, 2004 10:06 pm
Post subject:
And really pretty code that takes you three years to figure out how to work is by those who learned Brainfuck.
Dr Brain - Thu Feb 12, 2004 10:50 pm
Post subject:
Java isn't just for lazy people. It's for people who don't care about an ugly GUI who want their program to work right the first time in 1/2 the time it would take to write it in C++.

I find that lazy java coders are easy to spot. They are sloppy with their whitespace and don't label functions well. But the same problem exists in C++, just no one cares.

That said, Java is no longer my primary programming language. But through no fault of Java.
Helicon - Thu Feb 12, 2004 11:07 pm
Post subject:
c++ is a poluted language... especially thanks to MS VC++ and this new "Managed" shit with .NET

(i will resisit the urge to make this a language-political thread right here and now)

but, en passant, i submit the following:

the D Programming Language

the Chef programming language
Helicon - Thu Feb 12, 2004 11:09 pm
Post subject:
Dr Brain wrote:
That said, Java is no longer my primary programming language. But through no fault of Java.


honestly, i don't consider java a true language. It's not compiled. I have learned to consider it high-level graphical cross-platofrm scripting.

In the end, we're all "assisted" asm programmers
Jason - Thu Feb 12, 2004 11:12 pm
Post subject:
Okay, here's something that's been bugging the shit out of me, albeit a tiny thing. I see tons of identifiers in various chunks of code, be it PHP or Java or C++ in which prefixes such as 'fn' and 'fc' are used. I did a little Google research and found that this naming convention is called "Hungarian Notation." However, that's about all I could find. I couldn't find any document which actually explained the significance of each individual prefix. So then, what the hell do those damn prefixes mean?! When do I use 'fc' versus 'fn'? I figure someone here will be be able to explain this to me. :]

On a side note, something tells me this is a little bit of knowledge I should have picked up in one of my introductory CS courses. Bad RIT (That's the school I was attending.) for not teaching it to me. :/
Helicon - Thu Feb 12, 2004 11:17 pm
Post subject:
from microsoft developer network

Hungarian Notation


i generally ignore it.
i have seen entire open source (successful) projects without it
Jason - Thu Feb 12, 2004 11:21 pm
Post subject:
Alright, so that nails most of them down. Still, is 'fc' some kind of combination of prefixes?
Mine GO BOOM - Fri Feb 13, 2004 1:44 am
Post subject:
Hungarian Notation was good, back when you'd edit code in a simple text editor. But, with IDEs and kickass text editors, you don't need to remember if JoeColor was an int, short, or string. And with functions, it tells you what each argument in the function requires as you type it, thus making it not required for that either.

Technology killed this notation. Windows still uses it for their API, but I havn't seen much of it since.
Jason - Fri Feb 13, 2004 3:57 am
Post subject:
I guess that's why RIT never bothered to teach it to me then. Thanks, as always, for the informative post MGB.
Smong - Fri Feb 13, 2004 7:36 am
Post subject:
Quote:
Code: Show/Hide
std::cout << "test" << std::endl;
Without looking at the tutorials, is this right?
Code: Show/Hide
namespace std;

void my_func()
{
   cout << "test" << endl;
}

Quote:
I find that lazy java coders are easy to spot
Am I a lazy Java programmer? I would prefer not to be lazy while at the same time taking advantage of the RAD capabilities of Java.
Dr Brain - Fri Feb 13, 2004 7:48 am
Post subject:
Quote:
Am I a lazy Java programmer? I would prefer not to be lazy while at the same time taking advantage of the RAD capabilities of Java.


I honestly don't remember icon_smile.gif
D1st0rt - Fri Feb 13, 2004 5:32 pm
Post subject:
RIT? is that Rochester Institute of Technology? They keep spamming me to go there.
Cyan~Fire - Fri Feb 13, 2004 6:17 pm
Post subject:
@Smong, that will work as long as you don't include 'iostream.h', since there's also a non-STL cout and endl.
Mine GO BOOM - Fri Feb 13, 2004 6:27 pm
Post subject:
You should learn to do printf. Much nicer, in my opinion, once you get the hang of it. Though, if you suck at remembing that %s doesn't work for ints, then you may not want to use it.
Jason - Fri Feb 13, 2004 9:23 pm
Post subject:
D1st0rt wrote:
RIT? is that Rochester Institute of Technology? They keep spamming me to go there.

Yep, that's RIT. It's a great school if you're a hardcore nerd concerned only with programming/engineering. If you're like any normal college kid though, prepare to be bored shitless and probably depressed too. It's a drab and dreary place. Another thing to take note of is the fact that there is roughly a 7:1 guy to girl ratio. That's right, every party you go to will be one giant sausage fest. Yay!

I'm getting the fuck out of there and heading south, possibly to the University of Maryland or Virigina Tech.
Helicon - Fri Feb 13, 2004 10:58 pm
Post subject:
Jason wrote:
I'm getting the fuck out of there and heading south, possibly to the University of Maryland or Virigina Tech.


you call that south??? damn yankee...
ExplodyThingy - Sat Feb 14, 2004 12:06 am
Post subject:
From one who lives in maryland, and knows people ho go there, dont. They have good areonotics and other junk, but just stay out. For your own good.
Jason - Sat Feb 14, 2004 12:58 am
Post subject:
Helicon, I call it south relative to Rochester, NY. Yes, I'm a yankee as I was born and raised in northeastern PA, but I have spent quite a bit of time in the south over the years, mostly in Tennessee, Florida and Louisiana. :]

Splody, any recommendations of other schools down that way then, perhaps even in the DC area?
ExplodyThingy - Sat Feb 14, 2004 1:44 am
Post subject:
Im saying from a cultural (or lack thereof) aspect, dont come here. Yea its got all those monuments and the whole Smithsonian thing, buts its either extremely tourist or extremely political. Its boring here. In fact, I dont know a single adult who lives here now who actually grew up around here, they get fed up with it in a few years. Everyone around here in school wants to leave. No, Im not exaggerating in the least.

Thats not to say that Maryland isnt a good school, Im sure its fine. I can rattle off a long list of schools around here if youd like.

South Eastern University
American University
Maryland University
University of DC
Shaw-Howard Universit
Georgetown University
George Mason University
George Washington University
Catholic University
Virginia Tech
University of Virginia
And many more!

Heres something if youre seriously considereing location, the Metro (subway) system map, most of the stations share names with the school they are close to. So if you want an escape plan to Regan National Airport, enjoy
http://www.wmata.com/metrorail/systemmap.cfm

BTW, for those who care, my school is two blocks from Union Station
D1st0rt - Sat Feb 14, 2004 11:56 pm
Post subject:
UMD and Tech are my 1st two choices for college, and I grew up in PG County, MD. Now I'm in fairfax, but im really still from PG.
Jason - Sun Feb 15, 2004 2:59 pm
Post subject:
Maybe I'll see you there at one of 'em then!
Fuzzjdc - Tue Feb 17, 2004 5:02 am
Post subject:
Jason wrote:
MGB, thanks for the offer about the PDFs, but unfortunately I'm on dialup so 100megs is out of the question.

hehehe, 100 megs is big for dial up??? you should see my stats for one month!!
(stats for one month on dial-up)
Total Time | Total Uploads | Total Downloads
736h 43m | 2711.58 MB | 3207.27 MB
Jason - Tue Feb 17, 2004 6:39 pm
Post subject:
Sweet Jesus man! I'm home from school, where I was downloading 700MB movies in under a minute. What a smack in the face dialup has been. :/
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group