News for hackers. Stuff that matters.
Re:Why Perl? by Mithaldu on Wednesday November 16, 2011 @07:08AM (#3242799)

  > And you don't believe how many people like this are out
  > there (not related to Perl, but in every area)!
This is the core point i was making. You have people who couldn't care less about their tool in every human endeavour. You knowing some doesn't mean that on average Perl devs don't love it.

To elaborate a bit more: At my last $work i was in a team of four, who preferred to use bash for most things. This however was borne from a sheer lack of knowledge and once i showed them how to get real work done with Perl they started to prefer it.

  > A forum, bugtracker or other means of collaboration 
  > software is far better suited for this, IMO.
There is a bug tracker attached to each project. Them having old bugs in there does not mean that they're being ignored, just that the author is lacking round tuits.

Also, there is a cpan annotation thing. Unsure of how much it's used. I must admit: CPAN's biggest weakness is that search.cpan.org is closed source. However metacpan is trying to fix that and has made huge strides. :)

  > "there is nothing like it" states that CPAN is unique
  > in every way, and it is not!
It is a question of scale. Is a 5% match in similary enough to say that it's "like it"?

  > I don't want to ask around for two weeks
I have never needed more than two hours to get feedback on a module in #perl. In fact, i was once trolled for taking more than 5 minutes to accept that XML::Simple is crap.

  > Config::Simple (is it crap too? i don't know now anymore)
Yes it is. Note how it has not been touched since 2005. As i mentioned: Config::INI::Reader/Writer are preferrable nowadays.

  > So a module is stopped being developed and determined
  > as being crap but how do i know that from the look at
  > CPAN?!
We are a community. You look at the reviews to see if there's anything obvious (I just added one: http://cpanratings.perl.org/dist/Config-Simple ) and if the module looks sketchy (long ago since last release, bugs open) you ask on IRC if better solutions have come around in the meantime. As mentioned, you'll get speedy answers.

  > A TOP100 of most active modules?
I like this idea. I have the feeling i've seen something like that before, but i'm not sure. I think the best solution would be to be able to order the search results by date.

  > Tried that, but somehow it didn't work for everything,
  > i'm not sure if some module was misbehaving.
It's lexical and only applies for your code. If you wish to capture warnings in third-party code, the cleanest solution is to wrap it in Capture::Tiny. :)

  > Try to remove an item in the middle.
Is this nice enough?

  @list = grep { $_ ne 'dogfood' } @list;

  > Unforunately i have read this statement in a magazine
  > about Perl 6 and some tutorials for it.
Ah, ok then. Honestly, i can accept that, i just would've liked to see more. Then again, not everyone writing about Perl 6 actually know a lot.

  > Sorry to have wasted your time, then.
Nah, it's fine. You allow me to demonstrate more powerful perl to the casual reader.

  > This doesn't change my mind, though.
This is a problem though. You've already decided that no matter what i say, you will remain stubborn.

  > Rest assured that i had this discussion with other IT
  > guys in the past and i'm not alone.
How many people think Britney Spears made amazing music? Appeal to majority is not always a good idea.
Re:Why Perl? by buster on Wednesday November 16, 2011 @07:32AM (#3242868)
I think we have reached the depth of discussion threads on HN, so i'd like to thank you and tzs for your comments and this (imo) good discussion.

The use of map is nice, BUT it shows partially what is wrong:

1. there are too many non-obvious ways to do simple things (this means that out of 10 programmers you will typically see 10 different solutions to a simple problem)

2. i have a problem with using functions for "different" usecases as what their name implies.. in my world eval simply evaluates code and map is short for "apply function to every item" not "filter out an item"

- i hate doing "go over every item in a list and execute a function that returns the item if it is not 'dogfood' and return that new list, overwriting the original one" when all i want is "delete 'dogfood' from my list"

As good as your answers were, you've shown me some good points and that your community indeed is very helpful, i am not convinced of this language. Both of you said yourself that there are quirks in the language. "still try to decide what exceptions look like" after how many years of perl? That was my thought ;)

At the end of the day i will still try to find and fix bugs in other peoples perl code, curse frequently and hope that people move on to the next language..

Re:Why Perl? by Mithaldu on Wednesday November 16, 2011 @08:07AM (#3242939)
I do appreciate the grace you've shown in replies.

> 1. there are too many non-obvious ways to do simple things

To a person who learned Lisp first your pythonish ways would be similarly non-obvious. Obviousness depends always on previous knowledge and you seem to know a lot about python; and as such expect things to operate like there.

Consider how confused a foreigner would be when he hears the word "bowling" and does not know about the sport and thinks it has to do with bowls.

> map is short for "apply function to every item" not "filter out an item" - i hate doing "go over every item in a list and execute a function that returns the item if it is not 'dogfood' and return that new list, overwriting the original one" when all i want is "delete 'dogfood' from my list"

But that is what filter does. Literally, there is no other way to implement this, unless you're operating with linked lists, which are not arrays. Filter is a map with a negated search func - wait, i'm an idiot. it should've been grep. But yeah, filter is just a grep with a negated search function.

  @list = grep { $_ ne 'dogfood' } @list;
Let me ask you a question though. In Perl, if i have a list of objects representing links and i want to remove all SSL links, i can do this:

  @links = grep { $_->protocol ne 'https' } @links;
How would i implement this in python? Does array.remove() accept lambdas as parameter? Or would i need to go another way?

> At the end of the day i will still try to find and fix bugs in other peoples perl code, curse frequently

Good luck and hop by on IRC! It will increase your curse frequency a LOT. (Until you meet mst and start to pick things up from him.)

Re:Why Perl? by buster on Wednesday November 16, 2011 @08:22AM (#3242988)
I'll visit that channel when back from vacation for sure.

To do what you want you could use list comprehensions or the filter(function, sequence) function:

List comprehension:

  links = ["https://securesite.com", "http://unsecuresite.com", "https://sec2.com", "http://unsec2.com"]
  [url for url in links if not url.startswith("https")]
  >>> ['http://unsecuresite.com', 'http://unsec2.com']
filter() + lambda:

  links = ["https://securesite.com", "http://unsecuresite.com", "https://sec2.com", "http://unsec2.com"]
  filter(lambda url: not url.startswith("https"), links)
  ['http://unsecuresite.com', 'http://unsec2.com']
I'd go with the list comprehension, from your use of map i'd guess you'd go with the filter ;)

Of course you'd replace the url.startswith with whatever your criteria is.

Re:Why Perl? by Mithaldu on Wednesday November 16, 2011 @08:28AM (#3243008)
Ah, that's kinda what i expected. Suddenly the two languages look fairly similar, no? :)

Also, list comprehension doesn't look bad to me. It's just a slightly weird and more verbose syntax of doing map, while filter does an in-place operation.