Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

69 views
Skip to first unread message

pintreo mardi

unread,
Jan 11, 2014, 3:07:37 AM1/11/14
to
Hi, I've just begun to learn programming, I have an open question for the group:
Is the Python language an all in one computer language which could replace C, C++, Java etc.. I only ask becuase I am starting off with python and I want to learn everything in basic and advanced programming with python itself...So any advice and suggestions would be more than welcome.
Thanks!!

Chris Angelico

unread,
Jan 11, 2014, 3:21:53 AM1/11/14
to pytho...@python.org
Python is a viable applications language, yes. There's nothing you
can't write in Python that you can write in (say) Java - both
languages are what's called "Turing complete". Every language has its
special focus, though, so there'll be some things that are far easier
in one language than another. In general, Python is a fine language
for simple tasks like printing "Hello, world", for scripting, for
writing GUI programs, and for building web applications. It's not
restricted to tiny projects or to huge ones. There's no critical limit
on the amount of "stuff" you can do before the code gets unwieldy, for
instance, nor is there a level below which it's just too much hassle
to put together a program.

ChrisA

pintreo mardi

unread,
Jan 11, 2014, 5:10:18 AM1/11/14
to
Thanks mate!! I'm a bit relieved. If I could get some really good books on programming with python, those for the beginners would be very helpful.

Mark Lawrence

unread,
Jan 11, 2014, 5:47:00 AM1/11/14
to pytho...@python.org
https://mail.python.org/pipermail/python-list/2002-November/141486.html

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Mark Lawrence

unread,
Jan 11, 2014, 5:51:41 AM1/11/14
to pytho...@python.org
No, no, no, this can't be happening!!! Surely outlook can't have caught
double spaced google disease, please see
https://wiki.python.org/moin/GoogleGroupsPython for a description of the
original problem and compare it to what's shown above.

Roy Smith

unread,
Jan 11, 2014, 10:45:53 AM1/11/14
to
In article <18b67e59-39d1-41e2...@googlegroups.com>,
That's a really hard question to answer, or at least to answer well.

At a theoretical level, when you ask, "Is Python equivalent to C, C++
and Java", the answer is "yes". In computer science, programming
languages are classified by whether they are "Turing Complete" or not
(google that for more info). In theory, any Turing Complete language is
capable of writing all programs which can be written in any other Turing
Complete language. All of the languages you mention are Turing
Complete, so, theoretically, they are all equivalent.

But, at a more practical level, some languages are easier to learn, some
run faster, some are more portable, some are more convenient to use,
etc. If I had to rank the languages you mention by a few categories,
I'd say something like:

Python: Easiest to learn (and use), slowest execution speed.

C: Pretty easy to learn, but difficult to write large projects in,
fastest execution speed.

C++: Hardest to learn, hard to use, speed close to C.

Java: Somewhere in-between Python and C++ on all counts.

All of these are currently in widespread commercial use today, so you
can't go too far wrong staring out with any of them. The TIOBE people
have been tracking programming language popularity for a long time
(http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html), so
that's a good place to get some vague idea of what's hot and what's not.

One thing to be aware of is that some programming domains require a
specific language. If you want to do iOS, you need Objective C. For
Android, Java. Web front-end programming, Javascript. No getting away
from those. In the server environment, it's a much more wide-open
field. People write web servers, for example, in Python, Ruby, Scala,
Javascript, PHP, Java, and probably a host of other languages.

This has already turned into a longer essay than I intended, but there's
just one thing I wanted to add. Whatever you pick to learn first,
realize that if you embark on a life-long career in programming, it
won't be your last. Languages come and go. I've done serious work in
(in vaguely chronological order) Fortran, C, Python, Tcl, Perl, C++, and
PHP.

So, pick one, spend a year getting really good at it, then pick another
language, preferably one that's very different, and learn that too.
Repeat every so often :-)

Dave Angel

unread,
Jan 11, 2014, 7:37:40 PM1/11/14
to pytho...@python.org
pintreo mardi <bigea...@outlook.com> Wrote in message:
> Hi, I've just begun to learn programming, I have an open question for the group:
> Is the Python language an all in one computer language which could replace C, C++, Java etc.. I only ask becuase I am starting off with python and I want to learn everything in basic and advanced programming with python itself...So any advice and suggestions would be more than welcome.
> Thanks!!
>

As others have said you can do nearly anything in any of those
languages. But you can expect to learn and use many over time.
I've used about 35 professionally, and a few more for fun. I've
done substantial work in machine language and also in microcode.
Sometimes I had to write the assembler, simulator, and debugger
while the actual machine was being designed. Was python an
appropriate language to write add and subtract in? Nope.


--
DaveA nr



----Android NewsGroup Reader----
http://www.piaohong.tk/newsgroup

Matěj Cepl

unread,
Jan 11, 2014, 8:36:15 PM1/11/14
to pytho...@python.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2014-01-11, 08:07 GMT, you wrote:
> Hi, I've just begun to learn programming, I have an open question for the group:
> Is the Python language an all in one computer language which could replace C, C++, Java etc.. I only ask becuase I am starting off with python and I want to learn everything in basic and advanced programming with python itself...So any advice and suggestions would be more than welcome.

- From one side this answer is probably as meaningful as the one
from the Alice in Wonderland
(http://www.gutenberg.org/files/19033/19033-h/19033-h.htm, page
35): “Why is a raven like a writing-desk?” These are just
different programming languages each designed for different
purpose. On the other hand what people said about Turing
complete langauges is true as well. So, yes it is true that
any Turing complete language you can write anything you wrote
in another Turing complete language. It doesn’t mean however
that it would be as easy or as efficient tool for doing so.
Some languages are specialized for high-power low-level
specialist programming of low-level stuff (e.g., almost all
serious operating systems are written in C), some are better
suited for writing enormous complicated projects consisting
of thousands of modules (Java, C++, Ada), some are designed
to be very easy to write (that doesn’t mean primitive)
although the speed and processing power of the result may
suffer a little bit (JavaScript, Python, Perl, Ruby).

If you ask for the language to start to learn programming as
such, then Python was oriiginally intended exactly for that
purpose (fortunately, it was written so well, it is now used en
masse for “serious” large programming projects as well). FOr the
list of resources take a look at
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers .
Particularly, I’ve heard a lot of good things about “How to
Think Like a Computer Scientist”. You won’t hurt yourself if you
start there.

Best,

Matěj

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iD8DBQFS0fGP4J/vJdlkhKwRAu6TAKCCdGP9b3z2M+NJlIY4HnqZFi+v3gCfYgE0
69QHLyfyG//dFhb9pcjdoNk=
=y2k/
-----END PGP SIGNATURE-----

Dan Stromberg

unread,
Jan 11, 2014, 9:43:03 PM1/11/14
to pintreo mardi, Python List
As others have mentioned, they're all turing-complete. In other
words, with an infinite memory and infinite coding patience, they can
all solve the same problems.

The main distinctions, at least to my mind, are:
1) Python tends to require fewer words to solve the same problems, but
tends to be slow running.
2) C tends to be very fast running, but takes a lot of words to solve
the same problems, and is prone to hard-to-fix memory errors
3) C++ and Java aren't that different in performance today, because of
Java's good JIT.
4) Java's not great for systems programming (apparently can't detect
symlink races for example), but C, C++ and sometimes Python are.

Each language will tend to have API's (Application Programming
Interfaces) that make some classes of problems easier or harder.
API's are basically reusable code you can use to make your own
problems quicker and easier.

You probably wouldn't write an operating system kernel in Python -
it'd be too slow. However, writing an application in Python might be
a very good use of time.

If Python proves too slow for a problem (which is uncommon), you can
rewrite small portions in C to get good performance. Also, there is
another implementation of Python called PyPy that's much faster than
the reference implementation, which is known as CPython.

C++ and Java cover similar kinds of programming - they're both object
oriented C-like languages. However, C++ is more prone to memory
errors than Java, and I'm told that C++ has many incompatible
implementations of fundamental things like strings. For these
reasons, I'd recommend Java over C++ for most things (except systems
programming).

C, C++ and Java are all statically, manifestly typed. Python is duck
typed. These are fundamentally different approaches to program
correctness. In C, C++ and Java, programmers tend to assume that if a
program compiles, it's working. This is not a great assumption, but
it isn't that far off the mark, either. Python on the other hand,
will compile a lot more programs than those that work - for this
reason, it's a very good idea to use automated tests with Python.
Automated tests are a good idea with C, C++ and Java too, just not as
crucial.

HTH

Steve Hayes

unread,
Jan 12, 2014, 12:08:59 AM1/12/14
to
On Sat, 11 Jan 2014 10:45:53 -0500, Roy Smith <r...@panix.com> wrote:

>In article <18b67e59-39d1-41e2...@googlegroups.com>,
> pintreo mardi <bigea...@outlook.com> wrote:
>
>> Hi, I've just begun to learn programming, I have an open question for the
>> group:
>> Is the Python language an all in one computer language which could replace C,
>> C++, Java etc.. I only ask becuase I am starting off with python and I want
>> to learn everything in basic and advanced programming with python itself...So
>> any advice and suggestions would be more than welcome.
>> Thanks!!
>
>That's a really hard question to answer, or at least to answer well.
>
>At a theoretical level, when you ask, "Is Python equivalent to C, C++
>and Java", the answer is "yes". In computer science, programming
>languages are classified by whether they are "Turing Complete" or not
>(google that for more info). In theory, any Turing Complete language is
>capable of writing all programs which can be written in any other Turing
>Complete language. All of the languages you mention are Turing
>Complete, so, theoretically, they are all equivalent.
>
>But, at a more practical level, some languages are easier to learn, some
>run faster, some are more portable, some are more convenient to use,
>etc. If I had to rank the languages you mention by a few categories,
>I'd say something like:
>

I think the significant thing is that some languages are easier to use for
some things than for others. Though you can use any language to write any kind
of program in theory, in practice some languages are designed to write certain
kinds of programs more easily and more quickly -- Prolog for AI programs, for
example.

So the question is, which kinds of programs is Python best for?

I'm a novice at it, so it's a question that concerns me. From what I've heard
and read, it seems to be a fairly good general-purpose language, and it seems
to be most used for writing web applications (though that is not something I
am particularly interested in).


--
Steve Hayes from Tshwane, South Africa
Web: http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk

Chris Angelico

unread,
Jan 12, 2014, 12:58:45 AM1/12/14
to pytho...@python.org
On Sun, Jan 12, 2014 at 4:08 PM, Steve Hayes <haye...@telkomsa.net> wrote:
> So the question is, which kinds of programs is Python best for?
>
> I'm a novice at it, so it's a question that concerns me. From what I've heard
> and read, it seems to be a fairly good general-purpose language, and it seems
> to be most used for writing web applications (though that is not something I
> am particularly interested in).

Python puts heavy focus on code readability (which also means it's
easy to write). So it gains you hugely for small scripts, less so for
things that need to run millions of times a second.

Python has a variety of libraries that make it well suited to internet
applications (as server or as client).

Python, especially as of version 3.3, is superb at handling
internationalization, Unicode, and related messes - you can sort out
files of different encodings and rewrite them in something consistent
(eg UTF-8). It may seem a bit harder at first, as you're forced to
think about the meaning of bytes and what's text and so on, but it's
worth it.

Python is NOT good at massively parallel numerical calculations.... on
its own. But there are libraries that can do that sort of thing for
you (NumPy, SciPy); I've no idea how good they are because I neither
use them nor write code that would benefit from them, but they're
extremely popular and well-used.

As a general rule, if your program is likely to spend most of its time
waiting (for the disk, the network, the user, etc), then Python is
probably at least as good a choice as C, Java, or any other language,
and the question will come down to library support and such.

Python is also an excellent "super pocket calculator". The
reasonably-compact notation for aggregate operations (list
comprehensions and such) lets you work with a functional programming
style, and you can use step-by-step imperative programming in the same
way. Want to calculate the average result of rolling six six-sided
dice, and discarding any results below 14? Try this:

http://www.kickstarter.com/projects/916188323/doublesix-dice-roll-better/comments?cursor=5623335#comment-5623334

(BTW, is there no better notation than six nested for/range for doing
6d6? I couldn't think of one off-hand, but it didn't really much
matter anyway.)

The incremental execution of Python's interactive interpreter (REPL)
is extremely convenient for this. I personally like using IDLE for
this, as (unlike command-line Python) it will recall and edit an
entire suite, rather than one line at a time. Extremely handy.

ChrisA

Rotwang

unread,
Jan 12, 2014, 9:36:24 AM1/12/14
to
On 12/01/2014 05:58, Chris Angelico wrote:
> [...]
>
> (BTW, is there no better notation than six nested for/range for doing
> 6d6? I couldn't think of one off-hand, but it didn't really much
> matter anyway.)

If you're willing to do an import, then how about this:

>>> from itertools import product
>>> len([x for x in product(range(1, 7), repeat = 6) if sum(x) < 14])/6**6
0.03587962962962963

Chris Angelico

unread,
Jan 12, 2014, 9:44:28 AM1/12/14
to pytho...@python.org
Should have known itertools would have something. That's a little more
complicated to try to explain, but it's a lot shorter.

ChrisA

Grant Edwards

unread,
Jan 12, 2014, 1:53:48 PM1/12/14
to
On 2014-01-11, pintreo mardi <bigea...@outlook.com> wrote:

> Hi, I've just begun to learn programming, I have an open question for
> the group: Is the Python language an all in one computer language
> which could replace C, C++, Java etc..

No. Python can not replace C in a number of application areas:

* Bare-metal applications without an OS.

* Low-resource applications with limited memory (like a few KB).

* Device driver and kernel modules for OSes like Linux, Unix, (and,
AFAIK, Windows).

* Computationally intensive applications where there isn't a library
available written C or FORTRAN to do the heavy lifting.

For general application programming on a server or PC, then Python can
replace many/most uses of C/C++/Java.


--
Grant Edwards grant.b.edwards Yow! Look into my eyes and
at try to forget that you have
gmail.com a Macy's charge card!
0 new messages