Posted by: capehart | November 5, 2009

On the Acquisition of Skill

I have been reading up on the Dreyfus Model of skill acquisition. I like the model reasonably well. I have always been a big proponent of something along the lines of Reflective Practice; that is, trying to understand your own learning and skill, and use this understanding to improve your skill. Similar to meta-cognition (thinking about thinking).

While moving some wood out to the trash pile (I do some of my best thinking while doing physical work), I had an interesting thought. The Dreyfus model does work well in modeling the acquisition of skill in a given subject, and can be nicely expanded on. Specifically, it can be used to model the acquisition of general skill. As you acquire skill in any given subject, you acquire a sort of understanding of the way skill works in general – unconsciously or, with meta-cognition, very consciously – and can move up through the levels of understanding much more quickly in other subjects. In fact you can, through certain types of exercises in meta-cognition, acquire this skill even faster. I suppose we could call it meta-skill.
I think perhaps the most important thing you must do to acquire this meta-skill is to decompartmentalize your mind; you must learn to connect each of your experiences with the rest, not thinking about something in isolation. Sometimes you have to think about something in isolation, but it needs to be a conscious, temporary thing. After all, if your experiences are disconnected in your mind, how can one field you possess skill in help you acquire skill in another?

The idea of decompartmentalization in meta-cognition is extremely important in even a single field. Take, for example, my primary field: software engineering. To simply believe that understanding syntax and a few maxims like “write lots of comments” will give you the ability to be a good software engineer is laughable. However, this is how many students – and even some professionals – view things. They ignore the complex and vital relationships between mathematics and programming for instance. Things get even worse when they start to try to work in a problem domain that they are not used to; they have no idea how to apply programming to the problem! It’s alright to start out like this – the novice level of the Dreyfus model – but one needs to move past it to become more skilled.

Posted by: capehart | October 24, 2009

On interviewing for fun and learning

A lot of people don’t like interviews; I think this is a shame. They offer great opportunities for fun and learning.

Fun? Well, you are getting the opportunity to talk about the thing you love, programming. And if you don’t love programming, why are you interviewing for a programming job? And when the interviewers ask technical questions, you get to solve a cool puzzle (assuming the interviewer is good). Plus, you get to brag about your accomplishments, and chat about your experiences. How often do you get to this, except when showing vacation pictures to captive family members?

As for learning, the whole thing is rife with possibilities. When they ask a questions you don’t know the answer too, that just means there is one more cool thing to learn about that is also important to prospective employers. If you can get them to describe it to you, you immediately get to learn about it, and can perhaps impress the interviewers if you grasp the concepts quickly enough.
For example, at my last interview the RAII (Resource Acquisition Is Initialization) idiom was brought up. I feel pretty dumb for not knowing about it, since it is such a simple idea, but I got it pretty quick when it was explained. It is very valuable, and I have read more on it now, and am very glad for it.

Why wouldn’t you get a kick out of getting to do this?

Posted by: capehart | July 15, 2009

On global objects

Global objects and variables are usually considered a bit of a no-no in programming. However, sometimes they are unavoidable, and oftentimes the prohibition can cause more troubles then it prevents.

The biggest reason for avoiding globals is that it makes it so any function can change them at any time, making it harder to trace execution and debug programs. However, sometimes avoiding them requires passing around a lot of arguments that can increase complexity and reduce understanding much worse then having them! This is especially the case if a function has to except an argument just because a function that is called by a function that it calls needs it! We don’t always need to do this, and in those cases globals should be avoided like the plauge; they should not be used just so you don’t have to be disiplined in argument passing.

However, in those cases where an object/variable is truly needed in a global scope, such as the console in an OS kernel, passing it around would be a nightmare. In these cases globals are something to be used, cautiously.

In the case of global objects in C++, another problem rears its ugly head: order of initialization. When a program is run, all globals are initialized, usually by functions provided by the standard library, or by you in kernels and low level code. The problem is that the order of initialization is undefined. When the program starts, every global object address is considered valid, but has not been initialized. If one object tries to use an uninitialized object in construction, there’s a problem, and it’s usually a run time error. To prevent this, we can use global object functions, like so:

Foo& getGlobalFoo() {
static Foo g_foo;
return f_foo;
}

The first time the function is called, the object is created and initialized. Because it is declared static, it is only created once and the same instance is used through the whole program. The best part is that we don’t need to worry about initialization order at all; the function calls will cascade down, creating each function as needed. In a fast response system we may not want this, so then we can call each one, in the correct order, on entering main (or wherever makes sense).

Posted by: capehart | July 15, 2009

On building a C++ kernel

It takes a lot of work to get an OS kernel working in C++. I finally fixed the problem in my previous post, which was a linking error.

Now, the basics can be done by linking largely the same way as for C, but important features (such as virtual functions!) require more work. Worse yet, there is very little documentation of the subject.

It took me a couple hours of stepping through assembly while watching registers, as well as reading through some LD scripts, but I finally figured out some of the problems.

1. Virtual functions: A virtual function call through a pointer in C++ requires a vtable lookup. This vtable is compiled (at least in GCC) with a linkonce.t label. If LD does not find a reference to this in its script, it will simply toss the whole section and continue as if nothing happened! So, we have to tell LD where to put it, as such:

.text phys : AT(phys) {
code = .;
*(.text)
*(.gnu.linkonce.t.*)
*(.gnu.linkonce.r.*)
*(.rodata)
. = ALIGN(4096);
}

2. Above is also a linkonce.r label. This is used, (possibly for other things as well?) for member functions defined in the class body. Same problem of non-inclusion if not expressly linked.

A good source for information, but far from complete, is: http://wiki.osdev.org/C_PlusPlus

There they discuss some important issues, such as global objects (see my next post!), pure virtual functions, etc.

Posted by: capehart | June 26, 2009

On OS difficulties

I’ve been building the C++ OS that I mentioned in a previous post. There are fairly significant difficulties, and now I suspect there are some issues with the build process I was provided with. I’m using djgpp (a windows port of GNU gcc), including gpp, ld and make. I am using the bochs emulator to run the OS.

Well, the big problem is that the system dies when any attempt is made to do an indirect virtual function call; that is, any call to a virtual function through a pointer instead of an object. I have been using the free version of the IDA disassembler to examine to fully linked executable. The full version is over $400, but even the free version is nice!

The best idea I have come up with yet is that the vtable is somehow not being initialized or even allocated. The best indication of this is that when the vtable reference is made the address of the function is supposed to be in the eax register, at least with the compiler and architecture I am using. The problem is that it is not! By the time the function is called, eax contains 0×0, which is quite bad.

Posted by: capehart | May 20, 2009

On operating system education

The CS department here at A&M has recently gone through a complete program redesign. I will be on of the first students to complete the new program. Now, a certain class, a capstone, is required for graduation. However, this class does not exist, and will not exist until the semester after I am slated to graduate. So, the adviser gave me the option of doing an undergraduate research project instead. While I am not as interested in research as practical work, the subject is not without its benefit, and I found a project of interest.

I am to design and implement the machine problems (projects) for the senior level operating system class here at A&M. The professor in charge of the class asked me to do this because he does not have the time, and does not get a TA early enough; especially since it will take a couple months. He wants it to be designed in an extremely modular fashion, so the students can take out a module and replace it with their own. I will implement these modules (such as paging management, non-blocking keyboard I/O, etc.) with naive algorithms and techniques. The students will be assigned to remove my module and code in their own, using appropriate algorithms. This has some pretty nifty benefits:  the students will have a largely working operating system in which to test their algorithms; the professor can pick and choose which aspects of the OS he wants to teach; and the simple design will allow the students to learn from the whole system, not just the assigned parts.

To allow this modularity the professor would like me to build the OS in C++. I am not completely convinced this can be done well, but I have some ideas and am certainly going to try. I am currently learning the about the C++ object model implementation so that I can work with it to get the results I need.

Posted by: capehart | March 25, 2009

On Colorado

Lauren and I spent spring break in Denver and the surrounding area, snowshoeing around mountains and hiking in Canyons. It was immense fun, and good relaxation, but was also to see if the Denver area was somewhere I might like to live. I still need to do a bit of research on cost of living, taxes, etc., but I really like it so far. Denver is a much nicer city than Houston or Austin. It feels less crowded, even during rush hour, and a bit cleaner. There are lots of people into outdoor activities (how could you not be, with the mountains right there?) There area around Denver is a little odd though: everything East, mostly North and South as well, is extremely dry and brown in the early spring. However, to the West are beautifull mountains, with lush green trees on the Western side.

I think if I lived there, I would want to live West of Denver, maybe South-West, and drive into work. My top interest in a job right now is Lockheed Martin in Denver. They are a great company, I could work there I would love on exciting projects, live in a beautifull place, and I could hopefully even work at the space systems company, my greatest interest of all.

Posted by: capehart | February 7, 2009

On math and knitting

As a bit of background, I knit in class. I found that in lectures my mind tends to wander, often to related subjects to the lecture, but wander nonetheless. I am so used to multitasking that my mind has trouble concentrating. Even more of a problem is lack of focus when I am tired. Having something to do with my hands helps immensely with both problems. I learned to knit because it is an inexpensive hobby, that is quiet, easy to do, and keeps just enough of my concentration to help me stay awake and pay attention in class. I used to have a friend who made chainmail in class for the same reasons. People are generally amused, professors never seem to mind, and I learn better.

Well, several days ago I was in my analysis of algorithms class. The professor was discussing the use of induction for a particular problem and a fellow student said “That’s horrible!” I commented that “If you hate induction this might not be the best career for you.” Now, I said in a polite tone; it was a touch harsh I admit, but very true, and a very important concept. If you hate math, computer science/programming will just get more difficult, and your quality will suffer. However, his reply? “So says the man who is knitting.”

Now, I simply have trouble understanding why he would say such a thing. I suppose it is possible he thought I was not paying attention in class, but he well know I love this stuff and get good grades. The best a friend of mine can figure is that it was simply the first ad hominem attack he could think of. It might go a bit like this:

Joshua said a harsh thing.

Joshua is an in class knitter.

In class knitting is a statisticaly strange thing.

Therefore, Joshua is a strange person.

Strange people’s opinions can be ignored.

Therefore I ignore Joshua’s false comment.

Now, I’m not particularly upset. I can’t even figure out for sure what he thought he meant, so why would I be bothered by it? But ultimately, it worries me, this idea that math is not important for programmer. The idea so widespread, people thinking their math class are useless, that they don’t need to worry if they hate math and logic. Programming is logic, it is problem solving; if you can’t handle math, you can’t really handle programming. That is, not in any capacity as a career.

Posted by: capehart | February 2, 2009

On low level programming

I have been pondering an interesting dillema. I vastly prefer low level programming, with its challenges and fun, to application or web programming. However, I have a very definate love/hate relationship with C++ (is there any programmer who does not?) While C# is my favorite language, that is mainly from a design and productivity standpoint; the capabilities of the language are far more important. I suppose that C++ is more challenging, but sometimes it can be more frustrating then invigorating. But nonetheless, I enjoy programming in it more because I am usually working on lower level stuff.

Posted by: capehart | February 2, 2009

On career paths

I have decided it is well time for me to solidly decide where I want to head as a programmer, at least in a general sense. I do not need to know exactly where I am going, but a general idea is good. For a long time I have been heading towards low level programming, real-time programming, and embedded systems programming. I’ve always had a things for binary, digital logic is a blast, and I think web programming is an utter bore (unless backed by some interesting algorithms, or having some difficult problems to solve).

Embedded systems in particular is very cool. I have less experience in that then I would like however, because I simply have not had access to any embedded systems to program! I am planning to find and order components to build one myself, something I can practice with. I like working close to the machine, and love a good challenge; embedded certainly offers these.

Real-time is also very exciting. Programming with time constraints is more fun then without, because there is more to think about, bigger problems to surmount. I know there are very good reasons some applications programmers don’t worry about effeciency as much as they used to, but I just don’t have fun that way.

Web programming and most applications programming just are too easy; I can’t get excited about them. Plus real-time and embedded systems are often in really fun areas, like aerospace and defense. I could also imagine myself working on low level operating system internals.

Older Posts »

Categories