"I can write C in any language."
And it's true. He could write beautiful C code in Perl, Java, Ruby, etc - whichever language the current project was using - when he needed to hack something (usually gathering data for business metrics).
"I can write C in any language."
And it's true. He could write beautiful C code in Perl, Java, Ruby, etc - whichever language the current project was using - when he needed to hack something (usually gathering data for business metrics).
Basically only using if/for/while and function/return constructs.
It was strange to open a Perl script and see "C" code, with single-letter variables (declared at the top), etc.
Other things I think make for good perl style:
* Never use unless, especially as the after-statement conditional and/or with a negation. (I once spent a whole day ripping my hair out to figure out that an unless with a negated clause that was itself ambiguously named did the exact opposite of what it seemed to. Think [...] unless not $unregulated;)
* Do use foreach wherever possible.
* Keep reference usage to where it's really needed.
* When in doubt, don't write new OOP code. (The benefit to the caller has to be much greater than the extra complexity in implementation.)
* Lists are the core data-structure and regex are first class construct.
* Avoid the use of implicit $_/@_.
* Avoid the use of explicit $_.
* Use map / grep / sort and similar in pipelines but don't nest too deep on a given line.
I want to see how he writes C style in Haskell.
The real performance penalty is growing objects as you go. If you preallocate a list or vector of the appropriate length, then there typically isn't much difference.
That being said, you'll pry lapply(x, fun) from my cold dead hands (lapply(x, function (x) g(f(x)) is even better :) )