Light Table is a code editor with some cool new ideas

Chris Granger (@ibdknox) has put up a Kickstarter for his interesting new code editor, Light Table. It has some new ideas for how a developer works with the code they’re writing. As you’re editing code, Light Table will show you how the data will flow through that code in realtime, making it easy to see how values will be used as you code. Think of it like writing code with a debugger helping out in the background. There’s a lot of other cool ideas too, like editing a function at a time instead of an entire file, an inline doc viewer and a cool code searching system.

Initially it will have support for Clojure and JavaScript but more languages will appear after the initial release. Python support will be added if the project reaches $300k.

I hope this sorta becomes the “unofficial” editor for Clojure and helps get some more exposure for similar languages… Check it out and help fund the project on Kickstarter so this project can quickly become a reality: http://www.kickstarter.com/projects/306316578/light-table

Fixed-size arrays in MongoDB

Creating a fixed-size array in a MongoDB document can be less than straightforward. Mongo doesn’t support declaring an array’s maximum size or limiting the size of the array when $pushing onto an array (see SERVER-991). The solution I had initially thought up was to create new documents with the fixed-size array filled with empty values. Writes would then use a $push to add a new item and $pop : -1 to remove the first item, keeping the array the same size as when it was first created. However, I learned that MongoDB will not let you use the same field name in two operators in the same command (see SERVER-2643):

Well, that sucks. How about breaking out the $push and $pop into two separate commands:

The functionality is the same but, since it’s not within one command, a few potential problems have been introduced.

The $push could happen without the $pop meaning the array could grow longer than intended. This shouldn’t happen very often: only if there’s an error with the $push, the database connection is lost or the code dies between the commands. The code that handles the reads can log a warning when it encounters a document with an oversized array and then grab only the last n items from the array (see the $slice operator).

Having a few extra items in the array shouldn’t be a problem, as long as it doesn’t get out of hand. However, if the $pop occurs without the $push the array may become smaller than desired, possibly losing data. The update should only remove items from the array if it’s larger than the minimum required number of elements. MongoDB has a $size operator but it only allows matching an exact number of elements, not a range. The solution is to add a size field that gets incremented with a $push and decremented with a $pop. The criteria of the $pop can then use the size field as a check.

In addition, if safe writes can be used, the return value of the $push command can be checked to see if the write succeeded before the $pop is issued, ensuring array can only grow too large.

This all seems a bit convoluted to simply get fixed-sized arrays in MongoDB. Hopefully 10gen will add them as a native feature soon. If these features are important to you, please vote on SERVER-991 and SERVER-1050 on 10gen’s JIRA.

Amazing Beer at The Refuge in San Carlos

Another trip to San Francisco gave me a chance to visit The Refuge again. I visited this amazing Belgian Beer bar last year but wasn’t really prepared for the awkwardly early closing time (9pm on weekdays, 10pm on weekends) and huge selection of beers available. Figuring out which beer to drink next from their large list of draft, bottle and reserve brews takes almost as long as drinking the beer. It’s best to go with a group of people who also enjoy good beer so everyone can discuss their selection and the bartender can make better suggestions. Having access to Beer Advocate also helps if you want to have a better idea for each style and source.

I started off with Brasserie De Brunehaut’s St Martin Brune and really enjoyed it. Malty, dark, moderately rich, easily drinkable. Good overall beer.

The next beer was Brouwerij Verhaeghe’s Duchesse De Bourgogne which was amazing. I’ve never tasted a beer with such strong fruit (cherry) flavor and enjoyed it. It is sweet but it was amazingly delicious.

I asked the bartender for something a little less fruity but still in the same style as the Duchesse De Bourgogne and got the Rodenbach Classic Red next. It was a nice departure from the Bourgogne but still very tasty. Very drinkable, great flavor and interesting color.

By now I was feeling quite good and wasn’t carefully reading the menu. A coworker got the Fantôme Dark White which everyone really liked so I went for the Fantôme de Noel without reading the size of the bottle or the abv (10%) . It took me a while to drink it but I enjoyed every sip. I’ve written “Fucking Amazing” on the beer menu I brought home.

A few beers friends had that were throughly enjoyed:

  • Nøgne Ø - Det Kompromissløse Bryggeri - Dark Horizon
  • Brasserie Grain d’ Orge - Belzebuth
  • Mikkeller - Mt. Hood
  • Young’s Double Chocolate Stout
  • Tripel Karmeliet

Their beer menu should not distract you from their amazing sandwiches, fries and burgers. The sandwiches have some of the best Pastrami I’ve had which makes for impressively delicious Reuben. The servings are big enough to keep you going through a few beers which explains part of the seemingly high prices. If you’re looking to save a bit of money, their fries are a sizable appetizer and are flavorful enough to easily be a meal.

It was a great night, I think I even hugged the bartender on the way out.

migueldeicaza

Premature extensibility is like premature optimization: most likely, it will go unused, but you will pay for maintaining it.

https://twitter.com/spolsky/status/30725161468563456