SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question why Perl and Python

    Hi guys,
    I code in php for server side coding and I have seen some sites that user perl in their sites. I have also heard of some people using python, but never a live example.

    I was wondering if you could explain to me why one would use perl and or python, what is it for, and would it replace php and asp.net ?

    Because it sound interesting. Also are there any things that Perl and or python do that languages in the same category can not, if so what?

  2. #2
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    There is unlikely to be anything in particular that Perl or Python can do that PHP cannot. The reason to use the other languages is coding styles, syntax, community, available frameworks, and legacy/existing code.
    Some of the larger Perl-based sites may have started in Perl because back in the beginning of the web, Perl's all there was, really. Python, you can find it running the Planet sites (a series of wiki/blog things).

    While you may not see as much of it, you should probably add Ruby to your list. It too has its adherents (Twitter, for example).

    What specifically do you want to know about? At this point of the web, it's a bit like wondering why people wear other brands of jeans. They have their reasons, but to really find out why, you'd want to learn what specifically is different about any particular brand of jeans. Syntax would be one of the biggest differences, esp if you look at Perl.
    Well, after thinking about it, Python's syntax is pretty peculiar and notable because of its use of whitespace as block delimiters ("look ma, no braces!") and Ruby definitely wanted nicer, funner syntax than what you see in Perl, who has a lot from C, a lot from Unix, and whatever else it ran into in the early days.

    In the Perl Sticky, under the "Articles/blogs" section, there is a nice little bloggy story called "How I learnt to love Perl" which is specifically from a Java/PHP guy's point of view.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If you are looking for a site written in Python then perhaps the biggest example would be google.com
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Is the actual core of google written in Python? I know they embraced it hugely but I didn't know what exactly was written in Python over there.

    I mostly see Python in my computer: many of the Gnome desktop applications are written in Python, including yast, gEdit, and the orca screen reader.

  5. #5
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hmm,
    google.com
    i havnet heard of this before... ugh look at all the links-- bing is so much cleaner & more useful!

    So, I know php, what do you guys reccomend I start off with.
    From a sitepoint article, i read that one should learn the basics of ruby before ruby on rails.

    if it helps, I work with: C++, Java, PHP, HTML 4 & 5, CSS 2 & 3, Javascript, and jQuery.

    What do you think would be most useful and the easiest and best to be the first i learn out of Perl, Python, and Ruby?

    And by the most useful, I mean learning actionscript to make dynamic web-pages is something that wont better my skillset in web-design.

    Also, do you guys have any references or books that have helped you or you found useful when learning the language you recommend.

    Thanks for all your help!

    Best regards,
    Team 1504

  6. #6
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    What do you think would be most useful and the easiest and best to be the first i learn out of Perl, Python, and Ruby?
    You haven't said WHY you want/need to learn any of these languages. If you already know PHP, you know a language which is perfectly capable in web back-ends. If you know PHP and hate it, look at what is the core reason of existence for each of the above languages. Something particular to any one of them may catch your attention and look attractive.

    I'm very biased so you shouldn't listen to me when I say learn Perl : ) Perl would be easiest, possibly, if you have a Unix, esp sysadmin background. Ruby has nicer/cleaner syntax than Perl, but also known for being a little... slow. Python is very strict in HOW you code, visually. Your code must look like all other Python code. Python believes there is usually just one good way to do things. Perl believes there's more than one way to do it (Tim Toady). Ruby believes in the principle of least surprise, and being fun.

    And by the most useful, I mean learning actionscript to make dynamic web-pages is something that wont better my skillset in web-design.
    Actionscript is part of Flash. It is most like Javascript (it's a muddled form of ECMAscript). It's front-end only, so far as I know, not back-end. Actionscript only makes dynamic web pages with Flash. Maybe you want to learn Javascript, the front-end programming language, and specifically AJAX (using XML or, nowadays, JSON to communicate with the server via Javascript without reloading the page).

    If you are interesting in Perl, I have a huge steaming pile of sticky thread goodness at the top of this subforum : )

  7. #7
    SitePoint Addict Divisive Cotton's Avatar
    Join Date
    Jun 2008
    Location
    Andy lives in London, UK
    Posts
    393
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That can't be many people these days starting to learn Perl... it must be slowly dying out...
    Let everyday be Christmas

  8. #8
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Lawlz, Andy, don't listen to the FUD!!! Perl is alive! : )

    My husband recently saw a job offer for a middle-large sized company who is actually switching from PHP to Perl (I really really would love to know why, or maybe it was a who).

  9. #9
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    I started learning Python 2 days ago, I don't know how far I'll commit. I will say I find the language very easy to follow and extremely clean. It's very easy to get started and play around, they have different words for things I found confusing:

    (I might be off but what I found so far)
    Array = Sequence
    Associative Array = Dictionary
    Tuple (Kind of like a constant or global)
    include = import

    You can make GUI's with Python using wxPython also. I don't know if it must use Python Engine to run on someone else's computer (I'm guessing it does since it's interpreted code).

    Anyways, you might have fun trying it atleast, comes with a cool little Shell to play in.

  10. #10
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Tuple (Kind of like a constant or global)
    Weird, usually a tuple is a sort of ordered list. Like in the name... -tuple. sextuple would be a list or set of 6. 'tuple would be a list of ... anything including 0.

    Perl's version:
    Array = Array (yay) (uses @)
    Associative Array = hash (uses %)
    include = use, as in
    use Moose
    use strict

  11. #11
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heya,

    Yeah tuple appears to be in array format, but it's like a constant array. I don't really know what I would use it for.

    You just type
    ('something', 3444, 'other)

  12. #12
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    In Perl typing anything in parens like that makes it consider the elements in list context... which doesn't necessarily mean anything, you can use it of you start out knowing you want to declare 5 or 6 variables or something

    my ($stomme, $domme, $poes, $cat) = (stupid, dumb, cat, tom);

    I'm not sure but I guess you could call that a 4-tuple lawlz.

  13. #13
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    well I bought the llama book!

    Thus i am choosing Perl for now. I was going to go with Python-- but Perl seemed better.

    I am thinking of learning Ruby as the slogan: A programmers best friend is quite attractive. I looked into much more than the slogan and I like the syntax.

    So for now it will be Perl, Ruby (not on rails), and Python.

    Regards,
    Team 1504

    P.S. I found out that I dont care much for rails idk what you think

  14. #14
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    IMHO Rails would be very helpful if you were routinely creating sites. It would speed things up for you once you learned how it worked. i.e. a "tool". Similar to using Eclipse or Netbeans. A learning curve to get over, but once you have it makes things faster and easier.

    But if you're only interested in putting together one site for fun, it means more to learn. I guess some would like using it any way. Maybe it's my deeply ingrained "procedural" mindset that gives me the most trouble with it. Maybe I just like to "roll my own" too much. I mean, it's OK, just it didn't really "grab hold" of me like it seems to have with others.

  15. #15
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    well I bought the llama book!
    Woo, did you get 5th edition?? (I hope to get my battered copy signed by brian d foy in about two weeks).

    Only thing it really seems to miss, that you don't see until the Alpaca book, is references. Those are regulars in Perl.

    If your regexen aren't up to date, you might want the Owl book: Mastering Regular Expressions by Jeffrey Friedl (or PerlReTut). Perl lives for regular expressions.

    Remember to use Modern Perl, not nasty icky Perl.

    As you learn Ruby you'll prolly see it's kinda like Perl but with prettier-looking syntax : )

    The Ruby people will tell you the Rails people are batsh*t crazy and possibly from another planet. : )

  16. #16
    SitePoint Guru team1504's Avatar
    Join Date
    May 2010
    Location
    Okemos, Michigan, USA
    Posts
    732
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Just a warning: I am sorrry for all the questions as you may know I am just learning Perl as in a few days ago...

    Hmm yes I have the fifth edition!
    And what is the Alpaca book?
    I know the llama book is the next one up.

    I was planning in learning Ruby next, do u reccomend so?
    If its like Perl but with preetier syntax then why not right?

    Um also what is modern Perl and how to I keep myself i'm using old icky Perl?
    Btw im on my android phone & I decided to use voice to text customer I was tired of ttyping for a sec but it heard me wrong
    And wrote "keep myself from using old girls." lol wow

    Finally, can I save all my Perl programmes as. Plx?
    What about .pl I thought that was for perl?

    And then I find it in terminal on my Mac tell the Mac to use perl and it should run the programme once I find it using CD to the dir it is in?
    So I don't have to run Perl scripts thru a server, I can just run them thru terminal?

    Anyway,
    I dislike Python's only one way to do something because I am creative. However I love Python's applications especially with
    Thanks for your advice & Regards,
    Team 1504

  17. #17
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    And what is the Alpaca book?
    Intermediate Perl, the next book up from the beginner's Llama book.

    I was planning in learning Ruby next, do u reccomend so?
    If its like Perl but with preetier syntax then why not right?
    I have only started with Perl and have no reason to learn Ruby right now. In general it might not be a good idea to learn multiple languages all at once. Wait until you have the syntax in your head very good. I still catch myself using Javascript syntax in my Perl because I'm new to both.

    Um also what is modern Perl and how to I keep myself i'm using old icky Perl?
    Using Perl best practices (which you learn about as you read more about Perl... and the llama book doesn't teach bad perl, so you're ok there). Participate in the Perl community. Read chromatic's modern Perl blog. Read the Perl Resources sticky in this forum (it links to everything and more).

    Finally, can I save all my Perl programmes as. Plx?
    What about .pl I thought that was for perl?
    Unix does not actually care what the extension is on a filename. All files are files. Create your files as you learn with .pl but remember that that's mostly just for you (you know it's a Perl file).

    The llama book explains how to get started.

    And then I find it in terminal on my Mac tell the Mac to use perl and it should run the programme once I find it using CD to the dir it is in?
    So I don't have to run Perl scripts thru a server, I can just run them thru terminal?
    MacOSX basically runs on a form of Unix, a special Apple version called "Darwin". My computer runs Linux, which has perl already installed because it actually uses it to Do Stuff. So I did not have to install perl. However I keep my scripts in their own separate folder as I do not want anything I write getting in trouble with actual programs my computer needs. I assume your Mac has perl but I dunno which version (type in terminal perl -v) or whether you can do everything the same as someone on another type of Unix system.

    I do all my Perl-writing in the command line (in the terminal). I made my own folder called Perl and I cd to that, write programs there in vi, save them, and then give them permissions:

    chmod 755 perlfile.pl

    Because they reference where perl (the compiler and interpreter) is with the first line (the #! line), I can then simply run them by
    ./perlfile.pl

    and they do their thing.

    You could either do that or you can type your programs from the Desktop in a simple text editor like TextMate. You do not want to write them in a word processor program. Just plain text. I think the terminal is easier.

    I don't know if, on Macs, you need to or should start with the shebang line

    #!/usr/bin/perl

    On my system this references where perl is. Your perl may be somewhere else.
    You may need to ask a Mac user about how to get started with Perl on a Mac. You could check out Perlmonks.org, just be sure to read how to make posts before doing so.

  18. #18
    SitePoint Addict NetNerd85's Avatar
    Join Date
    Aug 2005
    Location
    Australia
    Posts
    298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JREAM View Post
    ...I started learning Python 2 days ago, I don't know how far I'll commit. I will say I find the language very easy to follow and extremely clean. It's very easy to get started and play around...
    I just picked up a copy of The Quick Python Book from Manning on the 19th/Monday. It seems like a nice easy language to learn (after already knowing PHP and Javascript). I was thinking of learning Perl for a while but it seemed too similiar to PHP. The main reason I wanted to start learning Python was because Battlefield 2 game mods use it and they need some tweaking

    Not sure what else I will be using it for at this stage but it is fun.
    a new day, a new beginning
    never follow the crowd, the crowd is poor!

  19. #19
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Not sure what else I will be using it for at this stage but it is fun.
    If you like contributing to open source projects, the Gnome windowing system for Linux has many of its applications written in Python.

    When my husband wanted a PerlTidy for gEdit (Gnome text editor), he had to write the plugin in Python. I'm pretty sure this trend is only going to continue.

  20. #20
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,272
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Team 1504:

    You may want to read this question over at PerlMonks:
    http://perlmonks.org/?node_id=851600

    The suggestion to get some tools and maybe a separate perl on your system sounds good. While I'm using my system perl on my machine, my machine does use it for other stuff, so if I do anything serious with Perl I'll likely also get a separate version as well.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •