November 2011
1 post
2 tags
Idea: Validation + Adapters for Terminal Programs...
Derive a common utility or library for options and constraints from something like scopt and Unfiltered’s parameter validation library. With a common way to specify input arguments, functions to produce boiler plate for command like programs and web endpoints would be easy to write. This would be a great use for scalaz / validation.
August 2011
1 post
1 tag
Too much curry!
What does a compiled curried method in Scala look like in java? Compile this:
object Concat {
def concat(s: String)(ss: String) = s + ss
def concat(s: String)(i: Int) = i + s
}
Now inspect the resulting class with javap:
Compiled from "Concat.scala"
public final class Concat extends java.lang.Object{
public static final java.lang.String concat(java.lang.String,...
July 2011
2 posts
There’s always a “best” tool for any job, but if programmers...
– Steve Yegge
3 tags
Moving to New York City
For several years now I’ve felt that, at some point, I’d like to move to New York City. I visited the city for the first time in 2009, and I was just taken. Its history, strength, character, diversity, and cultural wealth captivated me.
Still, there was something else. I had just recently discovered the Scala programming language. I’m a polyglot programmer but I’ve spent...
June 2011
1 post
If anything were actually “immeasurable,” it would bear no...
– Ayn Rand
January 2011
2 posts
Making Meetup: Real-life Meetups Deserve Real-time... →
makingmeetup:
First things first, open a linux or mac terminal and tap into the RSVPs stream: curl http://stream.meetup.com/2/rsvps What you’re seeing now is each RSVP to a public Meetup group as we receive it. When a user clicks an RSVP button or an application calls the RSVP method, the server handling the…
Best. Gift. Ever.
Last night, Erin and I opened presents that had arrived in the mail from my parents. One of them was a folded, unassuming manilla envelope, and inside was another folded manilla envelope. I unfolded the inner envelope to reveal a 5x5 floppy disk which, at first, confounded me. Looking at its label I immediately recognized my mother’s handwriting; it identified the disk as...
September 2010
3 posts
3 tags
Anxiety 2.0
Last weekend I attended the first annual WebDirections USA conference, in Atlanta, GA. My primary takeaway is that JavaScript on the server side will continue to make enormous gains comparable to those made by rails when it first appeared on the scene.
Yeah, that’s huge.
Of all the sessions, NodeJS and the expert panel resonated with me over the rest. The node session was a simple,...
3 tags
By investigating the logical properties of your programming language and finding...
– Tony Hoare
3 tags
If the proof of program correctness requires a very large number of different...
– Tony Hoare
January 2010
1 post
November 2009
1 post
2 tags
A Look at How Scala Compiles to Java
Consider this contrived example, based on an example from Beginning Scala. The point of the snippet was to demonstrate the congruency between using the higher-order functions map, flatMap, foreach, and filter (see Iterable), and performing the same operations inside a for comprehension.
object App {
def isEven(i: Int) = i % 2 == 0
def isOdd(i: Int) = i % 2 == 1
def main(args:...
October 2009
4 posts
2 tags
Lift Off
I arrived at the FGM building by way of my couchsurfing host, Jenny. At the moment, Reston looks a bit like London (at least if you look straight up). Fall has painted the leaves brilliantly, a sight I’m left wanting in Florida.
Jenny graciously dropped me off at the FGM building on her way to school (she’s a school teacher). I gladly accepted arriving an hour early for a free ride,...
2 tags
Functional Content Negotiation in Scala
Today I needed some code to assess if an HTTP request matched certain criteria, based on its declared content type. Essentially, I needed to know if the user-agent wanted XML (or JSON), and that it wanted only that type.
Requirements:
Check the Accept request header for a given content type.
Support a non-standard X-Accept header serving the same purpose as Accept (IE doesn’t let...
2 tags
Great minds discuss ideas; Average minds discuss events; Small minds discuss...
– Eleanor Roosevelt
2 tags
A Solution to the Set Combinations Problem
def combine[T](sets: List[List[T]]): List[List[T]] = sets match {
case List(l1, l2) => l1.flatMap(i1 => l2.map(List(i1, _)))
case head :: tail => combine(tail).flatMap(set => head.map(_ :: set))
case _ => sets
}
September 2009
1 post
3 tags
Recursion with an Arbitrary Number of Lists
{ apple, banana } { milk, cheese, yogurt } { nuts, legumes }
— would result in —
{ apple, milk, nuts } { apple, milk, legumes } { apple, cheese, nuts } { apple, cheese, legumes } { apple, yogurt, nuts } { apple, yogurt, legumes } { banana, milk, nuts } { banana, milk, legumes } { banana, cheese, nuts } { banana, cheese, legumes } { banana, yogurt, nuts } { banana, yogurt, legumes }
August 2009
1 post
4 tags
Dependency Injection Using Language-only...
I’ve been exploring dependency injection in Scala. Digesting this article by Debasish Ghosh, I was inspired to play with the code. At the time of the article’s posting it needed a few pieces to compile. You can find the inferred working source here. As an exploratory exercise, I transposed it to java. Chew on it a bit; it clarified some things for me about both the technique and the...
July 2009
7 posts
Vote for ROSA LOVES! →
2 tags
Super quick start with Lift's ProtoUser
Lift provides a trait called ProtoUser, which helps you in quickly adding base functionality to your application for user-specific data. The Lift book mentions this class very briefly, but it makes the assumption that the reader will be to intuit how to complete the example code to have a base starting point. Here’s what you must have (assuming this is in the model directory):
package...
3 tags
http://groups.google.com/group/the-lift-book/files →
The Lift Book group provides the built source of the full book “The Definitive Guide to Lift.” Grab the full PDF here (master.pdf).
3 tags
Lift Walk-through at Developerworks →
4 tags
Lift Framework API →
June 2009
4 posts
2 tags
Dear Neighbors
I live in St. Augustine Beach. If you live in the low-numbered streets or the early letter streets, chances are we’ve seen each other. I’m writing to tell you that yesterday, Sunday, June 21, my house was broken into and robbed. Our door was locked as it always is when we are gone, but the door was kicked in. Noone was harmed (noone was home), and fortunately no major damage was done...
In many “OO” languages, especially those with dot notation, the...
– Erik Naggum, comp.lang.lisp
2 tags
100+
It’s been a nice weekend. Great time with friends on Friday night, Saturday and Sunday at the in-laws, and lots of hacking relaxing interspersed throughout. This week I’ll be giving an expanded presentation on Scala, which is where most of my hack time has been spent.
Bonus: Erin is playing the piano
http://delicious.com/chris_lewis →
I realized that for a while I was using tumblr in cases where delicious would have better fit. Sooo - here’s my delicious page.
April 2009
2 posts
Wishlist
I’ve created a book a book wishlist at Amazon. If you feel compelled to hook me up, that’d be a good place to look :-)
2 tags
Parleys: The Feel Of Scala →
March 2009
16 posts
2 tags
S-99: Ninety-Nine Scala Problems →
2 tags
Flushing the OSX DNS cache
I need to do this often, but not often enough to remember the bin names.
Tiger: lookupd -flushcache Leopard: dscacheutil -flushcache
2 tags
ERB and JSP and ASP all have the fatal flaw of allowing code in the view.
– Lift framework documentation
3 tags
The Grey Lens Man's View: The Book Of JOSH →
I’ve made several posts about Scala and another reblog about Urbantastic, who’s employing an interesting static-view-dynamic-content mechanism. This link is much about Scala in the enterprise, and that’s exciting. However it’s also about how Java the language is fading, while Java the platform continues to rise. Very interesting, even exciting.
5 tags
Legacy PHP on Quercus: Checklist
Since Friday I’ve been playing with Quercus off and on. Running pieces of my company’s legacy code, playing, integrating and accessing Hibernate in PHP code (pretty sweet), and then actually adding some simple (but sane) Hibernate management (initialization and implementing the Hibernate session-per-request pattern for PHP scripts).
Throughout my work today, I experimented with...
3 tags
Sundays, Numeric Literals
Programming languages generally allow you to deal with numeric values using a literal syntax. In Ruby (irb), for example:
» 5*5 => 25
This is a literal expression of multiplying 5 by 5, resulting in 25. Often, languages also provide a literal syntax for expressing numbers of a different number system. Consider this snippet of Java code that creates three integer primitives, each with a...
2 tags
Dean Wampler and Alex Payne on Scala →
3 tags
Functional Programming for the Object Oriented →
I’ve found a nice series of introductory articles on the Scala programming language, a recent obsession of mine. If, like me, you’ve found some of the documentation on the official site too theoretical, I recommend this article as a good starter. 20% theory, 80% pragmatism.
3 tags
10 is the new 15
I’m on my lunch break and am reading a nice article about software architecture. I smiled (and then tumbl-tweeted) when I read a part that specifically called out method length as a sign of poor design. I’ve come to this conclusion lately and have been fairly vocal about it.
The author steps it up a notch though, asserting that 10 lines should be the maximum of any method in Java (he...
2 tags
My rule of thumb on Java projects says that no methods should ever be longer...
– Evolutionary architecture and emergent design: Test-driven design, Part 1
1 tag
4 reasons your methods might be longer than 15...
You were lazy.
You were rushed to the point of irresponsibility.
You don’t have a clear understanding of the problem you’re trying to solve.
Your chosen language sucks.
Facebook in 2010: no longer a walled garden →
And I was just thinking how flawed FB’s paradigm was. This could change that.
3 tags
RubyJax: March 24, 2009 - Groovy/Grails/Java MVC →
Bring the nerdy.
3 tags
Actors, Mina, and Naggati →
Interesting article on concurrent programming in Scala using some functional voo-doo.
2 tags
A Java Interface to the Bit.ly API
I’ve just pushed some alpha code to a google code project site, implementing a Java interface to the bit.ly URL shortening service API. There’s still a bit to do in the way of negative testing and data access for the /info and /stats calls, but it’s a start. Give it a hack if you’re so inclined: http://code.google.com/p/bitlyj/.
February 2009
22 posts
1 tag
Solar Rechargeable Batteries →
3 tags
My interest is piqued at this notion of a web application whose back-end deals in JSON exclusively when communicating to the front-end. JSON served by the server, processed and rendered on the client. Generated client events, from classic form submissions to exotic componentized elements, transmitting interaction and event data as JSON objects.
I haven’t yet had time enough to steep in...
2 tags
Tech Tuesday: The Fiddly Bits
urbantastic:
In my last post I promised to talk a little about the technology that underlies Urbantastic. It’s not the usual suspects, so it’s worth some explanation.
Warning: Here be severe geekery.
Urbantastic is a typical web 2.0 site in a lot of ways: users posting messages to each other has been done before, certainly. But in the main it’s completely new. The site shares certain aspects...