Perl or Python? [It is decided: Perl]

Need help with C, C++, perl, python, etc?

Please read my post and then answer this: Which should I use? Perl or Python?

Perl
6
55%
Python
5
45%
 
Total votes : 11

Perl or Python? [It is decided: Perl]

Postby thamarok » 2006-11-20 13:05

Hello!

I have been thinking of switching from assembly to a high-level language and Perl and Python are quite interesting.. But I don't know which to choose.

My previous experience with assembly: You might think using assembly is very bad, and it might be, but I started a project about 2 years ago... This project was about making my own high-level language. Firstly, I added some basic macros and functions, then every day more macros and features, until I came this far. With 'this far' I mean that I got a very powerful macro and function set that I was able to do complex programs with ease. Ofcourse the sourcecodes got big, but as long as they work it's good.

And so, I have been programming in assembly, and it was a lot of fun, but then I discovered that the outputted binary would not work on all machines, so AMD users would have to say bye for my applications... That's why I need to choose my new language of choice.
Also, I have been getting serious about programming, because I have also bought a QT license. I think I'll use QT for my applications, but I think it might be time to test out the KDE libraries also.

What I would need in either Perl or Python:
1. Easily import so libraries and use their functions directly.
2. Use the native KDE (not QT) libraries to make GUIs.
3. Should be powerful enough to make some complex stuff like a 32-bit music sequencer.

Thanks! Every kind of help is highly appreciated!
Last edited by thamarok on 2006-11-20 14:47, edited 1 time in total.
thamarok
 

Postby Lavene » 2006-11-20 14:15

Well, I'm just a 'hobbyist' and haven't done alot of real advanced programming but I like Python. Perl is nice too but I haven't done enough of it to know if it's 'better' than Python.

I just want to remind you that both are interpreted languages and hench might not offer the required speed and efficiency you probably need for your music app.

As for your requirements; it's mostly over my head I'm afraid. I do have some knowledge about using Qt/ Python but that's about it...

Tina
Lavene
Site admin
 
Posts: 5096
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby thamarok » 2006-11-20 14:51

I decided that I will use Perl for my programming.
The Wikipedia site helped me a lot to do the decision: http://en.wikipedia.org/wiki/Perl

Perl looks like it is exactly what I want. And what I like very much with it, is it's style as a script-language just like JavaScript, but the difference is, this one can be used also for applications, not only www-sites.

The Wikipedia site has also a link to a page with Perl optimization tricks, I think these are going to help me much. Also I can just look at the source of Perl Kana Editor to make my first Hello World! program.

Thanks to everyone who has read this post.
This post will destroy itself within 20 seconds. Don't panic; it's just a post.









:P
thamarok
 

Postby epostma » 2006-11-22 17:10

Hi thamarok,

I realize that your choice has already been made, but I'll suggest Python anyway. To my mind, Perl is an absolutely great language for small projects that you jot together quickly to get a task done then throw away, whereas Python is more of a serious language for programs that you'd like to be maintainable. In other words: for writing programs, they are about equally suitable in general, but Perl is impossible to read some time after you've written it whereas Python is inducive to writing legible programs.

I realize that all of these are matters of taste, and that I maybe don't even write about them very eloquently, but Eric Raymond does at http://www.linuxjournal.com/article/3882; he also compares extensively with perl in that piece. Yes, this is the Eric Raymond from "The Cathedral and the Bazaar", which you should read if you haven't -- google it, first hit.

By the way, if you would decide to go with Python after all, optimizing python with psyco is laughably simple and amazingly effective.

HTH,
epostma
 
Posts: 67
Joined: 2006-01-06 13:58

Postby thamarok » 2006-11-22 18:45

Thank you for your reply, I was waiting for it :P
I have already made some stuff with Perl, and it suits very good, and I would use Python, but it doesn't allow this:
Code: Select all
$a="text";
print "Yeah, this is just some $a..";


I would have to do this in Python:
a="text"
print ""Yeah, this is just some "+a+".."


And I love Perl now since I discovered perlcc, a command-line program to make Perl scripts into ELF binaries. If Python would allow that, then it might be also a good choice.
thamarok
 

Postby drl » 2006-11-22 22:07

Hi, thamarok.

I think perl can be seductive in its leniency -- you can type almost anything and it will do something.

I'm guessing that since you wrote a lot in assembly that you are a disciplined programmer. You are in a good position to develop good perl habits, and so you may want to avoid maintenance headaches by looking over Perl Best Practices. A lot of perl-folks think very highly of it ... cheers, drl

( edits: typos )
Last edited by drl on 2006-11-23 15:25, edited 2 times in total.
["Sure, I can help you with that." -- USBank voice recognition system.
( Mn, 2.6.x, AMD-64 3000+, ASUS A8V Deluxe, 3 GB, SATA + IDE, NV34 )
Debian Wiki | Packages | Backports | Netinstall
User avatar
drl
 
Posts: 434
Joined: 2006-09-20 02:27
Location: Saint Paul, Minnesota, USA

Postby thamarok » 2006-11-23 12:23

Thanks :)
I will still code in ASM, but mostly to make .so libraries which I can later use in my Perl scripts :D
thamarok
 

Postby epostma » 2006-11-24 15:59

Hi,

As a small addendum: I have heard of programs similar to perlcc but for Python, but all they do, in effect, is package up the python interpreter with your program. And, by the way, I'd think the closest python comes to the perlism
Code: Select all
$a="text";
print "Yeah, this is just some $a..";

is its own amazing type of string interpolation (sprintf-like):
Code: Select all
a="text"
print "Yeah, this is just some %s.." % a

which is (reportedly) more efficient than concatenation in addition to being more legible. To substitute multiple variables, use a tuple, as in:
Code: Select all
user="erik"
engine="google"
print "%s likes using %s" % (user, engine)


Anyway, wishing you happy perl hacking :),
epostma
 
Posts: 67
Joined: 2006-01-06 13:58

Postby thamarok » 2006-11-24 20:02

Thanks :D
Here are another two examples showing how Python and Perl communicate with STDIN:

Perl:
Code: Select all
print "What's your name? ";
chomp($in=<STDIN>);
print "Hello $in!\n";


Python:
Code: Select all
print "What's your name? "
a=raw_input()
print "Hello "+a+"!"


The above examples ask the user for their name and then the script prints out "Hello <name>!".
As you see, Python might be easier in this, but I like the Perl code more :D

It's actually about liking, not about performance, but that's me so just ignore this :P
thamarok
 

Postby _FOCUS_ » 2006-11-27 09:14

I read a writing about hackers and history of hackers. Then I decided to learn python according to suggestion of author of the writing. So I recommend to you python.
If you love something, let it go. If it comes back to you, it's yours. If it's run over by a car, you don't want it.
User avatar
_FOCUS_
 
Posts: 205
Joined: 2006-02-22 18:11

Postby thamarok » 2006-11-27 18:31

?

ignore this
thamarok
 


Return to Programming

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable