Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Using "my" suppresses "Name used only once" warning?

by dragonchild (Archbishop)
on Feb 03, 2003 at 15:50 UTC ( [id://232275]=note: print w/replies, xml ) Need Help??


in reply to Using "my" suppresses "Name used only once" warning?

With regards to your angst about strings and numbers ... flip your thinking. You're worried about making a mistake and using a string or number where you shouldn't have and getting wonky results because of it. That's a valid worry and every single monk worth their salt has had it bite them in the ass, easily losing a day or two of working time.

So, we stop using Perl, right?

Naaah! Instead, consider the following points:

  1. Perl was initially designed to process "stuff". One of its most common uses is to handle CGI "stuff". Having worked with CGI stuff in C++, the http server will give you everything in strings. That would've gotten real annoying in C, but C++ had these neat overloaded operators for me, so I could add two strings together. Perl takes that idea and makes it better.
  2. Ever since I started working with Perl, especially OO Perl app development, my skill as a developer has improved. In some cases, by leaps and bounds. Perl lets you do (nearly!) anything you want. But, if you want to work with it three months from now or if you want to work with it in a remote-development group, you'd better do it intelligently. Because Perl doesn't force you to design, it lets you design better. It lets you make the mistakes, then allows you to do it right. This means that I (now) naturally name variables and structure programs so that the number / string issue, well, isn't an issue. :-)
  3. If the above points don't convince you, consider that there are thousands of extremely smart developers who wish that every language they have to work in has X feature from Perl. (For me, it's hashes and regexes and, yes, scalars.) I hate not being able to use hashes. I hate having to do the stupid book-keeping to know if I'm going to want a string or an int or a float or whatever. I know I'm not alone. Even if you don't understand it now, trust that we do and that you'll understand it very soon.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

  • Comment on Re: Using "my" suppresses "Name used only once" warning?

Replies are listed 'Best First'.
Re: Re: Using "my" suppresses "Name used only once" warning?
by demerphq (Chancellor) on Feb 03, 2003 at 17:20 UTC
    Wow. The last sentence of every point you make is worth a ++ alone. Nice post!

    Perl takes that idea and makes it better.

    This means that I (now) naturally name variables and structure programs so that the number / string issue, well, isn't an issue. :-)

    Even if you don't understand it now, trust that we do and that you'll understand it very soon.

    Well said, and ++ to you!

    --- demerphq
    my friends call me, usually because I'm late....

Re: Re: Using "my" suppresses "Name used only once" warning?
by Wysardry (Pilgrim) on Feb 03, 2003 at 19:44 UTC

    I wasn't even considering not using Perl!

    Besides anything else, it excels at text processing, and text is at the core of most Web applications.

    I know Perl gives users so much more rope than other languages - I'm just trying to make sure I don't trip myself up or hang myself with it. ;o)

    There are also so many different ways to do anything, that I sometimes find it helpful to restrict the options a little.

      I'm just trying to make sure I don't trip myself up or hang myself with it.

      Actually, while you're learning, you should hang yourself a few times. It sounds like you were the kid (like me) who just wouldn't believe that "hot" meant "Don't touch" until you had to go to the emergency room.

      I sometimes find it helpful to restrict the options a little.

      Sure. Do what comes natural. But, leave your mind open for new paradigms. When I first came to Perl, I was very disturbed by scalars. But, over time, I learned to appreciate the power of dwimmery. ("Do What I Mean"-ery) I also learned I could trust the Perl developers. But, I've found that every "hot" kid has to learn that trust for themselves.

      Another comment - Perl is not the be-all-end-all of programming languages. (It's close, but not quite.) And, frankly, it wasn't intended to be (though Perl6 might be really, really close!). There are applications for which Perl is absolutely horrible, like embedded or time-critical apps. I just wanted to say that because you're sounding like you have Perl up on a pedestal.

      Remember - many of the most-used Perl modules have their guts written in XS and/or Inline::C. That's not cause Perl is bad ... just XS or Inline::C might be better for the specific purpose.

      ------
      We are the carpenters a.nd bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        Actually, the main cause of my caution is being burned by other languages during the learning process.

        I'm not asking for a bucket of water, I'd just prefer to some extra warnings given so I'm aware of the things that don't appear to be hot.

        I can then stop put some heat resistant gloves on first. ;o)

        I realise that Perl isn't perfect, but it is probably the closest thing available when working with text - mostly because that's what it was originally designed for.

        The main use I will be putting it to is creating static HTML documents from a database. My intention is to update them once a week or so, and as I would be the one administrating the database and resulting Web site, it wouldn't be time-critical or multi-threaded.

        With that use in mind, it's hard to think of another language that would be more suitable. So yes, for this task I do rate Perl much more highly than the alternatives.

        That's not to say I'd choose it to create a Quake clone, or a replacement for Windoze. :o)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://232275]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found