An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Entries Tagged as scala

The Strange Loop 2013

September 21, 2013 · 5 Comments

I'm providing a brief summary here of what sessions I attended, followed by some general commentary about the event. As I said last time, if you can only attend one conference a year, this should be the one.

[Read more →]

5 CommentsTags: architecture · clojure · programming · scala

Learn You a What for Great Good - cf.Objective() 2013 - Slides and Code online

May 16, 2013 · No Comments

The slides and code for my first presentation at cf.Objective() 2013 are now online - Polyglot Lessons to Improve Your CFML:

The other presentations will be posted after I've given them and the code will appear in that Github repository.

No CommentsTags: cfobjective · clojure · coldfusion · groovy · javascript · programming · scala

My cf.Objective() 2013 Presentations

May 12, 2013 · 1 Comment

Other than noting back in January that all three(!) of my talk proposals were accepted, I haven't blogged about them since, so the only information about them is on the cf.Objective() web site. The session overviews give a fair sense of what you should get out of each presentation and roughly what they'll cover.

[Read more →]

1 CommentTags: cfobjective · clojure · coldfusion · groovy · javascript · mongodb · scala

Polyglot projects?

June 23, 2011 · 7 Comments

In the LinkedIn ColdFusion Groups I recently asked the following question:

For the last three or four years, my CFML projects have general had other languages mixed in on the backend (Groovy, Scala, Clojure). I was wondering how many other people are leveraging the Java/JVM interoperability in CFML to take advantage of other languages?

What sorts of things have you done and why?

And if not, why not?

Several folks replied that they either didn't use other languages with CFML or they use a bit of Java. Several people also asked me to explain why I chose those other languages and how I integrated them with CFML. I replied to the group at some length but today on Twitter Aaron Greenlee asked me the same question and encouraged me to blog it for everyone to read. So, here it is...

[Read more →]

7 CommentsTags: clojure · coldfusion · groovy · scala

Scala Days 2011 - Fascinating but...

June 04, 2011 · 4 Comments

It's been a long time since I've been to a conference where serious research papers were presented. Pretty much every conference I've been to in the last 10-15 years has focused on practical use cases even for very bleeding edge topics. Scala Days had a mixture of practical and research but, at least based on the talks I chose, seemed very heavy on research - in several talks I felt like I was back at university in my final year computer science classes. It was all very interesting and thought-provoking / stimulating but I didn't come away fired up with new ideas I could apply at work. I did come away with a list of research papers to read tho'...

[Read more →]

4 CommentsTags: scala

Just For Kicks - Scala and Clojure

November 10, 2010 · 3 Comments

Jack Widman posted a Scala snippet on Twitter today to calculate the sum of squares up to a given number:

def sumSquares(n:Int) =
    (0 /: List.range(1,n+1).map((i:Int)=>i*i)) (_ + _)

(I renamed the parameter of the anonymous function argument to map just to make it clear it's different to the parameter of sumSquares itself)

I responded with a version of it in Clojure for comparison:

(defn sum-squares [n]
    (reduce + (map #(* % %) (range 1 (inc n)))))

They're very similar: they both reduce (using +) over map (using * to square items) over a range of numbers from 1 to n+1 (inclusive at the bottom, exclusive at the top). Note that reduce is called /: in Scala and the function argument comes afterward.

To be a true apples-to-apples comparison, the Clojure version should be typed, i.e., the parameter n should be declared to be an integer:

(defn sum-squares [^Long n] ... )

That makes quite a difference to the performance.

CFML doesn't have collections so it's not easy to produce an equivalent version without writing all of the primitives (reduce, map, range) from scratch and even then it would only be easy to write for arrays - and it wouldn't be very efficient since ColdFusion copies arrays on assignment (Railo treats arrays as reference types for efficiency reasons).

Of course, most CFers would just write sumSquares in a straightforward procedural manner like this:

function sumSquares(n) {
    var total = 0;
    for ( var i = 1; i <= n; ++i ) {
        total += i * i;
    }
    return total;
}

This is radically different of course since it conflates reduce and map (in the body of the loop) and range has become a for-loop. This is why I tell people it's so valuable to learn other languages: they help you think about problems in a different way and you can become a better programmer because of that. It's why I recently bought Seven Languages in Seven Weeks by Bruce Tate. Of the seven languages, I know three fairly well (Clojure, Prolog and Scala) although it's been years since I did anything significant with Prolog. I've dabbled with Haskell and I had a brief look at Ruby a few years ago. I'm a couple of days into the Ruby week and it's challenging in a good way. Tate deliberately doesn't provide any hand-holding for installation or "getting started" basics (and he explains why in the book) so even the relatively simple real-world exercises require a bit of work and some reading up on your own. Definitely a good way to force you to learn. I'm looking forward to revisiting Prolog and going deeper into Haskell as well as getting started properly with Erlang, Io and Ruby!

Put the book on your Christmas list!

3 CommentsTags: clojure · coldfusion · scala

Learning Scala (with Joel Abrahamsson)

August 19, 2010 · No Comments

For folks interested in a gentle learning curve for Scala, Joel Abrahamsson is a .NET developer who has decided to learn Scala - much as I recommend every CFer learn other languages: to bring back new lessons to use in your favorite language. This blog post is part four in his series but it's the first part that shows real code and compares it to Java/C#. Each post has a link to the first of the series (covering installation) which has links to all the other parts. Each post also has a link to the next part (once it's available).

Having gone through this learning curve myself over the last year, I can highly recommend Joel's series of blog posts for easing you into Scala.

No CommentsTags: programming · scala

Why I Love Programming (Part 94)

August 16, 2010 · 1 Comment

As I often tell people, the reason I love programming is because we (sometimes) get to solve hard problems.

I've blogged about my love affair with Scala as part of my "Learn a new language every year" commitment and I will admit that it's a more challenging language than, say, Java but that's part of its charm: it makes you think! I'm a bit advocate of learning new languages that make you think differently because you can bring that back to your 'favorite' language and it'll make you a better programmer. In the past, I've advocated APL, Prolog, Haskell because they're all very different to what you're used to. So, Scala brings some new challenges because it's a mixture of Object-Oriented and Functional Programming and it has an extremely strong type system. I love the Scala mailing list because it has some really interesting (and challenging) threads that make my brain work harder than usual.

A few days ago, someone complained on the mailing list that one of Scala's library types was "unsafe" because of one of its methods. What followed was a fascinating discussion about types, consistency and Turing completeness (which is kinda fundamental to all our programming efforts - or at least our debugging efforts :)

As the thread unfolded, one of my favorite list members, Tony Morris, explained why the method had to exist (OK, that's a simplification) and backed it up with a detailed analysis. I've read through the thread several times and I've also read a blog post from Tony several times and it's very instructive. Instructive enough that I feel the need to share it.

Here's the entire thread on the mailing list. Pay particular attention to Tony Morris's posts. Here's Tony's blog post about the proof behind his contribution to the thread on the mailing list.

I hope you find some nugget of interest in this and that it may interest you enough to learn more outside your comfort zone - that's why I do Scala!

1 CommentTags: programming · scala

Why I Like Scala

June 10, 2010 · 11 Comments

CFML and Java go very well together but I've been using CFML and Scala together for quite a while now. Find out why I like Scala so much!

[Read more →]

11 CommentsTags: coldfusion · oss · scala