Chad Perrin: SOB

31 August 2006

the role of OOP for programming instruction

Filed under: Cognition,Geek — apotheon @ 04:16

There’s quite a bit of discussion floating around on the Web about what makes one programming language “better” than another, both in general and in specific cases. While much of that is dependent on circumstances, personal preferences, and assumptions about the sort of tasks you wish to complete, some of it is fairly universal. There are precious few, for instance, who would say that GWBASIC is a better language than Ruby. There are fewer still who would say Brainfuck or Whitespace is better than both. On the other hand, as a joke language, Whitespace is hard to beat.

Personal preferences make a difference in how easy it is to learn a given language but, again, there are some generalities that can be made. It’s generally easier to learn to program via Perl than, for instance, C++. There are some specific, somewhat measurable characteristics of languages that contribute to this. I would suggest that a language that aims to be easy to learn as a first language should include the following characteristics:

  • not much of the syntax need be known to be able to write code
  • not much of the syntax need be known to be able to read code
  • unknown syntax is very easy to look up
  • semantic structure lends itself to thinking about program architecture
  • language lends itself to succinct code
  • syntax is easy on the eyes
  • programs with errors should fail in a verbose and helpful manner

I intentionally avoided social aspects of programming languages, focusing instead on the technical design characteristics of the language.

A language like Ruby or Python is among the easiest on the eyes (generally — my personal preferences make Python very hard on my eyes in particular), as contrasted with some other languages (many will think of Perl here, but it’s not all that bad — better than Lisp, I would think). It’s incredibly easy to look up unknown syntax in both Perl and Ruby, both of which are also very helpful and verbose when a program errors out. It’s unlikely that I’ll surprise anyone by mentioning that Ruby and Python kick Perl’s ass in terms of being able to read code without having to know much of the syntax, though Perl makes up for it somewhat by being one of the best languages in the world for looking up unknown syntactic elements. Python is reasonably good at making it possible to write useful programs without knowing too much of the language’s syntax — marginally better than Ruby, in fact, which might surprise some people who know how much I like Ruby in general and detest Python. PHP is generally better at being writeable without knowing much syntax than either Python or Ruby, largely because its core syntax could probably be written on a thumbnail by an enterprising cheater on a college exam that has very neat handwriting. Perhaps surprisingly, I think Perl is actually just about as easy as PHP for a newbie to start using without knowing much syntax — it’s absurdly easy to start with a tiny subset of the language while writing useful programs. In fact, I think it’s easier than PHP in this respect, one of the easiest languages out there in this regard, though Lisp dialects are clear winners over even Perl.

It was the realization, earlier today, of the relative difficulty of writing useful Ruby without knowing much syntax that struck me as odd. I think it is better than C++ or Java in this respect, but it is still surprisingly more difficult than I would have expected. The major win is not in needing very little of the syntax, but in the fact that the syntax is easy to use once learned, and in the fact that it is easier to guess valid syntax than in many other languages.

I was considering how it stacks up to Perl and Lisp on this matter, as I spoke with Sterling. While Perl itself is dead easy to use with very little volume of knowledge of its syntax, and Lisp even easier, both languages by contrast require a hell of a lot more knowledge of syntax to be able to use their object systems. I thought about this in relation to what makes Ruby sort of a “loser” in this regard, and realized that it is, in essence, the object orientedness of the language that forces a heavy necessary syntax knowledge overhead on the newbie programmer.

Once I start separating things into categories by object orientation, Ruby starts to look a lot better on this easiness of learning metric: compared to other object systems, Ruby’s does not require a very heavy syntax knowledge overhead for writing useful programs. While Perl itself is easier to learn in this respect than Ruby, Perl’s object system is more difficult to learn by this measure than Ruby’s. In comparison with other object oriented languages then, Ruby is a net winner (though, as Sterling pointed out, whether it is a .NET winner is still up for debate), as is Python (for very different reasons).

I don’t really know, off the top of my head, how this helps us in determining how to teach programming to people (even if those people are ourselves), or just to teach new programming languages to people who already know how to program. It may be something worth considering the next time you decide to start designing a new language, though. I think it’s an important consideration, even if I’m not entirely sure of how it can be translated into concrete benefit. Something it suggests to me, however, is that the Logo advocates were probably right to choose it as the first instructional language to introduce to children, and those who advocate object oriented Visual Basic should probably be drug out in the street and shot (not that I wasn’t already leaning in that direction in the first place).

At this point in the evolving history of programming, on the other hand, OOP is something that is very important to learn if you’re serious about programming. In that regard, then, Ruby is one of the best languages available for teaching object oriented programming. If you believe that OOP should be taught first, maybe Logo isn’t the way to go.

29 August 2006

restrain power by granting more of it

Filed under: Liberty — apotheon @ 02:53

unsurprising statement, coming from me: The law enforcement and criminal court system in this country is screwed up.

surprising statement, coming from me: We can fix some significant problems with this country’s law enforcement and criminal court system by giving the police more power to convict the guilty.

No, really.

Let’s take a case study. I stumbled across the writings of Scott Broadbent, who says the USA is a police state, or at least rapidly becoming one. He, in turn, apparently found the information on which that entry is based at Boing Boing, which relayed information about a man who was arrested for taking a pic of a cop arresting someone else. Boing Boing credits the story to Thomas Hawk, but sources NBC10.com for the story about a Cell Phone Picture Called Obstruction Of Justice. Here’s the short version:

Cruz said that when he heard a commotion, he walked out of his back door with his cell phone to see what was happening. He said that when he saw the street lined with police cars, he decided to take a picture of the scene.

“I opened (the phone) and took a shot,” Cruz said.

Moments later, Cruz said he got the shock of his life when an officer came to his back yard gate.

“He opened the gate and took me by my right hand,” Cruz said.

Cruz said the officer threw him onto a police car, cuffed him and took him to jail.

A neighbor said she witnessed the incident and could not believe what she saw.

“He opened up the gate and Neffy was coming down and he went up to Neffy, pulled him down, had Neffy on the car and was telling him, ‘You should have just went in the house and minded your own business instead of trying to take pictures off your picture phone,'” said Gerrell Martin.

Let’s assume for the moment that Cruz, his family, and his neighbor are all telling the truth about what happened. My point in bringing it up is not that it did happen, but that it easily could have happened exactly as described, and none of us is likely to deny that any time soon. That’s a scary thought.

Assuming it’s true, and provably so down to the last detail, here’s what’s likely to happen:

All charges against Cruz will be dropped. The police officers involved will be told they shouldn’t do that. Life goes on, same as before, only now we’re just a little more afraid of the police.

How do we fix this? I, for one, am absolutely convinced it needs to be fixed. Let’s just go with that opinion for now.

The answer is, believe it or not, to grant the police and courts more power to convict the guilty with gathered evidence, regardless of how the evidence was gathered — assuming it can be shown to be legitimate evidence, rather than manufactured evidence, of course. The answer is to stop “punishing” the police and courts by letting criminals go because someone didn’t have “probable cause” when he entered someone else’s home and gathering the perfectly valid evidence improperly.

That doesn’t mean we should just let the police go around breaking into random homes and looking for evidence of crimes, of course. No, my solution would probably actually reduce the incidence of malfeasance on the part of the police. See, as far as I’m concerned, whether or not a police officer was acting properly has zero effect on whether or not the evidence is good. On the other hand, a police officer that violates someone’s rights is, in my estimation, a criminal. He should be treated like one. If someone breaks into your home without a warrant or “probable cause”, he should be put on trial for breaking and entering, whether he carries a badge or not. If, while there, he finds the severed thumbs of your last twelve murder victims, those thumbs should not be excluded from the case against you, though.

The criminals go down for their crimes — both of them. With the system we have now, both criminals get off free. That’s just not acceptable.

2006241: links for 29 August 2006

Filed under: Geek,Liberty,Metalog — apotheon @ 11:58

Taking a page from Sterling, among others, I’m putting together a list of worthy links for you:

  • The War on Terror as viewed from the Bourne Shell: hilarious. My favorite part is
    $ ls bin $ cd bin $ ls laden
  • Eulogy on Disc: an insightful analysis of the direction of storage technology (hint: kiss your CDs goodbye).
  • Some of Your Friends are Already This Fucked: a hypothetical example explaining exactly how the RIAA and its member labels are using copyright law to “protect the artists”.

That’s enough for now. That last one just depressed me.

Older Posts »

All original content Copyright Chad Perrin: Distributed under the terms of the Open Works License