Archive for the ‘Scala’ Category

Western Mass. Developer’s Group and Snowtide Host Rich Hickey and Clojure

Friday, March 21st, 2008

Last night, we had the privilege to host a talk by Rich Hickey on concurrency in Clojure at our offices in Northampton.  A good portion of the Western Mass. Developer’s Group showed up for the event.  Many thanks to Lou Franco for coordinating things, and Shawn Fumo for arranging to have Rich’s talk taped for posterity (a link will be coming soon, I would think).

And, of course, thanks go to Rich who took the time to make the drive up to Northampton from New York City.  (Fanciful thought: does this mean that the developer’s group constitutes a programmer’s oasis?  Is Western Mass. the new center of gravity for innovative software development in New England? *wink*)

Lou’s notes on the talk itself capture its content far better than I’ll dare to attempt at this point.  Suffice it to say that it was a great presentation by Rich, who clearly has a penchant for teasing apart complex topics and evangelizing Clojure very effectively.  Luckily for the rest of us, there are a number of other talks about Clojure by Rich floating around in the ether.

It should come as no surprise to anyone who knows me at all that I love what Clojure has come to be.  I followed Rich’s prior attempts to marry Lisp and Java (specifically, Foil and jFli), but Clojure tops those efforts handily on essentially every front.

But, what of my fervent love of Scala, so earnestly professed in this very space?  Clearly, I’m not particularly monogamous when it comes to programming languages.  Clojure and Scala have a lot in common, but they are very, very different from each other — although they share the common traits of (a) being better than “straight” Java in so many ways, and (b) enabling functional programming on the JVM (and of course, .NET via ikvm).  You can love both; maybe it’s a right-brain, left-brain thing.  (I can clearly imagine Professor Stillings scowling at me for that one.)

Anyway, again, a big ‘thank you’ to Rich Hickey and everyone else who made last night possible.

…recommended by 4 out of 5 surveyed seasoned programmers…

Tuesday, November 6th, 2007

In a thread on the Google Group dedicated to discussing languages hosted on the JVM (i.e. Scala, Groovy, JRuby, et al.), it was asked by a fellow named Jon Harrop whether something like F# (an OCaml / Standard ML derivative that targets the .NET CLR) would find any traction if it were made available for the JVM. Well, some unremarkable discussion ensued about the costs associated with developing languages, how existing efforts attract funding, etc., and then things turned towards the question of “Why not just use Scala?”, since Scala does fold in a lot of functional programming primitives.

Mr. Harrop’s replies centered on various aspects of ML-style languages that he misses in Scala, and aspects of Scala that he finds irritating. All fine and good — hey, everyone has their own preferences — until he unveiled this nugget (emphasis mine):

OCaml and F# have shown that ML’s approach to structured programming using modules, variant types and pattern matching and extensive type inference is almost always preferable to OOP. When given the choice between OOP and FP, seasoned programmers rarely choose OOP.

Zealotry isn’t anything new — you can probably find inverse statements right now in some Smalltalk newsgroups, or someone agitating about the uniform superiority of s-expressions in a Lisp or Scheme forum. The odd thing about this is that Mr. Harrop is not exactly a random troll — he seems fairly well-respected in the F#/OCaml/ML community, is a prolific writer, and looks to be writing a book on F# for Microsoft Press.

Stuff like this makes the whole facade about software development being akin to engineering even more farcical than one might initially imagine. Can we please recognize that there is a difference between spirited advocacy and demagoguery? I’ve certainly been guilty of the latter on occasion (usually much to my later regret), but it’s particularly irksome to find those that are apparently unaware of the distinction at all.

WMassDevs Meeting Notes (2007.11.01)

Friday, November 2nd, 2007

Paul and Miles have been keeping notes at recent meetings of the Western Mass. Developer’s Group lately so as to keep those who can’t make it some weeks in the loop. However, neither of them could make it last night, so I thought I’d take a whack at providing a bullet-point précis.

Now, keep in mind that this is my first foray into anything resembling journalism hackery.

  • A couple of new faces showed up, including (dear god, I hope I’m getting the names right) Jason from Studio4Technologies, who mostly works with C#, Dan, who lives in Avon, CT, has a day job using C#, but is working through SICP on his own and is interested in all manner of functional programming languages, and Michael (Eger, not McIntosh), who is a jack-of-all-trades consultant.
  • Gerard and Lou had already installed Mac OS X 10.5, and sang its praises (for the most part). Highlights include Spaces (a “killer” implementation of virtual desktops), the Exposé/Safari select-and-clip widget maker (very cool feature, although no one can think of a good practical use of the tech), and the salvation that is having the Dock on the side of the screen so as to avoid the absurdities associated with how it’s rendered at the bottom of the screen.
  • Lou’s going to a tech convention in Las Vegas next week (thereby missing election day!); it turns out that the whole gang from Atalasoft is going to be sporting snazzy pixelated ties on the convention floor. Very cool, but clip-ons?
  • Logo design is always about whatever the guys in the design shop happen to be messing around with in Illustrator the day your order hits their desk. Thus, the cyclic obsession with graceful swoops, cubist abstract styles, and flaming butterflies.
  • Gerard took a look at Scala since our last meeting, and found much to his liking. “If I were using Java, I’d definitely be coding in Scala,” said Gerard, in yet another example of how Sun made everything more complicated for everybody by conflating the JVM and the Java programming language for years. Here’s hoping IntelliJ gets moving on some first-class Scala support.
  • Dan’s been using Scheme to go through SICP and the Little Schemer (an obvious choice since that’s the language used in those materials), but he’s somewhat overwhelmed by the number of functional programming languages that are available — how can one choose what to use? My response was that they’re all functionally the same (ba-dum-crash!) in terms of the primitives they provide. Which FP language to use in any particular situation generally comes down to the details of one’s deployment and runtime requirements at the time. For example, I’m using Scala right now because it interoperates smoothly with Java and .NET, making it easy to work with PDFTextStream’s existing codebase.
  • Michael asked what functional programming is, exactly. From there, I somehow found myself holding forth on definitions of functional programming, why minimizing state is Good™, what continuations are and why they’re handy, and the differences between global continuations and delimited continuations. I’m sure most people were groaning. Lou mentioned Common Lisp’s exception handling (better known in that world as conditions and restarts) as an instance of delimited continuations.
  • Jason mentioned that there seems to be some noticeable growth in the number of startups in the area, his Studio4 Technologies being one of them. Maybe it’s time for the group to start tracking how much work is coming into the area, how many new businesses have opened and where, etc.
  • Greg pulled out his new Thinkpad, running Linux (though I can’t remember the distro).
  • Using OS X Mail to access GMail via IMAP is apparently still a no-go, given Mail’s lack of tag support. Thunderbird was thrown out there as a possible alternative, but some had doubts that GMail’s tags would be properly represented via IMAP.
  • The state of social networks is totally out of control — there are too many profiles to manage on too many sites. Some fun was had at the expense of those that are “professional networkers” — those people that have thousands and thousands of LinkedIn connections, etc.
  • Michael polled the group for thoughts on XSLT, at which point a wave of grunts was heard ’round the table. Just about everyone panned XSLT as being handy, but inevitably too complex without the right tools. XSLT 2.0 doesn’t exactly make progress on this front. As an aside, I noted that XSLT also happens to be a functional language (perhaps the most widely used FP in industry these days, I’ll wager). [As an aside, Dan's first message to the list arrived with the title "XSLT is like Lisp, but with a punch in the face."]
  • Generics were briefly discussed, including some comparison of how they’re implemented in the JVM (erasure) and the CLR (not-erasure, although no one knew the details there).
  • ikvm was mentioned as a practical and totally usable way to cross-compile Java libraries for use in .NET environments. [We happen to use it in order to provide PDFTextStream.NET.]
  • For those new to the group, the mailing list was mentioned, as well as our usual IRC channel (#wmassdevs on Freenode), which is unfortunately pretty sparse these days!
  • A pretty lively exchange was had on the topic of Borders vs Barnes and Noble, especially as it relates to the availability of technology tomes. The B&N in Hadley is tremendously mediocre, and the one in Holyoke isn’t a whole lot better. The general consensus was that Borders generally has a better tech book section than B&N, so there’s reason to hope that the significant presence that Borders looks to be building in the Holyoke Mall will make things a lot easier when one of us just absolutely has to have a particular tech book today. There was also talk of the partnership between Borders and Amazon, which apparently yields various benefits.

That’s all that I can recall. I really should have had a notepad with me, I suppose. If anyone has anything else they want to add, feel free to drop it in the comments.

Scala Makes Me Think

Wednesday, October 31st, 2007

(…or, “Oh, Dear, Wasn’t I Thinking Before?”)

As my friends will attest, I really enjoy programming languages. I’m one of those language fetishists that talk about “expressiveness” and “concision”, and yes, I’m one of those very strange fellows who blurt out bad Lisp jokes while getting odd looks from innocent bystanders. And while my bread and butter is built in Java, I often find myself yearning for a more expressive language while deploying, customizing, or integrating PDFTextStream (there I go again with the “expressiveness” bit). That yearning can reach almost pathological extremes at times, prompting me to go so far as to sponsor projects that make it possible to use Java libraries (including PDFTextStream) from within Python.

Fortunately, things don’t always have to be so hard. Case in point, I recently dove head-first into Scala, a language that combines object orientation and functional programming into one very tasty stew. Scala has a number of characteristics that make it interesting aside from its merging of OO and FP mechanisms:

  • it is statically-typed, and provides moderately good type inference that enables one to skip most type declarations and annotations
  • it is compiled, which provides a minimum level of performance (sure, it’s actually byte-compiled, but let’s not quibble right now)
  • and the real kicker: it compiles down to Java class files (or .NET IL), thereby enabling it to be hosted on a JVM (or .NET’s CLR), and call (and be called by) other Java (or .NET) libraries

There’s a lot to like here, for programmers from many walks of life, and I could go on and on about how Scala has single-handedly created and filled a great niche of delivering most of the raw power of purely functional languages like Haskell and ML within a JVM-hosted environment with respectable performance. But what has really impressed me has been the way that Scala has improved how I work. In short, it’s made really think about development again.

I generally have two working styles. In a classic statically-typed environment (say, Java or C#), I tend to generate pretty clean designs, but my level of productivity is very low. I attribute both of these characteristics to the copious amount of actual work (i.e. finger-typing) that has to go into writing Java or C# code, even with the best of tools. See, while I’m typing (and typing, and typing), I’m thinking two, three, four steps ahead, figuring out the design of the next chunk of code. The verbosity of the language gives me time to reason about the next step while my fingers are working off the previous results.

In a dynamically-typed environment (say, Python or Scheme), I tend to be extraordinarily productive, but unless I consciously step back and purposefully engage in design, the code I write is much more complex. In such environments, there’s less finger-typing going on, so I don’t have a natural backlog allowing me to think about the code before it’s already on the screen. Further, I know I can get from point A to point B relatively easily in many circumstances, so I end up skipping the design step, switching into Cowboy Coder mode, and hacking at things until everything works. Oddly enough, in certain circles, this isn’t so much frowned upon as it is recommended.

Scala is statically-typed, so the naive observer might speculate that my working style in Scala would be much the same as in Java. However, I’ve found that working with Scala has prompted (forced?) me to consciously step back and think about everything, at every step along the way: class hierarchies, type relationships in general, testing strategies, eliminating state where possible…the amount of actual thinking I’ve done while working with Scala has far outstripped the amount of reasoning that typically goes into any similar period of coding. Unsurprisingly, this has led to quite the spike in code quality, which translates into productivity through fewer bugs and less rework.

I attribute this to the strong, static typing that Scala enforces, combined with the type inference that Scala provides. The former forces me to reason about what I’m doing (as it does in Java, for instance), but because the latter eliminates so much of the finger-typing associated with static typing in other environments, I’m given the opportunity to realize that a concrete design phase would yield tremendous benefits, regardless of the scope of code in question. I suspect I would find working in Haskell or ML to be a similar experience, but because those languages don’t easily interoperate with the libraries I need to do my work, I’ve never really given them a chance.

Thankfully, I don’t think I’ll have to. Scala is a great environment, and even more important than its technical merits, its design has led me to engage in a more thoughtful, more conscious development process.