## Posts

Showing posts from June, 2007

### links for 2007-06-27

Binary marble adding machine
A six bit adding machine, storing state with marbles.
(tags: video)

### links for 2007-06-26

TrimJunction
A javascript clone of Ruby on Rails.
(tags: rubyonrailsjavascript)

### Performance with Scala Arrays and Lists

As I continue to tinker with Scala, I was wondering about the performance differences between an Array and List. This post will detail what I've found, but as always YMMV and I could be doing it all wrong. If there's a better (in this case, better == faster) way to do this in Scala, please let me know.

My application performs a lot of collection iteration as it combines the values of two collections into a new collection by addition. For instance, I need to combine [1,2] and [3,4] into [4,6]. I wanted to find out if the collections should be an Array or List.

Intuition tells me that the Array will perform better, but this is Scala, and Lists reign supreme. So we'll go head to head.

For each test, I wanted to write a function that combined the two collections using tail recursion.

Test One - Two Lists Into a Third

First up, I am adding two lists together while forming a third. One problem here is, due to the way the algorithm is structured, the resulting list is built back…

### links for 2007-06-22

The Sarcastic Gamer: Twisted Trailers: MS Surface
Why interact with real humans when you can order your food via a big ass table. Take that, Apple.
(tags: humorvideo)

### Converting Array to List in Scala

Now, this has to have a built-in somewhere in Scala, because it just seems too common. So, how to convert an Array to a List in Scala?

Why do I need this? I needed to drop to Java for some functionality, which in this case returns an Array. I wanted to get that Array into a List to practice my functional programming skillz.

**Update**: I figured out how to convert Arrays to Lists the Scala way. Turns out it's a piece of cake.

val myList = List.fromArray(Array("one", "two", "three"))

or

val myList = Array("one","two","three").elements.toList

The call to elements returns an Iterator, and from there you can convert to a List via toList. Nice.

Because my first version wasn't actually tail recursive, what follows is a true tail recursive solution, if I were to implement this by hand. The above, built in mechanism is much better, though.

object ArrayUtil {
def toList[a](array: Array[a]): List[a] = {
def convert(ar…

### That’s a Lot of Actors

As I continue to explore Scala, I wondered just how many (react based) actors I could create in a single JVM. The answer, apparently, is a lot.

Before I canceled it, the count was up to 13,500,000 actors. This is on an old Centrino laptop running the Sun 1.6 JVM. I did have to turn up the memory limit a bit, but I never saw memory go above 20MB. Also, I wasn't doing anything inside the Actors.

Still, that's enough for me to not have to worry about it.

Scala: It's as if Java and Erlang had a baby. Fun stuff.

### links for 2007-06-20

Mapping Between Java and Scala
A helpful mapping between Java and Scala syntax and idioms.
(tags: javascala)

First Steps to Scala
In this article, you'll follow twelve steps that are designed to help you understand and gain some basic skills in the Scala programming language.
(tags: scala)

### links for 2007-06-19

Chinese Room Argument [Internet Encyclopedia of Philosophy]
In which a thought experiment attempts to discredit A.I.

### RESTifying a Real World J2EE Application

RESTify DayTrader, in which Joe Gregorio converts a real world J2EE application's interface into a REST interface.

Perfect example of how to do REST with real life requirements.

### links for 2007-06-14

Sigma 10-20mm Wide Angle Lens
Wide angle lens, recently recommended.
(tags: photography)

### A brief history of Consensus, 2PC and Transaction Commit.

A brief history of Consensus, 2PC and Transaction Commit, in which Mark Mc Keown attempts to keep us all in sync with the history of consensus across processes in a distributed system.

Excellent read. Thanks Mark!

### links for 2007-06-13

Some more Rails to lift code examples
Converting a Rails application to a Scala on lift application.
(tags: scalarubyonrails)

Super Mario Bros: Frustration
A hilarious soundtrack to the hardest levels of Super Mario Brothers. Warning, not for virgin ears.
(tags: humorvideo)

### links for 2007-06-07

The Best MySpace Page
Words to live by.
(tags: myspace)

### links for 2007-06-02

Google Developer Day Videos
93 videos from Google Developer Day.
(tags: googlevideo)

### Interview and Book Excerpt from RESTful Web Services

InfoQ has an Interview and Book Excerpt from the book RESTful Web Services, the new book published by O'Reilly. I've ordered my copy from Amazon already, and I'm looking forward to reading it.

The interview also links to a sample chapter from the book, titled The Resource Oriented Architecture.

A great quote from the interview, by Sam Ruby:

I also wanted a book that rose above the “we are 733T, WS are the Sux0rs” zealotry that, sadly, one too often hears.

Congrats to Leonard and Sam on their book!