Skip to main content

Keeping Perl Classy

Perl 1 was released in 1987, before object oriented programming was a popular paradigm; while Perl 5 did add an object system, it is very minimal. Moose is an extremely popular module which adds more extensive support for object oriented programming.

I don't know anything about Moose or its history, but I figured I could write something anyway, making educated guesses about how things went down. [1] Fortunately haarg came along and sacrificed an hour of his time to save us all from that. Here's some stuff we typed at each other, with minor rearrangements and editing to make me look literate. Any resemblance to a real interview is entirely fictional, and you should contact your doctor if it lasts longer than 4 hours.

Read more…

Dare to be Stupid

So, part of the deal with OPW is that I'm supposed to blog about it frequently. Weekly, in an ideal world; but definitely every other week. At a month in, I still haven't written a single post.

The problem, as always, is a fear of looking stupid. I wanted to write about all the impressive stuff I've been getting done, but as far as productivity goes, I might as well have spent the last month writing ascii art porn [1] to my boot sector.

Read more…

All Good Things

This will be my last blog post for a while. Over the last couple of weeks I've had a lot of fun writing these daily posts, and looked forward to the resulting conversations with my amazingly smart and thoughtful friends.

Read more…

Unsafe Cast

This is the first time in this whole experiment that I've been tempted to skip a day. A lot happened today, some of it expected, some not, and now it's 11:40 and I got nothing. I can barely write my name in 20 minutes, let alone a lengthy and heartfelt dirty joke about C++.

Here's a poem instead:

I start a limer-
ick sometimes / but often can't
get all the rhymes. /  An
idea hits! / I'll pretend
that it's / really a tanka

Code tomorrow.

Prime Time

I just finished pairing with Gargravarr. [1] My sinister metacarpals have been in revolt for the last couple of days, [2] so he drove and I mumbled incoherently <esc>d2bi navigated. We're learning Rust and finding it a little rough.

Read more…

Real Time

I don't understand how software companies schedule jobs at all. Anything a programmer knows how to do, she automates. By definition, the remaining work involves flailing desperately across a sea of poor documentation and broken dreams, wearing the cement shoes of our own ignorance.

This summer I did a short contract, for which I had to track my time. Here's a log excerpt for a typical 5 minute task:

8:00 - try easy straightforward thing that will definitely work in less than 5 minutes
8:03 - wtf
8:04 - google
8:18 - try stack overflow solution that worked for 687 other people
8:20 - WTF
8:26 - reboot server
8:31 - google
8:38 - reinstall python
8:53 - read documentation of all software involved in easy straightforward thing
10:18 - reinstall grub
11:27 - read source code of all software involved in easy straightforward thing
16:87 - WHY IS THIS HAPPENING TO ME 16:87 ISN'T EVEN A REAL TIME
1:32 - try easy thing that I tried at 8:00
1:33 - it worked.  W.  Tf.
1:34 - sooo... how many hours should I bill for this?

Meet Mr O

A while back I promised to add inheritance to the quick-n-dirty 'classes' I wrote in javascript. But, I realized that this requires some background on the problems that can arise with multiple inheritance. So, let's look at how this works in Python, and then we'll implement the algorithm in a later post.

Recall that inheritance is a way to find attributes on an object that the object and its class do not have themselves. We can think of it as getting advice from a friend:

class Carol:
  def hide_body(self):
    return "Carol says:  I think there's still room in the root cellar."

class Bob(Carol):
  pass

bob = Bob()
print (bob.hide_body()) # "Carol says:  I think there's still room in the root cellar."

note: these code samples use Python 3. If you're using Python 2, you should have all base classes inherit from object

Even though Bob doesn't know how to solve his basic life problems, he's ok, because Carol has his back. Things get a little more complicated when we add more friends:

class James:
  def hide_body(self):
    return "James says:  Just turn it over.  If it can't see the police, the police can't see it."

class Betty(Bob, James):
  pass

betty = Betty()
print (betty.hide_body())

Does Betty's golf instructor end up in Carol's root cellar or not?

Read more…

The Write Stuff

I was talking with Gargravarr [1] recently about writing, and he asked how much work I put into my blog posts. The answer is a lot. I treat instant messages like emails, emails like term papers, term papers like Master's theses, and Master's theses like - well, who knows. I'm a little high strung, is what I'm saying.

My first drafts usually look like this:

Hah, C++ is weird.  And javascript.  But they're different.

My favourite chocolate bar used to be Snickers, but I now I don't like them as much, and

Forth something something (dick joke?)

One really clever sentence for beginning a blog post is

Dammit.

Used to be I'd give up around here, because how the hell is that going to turn into anything that anyone would want to read?

Read more…

Measured In Wats

Knowledge is power - it's measured in wats. That's the best line in the post, but you can keep reading if you want.

Javascript has a parseInt function that does what you'd expect:

> parseInt("3")
3

Its array prototype has a map function which also does what you'd expect:

> foo = [1,2,3]
> function addOne(x) { return x + 1 }
> foo.map(addOne)
[ 2, 3, 4 ]

I lied. Neither of these functions does what you probably think they do, at least not exactly.

> ['7','9','11','13'].map(parseInt)

I'm not going to tell you what the output of that is. Type it in to your browser console or Node. I dare you.

Read more…

The Poor Workman

Recently I found, not one, but two people who actually admitted to liking C++! I had always thought myself alone in that particular perversion. These people were in a much better position to judge it than I - they both work in C++ for Google, which I understand is an advertising company of some kind that has a largish codebase.

Programmers are people, [1] and programming languages, like anything else people talk about, come in and out of fashion. This has been on my mind since applying for OPW.

Read more…

Share