NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Reply (Score:1)
Re:Reply (Score:1)
How am I supposed to argue with your example? You showed a design wherein a class reads a config file every time it is instantiated. I have no idea how that can be construed as useful; the fact that you use
evalis incidental and at best draws attention away from the fact that you are reading a config file on every instantiation. After all, “the config file is code!” Do you really need to recompile the code every time someone makes an instance of it? Sorry, that example just doesn’t cut it.In any case I stand by my assertion that resorting to
evalreveals a weakness in the language or in the programmer. There are some things that you cannot easily do in Perl withouteval, and where the roundabout way confers no benefits overeval; these are things that I consider weaknesses in Perl.Anyway.
You write:
I have no idea how you get from Ovid’s point that DSLs should be parsable without the full host language executing the code, to the idea that Perl programmers are against
evalbecause the language is lacking in DSL support. I don’t even know what the latter is supposed to mean. In my best effort to understand that paragraph I cannot find anything more than a non-sequitur.Not to mention that I don’t agree with Ovid on what a DSL is, so lumping all the Perl types together based on his assertion is… silly at best.
That’s silly. Perl has this handy function called
do[perl.org] (I believe I wrote about it in my last entry, didn’t I?) which will let youevala file; and the code in the string passed toeval(and by extension, in the file loaded bydo) can return a value, so the file could consist of the initialisation of an anonymous hash, which will be passed back to whoever invokeddoto load the file. It is very easy to use Perl as the configuration language for programs written in Perl.In the case of that program, yes, that would be the right approach.
Where “DSL” is a grandiose way to say “string
eval”, “mess with package overhead” is a grandiose way to say “apply proper programming discipline so that code in one of the files doesn’t trample all over code in the other”, and the other part is a grandiose way to say “I didn’t know about Module::Pluggable [cpan.org]”.I did the same in Perl. It’s about 60 lines plus a bunch of CPAN modules – mostly glue to bind Mail::POP3Client to Email::Filter…
… except for, I wrote it the other way around: the 60 lines of glue code are in a module, and what would be the “configuration file” in your case is, in my case, simply a short Perl program that uses the module. In this way I get to avoid the necessity for making up any conventions at all.
I think you lost track of your argument about Perl vs Ruby. All of the benefits you listed are completely incidental to the fact that you were using Ruby. There is no qualitative difference our independently conceived designs, judging from the description you gave.
Reply to This
Parent
Re: (Score:1)
Re: (Score:1)
Basically my opinion is that anyone who thinks Perl, Python and Ruby differ in any sort of significant fashion hasn’t seen a lot of languages. The three are close to identical. Sure, there are lots and lots of superficial differences – they optimise in different directions, and that is what ends up making me prefer Perl and you Ruby and still others Python. But their fundamental premises are completely identical so there is no substantial difference in terms of expressiveness, overall. Ruby wins