Page 1 of 2 12 LastLast
Results 1 to 20 of 32

Thread: Java to C++

  1. #1
    lolu is offline Member
    Join Date
    Nov 2009
    Location
    Abuja, Nigeria
    Posts
    15
    Rep Power
    0

    Default Java to C++

    Hi everyone!

    Please I do need some clarification. I started my programming experience with Java and I can say Im on average so far. However, it seems I might have to take on C++ and C, and I was wondering how its going to be. Normally, you just take the same concept and apply it to the new language and learn the written syntax but given that Java is more dynamic and Object oriented and C is not, not sure about C++. How easy is it going to be to apply my Java knowledge to C/C++? Or would I have to look for Beginner's Guides again?

    Thanks for taking a minute to clear my doubts!
    Lolu

  2. #2
    Valkyrie is offline Member
    Join Date
    Oct 2009
    Posts
    15
    Rep Power
    0

    Default

    C isn't an object oriented program, so you would like to get some books on that, but so far what I know about C is if you know how to use statements and loops in Java, you will be good there. C you have to declare what type of variable you want, like Java. I don't know about C++ since I never learned C++. Also, C doesn't support strings.

  3. #3
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    7

    Default

    c++ is pretty similar to Java(well Java is similar to c++ since c++ was around first I guess).

    One of the major differences is with C++ you use pointers and pass values by reference instead of actual objects. Also C++ does not have a built in garbage collector like Java does so any object you create you also need to make sure you clean up.

    I feel the syntax to C++ is a little more complicated than Java but it's also more powerful.
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  4. #4
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    5

    Default

    c++ is in some ways equal to java.
    object oriented,... i would go that way.
    but why leaving java?

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    You'll definitely need a book, as you've got call by value, call by address and call by reference in C++. Also you have to manage the memory (de)allocation yourself.

    EDIT: God I'm slow.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    7

    Default

    To answer your question you're going to have to look at beginners guides so you can figure out the syntax and probably spend some time on object references and such. Loops, inheritance, OO format, etc all that should be pretty similar. If you look at a chunk of C++ code you could probably figure out most of what's going on.
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  7. #7
    lolu is offline Member
    Join Date
    Nov 2009
    Location
    Abuja, Nigeria
    Posts
    15
    Rep Power
    0

    Default

    Thanks y'all! It seems C++ will be alot easier to master than C, so I guess I'l just have to get beginners guides to walk me through main features of both languages.

    @dino: Im not leaving Java. I could never have the guts to...:) Im just having to learn these two to have an advantage while applying for jobs.

  8. #8
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Thanks y'all! It seems C++ will be alot easier to master than C
    C (rather than C++) is probably the place to start.

    If you are familiar with Java - that is, with programming - consider Kernighan and Richie's The C Programming Language ahead of huge beginner's guides: it lives up to the authors' promise of it being a "small book for a small language".

  9. #9
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    The problem with C++ compared to java can get a little complicated with preprocessor directives class defs multiple inheritence and being able to redefine operators ...a c++ class can inherit any number of unrelated classes where the inheritance in java is chained and uses interfaces...

  10. #10
    lolu is offline Member
    Join Date
    Nov 2009
    Location
    Abuja, Nigeria
    Posts
    15
    Rep Power
    0

    Default

    C. I made it a point to express my lack of interest in it. And here I am...lol
    @pbrockway2: Thanks for the reference. Will check for the book.

  11. #11
    sky
    sky is offline Member
    Join Date
    Nov 2009
    Posts
    96
    Rep Power
    0

    Default

    C syntax is very similar to Java syntax. I would start learning C and then follow with C++, so you don't get lost with pointers, memory allocation and deallocation, etc. I feel it's easier to start with C and then go with Java, so you will need some books to do it in the other way. The one they recommended to you above is very good if you have some progamming experience (like in this case). Good luck!

  12. #12
    lolu is offline Member
    Join Date
    Nov 2009
    Location
    Abuja, Nigeria
    Posts
    15
    Rep Power
    0

    Default

    Alright. So now that im going Java to C, I hope this is not a case of Jil tumbling down the hill...lol

    But in any case, if Java is supposed to be the ultimate programming language, like most dynamic, lets you do more things, object oriented, yada yada yada...why are folks in major Software development companies and related firms still using C and C++? why arent they incorporating java? I dont really get it.
    All the java features makes one fall in love with it, and then you get to the real world and you find you dont have enough equipment to farm. ????

  13. #13
    collin389 is offline Senior Member
    Join Date
    Nov 2009
    Posts
    235
    Rep Power
    5

    Default

    Just a couple of fun c programs, look at those and tell me if you want to learn c, lol

    Winners - about the authors of winning IOCCC entries
    take a look at some of the .c files

    One program that coverts inputted text into morse code:
    Java Code:
    #define	DIT	(
    #define	DAH	)
    #define	__DAH	++
    #define DITDAH	*
    #define	DAHDIT	for
    #define	DIT_DAH	malloc
    #define DAH_DIT	gets
    #define	_DAHDIT	char
    _DAHDIT _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3d2f16g7c8a90l?e'b.s;i,d:"
    ;main			DIT			DAH{_DAHDIT
    DITDAH			_DIT,DITDAH		DAH_,DITDAH DIT_,
    DITDAH			_DIT_,DITDAH		DIT_DAH DIT
    DAH,DITDAH		DAH_DIT DIT		DAH;DAHDIT
    DIT _DIT=DIT_DAH	DIT 81			DAH,DIT_=_DIT
    __DAH;_DIT==DAH_DIT	DIT _DIT		DAH;__DIT
    DIT'\n'DAH DAH		DAHDIT DIT		DAH_=_DIT;DITDAH
    DAH_;__DIT		DIT			DITDAH
    _DIT_?_DAH DIT		DITDAH			DIT_ DAH:'?'DAH,__DIT
    DIT' 'DAH,DAH_ __DAH	DAH DAHDIT		DIT
    DITDAH			DIT_=2,_DIT_=_DAH_;	DITDAH _DIT_&&DIT
    DITDAH _DIT_!=DIT	DITDAH DAH_>='a'?	DITDAH
    DAH_&223:DITDAH		DAH_ DAH DAH;		DIT
    DITDAH			DIT_ DAH __DAH,_DIT_	__DAH DAH
    DITDAH DIT_+=		DIT DITDAH _DIT_>='a'?	DITDAH _DIT_-'a':0
    DAH;}_DAH DIT DIT_	DAH{			__DIT DIT
    DIT_>3?_DAH		DIT			 DIT_>>1 DAH:'\0'DAH;return
    DIT_&1?'-':'.';}__DIT DIT			DIT_ DAH _DAHDIT
    DIT_;{DIT void DAH write DIT			1,&DIT_,1 DAH;}

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,123
    Rep Power
    20

    Default

    Quote Originally Posted by lolu View Post
    Alright. So now that im going Java to C, I hope this is not a case of Jil tumbling down the hill...lol

    But in any case, if Java is supposed to be the ultimate programming language, like most dynamic, lets you do more things, object oriented, yada yada yada...why are folks in major Software development companies and related firms still using C and C++? why arent they incorporating java? I dont really get it.
    All the java features makes one fall in love with it, and then you get to the real world and you find you dont have enough equipment to farm. ????
    Because those firms already have a large investement in those languages in terms of code. Or they're techie companies, or defence, or comms, or or or.

    Or, as the thing I'm looking at at the moment, it happens to be the quickest way to deliver a solution to the client (COM gubbins). To be honest there's lots of reasons, hopefully to do with "right tool for the job", but not always.

    Still, this'll be the first C++ I've done in nigh on 10 years, bar toying with game frameworks...which doesn't realy count.

  15. #15
    hendrix79 is offline Member
    Join Date
    Dec 2008
    Posts
    28
    Rep Power
    0

    Default

    If you study Bohm-Jacopini's theorems, you just could program in every language. But don't forget to practicse yourself in programming without garbage collector and automatic memory allocation, because it's painful at first steps. Believe me, if you plan to make BIG projects, forget C++ and C if you don't know the basics about them. Maybe you'll need templates and strange data structures, and Java just do the job for you. If you plan to learn C or C++, take a look from the start: begin with C and practicse with the base syntax, then study from the only one book that it's worth to be read: the Kernighan and Ritchie. After, you can go to C++ and, if you studied that book, you could have all the world of programming in your hand. Don't forget to study algorhythm's theory, because it's fundamental to have a "slim" and fast computation when you have to allocate memory by yourself, often without knowing how much really you need.
    :-)
    Last edited by hendrix79; 11-26-2009 at 01:20 AM.

  16. #16
    aaroncarpet's Avatar
    aaroncarpet is offline Senior Member
    Join Date
    Nov 2009
    Location
    California
    Posts
    147
    Rep Power
    0

    Default

    C++ is probably the most powerful language, in my opinion, you can imbed assembler into your code you have more control over the computer but it is very hard to debug because they don't use exceptions and you can chase the addresses of your data.. The nice thing about java is that it is a more managable language ....C++ programs for gaming and multimedia can get very complex...it is much harder to grasp the structure of the code in c++....

  17. #17
    lolu is offline Member
    Join Date
    Nov 2009
    Location
    Abuja, Nigeria
    Posts
    15
    Rep Power
    0

    Default

    Quote Originally Posted by collin389 View Post
    Just a couple of fun c programs, look at those and tell me if you want to learn c, lol

    Winners - about the authors of winning IOCCC entries
    take a look at some of the .c files

    One program that coverts inputted text into morse code:
    Java Code:
    #define	DIT	(
    #define	DAH	)
    #define	__DAH	++
    #define DITDAH	*
    #define	DAHDIT	for
    #define	DIT_DAH	malloc
    #define DAH_DIT	gets
    #define	_DAHDIT	char
    _DAHDIT _DAH_[]="ETIANMSURWDKGOHVFaLaPJBXCYZQb54a3d2f16g7c8a90l?e'b.s;i,d:"
    ;main			DIT			DAH{_DAHDIT
    DITDAH			_DIT,DITDAH		DAH_,DITDAH DIT_,
    DITDAH			_DIT_,DITDAH		DIT_DAH DIT
    DAH,DITDAH		DAH_DIT DIT		DAH;DAHDIT
    DIT _DIT=DIT_DAH	DIT 81			DAH,DIT_=_DIT
    __DAH;_DIT==DAH_DIT	DIT _DIT		DAH;__DIT
    DIT'\n'DAH DAH		DAHDIT DIT		DAH_=_DIT;DITDAH
    DAH_;__DIT		DIT			DITDAH
    _DIT_?_DAH DIT		DITDAH			DIT_ DAH:'?'DAH,__DIT
    DIT' 'DAH,DAH_ __DAH	DAH DAHDIT		DIT
    DITDAH			DIT_=2,_DIT_=_DAH_;	DITDAH _DIT_&&DIT
    DITDAH _DIT_!=DIT	DITDAH DAH_>='a'?	DITDAH
    DAH_&223:DITDAH		DAH_ DAH DAH;		DIT
    DITDAH			DIT_ DAH __DAH,_DIT_	__DAH DAH
    DITDAH DIT_+=		DIT DITDAH _DIT_>='a'?	DITDAH _DIT_-'a':0
    DAH;}_DAH DIT DIT_	DAH{			__DIT DIT
    DIT_>3?_DAH		DIT			 DIT_>>1 DAH:'\0'DAH;return
    DIT_&1?'-':'.';}__DIT DIT			DIT_ DAH _DAHDIT
    DIT_;{DIT void DAH write DIT			1,&DIT_,1 DAH;}
    Is this C code? ummm...ok.
    I still want to learn.

  18. #18
    lolu is offline Member
    Join Date
    Nov 2009
    Location
    Abuja, Nigeria
    Posts
    15
    Rep Power
    0

    Default

    @Tolls: How 'right' is C/C++ if Java is supposed to do things better? Wldnt that make Java the 'best tool for the job'?

    @hendrix: Thanks for the pointers. Im going to look out for those. i already got the C Programming language book. I'l go check out the Bohm-Jacopini's theorem thingy.

    [By the way, Y'all wonderfull! i do appreciate all the contributions!]

  19. #19
    lolu is offline Member
    Join Date
    Nov 2009
    Location
    Abuja, Nigeria
    Posts
    15
    Rep Power
    0

    Default

    Oh, I forgot to mention: The C Programming Language book i got is a 1988 print. Am I on track? Or do l need to look for a later version?

  20. #20
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,682
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by lolu View Post
    Oh, I forgot to mention: The C Programming Language book i got is a 1988 print. Am I on track? Or do l need to look for a later version?
    If it mentions "2nd edition" or "ANSI draft" you're fine.

    kind regards,

    Jos

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •