FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Where should I start? C++ vs. JAVA





speeDemon
Ok, here's the deal, I made a post earlier regarding a competition, which includes the use of C++ and JAVA languages to solve some problems. I've taken 'Computer' as my optional subject in school, and so I know a little bit(the most basic stuff, I'll outline it at the bottom) of C++ but nothing about JAVA.

My first query is- Which is better, JAVA or C++, when it comes to making loops and solving these 'problems'. I'll give you an example of a problem, "Write down a program to print the closest number greater than the given number formed by rearranging the digits of the given(input) number" eg.
INPUT- 1674 OUTPUT- 1746

Do both of them present similar commands, or does one have an advantage over the other?
Also, If I look at making games then which language be more advantageous?

My second query is, where to start learning C++ and JAVA(in case I need to learn it). I'm talking about E-books preferebly, other than that a good website will also do, or maybe even a book.
Also, for starting making games(right from the basic stuff) could you suggest some good E-book, website, etc.

Here are some commands I know in C++(It's pretty basic stuff..):
Cin
Cout
int
for
do while
if /else
switch-case
break
getch
clrscr

I know about arrays, but haven't worked with them yet, other than that and these simple commands I may know a little bit more commands which aren't coming to me right now.
meep
Well if you gonna learn one of them I would go for C++, because I've never seen a good game in java.
Could be that I didn't look enough but most games aren't in java.
About the E-Books, you could take a look here; http://www.computer-books.us/cpp.php
They have books available free for download , and I've taken a quick look at one and it seemed pretty good ( http://www.computer-books.us/cpp_1.php ). I've scanned it and it didn't contain a virus so i suppose it's save, but i would still look at it in firefox with noscript just to be safe Smile
Fire Boar
Java is a lot easier to get to grips with than C++. C++ is a little bit fiddly, but well worth it if you can learn it. For very basic programs like that, Java is somewhat overkill and in that specific instance, the C pointer manipulation may be very handy.
Peterssidan
I would say that the strongest aspects of Java is that it has a large standard library and that it's easier to get platform independent. I have started to love C++ more and more. C++ is more complicated and you often have several option to do things on but it's very powerful and have good performance if you do it right. simple stuff like loops, variables and such are very similar in Java and C++. There are probably many good books on C++ but I haven't used any so I don't know. Many things you can learn by searching the web. A good website for game development is gamedev.net.
ankur209
Well,java is quite easy if u'll be starting with it.. Razz

coz once u'll get out its basic u'll be mastering every language...Smile
Peterssidan
ankur209 wrote:
Well,java is quite easy if u'll be starting with it.. Razz
coz once u'll get out its basic u'll be mastering every language...Smile

eeh.. I don't think so. Can you say that you mastering a language if you only knows the basics? It is true that the basics of Java is similar to many other languages but Java is an high level object oriented language so by learning Java there is much left to learn to be able to master every other language. How about low level languages like assembly, or functional programming like Haskell, or imperative languages like C. By only knowing Java you can only master Java. But the knowledge of knowing a language (any language) will still be very useful when learning new languages, similar or not.
snowboardalliance
I think the java vs. c++ thing has been covered a lot, but I'll just add,

speeDemon wrote:
My first query is- Which is better, JAVA or C++, when it comes to making loops and solving these 'problems'.
...
Do both of them present similar commands, or does one have an advantage over the other?


Both languages will give you the same ability to solve simple problems like the one you mentioned and I really don't think there is an advantage for either in this area. Java is strictly OO, while c++ is a multi-paradigm language. Either way, the differences will not affect this problem.

The differences are bigger when it comes to other projects like making a game.

I would recommend learning C++ personally, but it is probably worthwhile to pickup on Java later. Once you know one language really well, learning another is much easier (although mastering any language can take a considerable amount of time).
portoskt
java is better choice than c++ just because dont have pointers... but before you start learning java, i think you should spend some time with C, and after that learn about OO paradigm...
fladry
portoskt wrote:
java is better choice than c++ just because dont have pointers... but before you start learning java, i think you should spend some time with C, and after that learn about OO paradigm...

I dont think pointers are the problems of c++. You can just avoid it if you dont like- or may be you should learn the hard parts also to get more grip over your programs. Anyway, points are option in c++ with STL functions. I would recommend c++ as it is more powerful than java...
han007
as you can see it is important what kind of work u want do?
native speed or portable java app
if your answer is c++ See Qt
noobcake
If you're into programming competitions, C++ is probably the way to go. It's several times faster than Java, so it's much easier to get through the time limit. Of course, this only applies to problems solvable by brute force. In other cases, applying the proper algorithm is the way to go, so Java is just as good if not better due to the standard libraries. If you ever encounter problems that involve bignums, Java would probably be the way to go to solve those since I don't think there are any standard bignum libraries for C++.

If you're in it for studying how to program, I would recommend checking out either C or Python. Python is really great for making stuff and there's are lots of built-in libraries (things that other people have made that provide functionality). Also, in Python you don't have to go through the nitty gritty of everything. Say, you have "foo" and you have "bar", you can just do "foo"+"bar" to get "foobar". This is nowhere near as easy in C.

The great thing about C though is that you HAVE to go through the nitty gritty of everything. This gives you a deeper insight of how computers do things, so you'll have a better understanding of which actions are slow, how much memory an object should take up, how data is represented in computer memory, etc. C is definitely much harder to master than Python.

I think those two are good endpoints in the spectrum of programming language power to start programming with. C being the most low level of the high level languages, and Python being one of the most powerful.

C++ is a lot like C, but with a lot of added fluff, so it's a bit more difficult. Java is a lot cleaner and easy to learn than C/C++, but I think the lack of pointers makes the learning incomplete, but also much easier.
emanuel2
As many already proposed, if you really want to learn programming than start with C.
If you just want to "crash course" to a GUI application or other neat graphical programs (i.e. like games), I on my behalf would start with Java. But if you really want to do some professional stuff, then you may consider both C++ and Java, depending on you're real needs...
CraigHF
noobcake wrote:

C++ is a lot like C, but with a lot of added fluff, so it's a bit more difficult. Java is a lot cleaner and easy to learn than C/C++, but I think the lack of pointers makes the learning incomplete, but also much easier.


I have to agree with that... and everything else noobcake said in his post. Personnaly, the first language I've learned is C, then C++ followed by Java. I think that if you know C++, Java will be easier to learn as it is a derived of C++ (correct me if I'm wrong!). Pointers can be a little harsh at first glance, but when you get it, you see all the power it brings! I think one of the greatest way to learn and master pointers is to re-program containers such as lists, queue and stack.

So that being said, I also think that C and C++ should be a good starting point if you are willing to put some efforts, though ultimately, it depends on what you plan to program...

P.s.: I apologize for my english... it ain't my first language Wink
gcca
Personally, I think people should start with high-level languages​​. You should not deal with the problems of memory allocation, data type, and others.
You can start by bash, python, ruby. The syntax is always less important.
c'tair
Well, I'm learning Java now in school and it's easy as pie. The only thing that's bothering me is the performance - I started playing around with arrays and made a 2 dimensional one where the user sets the upper limit so I typed in a some reasonably big number and then the java IDE crashed.

Once I'm done with Java this semester, I'll head on over to C++ as soon as possible, that way I'll already know two languages.
davidv
c'tair wrote:
I started playing around with arrays and made a 2 dimensional one where the user sets the upper limit so I typed in a some reasonably big number and then the java IDE crashed.


You must of done something stupid. Razz

From my experience, it's faster to create solutions to complex problems using Java than C++. However solutions to trivial problems like your example:

Quote:
"Write down a program to print the closest number greater than the given number formed by rearranging the digits of the given(input) number" eg. INPUT- 1674 OUTPUT- 1746


permute, traverse... it honestly doesn't even matter. If you're more familiar with C++ then I'd recommend C++. Every language has its own tricks and those tricks inevitably speed up the process.

To be honest, I've never actually had to use a textbook or E-book when learning how to program. I have used them as references for things like tree properties (especially red-black trees... I can seem to remember them), time complexity proofing, algorithms etc. but learning how to program, never.

Judging by your post, I take it that you don't have much programming or theoretical computer science background so I say, forget C++ and Java. Go learn Python. The syntax is beautiful and as such, you focus on logic, control flow, problem solving, abstraction, modular code... the fundamentals of programming. It's much better to learn that than worry about silly syntax. As they say, each subsequent language you learn is some n% easier than the previous.
Peterssidan
c'tair wrote:
I started playing around with arrays and made a 2 dimensional one where the user sets the upper limit so I typed in a some reasonably big number and then the java IDE crashed.

Maybe the 2D array was very large and used up all of your memory? If anything goes wrong, Java normally throws an exception but that shouldn't cause the whole IDE to crash. sounds like a bug in your IDE.

davidv wrote:
Quote:
"Write down a program to print the closest number greater than the given number formed by rearranging the digits of the given(input) number" eg. INPUT- 1674 OUTPUT- 1746

Code:
#include <iostream>
#include <algorithm>
int main() {
    std::string s;
    std::cin >> s;
    std::next_permutation(s.begin(), s.end());
    std::cout << s << std::endl;
}

In java I'm not sure if I have to write the next_permutation function myself?
davidv
Quote:
In java I'm not sure if I have to write the next_permutation function myself?


I'm not sure if Java has a permutations class. Although I did find this: http://www.merriampark.com/perm.htm
Related topics
Fortran Tutorials(77)
Where to find Java Scripts
Dijkstra algorithm implemented in JAVA c or C++
DreamWeaver or Visual Studio
PHP VS ASP
Jackie Chan
Lineage II (C4 chronicle)
[Work]Unreal Tournament modification - Brother of Honor
VB.Net Or C#
mobile phone where java programming possible
Java vs. C++
my first forum...
Convert between C# and Java with CSharpJavaMerger
Custom Operating System in C#, C++, or Java
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.