Thursday, July 27, 2006

while ( still_stuck_on_c ) { ... }

Obviously I'm not the only one that keeps reaching for the while loop. This from CL+SSL:

;;; Misc
;;;
(defmacro while (cond &body body)
`(do () ((not ,cond)) ,@body))

Closures

As a novice in the ways of Lisp I'm constantly being reminded just how cool it is. In this particular case, I was working on some code for sending messages to our agent, and needed to provide a sync version of an async send-message. We do something similar in C++ and ended up with a special synchronous handler class, and about half a page of code. I was approaching the same issue in our new Lisp backend with some trepidation since I knew I was going to need to use some mutexes and condition variables, which I had never used in Lisp before. Including the time it took to actually read the docs and get reminders about how Lisp works from Jasko, I had something working in a matter of minutes:

(defmethod send-message-sync ((client client) command)
(let ((condition (make-waitqueue))
(lock (make-mutex :name "sync lock"))
(result nil))
(with-mutex (lock)
(send-message client command
#'(lambda (obj &rest args)
(with-mutex (lock)
(setf result args)
(condition-notify condition))))
(condition-wait condition lock))
result))

That little lambda tucked away in there closes around a lock, condition variable and result—all waiting for our eventual message return. It is not that I can pass the value of result into the lambda that is so powerful. But rather, when the lambda assigns a value to result and fires off the condition variable in whatever far-off place it ends up, back in the thread where I started and am patiently waiting my result gets the new value.

When you read about closures in texts on Lisp they seem so pedestrian. "Yeah, but I can do that with a functor in C++, pointers, references, blah, blah, blah." Then, you actually use them to solve a real problem, and the lightbulb goes off.

Tuesday, July 25, 2006

Remember the firewall

If you are doing network coding it is very important to remember that you have a firewall turned on. I would like to say I have learned my lesson, but I'm almost sure I've been here before. Sheesh.

Monday, July 24, 2006

Fedora-on-Parallels

I installed Fedora on Parallels on my mini at home so I could work on the networking parts of our server that were going to be very closely tied to the platform. Unfortunately, BSD and Linux have gone divergent paths when it comes to highly scalable networking APIs. Linux has epoll, and BSD kqueues. Since Rackspace supports Linux, epoll it is. I installed Fedora Core 5 on a Parallels virtual machine, and it seemed pretty nice.

Pretty nice that is except for the slight mouse lag, which started to get very annoying. Alas, there are no Parallel Tools for Linux yet as there are in Windows, which fixes the same issue when running XP as the guest operating system. My solution is to run X11 on the mini itself, and run:

ssh -X virtual-machine-ip-address

This works great, as long as you don't want to resize your emacs window. As soon as you do, you get a nice:

X protocol error: BadWindow (invalid Window parameter) ...

Google being the all-knowing, all-seeing eye, told me to add a -Y to the ssh command, and all was well:

ssh -X -Y virtual-machine-ip-address

Senior Software Developer

Paragent is looking for a Senior Software Developer to help deliver our next product over the web. We are seeking an individual with experience developing large-scale, secure hosted applications using Lisp. Responsibilities will include development and maintenance of all server-side applications and infrastructure. In addition, this position will provide database maintenance, backup, load-balancing expertise and server configuration.

Requirements:
Bachelor's Degree
3+ years experience in developing hosted applications

Skills:
Good written and verbal communication skills
Web site scalability
Load balancing
MySQL clusters
Encryption (OpenSSL)
Linux System Administration
Backup and Data-retention
Languages: Lisp, SQL, C/C++
SBCL, UCW development experience a plus

Lead Support Engineer

Do you have a passion for supporting customers? As a Lead Support Engineer at Paragent, you will be responsible for helping current and potential customers through training, installation and long-term support. Additional responsibilities will include the development and documentation of support procedures, as well as the participation in new product testing. You will work closely with both the development and sales teams to lay the groundwork for new product and feature rollouts. This position requires someone with excellent verbal and written communication skill with an outgoing, friendly and patient personality.

Requirements:
Bachelor's degree
3+ years of experience in a support or QA position

Skills:
Windows, Linux
Active Directory
Large-scale package rollouts
Scripting Languages (Perl, Python, etc.)
Unix administration and C++/Lisp programming a plus