Monday, August 23, 2010

8/24 Final Reflections

Since I am about to get on a plane, I had a few last thoughts about my experiences in Cambodia.  Some things I learned.  Some things I wanted to share.  These thoughts exist in four levels: technical, political, philosophical, and personal. 


Technical: Work at InSTEDD


The most obvious part of my work with InSTEDD was programming.  I made a Ruby on Rails service that makes it easy to run machine learning using things like Google Prediction.  This will help InSTEDD's other projects if they want to use machine learning. 

I'm not sure how big of an impact it will have.  The people at Manas (an organization that helps out InSTEDD) said that they got a grant to do exactly what I was doing, so they'll be continuing my project after I leave, which means that the work I did will have some future use at a bare minimum, and organizations like Sahana have been asking for different types of machine learning, so I hope that it will help people.  It's just still in its early stages.

The project taught me about a startup atmosphere.  I had heard that working at a startup is more independent and that you'll be doing a bunch of different jobs (whatever needs to be done).  That caught me a little off guard.  I came in expecting a lot of support and a clear description of what I would be doing.  Instead, I was presented with a mandate to make a machine learning service in Rails and was left to figure things out on my own, with some help from people around the office.  I think that this would be fine if I were in my domain, but since I didn't come in with much web programming experience, any Rails experience, and I didn't have a clear idea of who would be using my product, I had a lot to figure out.  On the one hand, I think I did figure it out.  On the other hand, I don't think that I got as much done as I could have if I were working on an established project or had a more direct mentor.

It also taught me about Ruby on Rails and web programming, and about myself as a programmer.  Web programming is a necessary skill, and Rails makes it easy to make small, quick, fast projects, which will be an asset for me in the future.  I did learn, though, that I'm not completely language agnostic.  I don't think that I would take a job programming in Rails.  I really like C and C++ (and I think that I would be OK in Java or maybe Python).  The things that trip some people up in lower level languages feel intuitive to me, and the levels of abstraction that make Rails Rails makes it feel unintuitive to me.  Thankfully, even though Rails is increasing in popularity, C, C++, and Java each have about 30% of the market in terms of code (though my numbers may be a bit old and inaccurate), so my job prospects are pretty good. 

The work also gave me an opportunity to do more with Linux and to see an office work atmosphere.

I think that the reason that InSTEDD wants to bring western students out to program in Cambodia is so that we can see an example of computer science benefitting people in the field and see an organizational structure that is dedicated to helping people in the field.  Focus on the needs of the people, and make a program that satisfies those needs.  Because there are people in need of help, and there are ways for computer scientists to help them.


I think that the most important part of my work, though, was interacting with the Cambodian programmers.  They work really hard, and they're smart, but they mostly didn't have a formal computer science education.  As a result, they know about programming, but they don't know the general principles underlying programming.  I think that they still think of programming as associated with a particular language (so programming in C would be fundamentally different from programming in Ruby rather than just two different flavors of the same computer science).  So I tried to work with them on some of the general principles.

I gave a few lectures on algorithms (Big O and algorithmic complexity, data structures, their implementations, and the runtime of various operations, recursion and functional programming).  I gave one talk about public key cryptography.  I talked with them about object oriented programming.  I tried to focus more on the intuitions in each of these subjects rather than formal proofs.  I think that, in general, it was pretty successful.  They were eager to learn, and the day after each talk, they would still have a good grasp on the things that I talked about earlier.  They also seemed to grasp the underlying ideas.  I just wish that I had more time.

I also helped them with their English.  They could all speak English, but they would still ask me for a hand when they were writing a formal letter or a speech introducing someone, or they would ask me to translate something when they were reading.  I think that it can really help to have a native speaker on hand to ask questions (especially since some of their questions were about English words used in a programming context, which non-technical native English speakers wouldn't easily be able to answer).  In Spanish class, I always felt nervous to talk or to ask random questions, whereas it felt a lot easier with the Spanish speakers in the office.  I imagine that it was the same for them. 


On the whole, I feel happy about my experience.  Rails wasn't enjoyable, but it taught me a lot, I feel confident that computer science and public service are deeply connected, and I was able to teach people who were hungry for knowledge.


Political: How to Save the World


Free market economists like to talk about just how socialist the US is.  Cambodia is, in many ways, planned by the free market (because the state has been slow to step in.  Also, planning a country is extremely hard), and it made me realize some of the things that the US got right. 


In the US, the state funds basic infrastructure.  Streets, water and sanitation, and schools are a good example of this.  In Cambodia, having decent roads between the major cities is a recent phenomenon.  Universal public education deserves a special mention: in the US, your taxi driver can read a map.  That may or may not be true for a tuk tuk driver in Cambodia.

Our markets also have some wonderful regulations.  For instance, you must post ingredients on food, and all of those ingredients must be proven to be reasonably safe.  Trademarks mean that I can't just copy the external wrappings of a product and make a cheap fake (the lack of strong trademark regulations is problematic in the case of pharmaceuticals). 


In some places, they value equality.  In the US, they value 'meritocracy' ("it only takes a dollar and a dream"), which I am quick to criticize because 'merit' is usually shorthand for 'luck' (were you born in a loving family with enough money to give you a good education?).  I think that Cambodia is still searching for a value that its society will strive towards.  In lieu of a value, the free market has stepped in.

This means that in Cambodia, the invisible hand controls some markets that I don't even think of as markets because the regulations in the US work so well.  Take the example of scholarships.  I think that the best model is the need based model that the rich private schools in the US have started adopting in the past few years.  That model values equality: financial need should not be a barrier to education.  There are also merit based scholarships.  In fact, I'm competing for one right now.  In theory, these would be awarded to the students that are the best in some group.  In Cambodia, some scholarships are susceptible to bribery, and the free market decides how much the scholarship costs. 

Some other domains in Cambodia where the free market features too prominently: the police (the Lonely Planet guide calls them the best police "that money can buy"), government property (the land on which universities or historic sites stand might be sold off.  Did you ever wonder where the US embassy got its land from or what stood on that land before the US put up all of its stars and stripes?), jobs (pretty much the same story as scholarships), and permits and licenses (how much do you think a driver's license costs if you fail your test?).

Even though the pretense of meritocracy in the US is only a pretense (the dollar matters a little more than the dream), it is still a nice pretense to have.


A lot of good is happening in Cambodia.  There are a lot of people working to make the world and Cambodia a better place.  There are even a lot of good businesses.  The government just needs to make sure that the work that they're doing is as effective as it could be.  The hard part is that many of the needed regulations need to apply to the government itself as much as external organizations.


Philosophical: Human Nature


It seems like everyone is an expert on human nature.  ["human nature"] has 9 million hits on Google (and that's a phrase!).  Even ["humans are naturally"] gets almost 1 million hits, which is remarkable for a three word phrase.  Compare that to 3 million for [biopower], half a million for [agricultural subsidies], or 40,000 for ["lesser jihad"]. 

Economists think that human nature is selfishness.  Ironically, studies of economics students demonstrate that taking an economics course makes a person more selfish, indicating that selfishness is something learned, not something natural.  People often think that humans who go into nonprofits are naturally good.  When a person sees how nonprofits behave towards each other when competing for a small pot of money, that person might change their mind and think "nonprofit workers are just like the rest of us: nasty, brutish, and short" (I would never misquote a Leviathan!). 


In science, if you want to establish truth about something, you come up with a theory and then come up with a study that could demonstrate your theory true or false (it's important that the study can disprove your theory).  If you're saying that something is true, then all you need is one counterexample to disprove it.   


Think about what that would mean for human nature.  To say that something is human nature, you are saying that throughout history, all people in all cultures have a certain property.  If they lack that property, then they lack something that is natural to being human.  One counterexample would disprove it.  One person who is human and who lacks that property would disprove it.  If an entity lacks that property, they must be a part of a different species, godlike, or they cannot interact with the human community. 

The first note is easily understandable.  If I said that it is not human nature to be able to survive in a deep-water volcano, few people would disagree with me.  Humans cannot breath under water, cannot stand temperatures that hot (or that cold), and cannot perform chemosynthesis necessary to get energy from the chemical vents.  There are species that can, but we would not call them humans.

One of my old teachers made me realize the second note.  If someone says "it's unnatural to be gay," then they are saying that humans are not naturally gay.  Since gays are trivially not of a different species than other humans, they must have transcended human limitations in some way.  If a person can violate human nature, then, by definition, they are superhuman.  Just like I would be godlike if I could fly, perform photosynthesis, live in outer space, or travel faster than the speed of light, I would be godlike if I could violate a limitation that applied to all humans.  Nature is extremely strong, so if a person can violate human nature, then that person is stronger than nature.  The word typically reserved for entities that can violate natural laws is "god."

The third note recognizes that there are social elements associated with being human.  In the spring 2010 verbose letter, I talk about Paul Chappell's argument that war is against human nature because it drives 98% of soldiers crazy and the other 2% are violent psychopaths.  In order for his argument about human nature to be true, one would need to believe that the 2% lack something essential to the human experience.  Certainly, people without the capacity to love other humans deserve our kindness and understanding, but might a missing capacity for love also be an essential missing piece?


So no, it is not human nature to be selfish.  It is not human nature to be greedy.  Neither is it human nature to care about your family or your country.  There is nothing natural about good or evil, right or wrong, the Tao Te Ching, the Quran, the Talmud, the Bible, a Veda, a Sutra, or any economics textbook (the latter is the most dogmatic of the bunch).  Since humans started farming, there isn't even anything natural about evolution: for the last few thousand years, we have moved beyond living or dying because of individual fitness.


A human is born with the possibility to do anything.  A child might show duty to their family and pick on other kids.  They might grow up to desire power, wealth, both, or neither, and at the same time be humble or boastful.  A person might be loving or hateful, beautiful or ugly, smart or stupid, hard working or lazy, healthy or sickly, or anything else.  Greed is human nature to the same extent as sharing because both are potentials for all humans and each will manifest in different circumstances in different societies in different ways.  Put simply, human nature is potential. 


Personal: The Ugly American


I got used to the heat, but I still don't like it.


A lot of books put a big emphasis on heat.  In Camus' The Stranger, the protagonist talks about the sun making him kill the Arab.  In Seasons of Migration to the North, the heat is the symbol for the global south and the cold a symbol for the global north.  The trick?  Both are harsh.  One day the sun might be wonderful, but the next it might drive you crazy.

The air is hot.  It is usually calm; it's pacific (and Pacific).  You can feel it.  Getting used to it was one of the hardest things about coming to Cambodia.  The heat makes the environment different in more ways than one.  Regarding the homeless population, people say that it's still cold at night in California.  It isn't really cold at night in Phnom Penh (literally speaking, of course.  Figuratively, the chill is similar and more prevalent).  Even when it's raining, it's still pretty warm. 

At first, the heat felt like an invading external presence.  I could tolerate it, but my body never wanted it.  Even after I would get into an air conditioned space for a brief respite, the vestiges of heat lingering on me would leave me exhausted.  My body slowed down.  My mind slowed down. 

The work culture is different here.  At Stanford, I could pull off being always on.  If people can do the same in Cambodia, I have no idea how. 


Heat is natural comfort.  Regardless of the nation, time, or place, if I am exhausted and tired, heat feels good.  When tired at Stanford, I linger in bed, in the shower, and when washing my hands to feel the heat.  In Cambodia, I have learned to breathe the heat in to warm me from the inside as well as the outside.  But I don't think that it's me.

Cold means that warmth comes solely from bodies and minds.  My body has to work to keep up, or I will freeze.  Even then, I must use the products of human ingenuity: clothes, fire, walls.  A lone cub in the north won't live.  The cold will never stop me from fighting it.  It will encourage my struggle. 

You cannot struggle against the heat.  If you do, then it has already bested you.  When I say that I am used to the heat, I mean that I have learned that much.  I have learned to breathe it in.  But in its embrace, I am agitated.  I can see its beauty, but I cannot appreciate it.  In a land where the fire is all encompassing, I am still driven to melt the ice. 


I guess what I'm saying is that, on the one hand, English is a universal language, but on the other hand, English is a universal language.  Make sense?  I function in a Khmer speaking society without functioning in a Khmer speaking society.  I came in afraid of the stereotype of the ugly American.  It turns out that it doesn't exist here.  I didn't come in with a stereotype.  Just me.  Phnom Penh is a city like any other.  But it is hot.  And I can understand the heat.  Even my skin can understand it now.  It doesn't bother me.  When I breathe it in, it isn't the same cold, comforting Pacific wind that I'm used to, but I pretend it is. 

Saturday, August 21, 2010

8/21 English + CS

Being a native English speaker is a massive asset. Not having an accent (or, more precisely, having the universal American accent) is very helpful. I have met dozens of different English accents that are mutually unintelligible (that is, native Spanish speakers and native Khmer speakers have a hard time understanding one another even if both are relatively fluent in English), but I can understand most of them with only a little difficulty.

Knowing only one language, I can act as a translator between groups that don't understand each other.

In other news, my name (or something that sounds like it) means "30" in Khmer. Also, it means "three of a kind" in the context of a card game.

Being a computer scientist is also a massive asset. Every organization in the world needs one. Or several. Or many. Even the nonprofit that I volunteered with to build houses. The person who organized the trip handed me an 8GB jump drive at the end of the trip because her husband was trying to recruit me to his company.

8/7-8/8 Beach

While the highlight of the beach trip was the non-GMO corn discussed earlier (I also just tasted a real corn tortilla. It was so rich!), there were a few other notable experiences.

It was my first time wearing my backpack without a shirt on. The office went back to the hotel in two groups, and my group left earlier. The backpack was still in the car, and I wanted it when I arrived at the hotel, so I brought it with me. And, since I had just gotten out of the water at the beach, I was sandy. For some reason, I was more worried about my cheap shirt getting sandy than my awesome backpack.

Fireworks aren't just used for American 4th of July celebrations. At the night at the beach, people were walking around selling firework guns (and tons of people would buy them and shoot them off).

Imagine you had a bunch of fireworks -- simple stuff like ground blooms or crackling balls. Now imagine that you could shoot them up 20 feet into the air and that they would explode at precisely the correct moment. Now imagine that you had a gun that would automatically shoot them up every 2 seconds until you ran out of ammo. That's a firework gun.

Most of them were pretty reasonable. The one that was a little bit much to bear was the super crackling ball (my dad's favorite) gun. Every two seconds, there would be a massive crackling explosion in the sky that would continue exploding for about a second, as it was falling closer to the ground. Once or twice, one fell a little close for comfort.

Also, I learned that women swim with their shirts on because if they don't, they are labeled as a prostitute.

The swimming in general seemed a little more passive (ie, sitting down in the water and letting it flow over you) than in the US (splashing around, playing some water game).

Monday, August 16, 2010

8/17 The Arts

A Cambodian American friend in the office has been taking me to a bunch of cultural events in Phnom Penh.

On 7/31, I went to a Cambodian Rock show. It was pretty cool. They put a Khmer spin on a western style. The music was pretty cool, though I think I would have gotten more out of it if I had understood the language.
The only annoying part was that there aren't any laws about smoking indoors in Cambodia, so bars (the show was at a bar) are very smoky.

On 8/3, I went to a show at the Japanese Cultural Center. The (Filipino) stars of a musical from last year were performing along with a Cambodian orchestra. They switched off between songs from Where Elephants Weep (a love story with themes tailored to contemporary Cambodia) and West Side Story.
The stars were so-so, but the music was amazing. Usually, non-verbal music doesn't move me, but I could really feel the orchestra. They had a few instruments that you usually don't hear, and they were incredibly skilled.

The show at the Japanese Cultural Center was the lead up to a week long series of events at a big theatre in the center of Cambodia for the Cambodian Youth Arts Festival. I was able to make the shows on 8/9 and 8/10.
I think that I would have really loved the shows if I could speak Khmer, but because I can't, they were a mixed bag. The music was all very good, and I could appreciate it, but about half of the time was plays in Khmer. There was a traditional play about a couple who starts the plays as birds but die a tragic death and are reincarnated for a long series of lives until they finally have a happy ending together. There was a play about relationship abuse and sexual trafficking. There was a wedding play. The people that I went with explained what was going on, so it was still a good way to understand a little more of the culture, but I missed out on a lot. In particular, it seemed like all of the plays had a good mix of humor (some slapstick, some witty) that I wish I had been able to appreciate.
It was nice to see them talking about relationship abuse, though.

8/16 UGH RUBY

Note: this is me venting about programming and isn't meant to be read by non-programmers. Well, it isn't really meant to be read by programmers either.

Ruby has a few nice features. Rails means that you can set up a dynamic website quickly. There are a few things that make collaboration easy (ie, rake tasks for installing dependencies and database independence).

Ok, now that we have the nice parts out of the way, I can get to my real feelings.

I'm not a fan of Ruby.

In a language, letters are constant. For instance, in English there are 26 letters. The words are also fairly stable. They might differ as the years go by, but if I read a book, the way that it uses its words will be pretty much the same as in any other book. The language is relatively static. Creativity comes from how people use the language much more than how they change it. We are no longer living in Shakespeare's time. Many of the 'new' words that we have now are just variations on old words (ie, email was once e-mail or electronic-mail), with a notable exception for cultural phenomenon or proper nouns that become words (ie, Google, Facebook, Frisbee, Bandaid). Even new words that are uniquely created aren't integrated into our lexicons until they become sufficiently popular. If I'm using a new word, I shouldn't expect someone else to understand me until the word gains recognition by the culture. This is particularly true of words that start out as scientific jargon and then come into everyday usage as time changes.

In the programming languages that I like, this is also true. The language itself is controlled, and the creativity comes with how you use the language, not from how you change the language. In C, if you know how to do basic math (including some binary math), function calls, and manipulate pointers, then you can understand what a C program does.

Ruby, however, had the great (sarcasm) idea of making some basic language features changeable (in fairness, C++ also has some of these flaws. Maybe I just don't see them used as much in C++ except when it really makes sense). For instance, brackets and equals signs can be used for any function. That means that I can have a "foo=(bar)" function, and then when I type "foo = 2", it will pass in 2 as an argument to the "foo=" function. "foo" isn't an l-value; it's the name of a function (oh yeah, because in addition to making everything a function, they made it so that you can't immediately identify something as a function by looking for parentheses because parentheses are optional. Just by looking at code, I don't know if I'm looking at a function or a variable).

This is fine in some cases. Normally, the idea of the language is to trick you into thinking that foo is an l-value, just one that you don't really know where it is, so even though it's tricking you, it behaves mostly as expected. Usually, also, it's used as a method within a class (ie, "my_object.foo = bar", so that you are tricked into thinking that you're actually modifying something like you would a struct in C rather than just passing an argument to a function), and there it usually behaves as expected.

This can trip you (you == me) up when you start believing the lies that the language tells you. Notably, Ruby can't tell whether foo = bar means that you want to create a variable named foo and assign bar to it or whether you want to pass bar to the foo= method. Earlier today, I wrote current_user = user. current_user= is a method. But Ruby didn't know that, so it allocated new space for the current_user variable. This would have normally been unexpected but have left my program running fine; creating a local variable that was assigned to the value that I wanted would have left me without any immediate bugs. However, current_user is also a method (not a variable) that I use in other parts of the function to get the current user. When I added the current_user= in to a block of code that was never getting executed, it changed the behavior of a different part of the program because now Ruby had to allocate space in the local scope for a variable called current_user, which meant that, in the other part of the code where there was no current_user variable but where I was calling the current_user method, I was getting nil values unexpectedly. Commenting out a line in a block of code that isn't being executed shouldn't change the behavior of my program!

Now, it was my fault for not realizing that Ruby was lying to me about current_user = being an assignment operation, but it's hard to not believe the lies that Ruby and Rails tell because they're everywhere. In Rails, they try to make coding easier by including external files by default so that you don't have to. This translates to using a lot of code that you see no reference to in the file.

In the defense of Ruby, it does have a strict naming system for different variable types, so it is obvious to veteran Ruby coders that they are really dealing with a function call rather than with a variable assignment, and it would be nice if other languages enforced stylistic conventions so that code looked similar.

I guess that Ruby would work well if all of the abstractions provided were really black boxes with well defined input and well defined output. But that has not been the case with any of the libraries that I have used (except the built in ones -- the Ruby built ins are wonderful). I had to look at the source code of every one of them to figure out why I was getting some bizarre bug. This is because the documentation is usually incomplete. For instance, on the question of what type of variable I pass in or what type it returns to me. The documentation might say "pass in the request." Do they mean the body of the request? Do they mean a signed request? Do they mean some request object defined in their library? Do they mean some other request object?

Often, the most commonly used part of a library will have some documentation. Often, that will be the only documentation. This is especially annoying when that documentation says "returns a Foo object" or "for use with the bar method" and neither Foo nor bar have any documentation. It's also common for a library's documentation to say "works with all of the options from the Bar library" and for the Bar library not to have any documentation on its options because the method that Foo used was internal to Bar rather than one of the main methods.

I guess when you're getting code that other people wrote from free repositories online, you can't expect them to write a perfect documentation. But that's why it's important to have code that is more structured. If I see an array in C or Java, I know exactly what it is, what it holds, what I can do with it, and how to give it to another function that needs it. I can see the type, and I can easily learn about any variable with a known type. I don't need to look at the source code of the function that gave me the array to figure any of that out. In Ruby, if I see an array, I can hope that it has a certain set of behaviors, but that is really just a hope: you can modify built in classes as much as you want to do whatever you want, so the foo array might not be very similar to the bar array. And most objects aren't just vanilla, but rather are classes with a bunch of methods that you probably shouldn't use and one or two poorly documented methods that you should.

In programming, you aren't typing that much. Most of your time is spent looking at code for bugs or looking at other people's code to understand it. Thus, I find it problematic that one of the major selling points of Ruby and higher level languages is that you don't have to type as much. They make the easy part of programming easier and, in the process, make the hard part of programming harder.

As Nick Parlante says, for small, independent, quick projects, scripting languages can be, but if you want to work with other people or work on big projects, then languages like Java are much nicer.

Wednesday, August 11, 2010

Loads of Pics

I discovered that Google's Picasa doesn't allow subfolders, so it's not really usable. Thus, for now, I'm just uploading my photos to my server.

Take your favorite FTP client (I like FileZilla) and connect to samking.stanford.edu with username pics and password cambodia (use SFTP or Port 22). Then, you can download my most recent batch of photos. There are a ton of them, so make sure you have a fast internet connection. About 2/3 of the photos are from Siem Reap, so if you want to download quicker, don't download those.

Verbose letter will be posted imminently.
-Sam

Sunday, August 8, 2010

8/8 Same Same (but Different): My First Taste of Corn

In Cambodia, there is a phenomenon of many things that are 'Same Same (but Different).'  Something is Same Same if it is an imitation that, on the outside, is a good replica of some brand but, on the inside, it is different.  For instance, I could get a pair of Same Same Birkenstocks for about 3 dollars.  If you looked at my feet, you would think that I was wearing Birkenstocks.  They have the same imprints on them; the soles look the same; everything looks like the real deal.  But if you care about substance rather than just style, then it's different.  Same Same soles are soft rather than hard, so they won't last.  The body isn't the same corky substance, so it doesn't mold to and support each individual foot.  In short, they're bad shoes.


My office took a vacation to the beach.  We were originally going to an island, but the weather didn't agree with our plans.  Also, I think the ocean gave me a fever (let's hope it's a light one).  However, one thing made it all worth it.  I had my first taste of corn.


In the US, we're taught to think that the yellow genetically modified stuff that they sell in stores is corn.  I have talked before about how much of the corn in Cambodia is the same GMO variety that comes from the US and about how the GMO stuff is worse than corn, but I never realized just how bad GMO 'corn' is. 

If I said that I was having a Coke for dinner, it would seem ridiculous because it's just sugar and water.  Well, that's what GMO 'corn' is.  The skin of each kernel tastes sweet, and there's some water inside.  That isn't corn.  It's Same Same corn.  It looks like corn -- when I first saw the cobs, I thought that it was GMO corn from the US.  But the substance of it is different.  It is stylish enough to fool consumers into eating it, but it isn't food.  It's an imitation. 

Some of the properties of GMO corn: it is high in calories and low in nutrition; it is hard to raise in climates like Cambodia that are flooded half the year, in drought the other half, and sporadically windy; it uses a lot of water, so it has high weight (and, thus, can be sold for more money).


The corn that I ate was real.  The kernels had meat rather than just water.  It was sticky.  It stuck to your teeth because there was something there.  It didn't taste like sugar.  It tasted wholesome.  I tasted corn for the first time, and it was good.