Linux - NewbieThis 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.
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.
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.
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.
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:
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.
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?).
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:
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 ;)
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
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.
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.
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!
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.
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 ...
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.