(This is a snapshot of my old weblog. New posts and selected republished essays can be found at raganwald.com.)

Saturday, March 22, 2008
  Springtime Sunny Saturday

And I find myself writing:

$<.each do |line|
$> << line unless line.strip.split(",")[2].gsub('"','').strip.empty?
For some actual work. What else could be on my mind except golf?

Comments on “Springtime Sunny Saturday:
It's code like this that makes me wonder what the people are always complaining about with Perl being unreadable. Sure, I'm not a Ruby person but sheesh, this is no more readable than a lot of Perl code yet I never hear the bitching about Ruby syntax the way I hear about Perl syntax. I guess the benefits of being the cool new kid extend to this type of stuff as well.

Please reach over to the controls and set attitude to 'chill' :-)

This code was, in fact, a one-time throw-away shell script, not a piece of machinery embedded in an application. I personally don't care for this kind of thing, which is why I was making fun of it.

That being said, How could I use Java to filter a large CSV file by select the lines that have a value in the third column?

Hopefully, the answer would be "Use this library that hides the cruft." But were we to include the library's source, would the result be more readable somehow?

or perhaps we could include a lot of named variables. For example, STDIN and STDOUT would be much more readable than $< and $>. Unless, of course, you use Unix and use such a script with "script < infile.csv > outfile.csv," in which case $< and $> actually make some sense.


In summary, Real Programmers(tm) can write Fortran in any language. And Perl in any language. And Shell Scripts in any language.

Now go outside and have some fun today!
I have no idea how I would use Java for that, despite being a Java programmer in the Real World. I would probably pretend to write it in Java and do it in Perl instead. :)

I guess lack of sleep made that comment more cranky than it was meant, sorry. You get nothing but love from me, really. The comment wasn't directed at you but at the hordes of Perl haters I have to read regularly. In other words: ignore.push('matt'). :)
@what $are :you #guys talking= about? :)
Hey, I found the code to be perfectly understandable. I was just wondering whether [2] referred to the second or the third array member. And I have never programmed Ruby or, in fact, seen much Ruby code at all.

Then again, I haven't seen an unreadable Perl code yet. Bad Perl code, yes. But I have seen bad Java code too, and it was worse than anything I have ever seen in Perl.

I find that Perl code tends to be dense, the way that code above is. There's little redundancy, there are powerful first class types, and functional ju-ju.

So you go through 40 lines of code and feel like you have read 1000 lines of code. It's not that the code is bad or unreadable, it's just that there's actually 1000 lines of plain Java code (emphasis on "plain") worth of content in those 40 lines.

Now, I can't say I feel the same way about APL or MUMPS. :-) APL because my mind doesn't work well after the third dimension. MUMPS because it's control structures suck. I love being able to execute code I placed in a variable, for instance, but the following, frankly, sucks:

IF stuff execute A
ELSE execute B

The above can well result in executing both A and B. Or could, the last time I used it.

<< Home
Reg Braithwaite

Recent Writing
Homoiconic Technical Writing / raganwald.posterous.com

What I‘ve Learned From Failure / Kestrels, Quirky Birds, and Hopeless Egocentricity

rewrite_rails / andand / unfold.rb / string_to_proc.rb / dsl_and_let.rb / comprehension.rb / lazy_lists.rb

IS-STRICTLY-EQUIVALENT-TO-A / Spaghetti-Western Coding / Golf is a good program spoiled / Programming conventions as signals / Not all functions should be object methods

The Not So Big Software Design / Writing programs for people to read / Why Why Functional Programming Matters Matters / But Y would I want to do a thing like this?

The single most important thing you must do to improve your programming career / The Naïve Approach to Hiring People / No Disrespect / Take control of your interview / Three tips for getting a job through a recruiter / My favourite interview question

Exception Handling in Software Development / What if powerful languages and idioms only work for small teams? / Bricks / Which theory fits the evidence? / Still failing, still learning / What I’ve learned from failure

The unary ampersand in Ruby / (1..100).inject(&:+) / The challenge of teaching yourself a programming language / The significance of the meta-circular interpreter / Block-Structured Javascript / Haskell, Ruby and Infinity / Closures and Higher-Order Functions

Why Apple is more expensive than Amazon / Why we are the biggest obstacles to our own growth / Is software the documentation of business process mistakes? / We have lost control of the apparatus / What I’ve Learned From Sales I, II, III

The Narcissism of Small Code Differences / Billy Martin’s Technique for Managing his Manager / Three stories about The Tao / Programming Language Stories / Why You Need a Degree to Work For BigCo

06/04 / 07/04 / 08/04 / 09/04 / 10/04 / 11/04 / 12/04 / 01/05 / 02/05 / 03/05 / 04/05 / 06/05 / 07/05 / 08/05 / 09/05 / 10/05 / 11/05 / 01/06 / 02/06 / 03/06 / 04/06 / 05/06 / 06/06 / 07/06 / 08/06 / 09/06 / 10/06 / 11/06 / 12/06 / 01/07 / 02/07 / 03/07 / 04/07 / 05/07 / 06/07 / 07/07 / 08/07 / 09/07 / 10/07 / 11/07 / 12/07 / 01/08 / 02/08 / 03/08 / 04/08 / 05/08 / 06/08 / 07/08 /