I hope I won't sound trivial with asking my question.
I am a C++ programmer and I am thinking of learning something else
because I know second language might be very helpful somehow. I have
heard a few positive things about Python but I have never writen any
single line in python so I do not know this language at all.
Do you think python would be good complementary language for C++? Do you
think it's worth learning it or let's say try Java? and how difficult it
would be for me if I know C++ pretty well I would say?
Thanks
Bye,
bearophile
Yes, because Python is often used as a "glue" language used to script
C(++) components. Also, it's significantly different than C++ so it
will be a valuable learning experience that will expand your horizons.
> Do you
> think it's worth learning it or let's say try Java? and how difficult it
> would be for me if I know C++ pretty well I would say?
I would say Java would be comparatively less worth it since it's so
similar to C++ already; you could pick it up in just a few days. If
you're going to learn a new language, you might as well learn a
drastically different one.
Cheers,
Chris
--
I have a blog:
http://blog.rebertia.com
Certainly. A programmer that only knows one language would be too
limited. Try as many programming language as you can, and especially
look for programming languages that have "obscenely different" paradigm
than the language you already know.
You should know at least a language from each categories (anyone can add
if they feel something is missing):
- Object oriented, example: C-family, Java, Python, etc
- Imperative, example: C-family, Java, Python, etc
- Functional, example: Python, Lisp/Scheme, Haskell, etc
- Declarative, example: Haskell, Prolog
- Logic Programming, example: Prolog, etc
- Event driven, example: most GUI sublanguage, etc
- Domain specific language, example: Regular Expression (yes it is a
programming language, regex parser is a Finite State Machine), SQL, etc
- Concurrent programming, example: Erlang, etc
- any other paradigms
so basically, I still have much to learn...
My slight issue with this list that I think things are in too many
places. E.g. although you can do functional programming in Python (and
many do), I think it's worth trying to learn a language like lisp just
for the sake of forcing yourself to fully understand the paradigm.
I also think it's worth writing simple programs in a low level - either
in assembly, or as Turing/Register machine code.
> so basically, I still have much to learn...
so do I!
Every response is going to be pure opinion, of course. But learning
multiple languages that have different primary purposes is always a good
thing.
Python would be an excellent choice to supplement your C++. There are
other languages that might suit you better if you have more directed
needs in mind. But as a general use language, I doubt that Python would
disappoint. It is extremely functional and powerful, but still simple
enough that I generally recommend it as a FIRST language for those who
want to learn programming.
Indeed. FWIW, I use about four programming languages on a daily basis -
plus "non-programming languages" like SQL, CSS, (x)HTML etc, know at
least four others enough to be able to read code and do simple
maintainance, and have been studying (at least enough to get a general
feel and have a general understanding) half a dozen other languages.
Learning a new languages serves two purposes:
1/ add another tool to your toolbox, so you have the right tool for the
job (I definitively wouldn't use C++ for web programming or sysadmin
scripting)
2/ learn new concepts and idioms (and this can be invaluable, at least
if you hope to become a better programmer).
> I have
> heard a few positive things about Python but I have never writen any
> single line in python so I do not know this language at all.
Quite a lot of Python users come from other languages - mainly C, C++,
Java and Lisp, and these last times from PHP too thanks to Django.
If you're already an experimented programmer, specially from a C/C++
background, getting started with Python should be really easy. I guess
your main problem will be the mental adjustement needed to work *with*
the language instead of fighting *against* it.
> Do you think python would be good complementary language for C++?
Quite a few C++ programmers here seems to think it's the case.
> Do you
> think it's worth learning it or let's say try Java?
Java being mostly a stripped down version version of C++, and not being
usable as a glue or scripting language, I don't think you'd get any
benefices from learning it.
> and how difficult it
> would be for me if I know C++ pretty well I would say?
cf above. As I said, the hard part will be to stop trying to forcefit
C++ concepts and idioms in Python - as usual when learning a somewhat
different language. FWIW, learning Python 101 is a matter of days, but
it took me months to get rid of the declarative-static-typing /
defensive-programming mental straightjacket. Seems like some never get
past this point...
HTH
Yes
> Do you think it's worth learning it or let's say try Java?
Jave is basically C++ with the hard bits taken out. I wouldn't
bother.
> and how difficult it would be for me if I know C++ pretty well I
> would say?
Go here
http://www.diveintopython.org/
Download the PDF or buy the book.
You'll be writing your first python program in about 5 minutes!
We use lots of python embedded into our humungous C++ app. Gradually
the dev team has moved from writing C++ to writing python as much of
the time as possible and C++ only when necessary.
--
Nick Craig-Wood <ni...@craig-wood.com> -- http://www.craig-wood.com/nick
> My slight issue with this list that I think things are in too many
> places. E.g. although you can do functional programming in Python (and
> many do), I think it's worth trying to learn a language like lisp just
> for the sake of forcing yourself to fully understand the paradigm.
By a curious accident, just today I was closing my cycle of posts
about functional
programming (http://www.artima.com/weblogs/viewpost.jsp?thread=251159)
with this note:
"""
The intention of this third cycle of Adventures was just to give a
feeling of what does it mean to be a true functional language, versus
being an imperative language with a few functional-looking constructs.
"""
Indeed Python is not a functional language and that if your goal is to
learn
the functional paradigm you should look at Haskell, ML or Scheme.
Yeah, that issue did pass through my head when I posted it, but I was
too lazy to do proper listing of various language from various
paradigms. I thought if he is really interested in a paradigm, he should
find the entry for the paradigm in google or wikipedia to get more
insight and example language.
>> E.g. although you can do functional programming in Python (and
>> many do), I think it's worth trying to learn a language like lisp just
>> for the sake of forcing yourself to fully understand the paradigm.
>
> By a curious accident, just today I was closing my cycle of posts
> about functional
> programming (http://www.artima.com/weblogs/viewpost.jsp?thread=251159)
> with this note:
>
> """
> The intention of this third cycle of Adventures was just to give a
> feeling of what does it mean to be a true functional language, versus
> being an imperative language with a few functional-looking constructs.
> """
>
> Indeed Python is not a functional language and that if your goal is to
> learn
> the functional paradigm you should look at Haskell, ML or Scheme.
Definitely.
> Do you think python would be good complementary language for
> C++?
Yes.
> Do you think it's worth learning it or let's say try Java?
Either would be good, Python is probably both easier to learn
and a lot easier to use (at least on Unix).
> and how difficult it would be for me if I know C++ pretty well
> I would say?
Knowing C++ does tend to be a bit of a handicap, but I think
any competent programmer could learn Python.
--
Grant Edwards grante Yow! The PILLSBURY DOUGHBOY
at is CRYING for an END to
visi.com BURT REYNOLDS movies!!
> Do you think python would be good complementary language for C++? Do you
> think it's worth learning it
Absolutely, but it tends to become the first language over time.
Don't underestimate its reach. I've re-learned Python 3 or 4 times
already, over 11 years :-/
+2 QOTW !-)
What about the stuff on docs.python.org? Isn't that information just
as reliable?
> Do you think python would be good complementary language for C++? Do you
> think it's worth learning it or let's say try Java? and how difficult it
> would be for me if I know C++ pretty well I would say?
We're not exactly impartial advisors in here ;-)
I reckon Python and C++ make a good pairing, because:
- Python is far enough from C++ for each language to give you things
that the other doesn't (as opposed to Java; if I were still a C++
programmer I would only be interested in Java as a replacement for
C++, not to use alongside it);
- Python is far enough from C++ for you not to get confused over the
syntax; when I was learning Java I kept forgetting it wasn't C++ and
throwing in bits of C++ code! That never happened with Python
- Python integrates well with C++, at least for single-thread systems.
Python has a fairly shallow learning curve -- a reasonable programmer
can become productive in Python very quickly. For one programmer's
experience of learning Python have a look at
http://www.python.org/about/success/esr/ (although I grant that Eric
Raymond might count slightly higher than just a /reasonable/
programmer!)
--
Tim Rowe
They do not serve the same purpose. diveintopython is an excellent
introduction to python for someone already familiar with at least one
programming language, and the documentation on python.org aims at
being extensive.
cheers,
David
> Hi
>
[...]
>
> Do you think python would be good complementary language for C++?
Yes, definitely.
> Do you think it's worth learning it or let's say try Java?
I may not be objective (tried Java, hated it after 6 years). In the long
run, I'm afraid Java is going to slide into being Cobol/Visual Basic of
the future. I mean, not really fun anymore. Some people want fun and some
other don't care.
> and how difficult it would be
> for me if I know C++ pretty well I would say?
Easy :-).
One day of reading this, for a start:
http://docs.python.org/tutorial/index.html
and later:
http://docs.python.org/
http://diveintopython.org/
> Thanks
pl.comp.lang.python ;-)
Regards/Pozdrawiam,
Tomasz Rola
--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:tomas...@bigfoot.com **
I first learned Python using the official tutorial - already knew VB,
Java, Pascal, bits of C and C++ and some almost unknown crappy
proprietary basic-like language - and I found it a pretty good
introduction to what one *must* know about Python.
But YMMV of course - and I'm by no mean saying DIP is a bad book !-)
> I may not be objective (tried Java, hated it after 6 years).
Arf - only took me 6 months !-)
Yeah, I'm learning the language alreadying knowing scheme, haskell,
some perl, and enough C to get me by.
Short answer:
Yes
Long answer:
'Ye%s' %'s'*1000
> I am a C++ programmer and I am thinking of learning something else
> because I know second language might be very helpful somehow. I have
> heard a few positive things about Python but I have never writen any
> single line in python so I do not know this language at all.
>
> Do you think python would be good complementary language for C++? Do
> you think it's worth learning it or let's say try Java? and how
> difficult it would be for me if I know C++ pretty well I would say?
Python is an excellent first, second or 20th programming language. It's
a lot easier to interface Python with C++ than it is to interface Java
with C++ (but both are possible).
I tend to use multiple languages daily (at any time usually 4-5 in
regular use) and I've "forgotten" at least 20 languages (i.e. they're no
longer in regular use - but I could probably pick them up again
quickly). The more programming languages you learn, the easier it is to
learn new ones.
The first thing to do when learning a new language is to drop any habits
you learned with the language you're currently using. If you find
yourself asking "How do I implement <idiom> in Python?", stop and
instead ask "What problem am I trying to solve?". Quite often idioms
from other languages result in much more verbose and much slower code.
The same thing happens going the other way - so often in Java I get
frustrated because there's so much more boilerplate to implement what
are simple idioms in Python. Unfortunately in Java, usually there isn't
a simpler alternative available ...
Eventually you should learn both Java and Python, if only to be exposed
to different approaches to doing things.
Tim Delaney
I guess sometimes I need to be knocked really hard ;-/. But it works both
ways - I cannot imagine what should Java-the-language have to make me
interested again. Java-the-virtual-machine is still interesting a little,
but not as much as few years ago. Languages that I like (Python is one of
them) are already multiplatform, so running Jython is reserved to few very
special cases (those cases may be important and happening quite often to
other people but I intend to avoid them personally). Same for other
languages implemented over JVM, like Scheme or Common Lisp.
Of course, just my opinion.
Regards,
> --
> http://mail.python.org/mailman/listinfo/python-list
I've tried different languages (being mostly C programer at the time)
- even Java. Tried Python and stayed with it.
Other than that - the best language is the language you know.
B.
simplified long answer:
'Yes' * 1000
or did you mean
'Ye%s' %('s'*1000)
--
Wolfgang
> or did you mean
> 'Ye%s' %('s'*1000)
♦ Oops, must test snippets before submitting :)
I'm not even going to read the replies first because I have my own. I
was a C and C++ programmer exclusively for over a decade. During that
time I had a "whatever tool for the problem" approach to language
selection but C++ continued to be the best for the sort of thing I was
doing. During that time I continued to learn other languages at least
enough to consider them. I appreciated the role of interpreted
languages were filling, but also never felt comfortable in them.
Python, imo, is an excellent language to learn as a C++ programmer.
It is relatively easy to extend with C/C++ and so works together well.
When you find yourself writing some configuration language, you'll be
able to use python instead. Also, I have found that Python helped
open my mind a bit about object orientation and to realize that while
the compile-time decisions in C++ are great for the C/C++ linking
model, and provides a certain sort of power and control, that it also
really does (as many had complained to me) take a few blows at how you
really want OO to work.
So I love python's OO and things which can be done structurally in C++
(like metaclass programming) but with which the C++ syntax is not
cooperative, and which is very much harder to safely extend modularity
too (I could go into detail but why bother here, it's either already
clear what I mean or isn't that important)...
Finally, Python is a multiparadigmed language, like C++. It very much
seems to believe in Bjarne's original trust the programmer outlook on
languages. As a C++ programmer I enjoyed the responsibility and
power of choosing one's paradigms at the outset of a project. Such
choices are best made consciously, one learns a lot about their
project and develops a lot of philosophical standards for the design
and implementation by having to think first "what models and
programming paradigms will we adopt". It makes you think what sort of
code you will be writing often, and which idioms will be efficient and
maintainable.
Honestly, I've become more of a Python fan than I am really
comfortable with... it can't be as good as I think.
-craig
Don't fight it, just go with it man... just go with it! *wink*
What Can I say guys?
I really appreciate your help here. Thanks for your answers. I have read
all of them :P. Yes. Thanks for the websites: Dive In Python and
docs.python.org. And I most say I have been convinced to take it as
another tool for the programmer.
PS. Tomasz, thanks for pl.comp.lang.python I have been there and even
asked similar queastion =). Regards/Pozdrawiam
Ditto! Although I suppose you could just go for the jugular and say
that C++ is the BASIC of the 1990s.
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/
"Programming language design is not a rational science. Most reasoning
about it is at best rationalization of gut feelings, and at worst plain
wrong." --GvR, python-ideas, 2009-3-1
That long? It only took me six minutes.
Even if assembler language is specific to one architecture, the
principles that it teaches are universal and fundamental to all other
programming languages.
Besides, programming in assembler can be fun, in a sick sort of
way... :-)
> In article <49b58b35$0$3548$426a...@news.free.fr>,
> Bruno Desthuilliers <bdesth.qu...@free.quelquepart.fr> wrote:
>> Tomasz Rola a écrit :
>>>
>>> I may not be objective (tried Java, hated it after 6 years).
>>
>> Arf - only took me 6 months !-)
>
> That long? It only took me six minutes.
I was young and foolish - I actually thought Java was a decent language for a few months - until I had to maintain a program written by outside contractors. This was back in the Java 1.1 days ...
Tim Delaney
> --===============0027953262==
>
> In article <49b58b35$0$3548$426a...@news.free.fr>,
> Bruno Desthuilliers <bdesth.qu...@free.quelquepart.fr> wrote:
> >Tomasz Rola a écrit :
> >>
> >> I may not be objective (tried Java, hated it after 6 years).
> >
> >Arf - only took me 6 months !-)
>
> That long? It only took me six minutes.
Guess what, there was a time when Java was looking quite promising.
Especially in the field of distributed computing (which then meant not
only high performance clusters). And computers were of more than one type,
used other cpus than Intel, too.
Maybe it's easier to ridicule Java now, when it has not met the
expectations. But still, some people (better than I) have spent few
years writing software and doing their research in Java. Sure, that was
before Java had been nominated the common denominator of programming
languages.
Regards,
So? By the time Java was released, Python had already been around for
several years. Taking C++ and turning it into a VM model does not
exactly strike me as particularly good use of resources.
> --===============0836317661==
>
> So? By the time Java was released, Python had already been around for
> several years.
I've started to use Python around 1.5. If it could interest me more than
Java earlier than that, I don't know.
> Taking C++ and turning it into a VM model does not
> exactly strike me as particularly good use of resources.
It doesn't strike me either. But resources are not the only dimension of
judging the language, you know.
Also, I never actually liked the idea of dumbing down C++.
But, as I said, Java had some weight in the past (and some promises have
been made about its future and not kept). I felt that dismissing it "after
six minutes" might have been a little bit unfair. You should have done it
after a week.
:-).
BTW, if you spent a day on this, you could learn about few other Java
implementations, some of them not so resource hungry. Not that it makes
Java much better, but your choice could be better informed. Eh, English -
not sure if it is really what I've wanted to say :-).
Regards
You misunderstand me: I was talking about the resources (people and
money) used to create Java.
>But, as I said, Java had some weight in the past (and some promises have
>been made about its future and not kept). I felt that dismissing it "after
>six minutes" might have been a little bit unfair. You should have done it
>after a week.
>
>:-).
Java is yet another language with heavy static typing and an
object-oriented focus. What should have caused me to waste more time
before dismissing it?
Ouch ! This hurts !
> In article <Pine.LNX.4.64.09...@tau.ceti.pl>,
> Tomasz Rola <rto...@ceti.com.pl> wrote:
> >On Sat, 20 Mar 2009, Aahz wrote:
> >>
> >> Taking C++ and turning it into a VM model does not exactly strike me
> >> as particularly good use of resources.
> >
> >It doesn't strike me either. But resources are not the only dimension of
> >judging the language, you know.
>
> You misunderstand me: I was talking about the resources (people and
> money) used to create Java.
Ah, I see now. From my perspective, it depends on how things ended. Since
Java went into VB-like direction, I think I can agree. They have to go
deeper and deeper into this... dead end (business decisions and the like).
But it wasn't always looking as bad as now, so, you know, it is always
easy to judge past, especially knowing that something was a failure. As I
was reading about Java's prospects long ago, the use of people and money
by Sun seemed like quite good way of spending resources (not best, but
justified). In my opinion, it was the direction Java took somewhere around
dot com burst that has really sinked it (namely, letting go of innovating
aspect and pushing Java as, pardon the word, "business-level solution").
> Java is yet another language with heavy static typing and an
> object-oriented focus. What should have caused me to waste more time
> before dismissing it?
Really, I don't know. From how you wrote it, seems you had not much need
to investigate the subject. So, since you did not feel such need in the
first place, it could be difficult to convince you.
It really depends on what kind of programs you write (or are going to
write). For me, there are some cases, when I would at least consider Java
during design phase:
1. Writing code that has to be, umh, mobile (not in a cell phone sense).
Working on a network, sending code to other nodes. Special case - when
this code has to do some computations, not heavy enough to justify using
C, but still enough so that JIT is an advantage (even though JIT may not
be available on every node type). And, of course, having a C compiler on
every node is not always feasible. My favourites at the moment would be:
- Scheme. PLT Scheme has JIT and is my current workhorse language. It is
possible to find other Scheme flavors on almost any >=32-bit cpu. Cons:
all those flavors, albeit very similar and based on well defined common
standard - to be frank, not so common anymore, but this is irrelevant -
are still a bit different which can get problematic).
- Java. Has JIT and is quite ubiquitous, from mainframes to cellphones.
Cons: different Java flavors, EE, SE, MIDP... are quite different and
their common subset is too simple for my taste.
- Python. I like it more than Java, sometimes it is possible to use JIT.
Still, the fact that I like it does not always help enough to use it.
- Erlang? Who knows, I would have to read more about it first.
2. Using code written in few different languages:
- Common Lisp. Right now, I don't actually feel like I can program in it,
but from what I have read here and there, hacking REPL into accepting
foreign code is a lot of fun and adventure, so if only I had enough time
to learn, I would go for it, I suppose. Also, there is a possibility
(theoretical at least) to compile the whole shebang into native code.
- Java. As a platform, Java has a number of other languages
implementations on top of its JVM. They are a bit slow from what I read
but they are here long enough to be considered stable and/or mature.
- Python is not a big contender here, it is not a platform. It is still
possible to glue different libraries and interpreters with it (like Sage),
but this is not always convenient.
- Mono. I know it not well enough to consider its use. But maybe, maybe.
I hope this answered your question, at least partially. Learning Java as a
good Python or anything replacement is not a case, I think. However,
learning about it to have more choices is rather good idea. At least I
myself am not too sorry about knowing Java, maybe I should have just
jumped off its vagon a year or two earlier than I did.
BTW, I realise that there may be some costly alternatives to everything I
wrote above. But I am not interested so I would not consider them :-),
Regards,
> I've only read he subject and a few lines from other responses.
>
> yes, it is worth learning. I came from PHP to Python. It's very powerful and
> makes application development easier for me than in PHP and/or C#, but bash,
> well that depends on the type of bash. It has a lot of diffent ways you can
> use it too, so that adds to how powerful it is.
IMHO, Bash is great for quick and dirty hacks, as a kind of simplified
Perl. But when bash script grows too big, I would consider rewriting it in
Python rather than Perl. But this is just my personal choice.
Since we are already a little offtopic :-), did you see any speed
difference between PHP and Python? I understand, that you are doing web
devel in those two?
> -Alex Goretoy
> http://www.goretoy.com
> I really can't say too much about speed increase or decrease, it really
> depends on the site and how its built, what libs are used and how they are
> loaded, same thing in PHP, It would be difficult for me to same anything on
> speed because of that. I built a templated modulated cms in CodeIgniter(PHP
> MVC), google it, It is a base for a templated system. using smarty and ci
> templating syntax, although the smarty side of things makes it slower I
> think. Also it is modulated, which breaks up your code into modules that you
> can load on the page into a div with ajax, preferrably jquery but you can
> use any framework for that too
I see. Thanks for answering.