Tuesday, December 30, 2008

The problem with OO programming languages

In Object Oriented Programming we extend a class by specializing it with a subclass. Going from the General to the specific. This seems to be the excepted way things should be. But it seems backward from the way things work in the real world.

In the real world primitive man had the whole numbers. Eventually problems were encountered that the whole numbers could not solve, so the integers were introduces. Later integers were found to insufficient to solve some problems, so rational numbers were developed. Eventually it was necessary to extend the rational numbers with the real numbers. Much latter rational numbers were extended to the complex numbers. Each extension required creating a super class of the existing class, not a subclass. I am hard pressed to think of a single field of endeavor where a breakthrough was made by specializing an existing concept to make a subclass of an existing class, it always seems to be the other way around.

The other problem is that the subclasses must carry all the baggage of the super classes. Yet in the real world specialized subclasses are less complex than the general super class, not more complex. Consider the classic shapes example, we will consider the specializations of a quadrilateral.

To specify a quadrilateral, we must specify the lengths of all four sides and two of the angles.

We derive a parallelogram from the quadrilateral. Now all we need to specify are the lengths of two sides and one angle, only half as much information. But in most OO languages (Ocaml being the only exception I can think of), we need to carry around all the data needed by the super class, a big waist, but it gets worse.

If we now derive a rectangle (a parallelogram the right angles) and a rhombus (a parallelogram with equal sides) from the parallelogram. The parallelogram requires three data points, but the rectangle and the rhombus each require only two, the lengths of two sides in the case of the rectangle and the length of a side and one angle in the case of the rhombus.

A square is both a rectangle and a rhombus (the dreaded diamond), this is the definition. Only one data point is required to define a square, It is simpler than either the rectangle or the rhombus, so why should it carry the overhead of both?

It seems to me the the existing OO programming concept of going from general to specific is backward. We should be going from the specific to the general in most cases.

Labels:

Tuesday, December 23, 2008

Picadillo

They say there are as many recipes for Picadillo as there are cooks who make it. I do not think so, I'm fairly sure there are more recipes than cooks. I know I never make it the same way twice. yesterday I found two recipes in my mother's recipe file, this is not either one of them. This is how I did it last time.

  • 2 Tbsp. Lard (you can substitute vegetable oil, but it will loose something)
  • 1 Large onion, chopped
  • 2 cloves garlic, chopped
  • 2 zucchini, grated
  • 1 lb. Ground beef (you can substitute ground poultry, I even used 1/2 lb. firm tofu, and 1/2 lb. tempeh for a vegetarian version once, but beef is best)
  • 2 cups canned tomatoes
  • 6 oz. Tomato paste
  • 2 cups raisins
  • 3 Tbsp. Red wine vinegar
  • 6 - 10 tsp. Chili powder (I like a sweet chili powder with not too much heat)
  • 2 tsp. Cinnamon
  • 1 tsp. Cumin
  • 1 - 2 Tbsp Sweetener (Sugar, Honey, molasses, or some combination)
  • A pinch of ground cloves
  • 1 Tbsp. Cocoa powder
  • 2 Oz. Chocolate (I used bittersweet this time, some times I use unsweetened. You could use dark. You just need to adjust the amount of sweetener.)
  • 1 - 3 jalapeƱo peppers, seeded and finely chopped

Fry onions, garlic and zucchini in the lard until onion is translucent. Add ground beef and brown well.

Add all remaining ingredients except the peppers and simmer for two hours.

Add the peppers

I serve it in tacos or burritos, or over rice or pasta. I have heard of it being used to stuff peppers or squash, but have not tried this.

Labels: ,