Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Perl or Python? [It is decided: Perl]

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply

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

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

Message
Author
thamarok

Perl or Python? [It is decided: Perl]

#1 Post by thamarok »

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.

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

#2 Post by Lavene »

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

thamarok

#3 Post by thamarok »

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

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

#4 Post by epostma »

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,

thamarok

#5 Post by thamarok »

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.

User avatar
drl
Posts: 427
Joined: 2006-09-20 02:27
Location: Saint Paul, Minnesota, USA

#6 Post by drl »

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

thamarok

#7 Post by thamarok »

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

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

#8 Post by epostma »

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 :),

thamarok

#9 Post by thamarok »

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

User avatar
_FOCUS_
Posts: 205
Joined: 2006-02-22 18:11

#10 Post by _FOCUS_ »

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.

thamarok

#11 Post by thamarok »

?

ignore this

Post Reply