You are currently browsing the category archive for the 'programming' category.
I attended a Matlab training seminar yesterday with the dual topics of “Advanced Matlab Programming” and “Distributed and Parallel Computing.” Of the two, the Advanced section was more interesting, though my original motivation for going was the parallel computing part. In the morning, I felt like it was going to be a waste because my Matlab programming skills are weak, and if my advisor had not strongly suggested I attend, I might’ve skipped it. I’m glad he did, because it was surprisingly enjoyable and I felt like it was right on my level. This might be because programming in Matlab isn’t especially hard or different from other programming languages and I know enough to get by already. Or it might be because Matlab is becoming a little more like Python.
Just what value is there in getting a degree in Computer Science (CS)? Are new graduates competent programmers? Is that the purpose of a CS degree? Should companies be spending money to train new hires out of college in the programming languages and practices that they use?
Robert Dewar is a professor emeritus at NYU in computer science, and he believes that the status of software engineers in America is in danger due to general incompetence of new graduates. The long and the short of it is that after the dot-com bubble burst, and computer science enrollment at universities plummeted, schools restructured their programs to be more fun. Essentially, they were dumbed down. Specifically, the focus has shifted away from math and the theory of computation. Students are not taught a wide range of programming practices, but instead are trained to rely on large software libraries in a sort of “cookbook” approach. That is, students can assemble a solution to a known problem (in Java), but they are woefully undertrained for solving actual problems in the wild with “more practical” programming skills.
Today is Donald Knuth’s 70th birthday. If you haven’t at least heard of him, then you probably are not a programmer. I’ve heard several bloggers refer to him as a modern-day Alan Turing (who is widely considered the father of computer science). Knuth is sometimes referred to as the father of algorithmic analysis, so at the very least, his contributions to the field should definitely earn him a place of high regard.
While I’ve never read any of his books, I have used one of the tools he created quite extensively in the past two years: TeX. For those who’ve never had the pleasure of using TeX and seeing documents come out beautifully and professionally formatted with relatively little effort, you’re missing out. Some might argue that you’re missing out on hours of headaches for something you could do in Microsoft Word in 1 minute. I would argue back that while getting TeX to do exactly what you want can sometimes be hard, there are things you can do in TeX very easily that you will never, ever be able to do in Word. Try producing a lower case delta with a hat in Word. Unless you are lucky enough to have a font on your computer with it (and please send me a copy of that font if you do), you will be searching a long time.
There are many Knuth tributes out there from people with far more interesting stories than me. There was an even a call to post, issued by Jeff Shallit. Here are a few:
-
Recursivity - biographical notes and discussion of Knuth’s impact on his life (Jeffrey Shallit)
-
Computational Complexity - some observations about his achievements, his books, and TeX
-
Good Math, Bad Math - a lot about TeX if you’re interested
-
Geomblog - a discussion of something from the second volume of his book The Art of Computer Programming
-
Shtetl-Optimized - more in-depth observations of Knuth’s many contributions
-
in theory - more biographical info and background
-
0xDE - a pretty remarkable Knuth tribute with some very interesting CS stuff, complete with exercises!
I think this should be required reading for any novice programmer and probably even more so for established programmers. Agree with him or not, I think you’ll agree that Steve Yegge has some interesting things to say. My favorite quote:
“Bigger is just something you have to live with in Java. Growth is a fact of life. Java is like a variant of the game of Tetris in which none of the pieces can fill gaps created by the other pieces, so all you can do is pile them up endlessly.”
This is especially interesting to me as I just jumped on the IDE bandwagon. I received a few interesting comments on that post that are worth reading. A minor theme was the fact that you just can’t handle a massive code base without some kind of IDE (Integrated Development Environment). I have worked with a code base of about 20,000 lines of Java with no IDE and there were certainly challenges. I have also worked with a code base of over 100k lines of C (not ++) and that was a pain in the butt. Massive changes took me days to complete and then weeks to debug. Having an IDE would have made it easier, but it also would have made it much larger. It is so easy to bloat up code with every kind of get/set method and constructor there is, but many of them are never used. Is that a bad thing or just good future planning? There is definitely a trade off, and one that probably comes down on the side of bad thing more often than not.
In any case, it’s something I have to keep in mind as I go forward with my new project.
Up until recently, I was pretty old school with how I write my code. Vim, baby. No code completion only syntax highlighting. I had used a couple IDEs back when I first started taking classes, but just found them cumbersome. For my software engineering class this semester and for my project next semester, I will have to use Eclipse. This gave me my first opportunity to use Subversion in a team environment as well. I must say, I was seriously missing out. Eclipse has been really fun to use and being able to check in code and keep track of changes has been invaluable. Now I’m subversioning all of my side projects. Overkill? Well, this way I can instantly sync between my laptop and my school linux machine. I use the school machine to run experiments since it’s running four 3 GHz processors whereas my laptop has only two 1.8’s.
Anyway, last night I decided to check out the new version of the NetBeans IDE (6.0). I had used it very briefly in the past and found it to be a slow resource hog. It’s still a hog, but runs fine on my laptop with 2 GB of RAM. Plus the new features are pretty awesome. Not only does it have code completion, but code suggestions and instant generation of get/set methods for your class variables. Also, like Eclipse, it has subversion support built-in.
Which IDE do you use? I’m admitting here and now to being a noob to the IDE world, so is there something better?
I discovered the java.util.Properties class a couple weeks ago in the ginormous Java API docs. If you’ve ever created a software project where you have a lot of different settings that change frequently, this is the class for you. In my research, I implement all these different algorithms for various things, find out they don’t work, implement something else, rinse, repeat. Being able to look back at my results from two months ago and then loading the exact same configuration and running the experiment all over again is a must. Enter the Properties class.
From the most excellent xkcd:
I felt the exact same way when I first picked up python. It was like finding the holy grail of programming languages. To be able to just throw things into a list and access them without having to worry about casting. To throw around functions like they were variables. To weave functions out of thin air and watch them vanish when their usefulness had expired. It was magic.
Of course, the honeymoon faded. I still use python as a first resort. As a programming language for exploring new ideas, it can’t be beaten. Development time is ridiculously fast. There has been effort to get the runtime up to snuff as well, but with much reluctance I’m forced to admit it doesn’t compare to C or even Java, may God have mercy on my soul. Granted, it all depends on the application, blah blah blah.
Despite all that, I still love it. It’s definitely first in my heart as far as programming languages go.
Either the coolest or the stupidest programming language in the world, brainfuck was designed by Urban Müller in order to create the world’s smallest compiler of a Turing-complete programming language. Originally his compiler was 240 bytes in size, but he reportedly got it down to about 200 bytes. Others have gotten it below that. The language consists of only 8 operations, which I will go into after the jump.
Japanese electronics use is perhaps a faulty bellwether for the American market. Whereas new gadgets are often available in Japan long before they make their appearance (if ever) in the US, there are also interesting cultural differences that don’t always translate popularity. There does seem to be a trend in the area of PC sales, however. An AP article today points out that PCs are taking a less important role in Japanese households with the emergence of smart phones, consoles that can reproduce many PC functions (web browsing, gaming, playing DVDs & music), and flat screen TVs (versus flat screen monitors, say). If you can check your email on your phone, listen to music on your iPod, download music on your Wii, and play games on your 52″ LCD, why would you want a computer in your home? Note: throughout this post I will use the term PC in the general sense of computer, rather than specifically as an IBM-compatible PC.
So this got me thinking about what a PC is good for and why I liked it back in the day (well, I still like it).
I heard a great metaphor in my software engineering class today. We were talking about agile processes and somehow the issue of not relying too heavily on any one member came up. I think the term “heroic programming” was on the slide. It made me think of that one person who tries to take on too much and ends up coding the entire program himself. In my undergrad, that was usually me.
Back to the new metaphor. Bus Number is the number of people vital to a project. That is, if n people were to get hit by a bus, could the project continue? Great term that sums up the point succinctly.
Later, we were talking about the Scrum development method and the point came up that only people on the team should participate in meetings, though others might be in attendance. The TA was presenting the lecture today since the professor was out of town and there was a term on the slides that he attributed to a generation gap referring to people in the meeting as chickens and pigs. Another professor who sits in on classes put it this way (my paraphrase):
It has something to do with how close you are to the project. It’s like a breakfast of ham and eggs. Sure the chicken gives the eggs, but it’s not the same sacrifice as the pig.
Suppose you have an array of floating point numbers with each index into the array being an id number corresponding to some external data structure. You want to sort this array, but in doing so you would destroy the references to the id numbers, since the indexes of the array would no longer correspond to the correct id numbers in the external data structure. For example, let’s say we are dealing with customers of a store and each value in the array is their current balance.
balances = {25.61, 13.45, 89.75, 21.2, 96.50}
Each index in the balances array corresponds to an index in some other array, say:
names = {"Marjory Stewart-Baxter", "Hubert Cumberdale", "Barbara Logan-Price", "Jeremy Fisher", "Mable"}
Last year I worked on a project with my friend Israel Kloss called FreeAlert. The site is not-for-profit and was originally intended to help refugees entering the Washington, DC area find things they need for free. It now covers major metropolitan areas all across the United States and is intended to benefit everyone.
The idea is simple. Enter some keywords and get matching free items off of craigslist for your city sent to your cell phone. You can enter up to 5 sets of keywords and each set has exclusion terms. This makes it so that you can receive notices with the term computer but without the term desk. Israel just took the site out of private beta last week and it is currently in public beta mode.
It was an interesting project for me because it gave me the chance to work in python on some http and smtp protocol code. It also gave me the chance to work on processing xml and rss feeds. Definitely some cool stuff there and it has resulted in a spin-off that will probably be functioning fairly soon. Israel is one of those people with a lot of great ideas and he has the personality to inspire you with them. Plus he is also one of those rare people that actually care enough about the suffering of others to actually try to do something about it, which you just have to admire.
So, please, check it out and let us know how we can make it better.







