Archive for the ‘programming’ Category

programming is like writing – I can never start either

Saturday, October 18th, 2008

I hate to write and I suck at it. When I was in high school and college, I always start my writing assignment at the last second before it is due and I will work late into the night to produce some sentences that probably did not make any sense to anyone. The hardest part about writing was always about getting it started. I will write a sentence in the introduction paragraph, surf the web and then write another sentence.

I feel the same way about programming. A lot of time is spent doing random stuff and once in a while I will have a flash of brilliance and write a whole bunch of code. I wonder if an excellent writer will also make an excellent programmer. I think there are a lot of similarities between writing and programming. I wish I can list them and then I will work on them and become both a better writer and programmer.

The ‘Anti-Java’ Professor and the Jobless Programmers

Tuesday, July 29th, 2008

http://itmanagement.earthweb.com/entdev/article.php/11070_3761921_2

I read an interesting article today while waiting for some code to compile. The article discusses Professor Dewar’s view on Java in the current CS curriculum. Professor Dewar is unhappy about Java and its vast array of predefined classes that students can readily used. He thinks most students do not need really need to understand data structures and software engineering because they can easily create a program by calling the various classes that are already defined in Java. Then the article goes on to talk about some solutions that Dewar is proposing and the article also brought up some counter points such as code re-use in the real world.

I am not sure how easy it is to implement some of the proposed solutions nor have I worked long enough to really understand how code re-use works in reality. However, I want to give my 2 cents about the use of Java in CS curriculum.

One of the hardest class I took was CS61B at Berkeley, and every programming assignment and project was done using Java. Many of my classmates can verify that the class was not easy and a lot of materials were taught. I am not sure how much of it I actually learned :-) . I remember trying to write a quad-tree in Java and it was a pain in the butt to do. I think I even had trouble getting it to compile in Java. Now imagine writing the data structure in C or C++, and having to worry about pointers and why segmentation faults are happening. Java allows us to do the assignment and put all of my focus on understanding the data structure and implementing it without worrying about other issues that may go wrong.

I am not saying that Java is good or bad, but it fits well with the class. I think what it is needed is a well defined curriculum and whichever language is used is not that important. If you are teaching about data structures, assign some problem where the students actually have to implement the data structure. Suppose you are trying to teach the concepts of hash tables and the student is asked to implement it. Now, does it really matter whether the student uses the link list class in Java or write his own link list for the chaining part of the hash table (I think that is what it is called)? I think it is more important for the student to understand that the hash function should be uniform and collision should be avoided.

I am sure many people have different views on this, but to me a good CS curriculum is a carefully planned out curriculum and has little dependence on what programming language is used in the class.
Personally I hate Java; it may have something to do with my experience in the CS class I took.

Code review with emacs

Sunday, June 29th, 2008

Does anyone know how if there exist an emacs extension that allows you make comments on the source code. I am talking about comments boxes like the one in MS word. I do not want to modify the source code by adding comments to the file.
I am asking this because I need to perform code review, and I think that printing the source code on paper for each member of the review team is a waste of papers. I am curious to know if there are any free softwares that allows you to annotates source codes and saves the annotations in a separate file. Then we it comes time to meet face to face, we can just step through the list of comments/annotations and discuss it.

I did a little google search and found that there are some web based code review systems out there. However, they are way too complex for what I need. From the little descriptions I read, these systems were built for collaborative code reviews where people do not meet face to face. I just want a simple system that allows me to do annotations. Ideally this will be an emacs extension as emacs is the main editor I use.

backup into local directory in emacs

Saturday, June 14th, 2008

One thing I don’t like about emacs is the large number of backup files that it creates. However, this is really a necessary evil. The backup files have save my life many times. I am careless sometimes, and I may accidentally replace one of the files while using the mv/rm command. But I really hate having to see all of those files ending in the ~ sign scatter around my directory.

I searched online and found a solution where all the backup files are moved into a single directory. For instance, I had all of my backup files moved into an invisible directory ~/.saves. However, I find that there are way too many files in the ~/.saves folder and it is quite difficult to find the file you want sometimes. I am pretty sure emacs has a way to automatically recover the backup file without you having to manually locate the file and move it. I didn’t try to figure how to do that because I wanted to place all of the backup file into an invisible directory in the directory where the original files resided.

I search some more, and it turned out that you can easily do this by setting the backup-directory-alist. Basically if you put this line { (setq backup-directory-alist (list (cons “.” “.emacs_backup”))) }into your .emacs file, then all of your backup files will go into the invisible directory .emacs_backup in the directory where the original files are. If the invisible directory doesn’t exist, then emacs will automatically create it for you.

The more I use emacs, the more I like it as my primary editor. Now if I can figure out a way to get it to start faster, everything will be perfect.
(setq backup-directory-alist (list (cons “.” “.emacs_backup”))).