|XP is just a number|
Perl and C# - how I use bothby jdrago_999 (Hermit)
|on Mar 09, 2009 at 18:35 UTC||Need Help??|
I am not ashamed to tell you that I use both Perl and .Net (specifically, C#).
"But how to know which one to use, and when?"
My rule of thumb is: When on Windows, use .Net. When on Linux, use Perl
"But why not use Perl on Windows?"
I do use Perl on Windows, but only in a pinch. You see, C# is to Windows as Perl is to Linux. I run Ubuntu Linux as my desktop and do most of my software development on CentOS using Apache/MySQL/Perl. Perl just fits in so nicely with what I do on a daily basis it's difficult to imagine getting by without it.
However when the $client makes Windows a requirement, C# is my tool of choice. With new gadgetry like LINQ to SQL I get an Object-Relational Mapper (ORM) along the lines of DBIx::Class or Class::DBI, plus a hackneyed equivalent of sort/map/grep. IIS 7 feels to me like what Apache httpd will one day become. ASP.Net MasterPages + ASP.Net MVC + ASP.Net generic handlers feel very much like the environment provided by Apache2::ASP.
Aside from the fact that it is Windows and I have to put up with Windows' problems, shortcomings and arbitrary limits, it's better than it was before recent advances in C# and .Net.
"Isn't C# hard to learn?"
I feel that C# and Perl are very similar. Perl6 will include some ideas that C# already has implemented, so it could actually help by learning some C#. Specifically, the regular experessions in C# have named placeholders - something Perl6 Rules will have as well. C# also provides partial classes, first-class Delegates (analogous to Perl5 subroutine references) and lambda expressions (though not nearly as nice as Perl6 will offer).
After years of Perl-only or Perl-centric coding, C# offered a great way for me to get used to strict typing and true object-oriented design. This discipline improved my software architecture skills in general, and the way I design Perl software in particular. The result is that my Perl is much easier to write useful unit tests for, and is better suited to scale out.
"What about Moose?"
Moose is another option, but without compile-time type checking or runtime casting. Moose is a solution to another kind of problem - a good one at that.
"So what's your point?"
My point is that "Fivers" who could use a head-start on true OO could benefit from taking a good look at C# (use Mono if you like).