l33tminion: (Skilled)
I just read an article titled The "Anti-Java" Professor and the Jobless Programmers". The article seems to be a pretty typical piece about declining standards in CS education, and I won't address the main thrust of the argument. Rather, I'm interested in the bit where in which Robert Dewar, the professor in question, suggests these interview questions to separate the wheat from the chaff:

1.) You begin to suspect that a problem you are having is due to the compiler generating incorrect code. How would you track this down? How would you prepare a bug report for the compiler vendor? How would you work around the problem?

2.) You begin to suspect that a problem you are having is due to a hardware problem, where the processor is not conforming to its specification. How would you track this down? How would you prepare a bug report for the chip manufacturer, and how would you work around the problem?

"I am afraid I would be met by blank stares from most recent CS graduates, many of whom have never seen assembly or machine language!" he says.


I'm a bit bothered by the fact that I would indeed be stumped by these questions. I might be able to make some suggestions as how I'd begin to learn how to debug such problems, but I've never really worked on such a low level (although it isn't quite true that I've never seen assembly), and I've never been in a situation where I couldn't trust my compiler or CPU (although I am aware of various high-level issues with runtime environments I've worked in, the faulty garbage collector in SBCL, for example).

On the other hand, such issues are rare, in general modern compilers and hardware are well tested. It seems to me that in most of the cases where a programmer would "begin to suspect" such things they'd be suspecting incorrectly.

So, my programmer friends, what do you think? Am I (or "kids these days" in general) underqualified? Is this evidence why I should have pursued a proper CS degree instead of engineering? Or is Dewar just shaking his proverbial cane and shouting "get off my lawn!"?
l33tminion: (Default)
I went to the Boston Lisp Meetup on Wednesday, which was pretty good. The main talk was on implementing run-time contracts (type-checking or otherwise) in Scheme, a necessary component in a system that uses partially typed Scheme (PDF). In particular, it covered the tricky problem of implementing run-time type contracts for parametric polymorphic functions.

On a diametrically opposed note, I'm going to Sandy Island Camp on Lake Winnipesaukee (map) with my family all of next week (Saturday to Saturday), which means I'll be without phone, computer, and internet. That bit makes me grimace, but I'm still very much looking forward to it, and I'm sure the periodic detox is good for me in the long run.
l33tminion: (Skilled)
From today's hacker talk and, independently, from here:

Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.

Good advice.

Defective C

Jun. 5th, 2008 10:30 pm
l33tminion: Sporktacular (Spork)
In the classroom, C++ seemed like a modern language. When I took Java, I thought it seemed rather like C++. When I took C, I thought it seemed rather messy. When I saw C++ again, this time in real code, I was shocked. Every time I've seen C++ code in actual use, it seems far more messy and incomprehensible than Java or even C. Brushing up on C++ for work, I've come to agree with the author of the C++ FQA: C++ is a horrible language.

An interesting question: How critical should a programming reference / guide / source be of the language it discusses? One of my favorite programming books is Effective Java, which I feel improved my Java skills immensely. That book contains a very detailed account of all the weaknesses of Java and notes patterns to avoid copying from the Java standard library, yet the book is very positive about Java as a whole. I'm just starting a book called Let Over Lambda, whose author apparently thinks lisp-style macros are the very definition of win, and it's very interesting so far. And the above FQA is proving quite useful in getting myself reoriented for hacking C++.
l33tminion: Enter the l33tness (Matrix Largo)
The new house: My room is small, but the house is nice and the location is great, less than a mile from countless great shops and restaurants, three T stops, and my job, and right next to a bus stop, grocery store, and drug store.

The new job: Intense. I'm working on ITA's core technology, which means a code base of a million lines of Lisp or so (plus some other languages) and a system architecture beyond the ken of mere mortals. I'm getting a very different feel for Lisp than the limited use that CS classes provided. Lisp can be terribly complex and awesomely elegant. It will probably take me some time to get up to speed, though. My coworkers are friendly and skilled, the food is great, there's a movie night and a yoga class every week.

Other stuff: Went to see the new Indiana Jones movie last night with Xave and other members of DOOMCom. It was pretty sweet. Moral of the story: Harrison Ford is still Indiana Jones.
l33tminion: Enter the l33tness (Matrix Largo)
The following is only relevant to the programmers on my friends list, probably...

So, did you know that Java has syntactic sugar for iterating over a collection? So you can write this:
for (SomeType item: stuff) {
    // code here
}
Instead of:
for (Iterator<SomeType> iter = stuff.iterator(); iterator.hasNext();) {
    SomeType item = iter.next()
    // code here
}
I didn't until recently. When did that happen? Was that not around when I was first learning Java?

Despite that, I'm feeling more competent Java-wise lately. I feel that I finally understand the JNI (how to use it, anyways). I even got a C++ API for the multitouch hardware I'm using to play nicely with some Java code.
l33tminion: Enter the l33tness (Matrix Largo)
Fizzbuzz is a simple game. Players take turns counting up in sequence from 1, except all multiples of 3 are replaced with "fizz", all multiples of 5 are replaced with "buzz", and all multiples of both are replaced by "fizzbuzz". So players count:
1, 2, fizz, 4, buzz, fizz, 7, 8, fizz, buzz, 11, fizz, 13, 14, fizzbuzz...

This game has become a popular interview question for programmers; it's simple but many self-identified "programmers" don't have the basic problem-solving skills to tackle it. Of course, programmers' sense of humor being what it is, all sorts of odd solutions to the problem have popped up in response. My favorite definition of fizzbuzz(n) is:
['fizzbuzz', 'fizz', 'buzz', n][[n%15,n%3,n%5,0].index(0)]
Aside from being a very weird way of implementing a conditional, this is valid Python and valid Ruby. Nifty!

Dougal Stanton also provided this dramatic solution in Haskall (modified a little for brevity):
import Data.Maybe

fizz = concat $ repeat $ replicate 2 Nothing ++ [Just "Fizz"]
buzz = concat $ repeat $ replicate 4 Nothing ++ [Just "Buzz"]
fizzbuzz = zipWith (maybeWith (++)) fizz buzz
numbers = map (Just . show) [1..]

maybeWith f (Just a) (Just b) = Just (a `f` b) 
maybeWith _ (Just a) Nothing  = Just a
maybeWith _  Nothing (Just b) = Just b
maybeWith _  Nothing Nothing  = Nothing

main = map fromJust $ zipWith (maybeWith const) fizzbuzz numbers
This sort of stuff reminds me of another thing I encountered recently, a regular expresion to "check for primes". The expression in question is:
/^1?$|^(11+?)\1+$/
The first part of this expression matches "" or "1", the vertical bar is a logical or, and the latter part of the expression matches a sequence of two or more ones repeated two or more times. Much less cool than I originally thought it would be, given the title! But it is a regular expression that detects sequences of ones of non-prime length, so you can do the following:
import re
non_prime_length = re.compile(r'^.?$|^(..+?)\1+$',re.DOTALL)
def is_prime(n):
    not non_prime_length.match('X' * n)
That creates a sequence of characters of length n, then checks if the length is prime. This is the sort of thing I'd classify as a "stupid programmer trick", a sort-of clever, not-necessarily-practical, totally silly way of solving a simple problem.

So, to all the programmers out there, what's your favorite stupid programmer trick?

P.S. Incidentally, if you can provide a regular expression such that it actually matches the string representation of only prime (or only non-prime) integers, that would be pretty sweet. A proof that such a thing could not be created would be equally impressive.
l33tminion: Enter the l33tness (Matrix Largo)
I've been messing around with Haskell lately, and while I am still a total beginner, I'm greatly enjoying it. If brevity is the soul of wit, Haskell is a very witty programming language indeed (and it's humor is quite comprehensible, compared to something like K). For example, the following is a (sort of) quick sort implementation:
qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
The following is a program that takes a list of words on standard input and shows all the groups of anagrams (created with heavy borrowing of code from here):
import Control.Arrow ((&&&))
import qualified Data.Map as M
import Data.Char (isAlpha)
import Data.List (sort)

clusterBy f = M.elems . M.fromListWith (++) . map (f &&& return)
signature = filter isAlpha . sort
anagrams = filter ((> 1) . length) . clusterBy signature
main = (mapM_ print . anagrams . lines) =<< getContents
All functions are strongly typed (but with a huge degree of polymorphism (functions can take inputs of more than one type)). This typing is done intelligently, so you don't have to explicitly create type signatures for your functions unless you want to (for example, I could note that anagrams takes a list of strings and returns a list of lists of strings by adding anagrams :: [String] -> [[String]] before the function declaration, but this is already defined automatically). Functions can be defined in terms of pattern matching, as in the quick sort example above. And all functions are curried (takes parameters in sequence, returning the modified function) automatically, so you can do things like this:
sum = foldr (+) 0
  -- so that sum [1,2,3] -> 6
increment = (+) 1
  -- so that increment 3 -> 4
l33tminion: (Default)
Programming:Other:
l33tminion: (Skilled)
Another post while [gigantic test script] runs (so I can continuer debugging SQL weirdness). Probably worth reading if and only if you're a Python programmer:

Snakes Within )
l33tminion: Yay! (Yay!)
So I've spent several weeks working with Perl. Read books, modified code, did some high-level hacking in a corporate environment.

Here's what's good about Perl:
  • Flexible syntax makes regular expressions a bit easier
  • Flexible syntax makes "golfing" your code (doing it in fewest keystrokes) easier
Here's what's bad about Perl:
  • Anything having to do with objects
  • Anything having to do with references
  • Anything to do with variable names (sigils, magic variables, etc.)
  • High levels of kludginess in the core features
You should learn Perl if any of the following apply:
  • You need it for a job
  • You're a Level 20 Unix Mage
  • You hate maintenance programmers with a burning fiery passion
  • You're a sado-masochist who is still working on convincing your firm to program entirely in INTERCAL
l33tminion: Sporktacular (Spork)
If you tell Perl to sort an array of integers, which order does it sort them in? Hint: It's not numerical:
> print join(', ', sort(1, 2, 10, 20, 100, 200));
1, 10, 100, 2, 20, 200
ASCII order is already a lousy way to sort strings, but it's a completely nonsensical method for sorting integers.

Edit: Of course, you can sort in numerical order in Perl, using their (wacky) custom sort syntax:
> print join(', ', sort{$a <=> $b}(1, 2, 10, 20, 100, 200));
1, 2, 10, 20, 100, 200
But that syntax is really strange, and I'm still annoyed the default behavior isn't more sensible. (Incidentally, the case above also means that $a and $b are magic variables in this context, which means that overriding them can (apparently) cause bugs in some implementations of Perl. Argh...)

Note: <=> is the numerical comparison operator, as opposed to cmp, which is the (used-by-default) string comparison operator.
l33tminion: (Default)
It's that time again, when I share the best of the best of the latest on the web (from my point of view) for you to peruse at your convenience:

Film and literature: The movie version of Phillip Pullman's The Golden Compass premiers this Friday. It seems that the film has been somewhat sanitized with respect to the book's theological undertones, but that hasn't prevented the Catholic League from denouncing it as some sort of gateway drug to atheism. This has generated quite a bit of commentary in the last few days, with one article discussing the theology of His Dark Materials, another on the relationship between Hollywood and religion, and one focusing on Pullman's perspective on the controversy.

Food: Here's a website that suggests ingredient substitutions and pairings based on analysis of chemical flavor components. In a slightly related vein, here's a recipe for Kiwi Pomegranate Avocado Salsa. DO WANT.

Webapps: Here's an incredibly fast dictionary, and heres a tool for determining how walkable a community is (in terms of distance to various sorts of amenities). I may have posted the second one before, as I came across it soon after it first went up, but it now has the added advantage of actually working.

Programming: I read a very interesting essay on code design patterns (not of ideals but of design in imperfect practice) entitled Big Ball of Mud. There's also a page of evil C code examples.
l33tminion: (Skilled)
Among the other things I need to do to prepare for my winter break job, I've been trying to familiarize myself with Perl. So I've been looking through some of the documentation and tutorials, and it's been a real head-explodingly head-explodingful time. As near as I can tell, Perl was born when someone took a pile of kludge, stuck it together with glue and twine, then dipped it head-first into a bucket of crazy.

I've heard Perl described as being "like Python" in that they fill similar niches task-wise, there aren't parentheses everywhere, and many of the keywords are vaguely like English. Some of the differences are small, certainly, you use "elsif" instead of "elif" and "foreach $var (@list)" instead of "for var in list".

But then you get to things like the weird way Perl deals with variable types (not sure whether to call it strongly or weakly typed, but it is certainly strange), postfix conditionals, methods without parameter lists, strangely named magic variables, $_[0] being the first item of @_ and having nothing to do with $_.

I haven't gotten into how Perl handles object-oriented stuff yet. Wish me luck.

P.S. Have any of you worked in Perl? Have any words of wisdom to share? Sources to suggest? Comment, please.

P.P.S. Of course, I recognize that Perl is a fully-featured programming language, and that it's as possible to write good, maintainable Perl code as it is to write confusing, unmaintainable Python code. Still not looking forward to working with other people's Perl code, though... hopefully I'll feel a bit less nervous by winter break.

P.P.P.S. The subject of comparing Perl and Python has generated a lot of interesting discussion (and flamewars) in those language's respective communities. Check out this thread on Perl vs. Python and an essay titled Why Python?
l33tminion: (Default)
The more I learn about programming, the more I learn that I have a lot to learn. Technical stuff... )
l33tminion: (Default)
The latter part of the week was largely uneventful.

Today, I went to Ueno with Vito-san. I bought a new backpack. Ueno must be the かばん (kaban; bag) capitol of Tokyo, as there were an insane number of stores specializing in backpacks, handbags, and suitcases of various kinds. I found one where everything was on sale for 1050 yen an item (a little less than $10). The backpack I bought is not quite as good as my old one was, but it will do.

I've spent a bit of spare time on the computer playing around with user CSS. I was able to get Fark to bend to my will, but I found that Amazon still uses tables for their layout, with hardly an element ID in sight. (Are there any other websites that successful that are as poorly designed?)

I also made a map of my commute because Google Maps is addictive so you can take a look at my neighborhood and school from above.

I started my marketing research project on Wednesday, and I'm hoping I'll be able to make major progress on that tomorrow.

There's an IES side trip to Okinawa next Wednesday-Saturday. Time is really flying by...
l33tminion: (Japanese!)
Flash cards are really useful for language learning, but they're a pain to make and a pain to carry around. Xave ([livejournal.com profile] kihou) made a rather useful flashcard program back in the day. Unfortunately, it's Cocoa-based, so it only runs on Macs.

The Amazing Flash Card Machine shows promise, but the features are rather minimal, and the interface could be better. I should really consider coding something better when I have the time (open-source project, maybe, or part of a web start-up?). Still, that's what I'm using for now. Here are a few flash card sets I've made, so you can get an idea of what I'm learning:
Hiragana
Vocab 1
Kanji Vocab 1

If anyone could help me understand the origins / components / meaning of the following kanji, I would be grateful:
休 - きゅう or やす (rest?)
先 - せん or さき
週 - しゅう (week)
曜 - よう (day?)

Update: Props to the makers of TAFCM for being prompt to respond to feedback. They've implemented at least some of the suggestions I sent them, and responded to the rest (put them on their to-do list, apparently).
l33tminion: Yay! (Yay!)
<html>
<head><title>Hello World</title></head>
<body>
<?php 
echo 'Hello World!'
?>
</body>
</html>
*whistles*
l33tminion: (L33t zombie)
For the past few days, I've been trying to solve "Tour the T" programming puzzle here. I've finally finished my first solution. Unfortunately, my solution takes on the order of forever to run. (However, it does work in a reasonable amount of time on small subsets of the data, which is encouraging.)

I have a good way of simplifying the graph for the problem, but I need a better way of filtering suboptimal paths from my search. I think I have a few good ideas on how to approach that, but I'm too tired to try any of them at the moment. Bed now.

Wikimania

Aug. 6th, 2006 02:13 am
l33tminion: Wiki / World (Wikipedia)
Today, I went to Wikimania (at Harvard this year; I only signed up for one day of the conference). The panels and speeches I went to were good, but the most interesting thing was the librarian's discussion. One conclusion from that: Librarians are becoming more like software engineers, and many software engineering tasks are moving into territory that's already covered by library science ("metadata is cataloging!"). I hadn't considered this before, but a lot of the issues surrounding the organization and documentation of code are also librarian problems. Have any software companies hired librarians as part of their software engineering divisions? Either way, there's a real need for more communication and training between the two disciplines.
Page generated Sep. 20th, 2025 12:21 am
Powered by Dreamwidth Studios