Text

Why isn’t $LANG Popular in Industry?

With LANG=haskell, Why isn’t Haskell popular in Industry?

It’s interesting because I think that list of 9 points can apply to other languages too (such as Perl).

A language is unpopular because it’s different, and it makes it difficult to learn. Moreover a language can be popularly known to be difficult, or believed to have known problems, such as maintainability or code readability.

It’s very difficult to hire programmers that already know it, because it’s unpopular. Although you can teach it, it doesn’t make the language suitable for your projects, because you need good programmers already trained, and you can’t find them!

All together makes that language a risky option that gets discarded in favour of other ‘industry leading’ languages such as Java.

And don’t forget the customer: they’re used to some words, and although it’s not their business, they tend to be more happy if they know (or think they know) about the technology you’re using. So, it can be harder to sell an application made in Haskell.

At the end, sadly, the advantages of using $LANG aren’t that important.

Text

Workaround for the Battery Issue

Since I upgraded the firmware of my Acer Aspire One 110, I’ve noticed some little problems with the 6 cells battery: the laptop switches off when about one hour of battery time is left.

Well, it’s not really switch off but like it hangs: the power light it’s on, and the side cooler is working, and I have to press the power button for some seconds to stop it.

I did some research and tests, and these are the results:

$ cat /proc/acpi/battery/BAT1/info 
present:                 yes
design capacity:         7200 mAh
last full capacity:      6610 mAh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 300 mAh
design capacity low:     264 mAh
capacity granularity 1:  32 mAh
capacity granularity 2:  32 mAh
model number:            UM08A73
serial number:           096D
battery type:            LION
OEM info:                SIMPLO

$ cat /proc/acpi/battery/BAT1/state 
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            824 mA
remaining capacity:      6569 mAh
present voltage:         12232 mV

The remaining capacity (green) it’s the actual battery charge, and the design capacity warning (yellow) and the design capacity low (red) are the values I assume ACPI and the battery applet are checking to calculate the remaining battery charge:

$ acpi
Battery 0: Discharging, 97%, 08:41:40 remaining

I don’t know if I’m getting it wrong, but it makes sense to me (and that 08:41:40 remaining is obviously wrong). The netbook freezes when the charge reaches 19% (aprox).

I guess the battery is advertising wrong values, and because the applet uses time as factor, I can’t adjust it properly.

So I programmed a Perl script to run by cron every minute, to check the battery charge value instead of the time:

#!/usr/bin/perl

use strict;
use warnings;

# empirical fix
my $fix = 1200;

sub getData
{
        my $file = shift;

        open(FD, '<', $file) or
                die('failed to open: ' .$file);
        my @lines = <FD>;
        close(FD);

        my %data;
        foreach(@lines)
        {
                chomp;
                s/\s+//g;
                s/mAh//g;

                my ($key, $value) = split(':');
                $data{$key} = $value;
        }

        return %data;
}

my %state = getData('/proc/acpi/battery/BAT1/state');

exit 0 unless $state{'chargingstate'} eq 'discharging';

my %info = getData('/proc/acpi/battery/BAT1/info');

if($state{'remainingcapacity'} <= $info{'designcapacitywarning'} + $fix)
{
        system('aplay alarm.wav');
}

if($state{'remainingcapacity'} <= $info{'designcapacitywarning'} + $fix - 100)
{
        system('sudo /sbin/halt -p');
}

exit 0;
# EOF

Please, keep into account that this is a hack. After some tests, I’ve found that adding 1200 to design capacity warning it’s a good fix.

When the limit is reached, I play an alarm sound, until I call halt to switch off the netbook as cleanly as possible (notice that I’ve configured sudo to let my user run halt without password).

With this little workaround, everything in my LXDE based Fedora 13 fit my needs!

Quote
"Perl programmers of Earth! Browse though the Core modules before starting a new project. Use them, don’t rewrite them."

From Sven Heinicke (@failedvegan) at identi.ca’s timeline.

I agree, browse, and use them. Don’t repeat yourself.

Tags: Perl Core DRY
Quote
"SQLite library consists of approximately 67.2 KSLOC of C code. (KSLOC means thousands of “Source Lines Of Code” or, in other words, lines of code excluding blank lines and comments.) By comparison, the project has 679 times as much test code and test scripts - 45678.3 KSLOC."

From How SQLite Is Tested, via Reddit.

Impressive. In comparison, Perl 5.12.0 has 29826 tests*.

* from running egrep -ri "tests ?=> ?" * | perl -e '$s = 0; while(<>) { m/.*tests ?=> ?([0-9]+)/; $s+=$1;} print "total: $s\n"' inside t/ directory. Remember Tumblr RSS is broken, you may not see the right code in your feed reader.

Quote
"The yada yada operator (noted …) is a placeholder for code. Perl parses it without error, but when you try to execute a yada yada, it throws an exception with the text Unimplemented."

From Perlop about Yada Yada operator.

Perl 5.12.0 it’s out! Yada Yada!

Link

I’ve tested both frameworks, with one public result (built with Mojolicious), and another one ongoing (playing with Dancer).

I like both, but both frameworks have their own problems.

Mojo it’s more advanced than Dancer, but it has an important problem with the documentation (the lack of it) and with the non existent API stability (at least when I tried it, it was easy to break your application after an upgrade).

Dancer it’s simpler to use (and simpler overall), with good and almost complete documentation, but it’s less mature IMHO (and you can find rough edges while programming a real world application).

Anyway, both are interesting projects and I recommend them if you want to try a modern Perl based MVC framework.

Quote
"I’m tired of Perl being seen as a second-class citizen in the dynamic languages world. I freely admit that there’s a lot of bad Perl code out there (I’ll even admit to writing some of it) but it’s not bad Perl code because it’s Perl, it’s bad Perl code because it’s bad code."

From Crufty Old Perl.

Yes, I agree (indeed I’m guilty myself of coding some bad Perl code). Seems that Perl it’s the only one language capable of having bad practices: unmaintainable code, unreadable code, etc; or what it’s even worse, the only one language not being able to avoid these bad and undesirable things.

Text

Please, Help Me to Be Cool!

Recently there’s a very interesting thread in Planet Perl about marketing or we suck at web design:

I fully agree with those posts: the picture you show about your project is as important as the project itself. I think this is true in all the RoR projects I’ve seen so far. In fact, looking for a Trac substitute, I knew Redmine was a RoR application just for its appearance (well, I was lucky… it could have been a Django based application as well hehe).

How many times you have tried an application because of the screenshots? Yes, it looks cool, let’s make a try.

The problem is that not every developer has the skills or the good taste to make a cool website to support his project, and that sadly may affect the project success.

So, I bet there are good designers out there that want to contribute to the open source community. Would you adopt a project or developer?

PS: I would have liked to post a comment in the cited posts, but I don’t have an account. You guys should think about allowing comments of non-registered users.

Quote
"Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems."

From Jamie Zawinski, on comp.lang.emacs.

Seems that the now they have two problems kind of quote can be quite adaptable (s/regular expressions/threads/), but today it’s as true as back in 1997.

The now they have two problems is one of my favourite, followed by History repeats itself, first as tragedy, second as XML (a Karl Marx quote evolved).

Text

About Broken Links

This is not my first blog, I’ve been writing a blog in Spanish since October 2003. It has some big numbers: 1280 posts, 2561 comments and 58 trackbacks.

And recently I noticed it had broken links. Lots.

So I’ve programmed a small tool to help me clean out the posts of broken links: linkcheck.pl.

I’m sure the tool isn’t perfect, but it has worked great with my blog and has found 4544 links, and 611 were broken. I say had and were because now they’re over thanks to linkcheck.pl.

The tool is simple: connects to your database and gets the posts. Then it looks for links and checks them, and if any URL it’s broken, it’s replaced with the text in the link. Simple and neat.