Saturday, February 28, 2009

Combination Generator

I wrote a little program that generates all the combinations for a specified set and choice size; that is, it lists all the values of "n-choose-m". It's free, and runs on Windows, Mac, and Linux.

For instance, if you have eight players and need to list all the sports teams of three people you could make, this will do that.

Updated: you can now write the list of combinations directly to a file, which should help if you need to generate a very large list.

Updated (1/9/2012): you can set the names of the elements used to list combinations (for instance, to team names, player names, etc.)

Let me know ( if you find this program useful, or if you have suggestions.

Here's a screenshot (click to enlarge):

You can download it from here: download   (To run it, just double-click the .jar file you downloaded.)

Alternately, for Windows users, you can download a ZIP'd executable here: download ZIP

You'll need Java 5 or higher to run it. You probably have Java on your computer, but if not, it's a free download from

* I use Michael Gilleland's code in this program.

Wednesday, July 30, 2008

Perils of Thinking Java is to Blame

In 2005 Joel Spolsky wrote an article The Perils of Java Schools. The main point of the piece "is that Java is not, generally, a hard enough programming language that it can be used to discriminate between great programmers and mediocre programmers. " He goes on to list two of the characteristics of C that make it a good touchstone for a programmer's skill: pointers and recursion.

Pointers and recursion require a certain ability to reason, to think in abstractions, and, most importantly, to view a problem at several levels of abstraction simultaneously.

I'm not quite sure why he picked recursion, since the "recursive powers" of Java and C are pretty much identical--neither supporting tail recursion--so that leaves pointers.

My first minor disagreement with Joel's thesis is in that he feels pointers are a difficult enough topic to identify great programmers. Here is a great 5-page paper written by John Tsiombikas that clearly presents pretty much everything you need to know about C pointers. Basically, compared with pretty much any of the other topics in a rigorous undergraduate engineering education--differential equations, linear algebra, Fourier transforms, discrete mathematics, orders of growth, etc.--pointers are downright cake. It's not that they're trivial, but next to the hard stuff they're pretty simple.

That leads me to the biggest issue I have with the whole anti-Java movement: blaming the language for a perceived decline in the quality of CS graduates, and for an inability to distinguish good and bad programmers who program in Java.

I used to be able to tell the smart kids because they could rip through a recursive algorithm in seconds, or implement linked-list manipulation functions using pointers as fast as they could write on the whiteboard. But with a JavaSchool Grad, I can't tell if they're struggling with these problems because they are undereducated or if they're struggling with these problems because they don't actually have that special part of the brain that they're going to need to do great programming work.

Does that mean in the old days if a candidate knew C pointers he got hired without further ado? Hmm. How about asking the JavaSchool grad a question that tests his intelligence and programming acumen without being tied to an implementation language? Ask him to write some code in whatever language for an insertion on a red-black tree. I'd pit my army of "red-black hires" against the army of "C pointer hires" any day. And if red-black trees are too snooty (which they probably are) then heapsort or mergesort will probably do; and if mergesort is too snooty, then you should stop complaining about JavaSchools altogther.

It seems that people are blaming the quality of students on the language in which they are taught rather than the declining standards of computer science knowledge to which they're held. And students also are coming to view Java as the source of feelings of dissatisfaction with their education, for instance here.

Java does not need to hold back a programmer in the least!

Want to see some hardcore, low-level programming, like implementing an optimizing, JIT-compiling virtual machine? How about implementing one in Java? Yes, the Jikes RVM does just that, producing a self-hosting competitive performance JVM with pretty much everything, even GC, implemented in Java. Once you write a native-code compiler, whatever its implementation language, the whole world of systems programming is at your reach.

MIT's undergrad compiler class is taught in Java. The lecturer, Saman Amarasinghe, whose research specialties include compiler optimizations, computer architectures, and parallel computing, is certainly no n00b who chose Java because he didn't think his students could handle pointers or because he didn't know better. In my earlier days, when I was a C zealot, I asked him why he chose Java and he said it was because dealing with memory ownership (that is, which subsystem "owns" and thus has to free memory allocated on the heap) in a compiler was such a hassle that using Java let the students implement better compilers in the time allotted to them. Not a language bigot.

Even operating systems: take a look at JNode.

How about Donald Knuth's take on languages? (This interview is found here.)

Knuth: All through my life, I've always used the programming language that blended best with the debugging system and operating system that I'm using. If I had a better debugger for language X, and if X went well with the operating system, I would be using that.

[... Goes on to describe the horrors of the IMP language at Cray...]

It was not a great language or compiler.

However... it was still my language of choice, because it fit that operating system perfectly. The arrays would be named in a way that you could easily see in the debugger, and you could know where the storage was being allocated, you knew what was going on, and you could actually get your program running reliably, because IMP blended with the operating system. You couldn't do that with any of the other languages. You might be writing with a better language, but you would get your work done a couple of weeks later, instead of getting answers. I used IMP.

His superlative knowledge of data structures and algorithms and mathematics makes implementation language a less important aspect of his work. He'd have no qualms about using Java if its tool support were the best--and often it is. (Though admittedly he'd use a WEB compiler for Java so he could continue his practice of Literate Programming). Remember that he chose Pascal to write TeX and Metafont--and he said that he avoided the use of pointers because they weren't as portable as the other parts of Pascal (see section 3 of TeX: The Program).

In the end, what matters about a program is what it does, and how quickly and correctly, not in what language it was written.

So basically, don't blame students' degrading quality on Java - if you feel like blaming, maybe blame colleges for not being more demanding in their coursework. And if you're an employer, just put a little more effort into designing a better technical screening process. But are JavaSchools even in their unflattering sense a bad thing? Do we have fewer brilliant programmers now than we did a decade ago? Or just more mediocre ones? Would the brilliant programmers take the somewhat tedious CRUD webapp jobs that our Internet age has created a demand for?


From the discussion on Reddit, I learned of a cool book, "Elements of Computing Systems: Building a Modern Computer from First Principles", which teaches you the levels of abstraction from "NAND gates to Tetris". Knowing all of that will certainly give any programmer low-level perspective, and anyone who finishes it will have about zero trouble understanding pointers, I am sure. Incidentally, the book's accompanying software is in Java...

Wednesday, May 28, 2008

From Marcus Aurelius's Meditations

As he took examples of the good in life from others, so may I take them too:

Decency and a mild temper.

Integrity and manliness.

Generosity, simplicity of living, avoidance of the habits of the pampered.

To learn from good teachers, and to hold this at high value.

To tolerate pain and feel few needs; to work with my own hands and mind my own business; to be deaf to malicious gossip.

To avoid empty enthusiasms; to tolerate plain speaking and have an affinity for philosophy.

To want betterment of my character, not to be seduced by the music of rhetoric, and to want the same. To not deliver my own moral sermons or to paint a glorified picture of the ascetic; to avoid pretentious language, and to write and speak in an unaffected style. To offer ready conciliation with those who have taken or given offence, as soon as they are willing to join me. To read carefully, and not take comfort in my own superficial thoughts or those of others.

Moral freedom, and to be guided by reason. To stay steady, not having my character be molded by the facile hands of circumstance. To be patient in explanation and in listening to the explanation of others.

A kindly disposition and an intuitive concern for my friends. Tolerance of both ordinary people and the extremely opinionated.

Not to leap on mistakes or to pedantically correct those who make inconsequential errors.

To see and understand the effect of suspicion, caprice, and hypocrisy in managing others.

Love of family, truth, and justice. To value freedom and equality, philosophy, beneficence, optimism, confidence, and frankness.

Self-mastery and a constancy to not be unduly affect by passing whims; good cheer in myriad circumstances; a balance of character, gentle and dignified; an uncomplaining energy for what needs to be done. Being well-intentioned in all I do. Never to be downcast or cringing, or brooding upon anger or suspicion. To be forgiving and truthful, and to choose rectitude. To never be belittled and to not consider myself superior to others.

Gentleness, and a firm adherence to decisions made after full consideration. No vain taste for so-called honor; stamina and perseverance; a ready willingness to listen to anyone with a proposal for the common good. To give common courtesy, to be focused and persistent in deliberation when such must be, to never be satisfied with first impressions or leaving a question prematurely. Foresight in long-term issues and unfussy control of details. To put little worth in acclamation or flattery, to be tolerant of criticism; to avoid superstitious fear and obsequious courting of the public opinion. To have a sober steadfastness, and no obsession with vulgar or newfangled tastes.
      To enjoy the comforts of life without pride nor apology, to not take them for granted nor regret their absence. Not to be a fraud, impostor, or pedant, but rather to strive for a mellow wisdom and mature experience, able to take charge of my own affairs.
      To have a high regard for genuine philosophers, yet to have no hard words for others. To be sociable and have a sense of humor, though not taken to excess; sensible care of my body, neither vain nor valetudinarian, but neither neglectful, so that a healthy constitution leaves little need for doctors or medicines.
      To have a ready, ungrudging deference to those with some special ability, and to support those with a talent in a field. To resume life and work quickly, vigorously after any illness or pain. To not live an unduly secretive life.
      To not be consumed by care of comforts or building houses or acquiring possessions; to not be particular about food or clothing, or youthful beauty.
      To not be harsh, relentless, or impetuous; to not panic but rather treat everything with its own allotted time and thought, unhurried, organized, vigorous, and consistent in all. To regulate abstinences and enjoyments where some may not have the discipline to abstain nor the happiness to enjoy.
      Strength of character--endurance or sobriety as the case may be--and a full and indomitable spirit, in health and illness.

Good grandparents, good parents, good siblings, cousins, and fellows, good teachers, good family, relatives, and friends - to maintain peace with them all. To not be corrupted, nor feel the need to fancy outfits, jewelry, decorations, and the other trappings of pomp, but to maintain the highest dignity in whatsoever station may fall to me.
      To live life in accordance with nature and the common good.
      To give thanks for health, mind, those who love me, my fellows, and fortune's favor.

Friday, February 4, 2005

Remix Titles

Had you realized before that eletronic music DJ's are, in their heart, students of the pure sciences? You can tell by looking at the names of various remixes—to generate a remix name, take an ornate term from mathematics or physics or whatnot, and append the word "remix", and it sounds quite plausible. To wit,
Math: "Silence (Hyperbolic Cardiod Remix)"
Physics: "Fly Away (Quantum Entanglement Remix)"
Chemistry: "Ecstasy (Transitive Phasechange Remix)"

Monday, January 17, 2005

Beautiful Athena

Today marks the two year anniversary of the untimely deletion of my Athena account. *A lone tear traces its path down my cheek.* I'd felt that for many students, their Athena account was the priviledge the possession of which made them most feel a connection to MIT, and only after it was gone did they feel as though their college identity was truly in the past. For that, I think that the MIT administration would be smart to allow graduates to keep their accounts, perhaps with a reduced quota and constricted file-system rights, indefinitely. What would it cost to host a few more non-critical servers, ones that do not need guaranteed uptime or instant service? And how much more donation money would the school receive from a fleet of alums who feel a still vibrant link to their alma mater?

Wednesday, December 22, 2004

Cel Ringers

In Asia, there are two cell-phone ring tones called "Rockmelon" and "Body Thinning" which are marketed to increase one's bust size and make one lose weight, respectively. The following interviews were published in the October issue of Easy Finder, a Hong Kong youth magazine (*):

Age: 19

Before: 34.5" bust. After: 35.5"

The bust-boosting ring tone sounded strange at first, but after listening to it, it was super-easy to fall asleep. I used to go to the club maybe only once a month, but now I go at least once a week. I've become a better conversationalist, and more animated too! One of the times I went to the club, an artist came over and started flirting with me. After we flirted, I went into the bathroom and listened to the bust-boosting ring again to make myself feel ever more energetic. Although we didn't end up going on a date, we exchanged cell-phone numbers and sent each other text messages. I'm already happy!

Age: 22

Before: 35.5" bust. After: 36.5"

The bust-boosting ring tone sounds a bit scary, like a horror movie. I listened to it while I ate, and after a while it made my appetite decrease. I used to eat a big bag of chips as a snack every day, but after listening to the ring tone I didn't want to eat that kind of snack. The most amazing thing is that in a month my bust grew one inch---I couldn't believe it! Before, I wouldn't dare wear a see-through shirt, but now I wear one with a colorful bra underneath. When middle-aged guys pass me on the street they do a double-take!

Age: 24

Before: 102 pounds. After: 98 pounds.

The weight-loss ring tone is so harsh. It's really annoying! But after I had listened to it for a week, I started seeing results. I don't know why, but the ring tone makes me want to drink and eat less. Previously, after eating dinner I would eat four servings of ice cream in one sitting. Now one serving is enough! My boyfriend promised me that if I lose two more pounds he'll buy me a Burberry miniskirt! comment. But what it did make me think of is what would happen if ring-tones that are popular in the US had the same sort of testimonials? Here's mine, for instance.

Age: 26

Before: Six double-oh one. After: Dee oh double-gee.

The 50-cent ring tone is a little bit scary, like being in the hood. I listened to it while I drove, and after a while, I bought my car hydraulics and starting flipping switches. The most amazing thing is that I used to be an MIT nerd, and now I'm an honorary member of G-G-G-G Unit---I couldn't believe it! Before, I wouldn't dare approach any girls, but now when I'm "In Da Club" I get all the attractive ladies! Some of them wear see-through shirts with colorful bras underneath, but their ring tones sound like a horror movie, so I stay away from them. When middle-aged women pass me on the street they do a double-take!

I didn't even get to the Celine Dion tribute yet, either.

* - And subsequently in Harper's magazine, from where once again I lifted them. The translation from the Chinese was done by Christopher Rea.

Friday, December 3, 2004

Language Play

Some writers need more than one letter's worth of the dictionary to compose renditions of biblical events; and some do not...

Seduced, shaggy Samson snored.
She scissored short. Sorely shorn,
Soon shackled slave, Samson sighed,
Silently scheming,
Sightlessly seeking
Some savage, spectacular suicide.
-- Stanislaw Lem, "Cyberiad"

And when you're penning that next love/breakup letter, don't waste your energy writing different words for different men---just move around a few periods and commas.

Dear Thomas,

I want a man who knows what love is all about. You are generous, kind, thoughtful. People who are not like you admit to being useless and inferior. You have ruined me for other men. I yearn for you. I have no feelings whatsoever when we're apart. I can be forever happy--will you let me be yours?


* * *

Dear Thomas,

I want a man who knows what love is. All about you are generous, kind, thoughtful people, who are not like you. Admit to being useless and inferior. You have ruined me. For other men, I yearn. For you, I have no feelings whatsoever. When we're apart, I can be forever happy. Will you let me be? Yours,