Home
Tuesday, May 30, 2017
8:50:42 AM
Users online: 0   You are here >> Home > Programming

Forums | Programming Forums search
Forum FAQ
   
  1 | 2 Next Page 
Perl or Python?
robzy 
25/7/08 5:02:42 PM
Hero
Immortal


Which is better? :P

Or rather - which language is suited to which applications?

What is portability between Windows/Linux/Etc like?

How easy is it to make full-blown-GUI applications with with each of them?

Is it possible to "compile" the code+interpreted into one EXE/binfile of either of them?

Rob.

-----
עם ישראל חי

zephyr 
25/7/08 6:32:42 PM
Hero
Titan


Go python. Perl is dead, it just doesn't realise it yet :-p

-----
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in. We're computer professionals. We cause accidents. (N. Borenstein)

robzy 
25/7/08 10:35:53 PM
Hero
Immortal


Is Python going to give me more power than VB6 does?

Honestly, at the moment, it doesnt seem all that serious.

(I'm currently reading through http://docs.python.org/tut )

Rob.


Edited by robzy: 25/7/2008 10:37:55 PM

-----
עם ישראל חי

pwarren 
26/7/08 12:35:26 AM
Overlord

Another vote for python if you have the choice. Far more cross platform support, including a windowing/event driven gui framework (wxWindows), a really cool networking framework (twisted), and it's actually hard to write obfuscated code in python. And yeah, perl is only used by people who sysadmined unix boxes in the 80s and early 90's ;)

as to comparing it with VB6, I've no idea, never used any sort of visual basic.

edit:
heh, just looking at some obfuscated python code, looks like you have to fall back to lambda calculations, which make any language obfuscated.


Edited by pwarren: 26/7/2008 12:39:57 AM

-----
“Money is a powerful aphrodisiac. But flowers work almost as well.”
-- Lazarus Long

robzy 
26/7/08 1:49:44 AM
Hero
Immortal


Python is a pain in the arse :P

Let's just say I have a string variable filled with thousands of characters, what's the best way of finding [capital][capital][captial][lowercase][capital][capital[capital] and outputting that to the screen?

I did it by incrementing through each letter and checking it using 7 nested if statements.

[edit]: How about using regex and "[A-Z]{3}[a-z][A-Z]{3}"?

Rob.


Edited by robzy: 26/7/2008 02:13:56 AM

-----
עם ישראל חי

Girvo 
26/7/08 12:12:59 PM
Immortal

Python by far. Perl is painful.


Alternativley, Ruby! :P

-----
Quote by Disco
Edit: I got my own age wrong? o_0



pwarren 
26/7/08 12:58:24 PM
Overlord

heh, use the right tool for the job, for pattern matching in text regular expressions are the right tool :)

for a helper on RE's in python:

http://www.amk.ca/python/howto/regex/

-----
“Money is a powerful aphrodisiac. But flowers work almost as well.”
-- Lazarus Long

boyter 
26/7/08 2:03:33 PM
Guru

Python. I <3 Python and how expressive it is in so few lines. You just write psuedocode indent it and you have a working Python program.

-----
http://www.boyter.org

Sorceror 
26/7/08 7:44:17 PM
Master

Python all the way, I've been doing some Perl stuff at work recently and it's horrible.

-----
Ycros/Sorcy/Sorceror

hetman 
27/7/08 10:57:16 PM
Hero
Titan


Ruby!

Here's how you'd tackle your problem in Python:
import re 

for match in re.finditer(r'([A-Z]{3}[a-z][A-Z]{3})', some_string):
print match.groups()[0]


And here it is in Ruby:
some_string.scan(/[A-Z]{3}[a-z][A-Z]{3}/) do |match| 
puts match
end



For text processing applications I would seriously recommend Ruby. It has all the convenience of Perl, it borrowed a lot of syntax from Perl... although its modern syntax probably resembles Python more than Perl. It also took the highly structured object model from Smalltalk so it's not a smattered mess like Perl.

And once your regular expresions get large you can do things like the following which let me tell you does wonders for readability (*remembers RFC compliant implementation of server side cookie parser*):

caps = /[A-Z]{3}/ 
some_string.scan(/#{caps}
[a-z]
#{caps}/x) do |match|
puts match
end


In Python the equivalent might look something like this:

import re 
from string import Template

caps = r'[A-Z]{3}'
reg = Template(r'''($caps
[a-z]
$caps)''').substitute(caps=caps)
for match in re.finditer(reg, some_string, re.VERBOSE):
print match.groups()[0]



Look, whatever you do... just don't use Perl... for the sake of all that is holy!

-----
Wystarczy tego medrkowania.

freespace 
28/7/08 2:08:16 AM
Hero
Titan


Definitely python, for the ability to read what you wrote 2 days later if nothing else ;-)

-----
By perseverance the snail reached the ark.

http://www.shuningbian.net - blog
http://anonshare.pictorii.com - share files anonymously
http://dailydiscovery.b3ta.org - learn something new
its f reespace damn it!

robzy 
28/7/08 4:30:09 PM
Hero
Immortal


Okay, so it sounds like Python :)

hetman: I'm not just going to be doing string parsing, I'm pretty much going to be doing everything under the sun actually :P Python seems like it covers all bases.

To be honest though, it really doesn't feel any more powerful that VB6, and having to indent my code according to someone else's conventions sucks :P

Also, what WinXP IDE for Python should I be using? IDLE is giving me the shits :P It's cumbersome, and the built in text editor often can't decide between tabs or spaces, breaking my indents.

Rob.

-----
&#1506;&#1501; &#1497;&#1513;&#1512;&#1488;&#1500; &#1495;&#1497;

freespace 
29/7/08 1:37:41 AM
Hero
Titan


Quote by robzy
Okay, so it sounds like Python :)
To be honest though, it really doesn't feel any more powerful that VB6, and having to indent my code according to someone else's conventions sucks :P
Rob.

That's cause you aren't using some of its more advanced features, like say, decorators, or lambda functions, etc.

As for indentation, while I dislike white-space-as-syntax, at least your code will _be_ indented :-)

Pray tell, you a spaces man or a tabs man?

-----
By perseverance the snail reached the ark.

http://www.shuningbian.net - blog
http://anonshare.pictorii.com - share files anonymously
http://dailydiscovery.b3ta.org - learn something new
its f reespace damn it!

robzy 
29/7/08 3:25:45 AM
Hero
Immortal


Quote by freespace
Quote by robzy
Okay, so it sounds like Python :)
To be honest though, it really doesn't feel any more powerful that VB6, and having to indent my code according to someone else's conventions sucks :P
Rob.

That's cause you aren't using some of its more advanced features, like say, decorators, or lambda functions, etc.

As for indentation, while I dislike white-space-as-syntax, at least your code will _be_ indented :-)

Pray tell, you a spaces man or a tabs man?


IDLE pretty much forces me to use spaces, which imho is stupid :P

Looking for a better IDE...

Rob.

-----
&#1506;&#1501; &#1497;&#1513;&#1512;&#1488;&#1500; &#1495;&#1497;

pwarren 
29/7/08 12:07:43 PM
Overlord

bah who needs an IDE, just use emacs :)

-----
“Money is a powerful aphrodisiac. But flowers work almost as well.”
-- Lazarus Long

Girvo 
29/7/08 3:55:01 PM
Immortal

Na, vi.



:P

-----
Quote by Disco
Edit: I got my own age wrong? o_0



robzy 
29/7/08 6:08:20 PM
Hero
Immortal


vi > emacs

Something with auto-complete (like IDLE) would be great though.

If not I'll just go with Notepad++

Rob.

-----
&#1506;&#1501; &#1497;&#1513;&#1512;&#1488;&#1500; &#1495;&#1497;

boyter 
29/7/08 7:30:22 PM
Guru

If you want an IDE go for Eclipse with PyDev plugin. Generally I use emacs though.

-----
http://www.boyter.org

hetman 
29/7/08 8:16:07 PM
Hero
Titan


robzy - Ruby covers all bases very well, it just happens to cover the string parsing ones better than Python :)

Other than that, both languages essentially target the same application space so it comes down to your personal style on which you like better.

Ruby encourages meta-programming, Python conventions tends to shy from it. Python objects are attribute centric, Ruby objects are message centric... I find as a result you have to wade through a lot of interface protocols in Python to get what you get for free with basic Ruby objects.

One of the most noticeable aspects of the Python philosophy is that there should only be one obvious way to do things (which is why it's missing a case statement for example). The primary driver behind Ruby is that the language should be user centric, not computer centric (with the corollary that sometimes there's more than one good way to do things).

And the clincher: Ruby is not whitespace dependant :) Though you'll find you'll get used to that in time in Python.

You can't really go wrong with either language but do investigate them both enough to get a feel for which suits your style best.


Edited by hetman: 29/7/2008 08:20:08 PM

-----
Wystarczy tego medrkowania.

Sorceror 
30/7/08 12:43:27 AM
Master

I'm guessing you didn't Google for "Python IDE" or you would have found this: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments

IMO WingIde is the best (and I use it), but it's not free.

I think it'd be nice if Python only supported one style of indentation (ie. spaces OR tabs), that said I always stick to 4-spaces because this is the main convention and what the style guide ( http://www.python.org/dev/peps/pep-0008/ ) recommends. Pretty much all Python code I've encountered is 4-space indented.


Edited by Sorceror: 30/7/2008 12:43:44 AM

-----
Ycros/Sorcy/Sorceror

  1 | 2  | Next Page 
Forums | Programming