Unleash the power of the atom… to boil water?
I'm going to go off on a limb and blog about something I know absolutely nothing about. Power generation.
So I'm reading the news recently and I read that the U.S. is going to invest in building a couple of nuclear power plants. Now, I don't know much about nuclear power plants or power generation in general. But I know how to use the googles for finding out about stuff I don't know much about. So I hit wikipedia and all those other websites and I find about all of these wonderful methods of generating power.
Fossil Fuels: Coal for instance. Oil and natural gas too. The main idea is to burn these fossil fuels in order to boil water so that the steam can make a turbine spin and generate electricity using a big electromagnet.
Nuclear Fission: Create a controlled nuclear reaction so that we can heat up water and produce steam to spin a turbine hooked up to a huge electromagnet.
Geothermal Power: Drill a very, very deep hole to reach the hot granite that underlies the earth's crust. This granite is so hot we can use it to... boil water... steam... turbine... electromagnet.
Hydroelectric: Just avoid the whole boiling water bit and spin the turbine directly from a river.
Tidal Power: Make a dam in the ocean and put the turbine there.
Wind Power: Instead of boiling water and using steam, use wind to spin the turbine.
Solar power: At this point, if I had read that we were using solar to boil water I would've just given up hope for humanity. But no, at least with solar we actually just use the energy... no turbine involved.
So my question for more informed readers is: uh, how about not needing the turbine and using some other method of gathering the released energy? Especially in the case of Nuclear Fission. It seems somewhat wasteful to fire up an atomic bomb just to boil some water...
The case against snippets
Back when TextMate was relatively new and that famous video of ruby on rails was making the rounds. I watched in amazement with the rest of the nerds as code flew around the screen. I had caught Snippet Fever.
After using TextMate for a while I became addicted to snippets. The basic idea of a snippet is that you can write a few characters and they expand to whatever you want. For example, you can type: 'fl', hit Tab and TextMate will write:
for(int i = 0; i < ... ; i++) { ... }
Where ... is where the insertion point will be each time you hit tab. You can do the same with Emacs in many different ways: Emacs skeletons, the snippet.el plugging, hand-coded elisp, etc. The point of this post, however, is not to show all the different ways that you can get snippets. The point is to ask whether it's worth using snippets at all.
Snippets eliminate the need to type recurrent idioms. If you have to write accessors, it's very pleasant to type 'set', hit tab and watch the screen fill with 20 lines of code that just wrap a field in a class with a setter function. But this is fixing the problem in the wrong place.
The fundamental problem is that the language
Imagine English had no pronouns so if I wanted to tell you a story about my friend Tim and me, I had to write:
Tim had called Oscar to ask Oscar if Oscar could lend Tim the book that Oscar had bought the day before. Oscar told Tim that Oscar was still reading it, but that Oscar would be happy to lend Tim Oscar's book when Oscar was done with the book so that Tim could read it.
The above paragraph is too verbose. It's hard to write. Snippets would help me write it by automatically filling all the appropriate places with "Tim" and "Oscar".
If the language you are using is so verbose that you need snippets, how about fixing the language?
Even on languages that don't allow fixing the syntax you can still do something.
For example, in C, if you find yourself typing a for loop to access a list over and over again:
for (int i = 0; i < length(list); i++) { }
Make a small pre-processor macro that abstracts that:
#define EACH(list) for (int i = 0; i < length(list); i++)And now you can write:
EACH(list) printf("%s\n", list[i]);
And since code is usually read many more times than it is written, you have helped make the source base a little better.
Hidden Gems in C99 (1)
After some late night reading of the C99 spec, I've found quite a few hidden gems. I'm going to start posting some of these. Since it's late, I'll just post a teaser.
On page 64 of the C99 standard it says:
In all aspects of the language, the six tokens
<: :> <% %> %: %:%:behave,respectively,the same as the six tokens
[ ] { } # ##except for their spelling.
Really? Then let's try this program:
%:include <stdio .h> int main(int argc, char *argv<::>) <% printf("hello world\n"); %>
Compile it an run it:
dirac src $ gcc main.c dirac src $ ./a.out hello world
Whaddaya know... I know, I know... useless. Wait for the next post then.
Lazy-loading emacs functionality
Quick, how big is your .emacs file? How long does it take emacs to load? A few days ago I found that my .emacs file had slowly grown to the point where it was taking emacs a significant amount of time to load. Something needed to be done.
A quick glance at the file told me I was loading a lot of modules that I seldom use. For instance, I occasionally write some code in Common Lisp or Haskell, so naturally I was loading slime and the haskell environment. I commented those out.
However, after commenting them out, I quickly realized that not loading them was problematic. When I wanted to use them, I had to open my .emacs file, uncomment the relevant portion, and M-x eval-region the code.
Then it occurred to me that I had a clear entry point for some of these modules. When I write Common Lisp, I usually start by loading SLIME's REPL by running M-x slime. I came up with the following code:
(defun slime () (interactive) (add-to-list 'load-path "~/emacs/slime") (setq inferior-lisp-program "/usr/local/bin/sbcl") (require 'slime) (slime-setup) (slime))
Which basically sets up my slime environment and then loads slime. Note that the slime function itself is redefined as part of the evaluation of (require 'slime), so although this looks like a recursive call, it's not.
I've used this trick in several other cases and I think it's kind of neat. It helps me keep Emacs loading fast, but I still have all the bells and whistles available.
Leave a door open (for Peace)
![]()
Today is John Lennon's death anniversary. He was shot to death on December 8th, 1980. I always commemorate this day by listening to John Lennon's music, smoking unfiltered Gitanes, playing guitar, and letting my hair grow long... for a day... ok, not really, but I do try to listen to Imagine, at least once.
At any rate, there is a website now to commemorate John. It has a letter from Yoko Ono and a video from John Lennon.
The goal of an artist is to elicit some kind of emotion from the audience through his art. You cannot see the video and feel nothing. I left it running in the background while doing other things as I've seen Lennon interviews thousands of times and can usually remember how they go, but the imagery at the end, after John stops talking, pulled my eyes and engaged me like nothing has for a long while. I literally couldn't stop watching.
At any rate, here's to you John Lennon. You were the Walrus.
Norton Fighter
And on a lighter note... I found this clip hilarious.
Part 1:
and part 2:
If I used Windows, I'd buy norton antivirus just because of this ad.
Timeo Facebook et dona ferentes
Which can be loosely translated as "I fear Facebook even if it brings gifts". My friends have noticed that for quite some time I've stopped updating my Facebook status, or even interacting with the site altogether. The reason is simple. I don't trust them.
A short time ago, Facebook introduced a new feature called "Beacon" that lets websites send status to your mini-feed. It immediately drew a lot of criticism because of its invasion to privacy, to the point that many people figured out ways to block it. Facebook's CEO apologized for it today and made beacon opt-out.
Now, I was going to write a detailed article about why this bothers me and how insincere the apology sounded, but our good old friend Fake Steve Jobs did a much better job in this blog post. Money quote:
These guys are like Google, only their slogan isn't "Don't be evil" -- it's "Don't get caught."
And later:
The smarmy fake apology is not at all reassuring and seems to have been written by PR people who were trying to imitate a 23-year-old kid who's speaking from the heart and trying to sound all sheepish and aw-shucks -- except the flacks can't do it because they're as insincere and stage-managed as as the Facebook guys. Plus, let's face it, the flacks are getting paid in Facebook equity, right?
I couldn't have said it better myself. You should go read the whole post.
The Apple Experience
Last week I was once again sucked into the argument of whether Apple is a hardware company or a software company. My take on it: it's neither.
Apple is an "experience" company. They do hardware because it's the only way to have the software under control. They do software because without good software, the hardware is useless. What they ultimately worry about is the user experience.
They partnered with AT&T because they needed to add the cellular network to the experience and they couldn't build their own (they would have loved to). If they look like control freaks from the outside it's because, well, they are.
On that note, in this piece, Saul Hansell argues that AT&T allows applications on other phones, except the iPhone. Saul claims that Mark Bercow, senior vice president of business development for Palm, encourages developers to do pretty much as they please with the Palm Treo:
Indeed, some developers have made video streaming applications, a particularly big bandwidth hog. (Of course, the cellular companies are free to charge whatever they wish for bandwidth use.)
Now go to the AT&T website and try to find their data rates. I could find a $24.99 data rate that was limited to 10MB, and an unlimited plan (with some fine print about per-kilobyte charges) for $69.99. That is in addition to the cost of the plan. The iPhone unlimited data plan is $20 per month. So while developers can create apps for any other AT&T phone, customers get charged per kilobyte. Now consider again what Steve Jobs said about third-party apps:
You need it to work when you need it to work. Cingular doesn’t want to see their West Coast network go down because some application messed up.
My take on that is that AT&T doesn't want to see their network swamped with data transfers without being able to charge for them. However, a per-kilobyte service plan would have totally ruined the iPhone experience for the users. Apple wanted users to experience having a device that is always connected to the Internet. That experience is ruined if you're worrying about how much you're accessing the net because your service provider charges you per-kilobyte.
The reason Apple is so successful is because using their products is a pleasurable experience. That's their trick, they think about the "experience".
Meet the new Blog, same as the old Blog
As you can see, I finally bit the bullet and moved my blog to my own domain. I plan to do the same with the website (it's still being hosted at Galileo University). The website needs a lot of work. It' still so... twentieth century!
The blog is now running on WordPress and I have to admit it was trivial to install. The admin interface is also pretty decent.
My one complaint is that the WYSIWYG editor that they ship seems to mangle my HTML pretty bad, to the point that I have to use Emacs to fix it, so I won't use it.
One big improvement is that the code snippets now have syntax highlighting. Awww, look at those beautiful colors. I'll be posting more code snippets now that looking at them doesn't hurt my eyes.
Well, that's all for today. Don't forget to subscribe to the new RSS Feed and to cancel the old one. I won't be posting to blogger anymore.
