8 ms·
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 sessi
by logicallee 13y ago
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 :)
- heeen 13y agoperl unicode support is actually pretty good http://dheeb.files.wordpress.com/2011/07/gbu.pdf http://dheeb.files.wordpress.com/2011/07/gbu.pdf
- logicallee 13y agoupdated 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.
- einhverfr 13y agoCareful 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.
- einhverfr 13y agoAuthor 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.
- danellis 13y agoDon't languages with native MOPs, such as Python and Ruby, create better internal DSLs than Perl?
- kbenson 13y agoThe 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?
- danellis 13y agoIn Python the actual features that implement that would be metaclasses and descriptors.
- einhverfr 13y ago
- marcosdumay 13y ago> 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).
- __david__ 13y agoHmmm. 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!
- einhverfr 13y ago> 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.