LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-06-2005, 04:36 AM   #16
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,540

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041

Quote:
Originally posted by Megaman X
I'd say, go python first, you can't go wrong with it.
I'm not big on "religious wars". There's no such thing as wasted knowledge. Try any and every language that appeals.
Even if it all goes to shit, and you hate the language to hell, you've learnt something

Whilst I like Py, there are limitations that may cause it to be discarded by some.
 
Old 03-06-2005, 04:41 AM   #17
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
It's true and I could not agree more . Knowledge is good and a skilled programmer (not me, mind you, I suck at every possible language ever made) knows a lot of programming languages.

I just recommend python for a beginner because the syntax of C and C++ makes it more difficult to learn what programming truly is about: Finding solutions for a give problem. A beginner in C has more problems with the syntax then thinking clearly in a solution for the problem. Many give up right at the beginning because of a dated syntax from the 70's.

Not saying that C or C++ are bad. I love C above all others, but python really does, makes things easier and clearly, without discarding important subjects such as OO and memory management

Last edited by Mega Man X; 03-06-2005 at 04:43 AM.
 
Old 03-06-2005, 05:05 AM   #18
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Question Test!

Hi, I just did a little test with both C++ and python. I don't want to go so much off-topic nor start a flame war or anything, but this is what I did:

python
Code:
# test.py
for n in xrange(1000000):
    print n
C++
Code:
// test.cpp 
#include <iostream>
using namespace std;

int main(int argc,char *argv[]){

    for (int n = 0; n < 1000000; n++){
        cout << n << endl;
    }

}
The time they took to perform this test was:

C++: 59.09s
Python: 58.94s

I know, this is a dumb test, but in this case, there's virtually no difference between both of them. Now here is the catch: I just did this in my WinXP machine:

AMD Sempron 3000+
512MB DDR400
WinXP SP2
Borland C++
Python 2.3.5

I'd love to hear your experiences with g++ and python on a Linux box, since I can't boot into my Linux box right now and the console on XP kinda stinks too...

Last edited by Mega Man X; 03-06-2005 at 05:12 AM.
 
Old 03-06-2005, 05:55 AM   #19
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
I think that the answers depends on the application, but something that for me works in general is: prototype in Python (or Perl, if you need a lot of regular expressions) and go to C/C++ only if you don't find a way to improve your algorithm and still need more speed.

By the way, I'm just starting to learn python and I like it a lot. I've performed a "test" like yours the other day. I wanted to calculate PI by taking the ration between 2 integers less or equal than (not sure) 1000. C++ took something like 0.1 seconds while Python... I don't know, but was a lot more :-D (ten times?).

Anyway, if you are still interested in speed, you can look here http://www-106.ibm.com/developerwork...,lnxw16=PsycoC
 
Old 03-06-2005, 06:15 AM   #20
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Hey, thanks enemorales! Very cool link and I never heard of that "psyco" before either

Thanks again!
 
Old 03-06-2005, 11:40 AM   #21
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Re: Test!

Quote:
Originally posted by Megaman X
C++: 59.09s
Python: 58.94s

I know, this is a dumb test, but in this case, there's virtually no difference between both of them. Now here is the catch: I just did this in my WinXP machine:

AMD Sempron 3000+
512MB DDR400
WinXP SP2
Borland C++
Python 2.3.5

I'd love to hear your experiences with g++ and python on a Linux box, since I can't boot into my Linux box right now and the console on XP kinda stinks too... [/B]
Dumb is not the right word, you've tested the
speed of the terminal, though ... I've run your
test with Python, C++ and C on my notebook,
once with screen-output, once with a redirect.
(P4 1.8, 512MB, gcc & g++ 3.3.4, python 2.4
{compiled with the same compiler})

Here the results:


Code:
Python
real    0m21.804s
user    0m6.880s
sys     0m3.250s


C++
real    0m23.284s
user    0m5.960s
sys     0m2.720s


C
real    0m14.512s
user    0m1.030s
sys     0m1.960s



Python (redirect rather than term-output)
real    0m3.657s
user    0m3.560s
sys     0m0.040s


C++    (redirect rather than term-output)
real    0m9.321s
user    0m4.430s
sys     0m4.890s


C      (redirect rather than term-output)
real    0m0.479s
user    0m0.430s
sys     0m0.050s
I was a bit surprised to find that python outperformed
C++, and not surprised to see that C beats the crap
out of both of them ;)



Cheers,
Tink
 
Old 03-06-2005, 11:45 AM   #22
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Thanks a lot Tinkster!. That was kind of you for trying . And I've got surprised too. C is awesome. Even though this should not be used a benchmark for those languages, since a full program requires a lot of things as input, output, opening files and etc, this simple loop shows that python is quite there too.

Again, C is awesome. No wonders why Linux is written on it and is fast too
 
Old 03-06-2005, 01:47 PM   #23
SteveSch
Member
 
Registered: Jul 2003
Distribution: Debian
Posts: 102

Rep: Reputation: 15
Hi all,

Here is a link I find quite interesting.

http://www.99-bottles-of-beer.net/

Not about speed. It just shows the same result programmed with several, OK 600, languages.

Steve
 
Old 03-06-2005, 11:22 PM   #24
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Oh my, I not even knew there were so many programming languages . Thanks for the link!
 
Old 03-07-2005, 01:10 AM   #25
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by SteveSch
Hi all,

Here is a link I find quite interesting.

http://www.99-bottles-of-beer.net/

Not about speed. It just shows the same result programmed with several, OK 600, languages.

Steve
Does anyone know what that file is that that page
creates when one tries to view it with exploder?
Half of my windows-using colleagues couldn't see
the page (some use Mozilla) and it tried to d/l a
file instead (which contained THEIR "My Documents"
contents listing with some garbage ... very strange.


Cheers,
Tink
 
Old 03-09-2005, 01:00 PM   #26
wpn146
Member
 
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170

Rep: Reputation: 30
For platform independent development, the "mono" project is a .net implementation for Linux. They have much of the runtime done and a full C# compiler and they are working on a VB.net compiler. It is not quite ready for prime time yet, but I have compiled C# code on Windows, moved the .exe file to Linux and run them successfully on Linux, and vice versa.

See: http://www.go-mono.com/
 
Old 03-09-2005, 01:38 PM   #27
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Quote:
Originally posted by Megaman X

Just think about it, the only relevant line in the above C++ code is cout << "Hello there";. All the rest, regardless the book you are reading will threat the other lines as #include and what the braces does either in
Yes, but one example hardly proves that Python is more useful or versatile than C! It's like arguing that the pop band Aqua (or anyone else that had a single number 1) are better than Dire Straits because they never made it to number one!
 
Old 03-09-2005, 10:38 PM   #28
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Quote:
Originally posted by Tinkster
Does anyone know what that file is that that page
creates when one tries to view it with exploder?
Half of my windows-using colleagues couldn't see
the page (some use Mozilla) and it tried to d/l a
file instead (which contained THEIR "My Documents"
contents listing with some garbage ... very strange.


Cheers,
Tink
A tid bit of the song 99 bottles of beer on the wall in several programming langauges. Probably the proxy server or firewall is screwing up the information.

Where Python is very good is the code length and ease of debugging. Python is designed to be efficient, so the length of it is shorter than C or C++. With Python you can debug line by line very easily. C or C++ programming may have debug tools but they are mainly after compiling the code.
 
Old 03-09-2005, 11:42 PM   #29
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally posted by Electro
A tid bit of the song 99 bottles of beer on the wall in several programming langauges. Probably the proxy server or firewall is screwing up the information.
How would a coroprate firewall influence web-content
to scan the my documents folder? It didn't do that in
Mozilla, neither on WIndows nor (obviously) on Linux ...


Cheers,
Tink
 
Old 03-12-2005, 12:08 AM   #30
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
Quote:
Originally posted by Komakino
Yes, but one example hardly proves that Python is more useful or versatile than C! It's like arguing that the pop band Aqua (or anyone else that had a single number 1) are better than Dire Straits because they never made it to number one!
I never said that Python was more useful or versatile than C. I just said it's simpler to use and the syntax is cleaner then C, thus easier to learn and yet powerful. And the example above was just to prove that, nothing more, nothing less. And if you check python's documentation, you will find that all the syntax is simpler than C on every aspect...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
which programming language is used to do tcp/ip programming?? gajaykrishnan Linux - Networking 9 12-21-2012 05:16 AM
D Programming Language XsuX Programming 7 11-17-2004 08:55 PM
What programming language do you know? zikhermm Programming 11 09-15-2001 10:51 PM
Which programming language top111 Linux - Newbie 8 08-22-2001 07:21 PM
Programming Language Colonel Panic Programming 9 08-10-2001 01:57 AM


All times are GMT -5. The time now is 07:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration