Sep 25

For a long time, I’ve been building GNU Emacs for OS X with the carbon interface enabled. It’s been alright, true enough. But recently I stumbled upon Aquamacs, and it’s like all of my emacs prayers have been answered.

Take Aquamacs, add Markdown Mode and possibly weblogger.el, and you have the strongest blogging tool ever conceived. I feel funny being so excited about that, but I suppose I spend more time blogging than programming, nowadays! Strange…

Anyway, I’ve noticed that since I’ve been using that setup, my posts on my main blogs like move the markets and unaspected tend to be longer and better organized. The only drawback is that when I want to post a picture, so far I still have to go to my wordpress web interface to get the pics uploaded and processed into thumbnails, etc. Maybe if wordpress has APIs for all that, I can hack it into emacs as well. We’ll see…

The most recent version of Aquamacs has soft newlines available as an option, similar to what I think longlines mode did. This is a great feature to have, along with options in the edit menu to insert or remove the hard newlines in a buffer. I find that soft newlines work much better when I post my markdown output to wordpress, as wordpress converts hard newlines to <br/> tags. Yuck!

Sep 23

When designing a programming language, I always reach a few decision points where I have to choose between two options that both sound good to me. One of those is whether to allow variable arguments (a la scheme), or do automatic currying (a la haskell). Other languages have these features, but I pick on scheme and haskell because they are my favorites, and I use both often.

Anyway, I like both of these features, and use them a lot in languages that provide them. Sadly, it doesn’t seem too clean to have both at the same time. To curry you need to know how many arguments are coming, and to accept zero arguments you can’t auto-curry. They just aren’t very compatible features.

I mean, in scheme you can define the + function to take any number of arguments, including no arguments at all:

(+ 1 2)        ; valid
(+ 1 2 3 4 5)  ; valid
(+)            ; valid

That’s really cool. Haskell’s idiom seems to be to define a second function that accepts a list as an argument:

1 + 2   -- or "sum [1,2]" of course
sum [1, 2, 3, 4, 5]
sum []

You might think that the list-accepting function takes care of the issue on haskell’s end. But, it accepting a variable number of arguments turns out to be really useful in a variety of contexts, like map:

(map + '(1 2 3))                    ; valid
(map + '(1 2 3) '(4 5 6))           ; valid
(map + '(1 2 3) '(4 5 6) '(7 8 9))  ; valid

… whereas in haskell we need both map and the zipWith family to handle a similar task:

map id [1,2,3]
zipWith (+) [1,2,3] [4,5,6]
zipWith3 (\a b c-> a+b+c) [1,2,3] [4,5,6] [7,8,9]

Note that in the third case, we can’t use the sum function, since zipWith3 doesn’t pass the 3 arguments as a list. I suppose a version of map could be made which takes a function that operates on lists, along with a list of lists to zip over:

mapVariable sum [[1,2,3],[4,5,6],[7,8,9]]

… and for all I know that function’s already in the GHC libraries somewhere. But, making list versions of everything certainly doesn’t feel very efficient or haskell-like to me.

So, in this example, I’d say the scheme style definitely wins, in terms of using similar-looking code to accomplish similar-looking tasks.

However, I don’t see how I can support scheme-style variable args and also allow familiar auto-currying haskellisms like: map (+1) lst. In scheme, that example would look like:

(map (lambda (x) (+ 1 x)) lst)

It’s just not the same! With srfi-26, you can type:

(map (cut + 1 <>) lst)  ; srfi-26

… which is slightly nicer, I guess. But only slightly.

The automatic currying is also very useful when defining functions. I often write functions like:

fooize = map foo

… which in scheme must be much more explicit about grabbing the parameter and passing it to the function:

(define (fooize lst) (map foo lst))

So, we’ve defintely lost some brevity. However, I usually come down on the scheme side of this argument when designing little extension languages. I think it looks very clean to be able to use the same function name on variable numbers of arguments, and I can still manually curry functions even if it is more verbose.

Are there any valid compromises? Like, say, auto-curry all functions that don’t accopt variable numbers of arguments? Or auto-curry all functions until you have at least as many arguments as you need to fully apply the function? Those options seem confusing at best, and don’t work very well anyway for the toy cases like the + function. If your language has macros, then you can do like some people have done and make macros that allow you to auto-curry individual functions:

(define-curried (foo x y z) (+ x (/ y z)))
((foo 3) 1 2)
((foo 3 1) 2)

But, again, this leads to confusing programs in my opinion… where different functions seem to get different treatment. I haven’t been able to come up with any workable compromises… so when I put together a language, I just pick one approach or the other.

Sep 4

Here’s a tip for when you notice you are editing a file with silly dos
^M endings in emacs. I know it doesn’t really matter, but I can’t
stand seeing the little (DOS) notice sitting in the mode line. So:

Just introduce a change to the file, like hit the spacebar and then
delete the space, or whatever. This way, emacs will want to write out
the file next time you save it. Then use this command:

C-x RET c utf-8-unix

… and when it prompts you for the command to run as utf-8-unix, ask
it to save the file: C-x C-s

Now you have a utf8-encoded file with unix line endings. Perfect!

Jul 20

Elvis… what can I say? I grew up in Memphis, TN…

C    G   Am        F     C    G    G7

wise men say  only ...

    F G     Am   Dm         C    G    C

but i can't help falling ...

shall i stay  would it ....

[Bridge]

Em           Am

like a ...

Em            Am

surely to ...

Em            Am

darling ...

Em               A7       Dm   G7

some things were ....

Dec 17

Pretty nice speech by Randy Pausch. He’s got that scenario where you find out that you have 3 months of good health left (pancreatic cancer). The speech is about achieving your dreams, and helping others to achieve theirs. Pretty inspirational, I think.

Nov 19

As I wrote in this post, I was trying a few methods to get back in synch with the normal waking world. Recall, I was trying:

  1. Open my blinds during the day and rely entirely on sunlight to light my rooms.
  2. Only use dim lighting at night
  3. Avoid tv screens and computer monitors at night (especially computer games). Shift to reading paper books and listening to podcasts at night, and do the computer stuff during the day.
  4. No big meals after sunset
  5. No matter when I go to sleep, wake up at the same time every day (I chose 7:30 AM)

So, after a couple months, I would say the two most important tactics are (1) and (5). Even when I slip up and go to bed way too late, it really helps to just get up at 7:30 the next morning anyway. The funny thing is that it doesn’t even feel that bad, when your body is more-or-less trained to be awake in the morning. And, whenever I get up, I go look at the sunlight out my window for a minute or so. Supposedly this helps your mind register that it’s morning and resets your internal clock.

I have tried to follow the other rules, but I admit I regularly fail at (3) and (4)… I do a lot of programming/etc and sometimes I want to continue with that at night. I have been better about not eating meals too late, though at times I cheat and eat snacks. I can’t help it… it goes hand-in-hand with programming.

So far, it’s been a complete success… with only a couple exceptions, I have gotten up between 7:30 and 8:00 every day since that earlier post.

Oct 16

Great Radiohead song… The Bends has to be one of the best sophomore albums, ever. I certainly had no idea so many great songs were to come, based on their debut disc (which is decent, but nothing like the quality of their later releases).

Read the rest of this entry »

Watch this post's video on Youtube

Sep 12

Disturbing….

I do recall that MS DOS 5 was a big deal… there were some features I was definitely excited about. But, this video would have been incredibly embarrassing to watch even at the time, I’m sure. What were they thinking?!?

Sep 9

This is my favorite Bob Dylan song (at the moment), from Highway 61 Revisited. Unfortunately, Bob is kind-of a slacker in live performance, and I couldn’t find any of his that I thought did the song justice. Here is a live version by Neil Young, though, that’s pretty good, and faithful to the original.

Read the rest of this entry »

Watch this post's video on Youtube

Sep 6

Another fine google tech talk, this time on Quicksilver (the mac utility):

Quicksilver’s one of those apps I’ve heard about a lot, and have been meaning to try out forever. Just haven’t gotten around to it yet.

« Previous Entries