News for hackers. Stuff that matters.
Re:In Praise of Perl 5 by logicallee on Thursday February 27, 2014 @06:15PM (#7315981)
parsing text files is literally the only thing Perl is the best tool for. Of course, every single person who needs to update it would have a 20 hour RTFM session before they could do so. (fairly conservative; this is 3 hours per day for 7 days from a standing start to maintaining Perl.) Perl has a ton of context, and that context is really hard to learn (just try writing a Perl parser/interpreter), and it applies best to text files and configuration scripts from 1987-1997.

I am not saying it's not an appropriate tool for anything else. But as a tool to be learnt, it wouldn't be the 'best' tool for a new person to learn from scratch.

Except for parsing text files :)

Re:In Praise of Perl 5 by einhverfr on Thursday February 27, 2014 @08:42PM (#7316709)
Author of the article here.

> parsing text files is literally the only thing Perl is the best tool for

To be honest, Ruby has built-in regexps also and Rebol has built in recursive descent parsing (and has no regexp support at all). So I disagree with you on two counts, the first is that Perl is the best tool always for parsing text files. To some extent it depends on what you are doing.

What I do think that Perl is really good at is building frameworks and the reason here is that what you can do (and what I highlighted in the article) is create mini-dsl's for common tasks which can then be seamlessly worked into the general purpose programming environment. Lisp can do this too, as can Rebol, but these each have other tradeoffs (I found the Lisp learning curve to be rather steep, Rebol 2 is not open source, Rebol 3, though open source, is still in alpha, and has no Linux GUI support yet).

> But as a tool to be learnt, it wouldn't be the 'best' tool for a new person to learn from scratch.

I don't know that there is a best tool for a new person to learn from scratch. One should generally apply tools I think with an intent of doing something with them. IMO, Perl excels at very big projects and very small projects. It's in the middle that things get less than ideal.

Re:In Praise of Perl 5 by draegtun on Friday February 28, 2014 @04:28AM (#7317830)
>Rebol 3, though open source, is still in alpha, and has no Linux GUI support yet

Just to note that the first beta version of the Linux GUI for Rebol 3 was released a couple of weeks ago - http://atronixengineering.com/downloads.html

Re:In Praise of Perl 5 by einhverfr on Friday February 28, 2014 @05:12AM (#7317932)
How could I miss this? Awesome!

Edit: It looks like that is Saphiron's repo, not the main one, so still waiting on it becoming an official build, I see :-P

Re:In Praise of Perl 5 by draegtun on Friday February 28, 2014 @05:42AM (#7318013)
Yes that's correct. Atronix efforts have been towards producing 64-bit versions + the Linux GUI from the Saphiron code base (which was 32-bit and Windows GUI).

Here's the Atronix announcement - http://rebol.info/altme/105/announce#msg0688

I believe you can consider this as the official build for Rebol3 View/GUI because Saphiron took over the RebGUI/R3-GUI project from Rebol Technologies.

But yes some of the Rebol 3 Core stuff that Saphiron/Altronix have done do need merging back into main open source core [1], which itself as moved on from the Saphir codebase (Saphiron Rebol build) [2].

[1] - https://github.com/rebol/rebol

[2] - https://github.com/saphirion/saphir

Also see Rebolsource repo where lot of the community changes go before merging back into [1]. Ref: https://github.com/rebolsource/r3 | http://www.rebolsource.net

PS. I know that you're aware of some of this info. Posting for the eyeballs of others :)

Re:In Praise of Perl 5 by danellis on Thursday February 27, 2014 @11:14PM (#7317210)
Don't languages with native MOPs, such as Python and Ruby, create better internal DSLs than Perl?
Re:In Praise of Perl 5 by kbenson on Friday February 28, 2014 @12:14AM (#7317359)
The best I've come up with so far searching for information on MOPs (of the explicit, controllable sort) in those languages is sort-of/almost for Ruby and no for Python. Is there some other name they go by in those languages that I should be aware of?
Re:In Praise of Perl 5 by danellis on Saturday March 01, 2014 @02:31AM (#7323519)
In Python the actual features that implement that would be metaclasses and descriptors.
Re:In Praise of Perl 5 by draegtun on Friday February 28, 2014 @01:02PM (#7320356)
Nope.

* Some of the best languages for producing an internal DSL (dialects) don't have a "native MOP". For eg. Lisp, Rebol or Forth.

* Python & Ruby don't have native MOP's anyway :)

NB. I wonder what you mean by "native MOP" is baked-in OO? Python & Ruby OO systems do come with MOP like abilities. However for full blown (metacircular) MOP (http://en.wikipedia.org/wiki/Metaobject#Metaobject_protocol) you need to look at things like CLOS & Perl's Moose/Class::MOP.

Re:In Praise of Perl 5 by danellis on Saturday March 01, 2014 @02:33AM (#7323523)
By "native MOP" I really mean things like Python's metaclasses and descriptors (and whatever Ruby's equivalents are called), as opposed to an add-on library to simulate them like Moose.
Re:In Praise of Perl 5 by draegtun on Monday March 03, 2014 @05:49AM (#7333051)
A bit of apple & oranges going on here because you don't need Moose (or more precisely Class::MOP) to simulate Python metaclasses and descriptors. Because you could, if you so wished, build a Python metaclasse/descriptor based OO system in Perl's native OO.

To clarify things:

* Python comes with a pre-defined OO system with metaclasses/descriptors for dynamically building new Python classes/objects.

* Perl comes with OO lego blocks from which you build you own OO system.

* Class::MOP is a metacircular MOP mainly written in Perl using these lego blocks (it's turtles all the way down).

* A MOP (like Class::MOP) provide an API for building & managing extendable OO systems.

* Moose is an advanced OO system built on Class::MOP.

* Moose provides features like Roles, Method Modifiers, lazy attributes and many more.

There have been two attempts, that I know of, to bring (a subset of) Moose to Python:

    https://pypi.python.org/pypi/bullwinkle/0.3.6
    https://pypi.python.org/pypi/elk/0.2
There have been many clones of Moose to other languages as well, including Ruby (multiple clones/ports), Javascript & Lua.

For something comparable to Moose/Class::MOP then have a look at CLOS (Lisp).

Re:In Praise of Perl 5 by einhverfr on Friday February 28, 2014 @12:45AM (#7317420)
> Don't languages with native MOPs, such as Python and Ruby, create better internal DSLs than Perl?

Why would you say that?

It seems to me that a DSL's function is at least reasonably decoupled from the method it uses behind the scenes, and that there is no real difference between a native MOP (like that in CLOS -- I don't really see an equivalent in Python or Ruby) and a non-native one like Class::MOP in Perl in this regard.

Re:In Praise of Perl 5 by danellis on Saturday March 01, 2014 @02:36AM (#7323530)
> Why would you say that?

It helps you strip out code that isn't related to the DSL. For example, the mechanisms of class definitions in things like MongoEngine or Django's ORM. You end up with something that looks a lot more declarative.

Re:In Praise of Perl 5 by heeen on Thursday February 27, 2014 @06:50PM (#7316225)
perl unicode support is actually pretty good http://dheeb.files.wordpress.com/2011/07/gbu.pdf
Re:In Praise of Perl 5 by logicallee on Thursday February 27, 2014 @07:00PM (#7316284)
updated to remove refernece to unicode.

the additional context involved with knowing Perl isn't enough IMHO to learn Perl just to parse text. I would do that with a 'more popular' language and its regex library, especially for new users.

Re:In Praise of Perl 5 by einhverfr on Thursday February 27, 2014 @09:34PM (#7316925)
Careful though. There's a lot of parsing that folks want to use regexps for that don't do that well.

Why Perl really shines for text file parsing is that you have a fairly large set of tools as appropriate, which fall into largely three categories:

1. regexps (great for some things, lousy for others. DO NOT use these for parsing HTML)

2. Recursive descent parsers. You could write an HTML parser in one of these if you need to.

3. Dedicated format parsers (CSV, XML, JSON, etc).

It's the combination of the three that makes Perl a very good tool for parsing text files. One thing going for Perl is a strong community of people who can help point people to the right tool for the right job.

For example, I am in the process of writing a library to do PostgreSQL tuple parsing and serialization. It is sort of like Text::CSV with some differences. In this case, regexps are the right tool. But if I was writing something else, I would probably go with recursive descent.

Re:In Praise of Perl 5 by marcosdumay on Thursday February 27, 2014 @09:28PM (#7316904)
> Except for parsing text files :)

Have you tried Haskell?

Anyway, Perl referencing an deferencing syntax is a mess. I regret any time I start a new program on it, as it always lead to a long debugging session where I remove all the parse errors. I use no other language with a syntax as complex (and can't really remember of any).

Re:In Praise of Perl 5 by __david__ on Friday February 28, 2014 @12:12AM (#7317353)
Hmmm. so it always takes you a long time to debug a language that you clearly don't actually know?

What a terrible language!

I don't know Python very well. I've worked on some python code but every time I do I have go read the manual for the most basic stuff (what does an "if" statement look like in Python, again?). But I wouldn't ever dare to blame Python for the fact that I don't actually know it!

Re:In Praise of Perl 5 by einhverfr on Friday February 28, 2014 @03:45AM (#7317744)
> Anyway, Perl referencing an deferencing syntax is a mess.

It's not too bad. It is amusing however to see someone with twelve years of experience doing something like: somefunc(\%$someobject); Um, wtf?

I personally found the reference/dereference syntax close enough to C's I had no trouble with it but far enough away I didn't get references and pointers confused.