Archive for December, 2011

XMLisp?

I had a twisted thought about a potential future thought experiment of using XML and Lisp style languages.

Having used Lisp a very little bit back in college for one semester, and read more about it in Structure and Interpretation of Computer Programs, I started looking into Clojure recently. I did a session of CodeRetreat last year in it, and was hearing more about it this year at SCNA so I started to read up on it more and play a little bit with the language.

Tie that in with that I recently was transferred to a new group at work that is doing some SOA (Service Oriented Architecture) work. Something triggered when I thought about the XML payloads being sent between the SOA Web Services and how that tied into what I am reading about Lisp and Clojure.

In other languages we think about serializing command objects into XML and back and send those messages between Services as a message payload. What made me think was that XML is a tree structure as well as the code in a Lisp type language.

What if we did something like Javascript and JSON? What if we convert the Lisp structure to XML and back, and then we can execute this Lisp structure data as Lisp code? With XML we can then also apply transforms and convert one message/command into another message/command, which would allow one message to be sent and transformed into multiple messages to be received by inserting messaging splitters and transformers. This is also not worrying about things like the security of the evaluation of the Lisp data as code since this something to think about as a thought experiment.

I don’t know if this is a novel idea, or if someone else has already tried it, but to me it seems like an interesting thing to think about and mull over.

Advertisements

, , , , ,

3 Comments

Global Day of Code Retreat thought dump

Last Saturday, December the 3rd, was host the Global Day of Code Retreat. There were 90 cities participating with over 2000 developers taking time to practice and hone their skills. I was lucky enough to be a co-organizer for the one in Dallas, and wanted to share my thoughts about what I saw that day. For those unfamiliar with what a Code Retreat is I urge you to go check out the Code Retreat site for more information.

There were a number of things that impressed and surprised me about last weekend. First I was impressed by how many people showed up to the Dallas Code Retreat, we had nearly 40 people show up, and this was with only about a two week notice for the event. To have that many people set aside a day, to come out and practice coding with less than a two week notice was highly impressive. I was also impressed by the diversity of the people that showed up, we had people of all levels show up and participate, as well as a good diversity of people from those who had never pair programmed or heard of TDD to those who pair program or TDD on a daily, or near daily basis.

As one of the co-coordinators, and having has participated in two previously, both after the SNCA Conference the last two years, I only paired in one session. I was more interested in letting everyone else have an opportunity to experience a Code Retreat in the hopes of getting this to be something we can have happen regularly in the Dallas/Fort Worth Metroplex.

As I wasn’t the facilitator, we had Glenn Vanderburg, to whom I offer a hearty thank you to yet again, but as the odd man out I was able to walk around and see what the other pairs were doing. It was interesting to compare what the other pairs were doing compared to some of the approaches me and my pairs had done in the two I have participated in. It was also interesting to see how expressive the code they were writing was depending on the interval of when I swung by.

Though on my one pairing session, which was in Ruby, I noticed something interesting. I am not sure if it was the tests and the order they were written, or if it is some of the elegance/syntactic sugar of Ruby itself that lead to the route taken. And after thinking about it, I am not sure that I like the end result, which I will express after I show what it was.

We were testing an Alive state object and the transition between Alive and Dead. The tests started with zero alive neighbors returning a Dead state object.

def transition(alive_neighbors_count)
  Dead.new
end

The next test we wrote was for one alive neighbor. Which passed as expected.

We then tested for two alive neighbors, and that it should transition to an Alive state.

def transition(alive_neighbors_count)
  return self if number_of_alive_neighbors == 2
  Dead.new
end

The next test was for three alive neighbors, and that the state should transition to an Alive state as well. The code then looked like the following.

def transition(alive_neighbors_count)
  return self if (2..3).include?(alive_neighbors_count)
  Dead.new
end

While the range object and the include? method is expressive compared to an if statement about the number being between 2 and 3, after I thought about it for a while, think it is the wrong type of expressive. We opted for the expressiveness in terms of being in a range instead of the expressiveness of the domain and the actual ruleset. Conway’s Game of Life talks about dying as if due to underpopulation and dying as if due to overpopulation, but nowhere did we wind up expressing this in the code, unlike the following which expresses that domain knowledge.

def transition(alive_neighbors_count)
  return Dead.new if underpopulated?(alive_neighbors_count)
  return Dead.new if overpopulated?(alive_neighbors_count)
  self
end

This is more intended as an example of the following food for thought: Is the expressivity of the language leading you away from coming up with a way of expressing the domain in the language and losing the expressivity of the domain?

, , ,

Leave a comment