Java or C++?

S

s0suk3

Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?
 
B

Bob Martin

in said:
Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?

C++ is for masochists. Go for Java.
 
X

xakee

Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?

Well if you need an easier transition, go for java. But personally i
would recommend you to go for C/C++. There are a few very solid
reasons for that.
1. You can still use ur python konwledge, integrate python with you
applications, extend python with C/C++ .. and so on. That would not
only benefit you but the whole community.
2. C/C++ is likely to teach you more things in this transition than
java will. You probably know all the good software engineering stuff
and things like that maybe, (which you can still use in python) but
going to C/C++ you can actually delve into systems programming and
things like that. When you do that, again, you can extend python and
contribute to the community.
3. When you get hold of c/c++, there will be lesser friction in you
forever to transition to any other language. I appriciate that you
chose python in the first place since that is what i advocate as
well ... the way i see programming should be taught or taken up is
like :
bash/shell scripting -> python/perl -> c/c++ -> assembly .... (from
there on, given you give enough time to the end parts, you should not
have any difficulty going to C#/Java/VB/Delphi or whatever for some
nice RAD or even production level performance not-so-critical
applications). So if you're intrested in system programming getting to
know how things get done, have a SOLID computing background and give
python what python gave you, go for C/C++.
 
M

Marc 'BlackJack' Rintsch

Well if you need an easier transition, go for java. But personally i
would recommend you to go for C/C++.

What's that C/C++!? C and C++ are quite different languages.

Ciao,
Marc 'BlackJack' Rintsch
 
B

Bruno Desthuilliers

(e-mail address removed) a écrit :
Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?

if it's for educational purpose, then you have absolutely nothing to
learn from Java. On the hi-level languages side, I'd rather recommend
Haskell or OCaml (functional programming) and/or Erlang (concurrent
programming). And if you want to go the 'close to the metal' way, then
better to learn C.

My 2 cents...
 
R

Robert Bossy

Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?
Hi,

I vote for Java, it will be relatively smoother if you come from Python.
Java adds a bit of type-checking which is a good thing to learn to code
with. Also with Java, you'll learn to dig into an API documentation.

Brian suggests C++, personnally, I'd rather advise C for learning about
computers themselves and non-GC memory management. C++ is just too nasty.

If your goal is exclusively education, I suggest a functional language
(choose Haskell or any ML dialect) or even a predicate-based language
(Prolog or Mercury, but the latter is pretty hardcore). These languages
have quite unusual ways of looking at algorithm implementations and they
will certainly expand your programming culture.

Cheers,
RB
 
M

Marco Mariani

L

lbonafide

Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?

It depends on your reasons for learning either. If you're targeting a
specific job market, find out what is prevelant in that market. And
keep in mind that if it's for a job, you'll also have to get up to
speed on the relevant libraries and frameworks.

If it's educational, I'd recommend C++ just to learn about pointers
and memory management, so you get a better idea of what's going on
under the covers in languages like Java and Python and Ruby and C#.
 
G

Grzegorz SÅ‚odkowicz

Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?
I can't say from personal experience (it was C, C++, then Python for me)
but I think you'll find Java very annoying, especially if you value
Python for elegance. Both C++ and Java have different philosophy than
Python, but C++ is better designed and more flexible.

As for the 'number of jobs' argument, sure there are more Java jobs but
this is offset by the number of Java programmers.

Cheers,
Greg
 
C

Carl Banks

Hello, I was hoping to get some opinions on a subject. I've been
programming Python for almost two years now. Recently I learned Perl,
but frankly I'm not very comfortable with it. Now I want to move on
two either Java or C++, but I'm not sure which. Which one do you think
is a softer transition for a Python programmer? Which one do you think
will educate me the best?

If you weren't comfortable with Perl my bet is that you'll be less
comfortable with C++ than Java.

It's softer transition to Java than to C++ from just about any
starting point.


Carl Banks
 
B

Brian Vanderburg II

My idea, if you really love Python and never think about erasing it
from your mind, go for C (not C++). A script language plus C can solve
every problem you need to solve. Also Python works pretty fine with C.
I agree mostly with this one. Scripting is very nice when writing an
application especially one that needs to change very often. Plus there
are several toolkits and existing libraries available for Python. I've
used wxPython some with it, and it came in handy for a few applications
that I would have normally written in C++/wxWidgets and have to
recompile every few weeks to suit my needs (data extraction tools/etc)

However there are cases when a compiled language is better, especially
anything that needs to be 'fast' and have a lower overhead. I wouldn't
use Python to create a very graphics intensive game or anything, though
it can be used with pygame/PyOpenGL for some nice simple stuff. Also
everything in Python is an object so it can start to consume memory when
handling very large data sets. And since there is no guarantee of when
garbage collection occurs, simply 'deleting' an item does not ensure it
is completely gone, especially if there are cyclic references, though
that can be handled by using 'gc.collect()'.



I consider C++ just a simplification of C, in the sense that it makes it
easier to do things that would take more work to be done in C. One can
still use C++ without all of the more complicated aspects but still take
advantages of other aspects.

C has the advantage that it does not to anything behind your back. This
is very useful especially for any form of system development or where
you must know exactly what is going on. It is still possible to do
'object oriented' development in C, it just requires some more typing to
set up whatever is needed. Even things like COM for windows can be done
in C, it just requires manually building the 'vtable' so to speak.
Also, C seems to avoid the use of temporaries where as C++ can use them
in conversions and assignments automatically if needed.

C++ makes some of it easier by doing certain things for you. Take a
string object for example. In C, assignment would only do a memory copy
operation:

String a, b;
b = a;

The statement 'b = a' would only copy the memory and pointers from 'b'
to 'a' which means they would both point to the same buffer. To avoid
this, a copy constructor or assignment operator can be implemented when
using C++. The same in C would be something like:

String_Assign(&b, &a); /* instead of b = a */

Then if a structure contains objects, more work is needed. For example,
in C:

typedef struct Name
{
String honorary;
String first;
String middle;
String last;
String lineage;
} Name;

void Name_Create(Name* name)
{
String_Create(&name->honorary);
String_Create(&name->first);
String_Create(&name->middle);
String_Create(&name->last);
String_Create(&name->lineage);
}

void Name_Assign(Name* self, Name* other)
{
String_Assign(&self->honorary, &other->honorary);
String_Assign(&self->first, &other->first);
String_Assign(&self->middle, &other->middle);
String_Assign(&self->last, &other->last);
String_Assign(&self->lineage, &other->lineage);
}

Name p1, p2;
Name_Create(&p1);
Name_Create(&p2);
Name_Assign(&p2, &p1);

But in C++, this is no problem:

Name p1, p2;
p2 = p1;

This will automatically call the constructors of any contained objects
to initialize the string. The implicit assignment operator
automatically performs the assignment of any contained objects.
Destruction is also automatic. When 'p1' goes out of scope, during the
destructor the destructor for all contained objects is called.

And if you want more control you can implement the default and copy
constructors, destructor, and assignment operator, and tell them to do
what you want. Just beware because the explicit constructors only calls
default constructors of any parent classes (even the copy constructor)
unless an initializer list is used, and an explicit assignment will not
automatically do assignment of parent classes.

Neither C nor C++ is really better, it depends on the what needs to be
done. C does only what it is told, and also has easier external linkage
since there is no name mangling. C++ does a lot of the needed stuff
automatically, but explicit constructors and assignment operators can
still be declared to control them, and frequently doing the same thing
in C++ takes fewer lines of code than in C.

As for Java, I think it is 'overly-used' in some areas, especially in
embedded development. I attended NC State and during orientation this
representative was talking about a small little robotic device and how
it had a full Java VM inside it and it only took '6 minutes to boot'.
Some claim it is for portability that Java is so good in embedded
devices. But still, if the program is moved to another device, it may
still need to be changed and recompiled if the new devices has different
IO pins, timers, interrupts, etc. Most chips have a C
compiler/translator available, and the same program could have been
written in C, compiled directly to the machine code needed for the
device, 'booted' immediately, and not needed a Java VM as well. If
portability to other devices is desired then an abstract layer could be
created in the program and the device/hardware specific code could be
seperated to that layer seperatly from the rest of the program.

Well, all of that is just my opinion though, not meant to offend anyone.
 
B

Bob Martin

in 342436 20080414 160208 =?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?= said:
I can't say from personal experience (it was C, C++, then Python for me)
but I think you'll find Java very annoying, especially if you value
Python for elegance. Both C++ and Java have different philosophy than
Python, but C++ is better designed and more flexible.

You must be joking - better designed? C++ was a botch to an already poor
language.

Personally I find Java very satisfying to write.
 
P

Paul Anton Letnes

Brian: Impressive!


This is the most balanced, well-informed and interesting reply to this
debate. I would like to make some comments even so.

I have tried all languages, and consider myself agnostic. However, I
would like to roughly repeat what James Gosling (Java inventor) said
at a lecture I attended: Java is nice because you can work in Java
everywhere now - from embedded to desktops to supercomputers and
servers. And, I would like to make my own comment: Java is the
language I have tried which gives you the most help as a developer.
For every crash, there is a complete and useful stack trace. Using
Eclipse, you can auto-generate much of the 'boilerplate' code which is
claimed to make Java boring to write (get, set, constructors...). It
also more or less tells you how to fix small bugs - ';' and } missing
for example. Even python is less helpful; concider "Unexpected indent"
or the very informative "incorrect syntax" when you forget a ) or a : .

C (or C++) for learning to talk to the metal,
Java or Python for object orientation,
Java will give you the most help,
Python gets you started quickly,
C++ is the hardest to understand in every detail,
but C bogs you down with administrative stuff (try converting an int
to a string; I found myself googling for an hour!).

I tried this infamous "extending in C" and I would forget that until
you know both C and python a bit more... Also, extending python in C++
or Java is possible - I didn't manage C++ yet, and Java I didn't try.


Cheers!
Paul.


Den 15. april. 2008 kl. 05.46 skrev Brian Vanderburg II:
 
I

Ivan Illarionov

On 15 ÁÐÒ, 07:46, Brian Vanderburg II <[email protected]>
wrote:
[...]
C has the advantage that it does not to anything behind your back. This
is very useful especially for any form of system development or where
you must know exactly what is going on. It is still possible to do
'object oriented' development in C, it just requires some more typing to
set up whatever is needed. Even things like COM for windows can be done
in C, it just requires manually building the 'vtable' so to speak.
Also, C seems to avoid the use of temporaries where as C++ can use them
in conversions and assignments automatically if needed.

Great point. It's also possible to do Python object-oriented
programming in C. 'PyMethodDefs' are the same 'vtables'. I've found
that Python/C API is not that hard, the problem is a lack of good
tutorials and false assumptions that ctypes or SWIG are somehow
better. After `#include Python.h` C becomes very Python friendly.
 
E

egbert

What is the role or position of C# in this context ?
If I remember well, some people have said that C# is an improved
C++ or Java.
e
 
M

Michael Torrie

egbert said:
What is the role or position of C# in this context ?
If I remember well, some people have said that C# is an improved
C++ or Java.
e

I think C# is in a great position, and might be recommended. C# has the
added advantage of being able to very easily work with IronPython. Thus
if you want to develop with .NET you can easily wield the beauty of
python with C# for speed or library routines.

Of course Jython does the same for Java, although it's way behind in
development these days.

Slick python integration is one area where C# and Java would beat out
C++. Sure there's Boost::python, but the learning curve is kind of
steep. Installation, even, is difficult. Python's C API is very simple
and C-like, so if one chooses to use primarily a C/Python combination
(typically what I do these days), it works well, but not quite as easy
as IronPython and C#.

Diving into the debate, I personally think all programmers, and
especially computer science people, should be proficient in C. You
should be able to write thousands of lines of C code, use dynamic memory
allocation, data structures, etc, and have very few resource leaks if
you choose your tools wisely (glib for C ought to be standard!). This
is to give you a background and low-level understanding. However you're
not likely to program in C professionally unless you are into systems
programming, or are affiliated with core, low-level things like library
development, or embedded systems.

As for C++ and Java, I've found that good C++ programmers can *easily*
move to Java when they want/need to. The reverse is *not typically
true*. Java lends itself to too many bad habits that kill would-be C++
programmers, particular in regards to resource management and things
like destruction after scope. I think that is a critical thing that
people forget sometimes. Similarly people proficient in Unix and Linux
computers, both use and development on, can much more easily move to
Windows than the other way around.

A good programmer should be able to pick up new languages and paradigms
fairly easily, and become fluent in just a few weeks. For me it's
typically one week, although learning frameworks and toolkits is more
difficult (Java frameworks). A good exercise might be to pick up one
new language per year and do something major with it (say 4000-10000
loc). Choose a new genre like web programming to explore. Whatever.
Next time a little pet project comes up, try a new language or a new
toolkit. Try some shell-scripting in scsh using scheme.
 
L

lbonafide

but C bogs you down with administrative stuff (try converting an int  
to a string; I found myself googling for an hour!).

It took an hour to find sprintf()?
 
L

lbonafide

What is the role or position of C# in this context ?
If I remember well, some people have said that C# is an improved
C++ or Java.

C# is more similar to Java than C++. Neither is very similar to C++,
except in some cosmetic syntactic ways. Personally, that would be my
last choice. C++ is the most portable of the three, and the only non-
proprietary one (like Python).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top