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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
03-06-2005, 04:36 AM
|
#16
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,380
|
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.
|
|
|
03-06-2005, 04:41 AM
|
#17
|
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337
Rep:
|
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.
|
|
|
03-06-2005, 05:05 AM
|
#18
|
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337
Rep:
|
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.
|
|
|
03-06-2005, 05:55 AM
|
#19
|
Member
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410
Rep:
|
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
|
|
|
03-06-2005, 06:15 AM
|
#20
|
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337
Rep:
|
Hey, thanks enemorales! Very cool link and I never heard of that "psyco" before either
Thanks again!
|
|
|
03-06-2005, 11:40 AM
|
#21
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
03-06-2005, 11:45 AM
|
#22
|
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337
Rep:
|
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 
|
|
|
03-06-2005, 01:47 PM
|
#23
|
Member
Registered: Jul 2003
Distribution: Debian
Posts: 102
Rep:
|
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
|
|
|
03-06-2005, 11:22 PM
|
#24
|
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337
Rep:
|
Oh my, I not even knew there were so many programming languages  . Thanks for the link!
|
|
|
03-07-2005, 01:10 AM
|
#25
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
03-09-2005, 01:00 PM
|
#26
|
Member
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170
Rep:
|
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/
|
|
|
03-09-2005, 01:38 PM
|
#27
|
Senior Member
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938
Rep:
|
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!
|
|
|
03-09-2005, 10:38 PM
|
#28
|
LQ Guru
Registered: Jan 2002
Posts: 6,042
Rep: 
|
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.
|
|
|
03-09-2005, 11:42 PM
|
#29
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
03-12-2005, 12:08 AM
|
#30
|
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337
Rep:
|
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...
|
|
|
All times are GMT -5. The time now is 06:45 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|