Since the last time I posted anything of substance:
* I turned 21. That went pretty much how it should have gone.
* Classes have started again. I have two Physics classes, both of which started off kinda slowish, one much more than the other, but are now starting to become legitimately challenging and fun.
* I'm an SI Leader for Physics 152. I don't think I'm doing so well with that, but it's hard to know. I think I'm slowly improving.
* I've been working hard on the no on 8 campaign, which now has a small but mighty corps of volunteers here at USC, with phonebanks two days a week.
* I did the USC Programming Contest again, but I didn't really prepare for it at all, like I did last year. Did very badly, but it was also a tougher contest than the last one. And we all got t-shirts!
* I've agreed to help Elizabeth with a journalism project that will require some programming. I'm not even sure how I want to do it. It's the kind of thing that would be web-based in real life but Javascript is meh and other web programming languages I don't know at all. So I'm going to see if I can build up a proof-of-concept in Python. I guess.
Next post will be something about prop 8 I think.
10.09.2008
10.03.2008
7.20.2008
Prisoners and Lightbulbs
I've been chatting on IRC a little bit, after discovering that, yes, people still use IRC sometimes. I really had no idea. Anyone, someone there posted this problem called One Hundred Prisoners and a Lightbulb, and it was driving me insane trying to figure out the answer. Unfortunately, the paper they linked to also had the answer, so I looked after a little while. Still, a fun problem, and it might be interesting to derive the details of the solution just using the basic outline.
6.13.2008
Python Challenge
I've been learning Python lately, both for my job and just for fun. After all, all the cool kids are learning Python, aren't they? Best of all, I found a great puzzle called Python Challenge, which consists of several cryptic puzzles that require programming to solve.
If you're learning programming, or want to learn, or you already know some and want to expand your realm of expertise, I highly recommend it. Out of the levels I've done so far, there is one that requires Python. The others were designed to be solved in Python, but could probably be done in any other language.
If you get stuck, there is a help forum, but they usually help you more with the concepts rather than how to write the code, so I wouldn't necessarily think of it as "cheating"--but try to do them on your own. It's more fun that way.
If you're learning programming, or want to learn, or you already know some and want to expand your realm of expertise, I highly recommend it. Out of the levels I've done so far, there is one that requires Python. The others were designed to be solved in Python, but could probably be done in any other language.
If you get stuck, there is a help forum, but they usually help you more with the concepts rather than how to write the code, so I wouldn't necessarily think of it as "cheating"--but try to do them on your own. It's more fun that way.
5.15.2008
Lawmakers
I never intended for this blog to be political in any way, and I'm not trying to change that now. But I do have one question. Here are some quotes from 365gay.com's article on today's historic California Supreme Court decision:
I'm not an expert on how government works, but these two people, a California Supreme Court justice, and an actor-slash-governor, should both know a little something about how it works. If I'm not mistaken, we have three branches of government, just like the federal government does. One of them, the legislative branch, is responsible for making laws. We, the people of the state, are responsible for, among other things, electing the members of the legislative branch. The only reason for having the voters decide an issue directly is if the legislative branch is not responding to a pressing issue for some reason, and the citizens need to take things into their own hands. Now, it may be that the legislature is unwilling or unable to act on some issue, and in that case, it might be a good idea to have a ballot initiative. However, this is not that issue. The legislature has tried to make a decision, and, as it says in the article, Schwarzenegger vetoed their decision twice. I see no reason that this issue ought to be decided by the voters directly. Except perhaps that Schwarzenegger doesn't want to have a bunch of conservative anti-SSM people mad at him.
I'm not even looking at this from a gay rights point of view. I'm just saying, there are people in Sacramento whose job it is to make laws, and while there are other ways of doing that, I see no reason those other ways should be invoked now.
The dissenting opinion to Thursday's ruling was penned by Justice Marvin Baxter.
While he agreed with many arguments of the majority he said that any changes to the state marriage law should be decided by voters.
[...]
Schwarzenegger has previously vetoed bills that would have legalized gay marriage. Both times Schwarzenegger said that the courts or the people through a plebiscite should decide the issue.
I'm not an expert on how government works, but these two people, a California Supreme Court justice, and an actor-slash-governor, should both know a little something about how it works. If I'm not mistaken, we have three branches of government, just like the federal government does. One of them, the legislative branch, is responsible for making laws. We, the people of the state, are responsible for, among other things, electing the members of the legislative branch. The only reason for having the voters decide an issue directly is if the legislative branch is not responding to a pressing issue for some reason, and the citizens need to take things into their own hands. Now, it may be that the legislature is unwilling or unable to act on some issue, and in that case, it might be a good idea to have a ballot initiative. However, this is not that issue. The legislature has tried to make a decision, and, as it says in the article, Schwarzenegger vetoed their decision twice. I see no reason that this issue ought to be decided by the voters directly. Except perhaps that Schwarzenegger doesn't want to have a bunch of conservative anti-SSM people mad at him.
I'm not even looking at this from a gay rights point of view. I'm just saying, there are people in Sacramento whose job it is to make laws, and while there are other ways of doing that, I see no reason those other ways should be invoked now.
5.12.2008
Writing "code"?
My friend from freshman year, Elliot, has recently started a new blog, Anyone Can Code. I guess he's going to teach some programming courses over the summer, partly because he, like me, doesn't like the way most of the courses he's taken at USC have been taught. And because he believes that, well, anyone can code.
His first post on the Anyone Can Code blog lamented the people who are somewhat interested in computer science, but think they can't code. I've always thought that "people who can't do math" were just people who had terrible math teachers and never took them time to learn any math on their own. There isn't really anything wrong with this, but it's now become relatively socially acceptable to know almost no math. It's also socially acceptable to know literally no coding, since most people never take any computer science classes.
I've digressed a little, but the point I wanted to make here is that perhaps referring to programming as "coding" is not good for making it accessible to the general public. Code, in everyday language, is a message which is unreadable until a person or machine performs some kind of operation on it to decode it, so that humans can read it. Back in the days of punchcards, that may have been somewhat accurate, but now writing computer programs is (or at least should be) almost the opposite. You write down what you want the computer to do, in as clear and straightforward a way as possible. Then the computer compiles or interprets it, which is when it becomes completely unreadable. But the programmer isn't writing "code". They're just writing down a set of instructions, in another language. So maybe instead of "coding," we should look at programming as writing in another language. Because that's all programming languages are--they're just languages, where the rules of grammar must be followed much more strictly than in languages like English or Spanish.
Oh great, you say, so coding is just like learning a language, except with even more emphasis on grammar? Sounds lovely. Well yes, but there's very little emphasis on learning new vocabulary. In fact, most of the important words in most languages are actually words you already know. And the grammar rules are much clearer and completely unambiguous, especially in languages like Ruby and (from what I hear, although I haven't used it myself) Python, which were deliberately intended to be easier to use. I think Elliot is right that anyone can code. It doesn't mean everyone will find it fun. But if we stop thinking of code as "code," perhaps everyone will be able to do it.
His first post on the Anyone Can Code blog lamented the people who are somewhat interested in computer science, but think they can't code. I've always thought that "people who can't do math" were just people who had terrible math teachers and never took them time to learn any math on their own. There isn't really anything wrong with this, but it's now become relatively socially acceptable to know almost no math. It's also socially acceptable to know literally no coding, since most people never take any computer science classes.
I've digressed a little, but the point I wanted to make here is that perhaps referring to programming as "coding" is not good for making it accessible to the general public. Code, in everyday language, is a message which is unreadable until a person or machine performs some kind of operation on it to decode it, so that humans can read it. Back in the days of punchcards, that may have been somewhat accurate, but now writing computer programs is (or at least should be) almost the opposite. You write down what you want the computer to do, in as clear and straightforward a way as possible. Then the computer compiles or interprets it, which is when it becomes completely unreadable. But the programmer isn't writing "code". They're just writing down a set of instructions, in another language. So maybe instead of "coding," we should look at programming as writing in another language. Because that's all programming languages are--they're just languages, where the rules of grammar must be followed much more strictly than in languages like English or Spanish.
Oh great, you say, so coding is just like learning a language, except with even more emphasis on grammar? Sounds lovely. Well yes, but there's very little emphasis on learning new vocabulary. In fact, most of the important words in most languages are actually words you already know. And the grammar rules are much clearer and completely unambiguous, especially in languages like Ruby and (from what I hear, although I haven't used it myself) Python, which were deliberately intended to be easier to use. I think Elliot is right that anyone can code. It doesn't mean everyone will find it fun. But if we stop thinking of code as "code," perhaps everyone will be able to do it.
4.28.2008
USC Programming Contest: 6th Place!
This past Saturday, I participated in the USC Programming Contest. As you can see here, they used my code as one of the sample solutions. More importantly, as you can see here, I slipped in just two minutes shy of 5th place! I would have gotten to choose a video game as a prize, but since I had to leave early to volunteer at the GLAAD awards, I had someone grab one for me. I realize now that since my taste in video games differs so much from most people's, I probably could have just asked the contest organizers to give me whatever was left, and it would have been something I really liked. Instead, I ended up with an FPS from the Medal of Honor series, which Andy assures me is badly designed, badly coded, and generally just not a good series of games. So I'll probably sell it. It's more about the glory anyway.
In any case, I'm pretty excited, and the GLAAD awards were fun too. We got to watch the show for a few minutes, including seeing Kathy Griffin win for best reality show. The GLAAD people were so grateful for our help, they let us take gift bags with all kinds of swag in them. One paper, one programming project, and three big dance performances away from the end of classes! Then finals, then commencement (playing, not graduating), and then Brazil!
In any case, I'm pretty excited, and the GLAAD awards were fun too. We got to watch the show for a few minutes, including seeing Kathy Griffin win for best reality show. The GLAAD people were so grateful for our help, they let us take gift bags with all kinds of swag in them. One paper, one programming project, and three big dance performances away from the end of classes! Then finals, then commencement (playing, not graduating), and then Brazil!
Labels:
competition,
GLAAD,
programming,
videogames,
volunteering,
winning
4.10.2008
Star shapes
So I skipped Philosophy today and went to my CSCI 101 midterm pretty early. Before it started, I was talking to Ashley and Rollerblades Kid (I call him that because I don't know his name, but he uses rollerblades as his primary mode of transportation) about the impending midterm, and computer programming in general. Ashley has no programming experience other than this class, and she was telling me how she had been having trouble on a recent assignment with opening an input file. The relevant code would go something like:
I don't think I ever figured out, based on her description, what she had done wrong, but she said she contacted a friend who works at Google, and her friend had told suggested some sort of modification using character arrays in place of strings. It makes you wonder why, when C++ was designed, they didn't rewrite ifstream::open() to accept strings. I mean, you could just do:
C++ just seems so user-unfriendly after playing around with things like Javascript and Ruby. It would be interesting to learn the history of various languages, because programming languages do grow and evolve like spoken languages, but there are also some clear differences between the way they evolve. In any case, I suppose they use C++ for the 101 class because it's well established, and the people running the department probably aren't familiar with a lot of the newer languages anyway. Plus, C++ forces you to think a little bit about the way the computer deals with data, internally, when you pass things by reference, or try to access an array value that's out of range. I suppose that would be helpful when you get to classes on data structures. (One of many classes, by the way, that I should be taking this fall, but can't because it conflicts with a required physics class.)
However, Ashley is a chemical engineer. Many of the people who take this class are business majors. They're not taking a data structures class, and have no desire to become programmers of any kind. There really ought to be another class for such people. In fact, sometimes I think a few basic programming skills ought to be required of all students. However, I would never wish this particular class upon the student body at large. This other class would be like Physics 100, which I gather is a physics class for people who really don't like physics. It would probably be taught in some version of BASIC, maybe VBA since it's infinitely more useful for many people than any other language. Ideally, it would be something where students can type things in at a command line, rather than having to write, compile, fix compiler errors, recompile, test, fix runtime errors, recompile, etc. There would probably be no need to deal with OOP, but maybe they'd touch on it at the very end.
As it is, no one is going to learn anything from a single class like CSCI 101, especially when we spend more time worrying about things like header files than we do actually writing code. I guess that's the whole point of Ruby. The programmer's job is to write code, and the interpreter takes care of everything else, like memory allocation. Anyway, I have a few problems with the way our class is taught, as well, but I'm sure I'll post about that another day.
What I wanted to post about was actually an exchange with Rollerblades Kid. I was complaining about what I called "bullshit" on the test. I tried to reproduce one from today's test from memory, but Blogger tried to interpret the << operator as the beginning of an HTML tag and it got all messed up. In any case, we have a couple of functions that have a more or less random assortment of +'s, -'s, switch statements, if statements, arguments being passed by value/reference, etc. They don't correspond to anything real at all, it's just arbitrary data manipulation. We have to trace through the program, then write down the output it would generate. Admittedly, these problems are pretty simple, and I guess they're okay for test questions, but it completely goes against the principles of good code writing. You can't use descriptive variable names when your variables do not in fact describe anything.
In any case, Rollerblades Kid didn't seem that concerned with this type of problem, because he was used to them from the AP Computer Science test (which I didn't take), but he and Ashley both objected strongly to "Star shapes" problems. The kind which are supposed to print output like:
or
I must admit that, in modern times, when we have the ability to use "real" graphics, there is no need to learn this particular skill. Yet for some reason, I find it much less like a pointless busywork assignment than the "bullshit" trace problems. I think that's because it solves a real problem. Not real as in real-world. Just real as in, there's an actual problem with a non-trivial solution, and the code is that solution. Yes, it's a problem you may never face, but the same could be said of so many problems you're asked to solve as classwork. Still, it's hard to explain just what it is that, to me, makes Star Shapes problems seem not to be completely worthless. You can actually learn something about good programming style from such problems. But of course, there is absolutely no guarantee that will actually happen.
ifstream fin;
string filename;
/* ... */
cout<<"Please enter filename: "; cin>>filename;
fin.open(filename.c_str());
I don't think I ever figured out, based on her description, what she had done wrong, but she said she contacted a friend who works at Google, and her friend had told suggested some sort of modification using character arrays in place of strings. It makes you wonder why, when C++ was designed, they didn't rewrite ifstream::open() to accept strings. I mean, you could just do:
void ifstream::open(string filename) {
open(filename.c_str());
}
C++ just seems so user-unfriendly after playing around with things like Javascript and Ruby. It would be interesting to learn the history of various languages, because programming languages do grow and evolve like spoken languages, but there are also some clear differences between the way they evolve. In any case, I suppose they use C++ for the 101 class because it's well established, and the people running the department probably aren't familiar with a lot of the newer languages anyway. Plus, C++ forces you to think a little bit about the way the computer deals with data, internally, when you pass things by reference, or try to access an array value that's out of range. I suppose that would be helpful when you get to classes on data structures. (One of many classes, by the way, that I should be taking this fall, but can't because it conflicts with a required physics class.)
However, Ashley is a chemical engineer. Many of the people who take this class are business majors. They're not taking a data structures class, and have no desire to become programmers of any kind. There really ought to be another class for such people. In fact, sometimes I think a few basic programming skills ought to be required of all students. However, I would never wish this particular class upon the student body at large. This other class would be like Physics 100, which I gather is a physics class for people who really don't like physics. It would probably be taught in some version of BASIC, maybe VBA since it's infinitely more useful for many people than any other language. Ideally, it would be something where students can type things in at a command line, rather than having to write, compile, fix compiler errors, recompile, test, fix runtime errors, recompile, etc. There would probably be no need to deal with OOP, but maybe they'd touch on it at the very end.
As it is, no one is going to learn anything from a single class like CSCI 101, especially when we spend more time worrying about things like header files than we do actually writing code. I guess that's the whole point of Ruby. The programmer's job is to write code, and the interpreter takes care of everything else, like memory allocation. Anyway, I have a few problems with the way our class is taught, as well, but I'm sure I'll post about that another day.
What I wanted to post about was actually an exchange with Rollerblades Kid. I was complaining about what I called "bullshit" on the test. I tried to reproduce one from today's test from memory, but Blogger tried to interpret the << operator as the beginning of an HTML tag and it got all messed up. In any case, we have a couple of functions that have a more or less random assortment of +'s, -'s, switch statements, if statements, arguments being passed by value/reference, etc. They don't correspond to anything real at all, it's just arbitrary data manipulation. We have to trace through the program, then write down the output it would generate. Admittedly, these problems are pretty simple, and I guess they're okay for test questions, but it completely goes against the principles of good code writing. You can't use descriptive variable names when your variables do not in fact describe anything.
In any case, Rollerblades Kid didn't seem that concerned with this type of problem, because he was used to them from the AP Computer Science test (which I didn't take), but he and Ashley both objected strongly to "Star shapes" problems. The kind which are supposed to print output like:
*
**
***
****
*****
******
or
*
***
*****
*******
*****
***
*
I must admit that, in modern times, when we have the ability to use "real" graphics, there is no need to learn this particular skill. Yet for some reason, I find it much less like a pointless busywork assignment than the "bullshit" trace problems. I think that's because it solves a real problem. Not real as in real-world. Just real as in, there's an actual problem with a non-trivial solution, and the code is that solution. Yes, it's a problem you may never face, but the same could be said of so many problems you're asked to solve as classwork. Still, it's hard to explain just what it is that, to me, makes Star Shapes problems seem not to be completely worthless. You can actually learn something about good programming style from such problems. But of course, there is absolutely no guarantee that will actually happen.
Subscribe to:
Posts (Atom)