Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This will be a long post, and a lot of you will think that Im a blithering idiot... Im also buzzed, so this will probably ramble (no code even...)


I haven't programmed since before the internet was born. When I did program, it was on a Commodor =64; back in the days of Phreaking and Hacking when you actually had to blue box to get anywhere. Used to hack random Unix's... nothing that wouldv'e gotten me any real time back in the day. I used to write my ML apps by writing Basic programs to 'POKE X, Y' because I didnt have a compiler (thats why I like OO script languages; they're low tech and seem relatively eficient).


Im learning to program again because I have time again. At the moment, Im working within my means, and building...


Just taught m'self HTML, DHTML, and XHTML (like they're actually different), as well as style sheets and such; and am now working on JavaScript... I have to say I hate all of that crap. You can't do anything worth doing with any of them. X/D/HTML is moronic... Who writes any language where you can't define a formula? You do ANYTHING twice, you build a formula; even Word has macro's. JavaScript is just a pain in the *ss... to do anything actually relevant, you have to write a phone book... (but you can make it blink in one line =)...


To make matters worse, in all of these you have to trash your code to bow to every browser's quirks. I *thought* the internet was supposed to solve that type of garbage; but I guess that since he wrote =Commodor 64 Basic V2.0= in the early eighties, Bill Gates still hasn't learned to play nice with the other children.


What I want is a language that can do anything I want it to do; from writing applications, games, data proscessing, web pages, ANYTHING. I want it to be capable of running on server side, or client side; and be pretty much universally acceptable. I don't care if coding it by hand is a nightmare... I actually like that part.


I haven't found any books on Perl... at least not ones that I don't have to have shipped (I like to thumb thru first); but from what I've seen, Perl is the language I need.


1) Is Perl the language I should pursue? Is there a language like I describe? Anything close? From what I've seen, my three best choices are, in order of preference, Perl, C++, and Java. If Perl aint it, what about the other two? I would prefer Perl because I can code on the fly without a compiler.


2) What books do I want? Not the 'Perl for Dummies' type, but real code, syntax, and tricks. This place is too advanced still... I don't know how to dimension an array in this language yet. I need vocabulary; I need a straight user's manual.


I know this isn't the type of post you guys look for; but any help would be greatly appreciated.


Me


edited: Sun Mar 9 15:09:21 2003 by jeffa - title change (was: Sorry all.)

Replies are listed 'Best First'.
Re: Should I learn Perl?
by tachyon (Chancellor) on Mar 09, 2003 at 09:40 UTC

    Perl, C, Assembler C++ Java in that order if you want an opinion. You can do 95% of stuff in Perl, 4% in C if you hit Perl's glass ceiling and 1% Assembler for raw speed. C++/Java probably have the widest commercial market if that is an issue (and you want to use your skills to get a 'real job') Some VB(S) helps if you want to Perl Win32 with full power. If you are doing CGI stuff some Javascript is useful for trivia like form validation, focus() and that sort of basic UI stuff. The javascript/Jscript stuff is a pain in the proverbial - FWIW I often just use a browser detect, an if/else and write the code twice.The Comprehensive Perl Archive Network - CPAN has library code of generally very high quality to do almost anything you might want to do. And that does mean ANYTHING.

    The Camel Book (Programming Perl) is what you want for a reference. Learning Perl is among the better texts for learning the language. You will find all sort of useful links to these book and other relevant stuff at Outside Links

    See the Tutorials section for some good free stuff that you don't have to have shipped (or pay for ;-). If you have done BASIC you will find Perl syntax similar and the ability to make stuff happen in a few short lines (especially with library code to start) somewhat addictive. You seem to looking towards CGI stuff so I recommend Ovids free Web Programming In Perl Tutorials as a start. Have a look at home nodes like merlyn and ybiC for more links to free quality info than you will be able to read this month - or next.

    You will not find better support for any lang than you will find for Perl here and at comp.lang.perl.misc, Use Perl; perl.com to name a few others.

    Sounds like you have come to the right place and are looking at the right lang. Perl is a power tool. You can do just about anything in it although you can probably do it with less memory/cycles (but with much more effort and time) in another lang. With the fat memory and fast processors these days the need to do it with ultimate efficiency (memory/cycles) is diminished. Just ask M$/intel ;-)

    If you need it done yesterday you are far more likely to do it with Perl. BTW share your history to a degree. I started doing BASIC (and then assembler because you can't do much basic in 16KB of RAM) on a TRS-80.

    Never say sorry for asking a question. There are no stupid questions. Only stupid answers. Hope to see you round hacking code and having fun....

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

       (I have a similar background, BASIC -> Z80 ASM -> C + C++ + Perl + Lisp)

       I normally suggest that people who aren't new to programming jump straight into Programming Perl, and skip Learning Perl.

       Whilst perl does hold a few suprizes, things like implicit arguments and special variables I think that if you're a programmer who's experienced in several languages, such as javascript, basic, etc you'd be better of with a real programming + reference book.

      Steve
      ---
      steve.org.uk

        I did Programming Perl first but it is fairly heavy going when you are starting. Indispensible certainly. The best ref without a doubt. I think it depends on how much of a masochist you are when it comes to starting with it.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      KK, Didn't realize that Assembler had actually survived... Nice to see that you can still take it down to that level. Also thought C had kinda been superceded by C++; whats the deal between those two? Is C++ just a more specific application of C, or is it similar to the whole JavaScript/Java thing; where the two have nothing in common but a name?


      Again, nice to see the same books being referenced again and again... good sign that I can trust them to get me into the thick of it.


      Kinda noticed that Perl and Basic had a lot in common... JavaScript, too for that matter... the way they handle the variables and loops and such all has a familiar ring to it. The operators still look a little strange to me, as is the use of (), [], {} for seperate things... Im more used to puting everything in basic parenthases and quotes...Ill adjust quickly, I think.


      I already checked out the tutorials, namely the one named 'The Basics', but it was already looking Greek to me, so I shouted out here. I figure I need a good book to be more familiar with the actual vocabulary first, then work on concepts; from what I've seen, the concepts will be the easy part for me. (the '#$amp{a$::bname&&()}' stuff is still looking a bit bizzarre tho! =)


      Support as I've seen for Perl would be quite welcome... nice to see that everyone is willing to chip in for each other. Looking forward to not always looking like a moron! Probably be very proud first time I point out the bug in one of your codes!


      Memory/cycles isn't really the problem for me... I like tight, error and bug free code that works well. I like even better that it does its job efficiently, and leaves everybody else scratching their heads wondering how I did it in only three lines. From what I've seen, Ill probably generally follow your suggestion of languages... but I'll probably put the assembler off till I got C, C++ and Java covered...


      I can understand the TSR-80 problem... I lived with a Commodor 64 for a full year before I got a disk drive! Try running that long on tape! took almost 45 minutes just for Logo to load (after I boosted the tape drive speed!) Coulda been worse, tho... had a buddy that was real proud the day he got his Radio Shack special; the CoCo 3 (in color! WOOT!).


      Me

        Here is my take on the languagues:

        Perl - Basic on steriods, instant gratification and debugging
             - Got a bad wrap in CGI circles because it was so easy to
             - do CGI stuff that lots of people did - BADLY
        C    - THE language that made programming what it is today
             - All the power of assembler in a (slightly) more user friendly package
        ASM  - Everything ends up here. To code C you need to have
             - a handle on the guts of the system anyway
        C++  - C extended to do OO better. Unnecessary for single programmer
             - as you can do it in C in half the code (procedural)
             - Forces you to be OO which is not needed for short stuff
             - It is way easier to do multi-programmer stuff OO with solid APIs
             - Yeah, yeah what starts little often suffers featuritis 
        Java - C++ with all the power toys taken away. Comiles to bytecode not ASM
             - Supposed to be portable but MS got involved ;-)
             - speed not that great due to partial compilation
             - TRENDY in management circles.
        

        Here is a nice one liner for you:

        perl -pi.bak -e 's/something/otherthing/g' <FILE LIST>

        That particular snippet does a search and replace on a list of files writing a backup to filename.bak in the process. Handy and 100s of times faster than doing the same in a Windows based editor.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Should I learn Perl? -- in defense of Javascript
by bart (Canon) on Mar 09, 2003 at 11:10 UTC
    JavaScript is just a pain in the *ss... to do anything actually relevant, you have to write a phone book...

    I feel like I have to come to the defense of Javascript here... there isn't much that you can do in Perl that you can't do in Javascript. Featurewise, JS appears to have borrowed a lot from Perl.

    For example, here's a little yet powerful introspection function that can aid you in inspecting properties of Javascript objects.

    function enumerate (obj, re) { var r = ''; for (p in obj) { if((re==null || p.match(re)) && p!='filters') { var s = '' + obj[p]; r += p + ":\t" + s + "\n"; } } return r; }

    n.b. The "filters" property is something I've only seen in MSIE. It just gives an error if you try to access its value (as a string). That's why I just skip it.

    Wrap this between "<script>" tags... An example on how to call it, in a HTML document:

    <button onclick="javascript:alert(enumerate(document.body));"><b>all</ +b> body properties</button> <button onclick="javascript:alert(enumerate(document.body, /width/i)); +">width related body properties</button>
    This works well (tested) both in Mozilla 1.2 for Windows and MSIE 5.5. As you click on the "all properties" button, you'll see far too many properties to even all show up in the alert box. That's why I provide a property name based filtering mechanism, using an optional regular expression.

    It's all there: optional arguments, regexps as native objects — just like passing a qr// argument in perl, objects which are actually hashes...

    Before you slug on JavaScript any further, please look into a good book on the subject... I know there are more crappy than decent books on Javascript, just like on CGI. The Javascript book from O'Reilly is quite good. I'm not even suggesting that you should buy it, just checking it out is good enough for me.

      there isn't much that you can do in Perl that you can't do in Javascript.

      This is a joke right? You don't see a lot of browser depentdent 500 Internal server errors but I have lost count of all the offers to debug dysfuntional javascript/Jsctipt I have seen..... Javascript was of course castrated from birth in terms of available functionality.

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I think most of the opposition to javascript comes from certain large companies not supporting it properly in their web browsers, which leads to lots of tedious workarounds.

      OK, point made. To be fair, I am probably heavily biased against it due to finding bad books... most of them that I have seen focus on the event handlers, and have only really listed uses such as rollovers, scrolling marques and such. The BEST book I have on JavaScript atm has multiple chapters on doin image rollovers (controlling one rollover from multiple links, controlling multiple rollovers from one link, Using a function to code multiple images with a single rollover, Cycling banners, etc... goes on for almost forever)


      Assuming that my bad taste for JS is caused by bad books; What is the cure? Anything out there treat this language as anything but an HTML add-on? O'Reilly looks like it has been mentioned here with every post... I gotta buy stock in that place.


      Me

Re: Should I learn Perl?
by Marza (Vicar) on Mar 09, 2003 at 09:30 UTC

    Sure learn Perl! It's a fun language. I have used Basic, C, and Pascal. Also, the main frame stuff as well

    As to books, Look up the O'Reilly Books Learning Perl and Perl Programming. Usually called the Llama and Camel books. You might also look at Simon Cozens Beginning Perl. These three usually make everybody happy! You have to have the Camel book. You can't say you use Perl without it! ;-)

    Also, once you get your feet wet, do look around the tutorial section on this site

    Good luck and welcome to a fun world! And do ask questions on this site! You will usually get a "civil" reply if you post code and show effort. The questions listed now may look high level but if you search, you will find all levels of questions. Did you get the hint? ;-) The search feature is quite useful for finding answers. But if you need clarification; ask!

    Again, I can't say enough about using this site. My knowledge has increased significantly because of it!

      Well... Now I see what a 24 hour wait for a response gets you around here!


      Thank you all! I'll respond to each of you in turn, as many of you asked questions of me.


      So far, everyone seems to point to the same books... good sign. Stupid me checked out Waldenbooks, and couldn't find a single book on Perl. I was worried that 'Perl for Dummies' would end up being my only option!


      As to getting my feet wet... shouldn't be long... I've been cruising this site for a few days, and several chunks of code are already beginning to make sence... seems like my biggest problem right now is the vocabulary that you guys use to refer to seperate types of processes... Ill get it all down quickly Im sure.


      Me

Re: Should I learn Perl?
by Hofmator (Curate) on Mar 09, 2003 at 13:57 UTC
    Just a quick remark
    I don't know how to dimension an array in this language yet
    that's one of the nice things about Perl, you don't :), you just use it.
    # create array my @array = (1, 2, 3, 4); # push some elements on it - it grows automatically! push @array, 8; push @array, 9, 10, 11; # and print it out print "Here are the contents of the array: @array\n";

    -- Hofmator

      Wicked! Are their multi-dimensional arrays? If so, how do you controll what the coordinates are for the 'pushed' values? As an example, in Basic, you could dimension an array with 10 x elements, 10 y elements, and 10 z elements... then perform functions on the elements by refering to their coordinates... If you add extra elements, what would their coordinates be? I do like the ability to expand the array as such without disrupting what it already contains... thats nice!


      Me

        Yes, there are multi-dimensional arrays as well - we normally call them Arrays of Arrays (AoA). And accessing them is as easy as $array[3][4][0], but in order to understand them properly, you'll have to learn about the different data types in perl: scalars, arrays and hashes ... and references.

        If you have access to a computer with installed perl, I suggest, you open up a command line shell and try typing perldoc perl. You could follow this up by perldoc perldata and perldoc perlreftut ... then you'll understand some more. And if you have questions, come back and ask here - that's what we are here for, after all.

        If you don't have perl installed, then you could also read this up online at http://www.perldoc.com - though I can promise you'll soon want to start playing around with perl ;-)

        If you add extra elements, what would their coordinates be
        Whatever you choose them to be. You can add elements to the front, to the back or into the middle of an array. Sorry, but with your current level of knowledge that has to be sufficient as an explanation ...

        -- Hofmator

Re: Should I learn Perl?
by pg (Canon) on Mar 09, 2003 at 16:21 UTC
    Learn all of them.

    I don't see a single language can provide all the goodies that today's computer science can provide you. perl is good, c is good, java is good.

    In a void context, Perl is not the best, Java is not the best, c is not the best. Nothing is the best, unless we are clear what application we will deal with.

    In a web scripting context, you still have lots of choices, at least include Perl and Java.

    To learn a language should not cost you too much time, learn both, and be good at one (at least). After you tasted both Java and Perl, you can make a decision yourself.

    Gather opinions from others, those are insightful and based on precious experience, but good suggestions usually do not agree with each other, (and should not, because of things like different background etc.), so eventually ;-) you have to make your decision by yourself
      Well... That's probably the route I'll end up taking... Its more a matter of sequence than inclusion...


      I learned HTML because no matter what I do, if I can't even set up a basic home page, I'll feel like a moron. JavaScript was likewise mandatory; whats the point of a webpage if it looks like it was written by a grade schooler?


      My woman wants to start a business; so I am writing a Website for her, and realized that I couldn't actually have anyone order anything on the site without writing CGI scripts (thats what got me aimed at Perl originally).... but writing websites and webscripts are not an end for me, only the first logical step.... to be quite honest, I don't know if/where it will end... given the way my head works, and my history... I probably will end up learning both, being good at both; at least sooner or later.


      Me

Re: Should I learn Perl?
by Anonymous Monk on Mar 09, 2003 at 17:28 UTC
    Should I Learn Perl?

    No. In fact, don't learn any programming languages. Once you start down the path, forever will it determine your destiny. You'll work for 30+ hours straight, unable to stop, forced to develop an addiction to highly caffeinated beverages to keep going. One language will not be enough, you'll have to learn more, and more, and more. Your apartment (you don't need a house, you won't have time for wife/kids) will be full of computers to test your software on, you'll build beowulf clusters just for the hell of it! You'll put off eating for days because you just have to get those 460841 lines of asm written as soon as possible. Then, you'll start reading Perlmonks.

    For the love of God man, get out while you can! Go get yourself a law degree, a 150,000+/year job, a nice summer home in Dominica, and relax. You'll thank me later.

Re: Should I learn Perl?
by Abigail-II (Bishop) on Mar 10, 2003 at 00:24 UTC
    To make matters worse, in all of these you have to trash your code to bow to every browser's quirks. I *thought* the internet was supposed to solve that type of garbage; but I guess that since he wrote =Commodor 64 Basic V2.0= in the early eighties, Bill Gates still hasn't learned to play nice with the other children.

    Two things. Bowing down the browsers quirks shouldn't be all blamed on the browser vendors, but mostly on the people writing webpages. If they just said "we only use standards", we wouldn't have the problems we have today. (Lesson, if you are a web programmer, it's up to you to fix this, not Bill Gates, not Netscape, Inc, not the W3C, not ISO. It's just you.).

    Secondly, this tactics of "let's implement something else than the standard, see if we can lure web programmers to lock the users to a specific platform" was succesfully deployed by Netscape long before Bill Gates realized the Internet wouldn't go away if he'd ignored it. If you want to blame browser vendors for the current mess, blame Netscape, not Microsoft.

    I hate Microsoft, but I probably hate Netscape more.

    Abigail

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Should I learn Perl?
by webfiend (Vicar) on Mar 09, 2003 at 16:35 UTC

    I wonder if we are the right people to ask. Asking Perlmonks if Perl is the right language is like asking the Vatican if Catholicism is really all it's cracked up to be. What are we going to say? "No"? "Have you considered Buddhism?"

    We're a relatively well-balanced group here, but there is a chance - however slight - that we might be biased.

    Update: Chopped a rambling bit and softened the tone.


    I just realized that I was using the same sig for nearly three years.

      I agree completely with this. I love Perl, so I can always find reasons to recommend it. But I do know that it's not something that everyone needs to learn

      To the original poster, I'd like to pose a question: What is your goal in learning a programming language?

      • Are you just doing it for fun? (Perl is a good choice)
      • Are you doing to start learning programming so you can use it for a job in a while? (Perl might be a good choice, if you expand to other languages later (note that I don't know of a single college which teaches Perl as a first language -- there are many reasons))
      • Are you hoping to use it to get a job now? (Perl's probably not the best choice for this, try C instead)
      • Are you going to use it solely for web applications? (Perl's a good choice)

      In general I think that without knowing your purpose, it's impossible to recommend one single language. And I think it's difficult at best to recommend a series of languages. But if I missed this explanation in the OP, please try to be gentle with the cluebat -- it's still early. ;)

        Yes and No to all of the above....


        I wouldn't call programming anything fun... more like an addiction. As far as doing it for work? EEEWWWWWW... Talk about a buzz kill... I don't think I could ever do anything that I enjoy for employment. After its all said and done, any job is eventually just your job, if you used to love what you do, now you cant wait to get away from it... did the same thing to myself with mechanics.


        Why then? Well, probably closer to #1. Again, I don't consider programming to be 'fun'; Six Flags is fun. Programming is a headache that will leave you dreaming in code. What keeps you coming back? Finding solutions to problems; thats why we're all here. Like playing chess (which I also don't consider 'fun'); you hate every good move by the opponant because it makes you work ever harder for every victory, but a victory without a good opponant is hollow... so you spend forever looking to beat the unbeatable opponant... Its in the subtlties of just the right move that smashes your opponants unbeatable defence... not 'fun'... closer to love, obsession, or addiction.


        One more thing that you might appreciate... I've worked the other end of this industry. I used to work for Lucent Technologies installing high-end equipement for AT&T; some of the stuff I've worked on made me drool. How about the 400G? It can handle 5,000,000 simultaneous DS0 lines, or the Lambda Router? 4.3 TERABITS.


        That's mostly what won me back to programming... Many systems nowdays can interpret packet headers without ever needing to convert the header into electronic signal. These bad boys can actually perform logical arguments on a raw laser signal; that way it can blow through the equipment over 1,000 times as fast. Imagine that the computer your working on RIGHT NOW isn't processing electrons on a chip with diodes and wires... no; its splitting a laser signal with mirrors and holograms! Every 'wire' in the system, and even the logic circuits capable of handling multiple signals simultaneously by keeping them at seperate frequencies. Not sci-fi, guys... HERE AND NOW.


        They're even working on memory, but thats having a few problems... RAM atm needs a condensed cloud of super-cooled cesium atoms to store raw signal laser, and can only hold it stable for a few milliseconds before it begins to lose data; and Long-term storage isn't flawless yet either... they can store multiple holograms in a very small space, but there is no way to delete data or rewrite yet; but the storage capacity is enormous (1 storage crystal 1 inch on a side, cube can store data at 16 seperate points in the crystal; multiply by 36 for each location becuase you can store multiple images at each location by varying the angle of the signal laser by 10 degrees each time, then multiply by 256 for the colors that can be seperated easily without interference, and realize that each image can be a full PAGE of data... and we haven't even stated pushing limits yet... imagine when the storage system can handle 16.7 million colors or so? How long ago were our moniters limited to 256?)..


        There are other technologies in the works, but quantum computers will take forever to appear practical, and I haven't seen much coming out from the whole RAW architecture yet, either... but if/when they ever do come out, I want to be there. The photonic equipment is actually in the here and now... I've put some in myself; right now the thing thats delaying it is need... we already have a LOT more bandwidth than we need, so theres no point in pushing it furthur than it is right now. It will only be time, though, before its in my home and under my fingertips, so I want to learn NOW and be ready.


        I had pretty much given up programmin for chess for a while, but since I've seen whats coming down the pipe, my head hasn't gotten off of programming; got my time freed up, got my system together, and started working on every language I had easy access to (thats the other thing I like about Perl... writing code in NotePad is a lot more ground level than writing some language in a big bucks compiler... very cool).


        Me


        P.S. Sorry for rambling; bad habit of mine.

      Actually, I had an ex get pretty much precisely that response when she asked a Jesuit. He told her that if she wasn't feeling very connected to God thru Jesus and Mary, perhaps she should study other religions (Buddhism was mentioned specifically)...


      Course; now she's a holy roller.... go figure.


      Me

Re: Should I learn Perl?
by Chady (Priest) on Mar 10, 2003 at 08:26 UTC
    [...] X/D/HTML is moronic... Who writes any language where you can't define a formula? You do ANYTHING twice, you build a formula; even Word has macro's [...]

    You seem to talk about HTML as if it is a programming language. You say that it lacks formulas and you have to write “twice” but you're missing the point; HTML is a markup language, and not a programming language, so you use a scripting language (i.e JavaScript) to control it, and the implementation of such script depends on the browser, and that's where you have to write everything twice. The best solution would be not to try to control everything, and just settle for HTML as a presentation language.

    Just a note.


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
      Well, I must agree with you there at least... but once again, I must point out that at least Word has macro's; which is almost like a formula for a markup. CSS is getting close, but I still think its moronic to have to apply 3 languages (or psuedo-languages) : HTML, CSS, and Javascript; simply to approach some form of interactivity.


      And, to top it off, you still have compatability issues... again, IE still doesn't handle style sheets well.. better than it had, but not yet as well as Netscape 6.


      Anyway all, thank you for all of your answers... I will disappear for a while now, and reappear shortly once I've learned some decent syntax for Perl and ready to roll.


      Me


      P.S. You will know me when I come back... my signature hasn't changed in forever... Im always just 'Me'

        You will know me when I come back... my signature hasn't changed in forever... Im always just 'Me'

        *cough* dontcare *cough*

        Me