January 17, 2011 10:27 am
When trying to write some debugging code, I noticed something very strange. I could never get fuser to admit that its parent had a file open when called from a Perl script:
$ perl -e 'open(F, ">> /tmp/foo") or die; `fuser -a /tmp/foo`;'
But when I replaced the fuser call with a sleep, and then called fuser from a different shell, I’d get Perl’s pid, as expected. I was about to post this question to SuperUser and decided to try this just to make sure:
$ fuser . | grep -c $$
Wait, what? That worked? So I asked myself: Is this something specific to Perl? Is this something about the way Perl is running child processes? If only There Was More Than One Way To Do It. Oh wait, there is.
$ perl -e 'open(F, ">> /tmp/foo") or die; system("fuser -a /tmp/foo");'
I haven’t been able to find documentation about what exactly backticks do with open filehandles that makes fuser report the wrong information, but system() clearly doesn’t do it. I just thought I’d document it here for the next person who is trying to do the same thing.
May 22, 2009 2:24 pm
I’m not a huge fan of karma-accumulation websites. You know what kind of site I mean: Other people can vote up or down your stories and comments, and you get points when you’re voted up, and lose points when you’re voted down. There are lots of these, each with their own scoring foibles: Digg and Reddit are two of the most well-known. Slashdot has done it for a while (in fact, I think they’re why I still call this concept “karma”). The concept is good: You limit the requirements for moderators by allowing users to essentially moderate each other. If a post or comment gets enough down votes, it might vanish. If a post gets a lot of up votes, it becomes more prominent. Fewer dedicated moderators generally means lower overhead costs and, in theory, a “fairer” moderation policy.
In practice, though, there are a lot of things to not like about these schemes. Accumulating points becomes an end in itself, which leads to posting a lot of simple or purposely-misrepresented posts (“whoring”). When points are used to control if your posts are seen at all, creating multiple sockpuppet accounts to vote up your own contributions (“gaming”) is inevitable. On the larger sites, an above-the-fold link can mean tens of thousands of hits; gaming then becomes a lucrative business. Preventing whoring and gaming through algorithms can work, but search engine optimizers are smart and tenacious. It’s a continuous arms-race.
Stack Overflow is a point (“reputation”) accumulating site that somehow works extremely well. At first glance, it is a simple programming question-and-answer forum where you gain reputation for answering questions and having those answers voted up or chosen as “correct” by the asker. But there’s a number of things I haven’t seen anywhere else that makes Stack Overflow excel where other sites struggle. The most obvious difference is that you are able to do more things as you gain reputation. You can’t even vote up questions or answers until you’ve received a couple of votes of your own, increasing the burden to entry for sockpuppets and gaming. Maybe more importantly, points accumulation isn’t single dimensional. Stack Overflow gives you badges for activities that are difficult to game, and displays your badge count right next to your reputation.
But there’s a bigger reason why this works on Stack Overflow. There’s no real benefit to gaming or whoring. Since the focus of the website is question-and-answer, instead of directing traffic to other websites, there’s almost no way to make a profit from having a question voted way up. And the relative smallness of the audience compared to some of the giants out there means that even if there was a way to turn a profit, focusing on other sites would still give you a better return. What’s left to be seen is if Stack Overflow can keep such a high signal-to-noise ratio as it continues to grow.
April 8, 2009 8:49 am
Just over a year ago, I was sitting in a classroom at Sun’s virtually deserted Burlington campus, learning a new programming language from a living human in person for possibly the first time in my whole life. The class itself was a little slow; it definitely wasn’t geared towards experienced developers. But it was more effective learning than fiddling at work had been, since it successfully prevented all distractions. Now that I’ve had a year to work with the language (and have gone back and forth to programming in Perl), there’s several reasons why I’m still using Java.
- Strong typing: Perl has no type safety, and I used to think that was an asset. But when you have a dozen programmers working on hundreds of source files, type conflicts can easily get introduced and go undetected for a long time. Objects are hashes, references are scalars, and arrays are quietly scalar-ized.
- WAR files: Releasing a new version of a website is brainless with Java. See that .war file that was built by Eclipse or Maven? Copy it to your server. Done.
- JUnit, Hibernate, Spring, log4j: Perl has a lot of freely available modules. But not a single one of them is as useful as Hibernate alone. It encapsulates database objects transparently, and is remarkably flexible. We’ve got a lot of awkward legacy database schemas, and without Hibernate’s flexibility, we’d be building database objects by hand with JDBC. Spring’s dependency injection and session management, JUnit’s unit testing mechanisms, log4j’s logging simplicity, and Maven’s build architecture mean we spend less time planning and re-planning the infrastructure of our applications and more time implementing functionality.
- Eclipse: I know that there are Perl plugins for eclipse (EPIC in particular), but they never added that much useful functionality as far as I was concerned. Having a full-featured IDE with method completion and inline error display saves me huge amounts of time.
- Everything is a reference: Java’s object-oriented nature reminds me a lot of C++ (that’s the OO language I have the most experience with) except for the lack of the object/pointer paradigm. The fact that everything (okay, okay, besides primitives) is a reference keeps me from having to remember all of my pointer-management skills.
I could probably come up with a dozen other reasons that I enjoy programming in Java, but those are the big ones that make my life easy.
December 20, 2008 10:19 am
It’s been a week since I posted Film Addict. It got posted to kottke.org, Slashfilm, USAToday.com, and became a Twitter and Facebook meme on some level. At this point, it has received 100,000 pageviews, and it was filled out 37,000 times (peaking at a rate of over 1000 per hour, but at this point still about once a minute).
- If I use strict and warnings, I should keep an eye on the Apache error log. I generated 10GB of errors in the first 24 hours, filling up /var on my webhost, which resulted in 8 hours of downtime during the Slashfilm surge.
- Google Adsense now allows “personal” domains. I tried to sign up in 2004, when Weboggle was all the rage, and I was turned down because it lived under plutor.org. I’m not sure when the policy changed, but I applied this week and was approved on Thursday.
- Google ads don’t really make you much money. At this point, the ads on the Film Addict page have made me $2.90, but even if I had had them from day one, I’d only have made about $15.
- I sleep fine at night, even after creating something clearly intended to be meme-fodder.
- With enough data, you can get awesome bell curves. Histogram of number of movies seen:
It didn’t end up going much of anywhere on Digg or Reddit or Delicious. I’m not sure why, but I think part of it might have been the individual nature of the form. You could compare your list against your friends’, but there was no community interest. Another factor (especially on Delicious) was the unique id in every posted URL; there could never be enough posts of a single URL to get any momentum.
December 13, 2008 4:21 pm
A couple friends of mine posted one of those lame Facebook chain note things today. It was a list of a couple hundred movies, mostly 18-25-year-old targeted franchises from the past decade or so (think Scream, Saw, American Pie, etc) with some others (mostly very popular) thrown in. “Copy this list to your profile and check off the ones you’ve seen”. The list’s arbitrary inclusion criteria angered me, so I decided to make my own, with a better inteface than “copy and paste it yourself”. The list is IMDB’s top 250.
I posted it to MetaFilter Projects. Pretty much immediately, Mathowie Twittered it. At this point, more than 200 people have taken it already. Give it a try, compare your list to mine.