Showing posts with label presentations. Show all posts
Showing posts with label presentations. Show all posts

Friday, February 19, 2010

F# examples talk at BFG

Earlier this week I gave a short talk at the Brisbane Functional Group on F#. The idea was to give an introductory feel for the language by way of some simple examples. The talk was intended to be short so I assumed knowledge of previously discussed idioms such as tuples and curried type signatures.

I took the examples (with permission :-) from the environmental sensing project I work on at MQUTeR. This post is intended as a reference for those who attended rather than a self-contained introduction to F#.

  1. The uncurry function was first up.
    let uncurry f (x,y) = f x y
    We talked about the syntax of function definition, tuples and type inference in Visual Studio. We inserted the function into F# Interactive (the REPL available in Visual Studio) by highlighting it and pressing ALT-Enter. The F# Interactive transcript went something like:
    val uncurry : ('a -> 'b -> 'c) -> 'a * 'b -> 'c

    > 1 + 2;;
    val it : int = 3

    > uncurry (+) (1,2);;
    val it : int = 3

    > (+) 1 2;;
    val it : int = 3
    This lead to a discussion on operators and infix/prefix notation. The post F# Option orElse getOrElse functions should cover that.

  2. Next was the |> operator, which has type signature 'a -> ('a -> 'b) -> 'b.
    // Haskell catMaybes
    let catOptions xs = Seq.filter Option.isSome xs |> Seq.map Option.get

    let euclidianDist (x1, y1) (x2, y2) = (x1 - x2) ** 2.0 + (y1 - y2) ** 2.0 |> sqrt

    let spt' t a =
    let m = Math.Matrix.ofArray2D a
    allPeaks t m |> removeSmall |> dilate t m |> Math.Matrix.toArray2D

    // type signatures
    // allPeaks : float -> matrix -> matrix
    // removeSmall : matrix -> matrix
    // dilate : float -> matrix -> matrix -> matrix
    // spt' : float -> float [,] -> float [,]
    We briefly compared |> with the Haskell $ function, which has the type signature (a -> b) -> a -> b.

  3. A quick look at type annotations, pattern matching and Haskell like guards. The example is an implementation of the MATLAB smooth function, which calculates a moving average. We didn't dwell on the entire function, just the relevant parts.
    (* 
    yy = smooth(y,span) sets the span of the moving average to span. span must be odd.

    If span = 5 then the first few elements of yy are given by:
    yy(1) = y(1)
    yy(2) = (y(1) + y(2) + y(3))/3
    yy(3) = (y(1) + y(2) + y(3) + y(4) + y(5))/5
    yy(4) = (y(2) + y(3) + y(4) + y(5) + y(6))/5
    ...
    *)
    let smooth s (a:float []) =
    let n = (s - 1) / 2
    let f i _ =
    let (b, l) = match i with
    | _ when i < n -> (0, i*2+1)
    | _ when i + n < a.GetLength(0) -> (i-n, s)
    | _ -> (i-(a.GetLength(0)-1-i), (a.GetLength(0)-1-i)*2+1)
    Array.sum (Array.sub a b l) / (float l) // TODO try Array.average here
    Array.mapi f a

  4. Records are a common kind of data type. The labels are not automatically available as functions like they are in Haskell.
    type 'a Rectangle = {Left:'a; Top:'a; Right:'a; Bottom:'a; Width:'a; Height:'a;}

    let inline cornersToRect l r t b = {Left=l; Top=t; Right=r; Bottom=b; Width=r-l; Height=t-b;}
    let inline lengthsToRect l t w h = {Left=l; Top=t; Right=l+w-1; Bottom=t+h-1; Width=w; Height=h;}
    let fcornersToRect (l:float) r t b = cornersToRect l r t b // for C#
    let left r = r.Left
    let right r = r.Right
    let top r = r.Top
    let bottom r = r.Bottom
    let bottomLeft r = (r.Left, r.Bottom)
    let width r = r.Width
    let height r = r.Height
    let inline area r = r.Width * r.Height
    The F# overload-o-phone covers our discussion on arithmetic operators. The inline keyword is mentioned in the comments.

  5. Finally we looked at available API documentation. I find that I generally skim API documentation by first looking at function type signatures. The F# PowerPack is a useful library developed by the F# team and the format of the documentation supports my approach.

    The F# API documentation was previously in this format. It has now been moved to MSDN and the list of function type signatures is not presented for each module, rendering it almost useless.
Along the way there were a few comments about F# being strictly evaluated and having no effect tracking system, no higher-order parametric polymorphism and no type classes.

Thanks to everyone that participated in the discussion and I hope the talk was interesting.

Wednesday, August 19, 2009

Intro to functional programming talk



Last night I spoke at the Brisbane Functional Programming Group. Tried to scribble on the whiteboard a bit to avoid "death by slides". The objective was to help imperative programmers new to FP become familiar with some of the core concepts, so I tried to go at a slow pace. I think it went for about 1 hour 20 minutes.

The first part of the talk covered history and the landscape of popular functional languages. The rest was on functions, partial function application, algebraic data types, pattern matching and tuples. I used Haskell syntax, but the concepts are transferable to other languages such as Scala and F#.

Monday, June 15, 2009

The Science of Computing and the Engineering of Software

In his keynote at QCon London 2009, Tony Hoare attempts to characterise science and engineering as two ends of a continuum that describes the roles of software people (industry and academia) and their relationships with one another.

The comments about engineers general dislike of mathematics are consistent with my observations. As someone who is currently studying maths, I wonder how much of that is due to the way it is taught at University?

His humble and pleasant responses to the questions at the end is wonderful. I observe a genuine search for truth and clarity with disciplined thought, that is often lacking in much software discussion.

Video and slides here.

Friday, May 15, 2009

JAOO Brisbane 2009

The JAOO 2009 Conference in Brisbane finished on Tuesday.

Day 1
I missed most of the days program, although I did get to hear Clemens Szyperski talk about MEF and Oslo at QUT in the afternoon.

Jonas S Karlsson
from Google talked about Consistency, Storage, and Reliability in the Cloud. He was involved in the Google Megastore project which provides a scalable (in Google terms) storage layer with SQL style schema and secondary indices and consistency. I believe he made a comment about the importance of the dollar cost per user (of a hosted app) to be a single digit, especially when the app is available free of charge.

Mike Cannon-Brookes
finished the day off with lessons learned at Atlassian.

Caught up with various people at drinks afterwards and went out to dinner with some of the presenters at SouthBank.

Day 2

Joshua Block gave the keynote on various technicalities in Java. It is not often that someone mentions covariance and contravariance in a Java talk! Seems to come up more in Scala discussions and then people are scared off by the terminology. :-) While probably not the intent, I think the talk was great in that it clearly demonstrated some of the complexity of Java.

Douglous Crockford
, Writing Large Applications in JavaScript. Interesting talk, although I think it was a mistake for him to use Java as an example of strong, static typing in his argument for the benefits of loose typing in JavaScript.

Mahout by Jeff Eastman. This was given on a few hours notice to fill in for someone who was sick. I have done stuff with Hadoop before and am developing an interest in machine learning, so I found this talk interesting. There was someone in the audience who was a little confused though, as he thought Jeff meant java.util.Vector whenever he used the term vector. :-)

Unfortunately Joe Duffy was sick, so his talk on parallel programming was canceled.

The last talk I went to was Joel Pobar on F#. It was great to hear from a local who knows some stuff about functional programming (FP). He was suffering from a cold, but sill powered through some interesting algorithms. I don't think he helped the mainstream perception that FP is really technical (given that many are scared by this) when he mentioned vector spaces. :-) We talked to Joel afterwards about the Brisbane FP group starting up and he was really excited, so it will be fantastic to have him involved.

Tuesday, May 12, 2009

QOTD

Regarding JavaScript:

Given the process we use to create web standards we deserve something much worse.
Douglas Crockford at JAOO Brisbane.

Friday, January 23, 2009

Agile Development Methodologies - Reality vs Hype

Just tidying up. This is an old presentation I gave at the QUT FIT Dean's Industry Working Breakfast.


The circulated abstract for the morning was:
Over the past decade agile development methodologies have become an increasingly common approach to software development. While there are a number of different agile methods, the various agile approaches are underpinned by the capacity to embrace and promote evolutionary change throughout the entire life-cycle of the project. Common characteristics of agile methods also include the frequent delivery of software, close interaction between clients and developers, and the expectation that requirements will not only change but that all requirements may not be known at the outset of a project.

Mr Richard Thomas will highlight research currently being undertaken at QUT’s Faculty of Information Technology including the findings of a recent study exploring how organisations, particularly SMEs, go about adopting software engineering methodologies. Richard’s presentation will briefly outline development of an Agile methodology called RSWP which is aimed at supporting inexperienced developers. He will also discuss how research indicates Agile methodologies will impact on the commercial world of tomorrow.

Focusing on the business perspective Mr Brad Clow will draw on the experience of Workingmouse in delivering commercial projects based on Agile Development Methodologies. His presentation will include not only the advantages of the approach, but issues which need to be addressed in order to successfully establish such an initiative, concerns of business projects moving to an agile approach and some of the pitfalls to avoid.

Tuesday, August 19, 2008

Introduction To Scala Training Course

Workingmouse is running an Introduction To Scala training course from Tuesday 2nd September to Thursday 4th September. The course will be run in an interactive, "hands-on" format, with a small number of people, ideally between 4 and 8.

The course covers topics including:

  • Scala syntax

  • A brief introduction to the essence of Functional Programming

  • Algebraic Data Types and Pattern Matching

  • Closures and Higher-Order Functions

  • Integration with Java

  • Intermediate Functional Programming topics (if time permits)

Tuesday, August 5, 2008

Presentation: Paul Cormier from Red Hat at QUT

Yesterday, Paul Cormier, Executive Vice President and President, Products and Technologies, Red Hat gave a talk titled "Red Hat and the Open Source Software Business: from boxed software to a half billion dollar server company" at QUT.

Paul made two points that stand out in my mind:

  1. The primary differentiator of an open source project software project (compared to closed source) is in the ability to build a community of people around the project.

  2. He sees Red Hat as taking open source work and packaging it in a way that is palatable from an enterprise perspective. Specifically, providing stability and backward compatibility for a 'long-enough' period of time.
If I consider Scala in this light, it is currently doing well on the first point, but not so well on the second. Given that the primary users of Java are enterprises, this is important if mainstream penetration is an objective.

Having said that, I think there is a time when the cost of backwards compatibility outweighs the benefits and my threshold seems to be a fair bit lower than that of the average enterprise. In this case, I think enterprises would do well to step back and consider the real costs in doing a software project in Java (or Ruby/Groovy for that matter) and seriously consider the potential benefits from more advanced programming languages.

Sunday, June 1, 2008

JAOO Brisbane, Day 2

A highlight of JAAO Brisbane Day 2 was standing around talking with Erik Meijer, Don Syme, Joe Albahari and some Workingmouse guys. The conversation comparing Java with C# and the JVM with the CLR was a bit of fun. Catching up with Dave Thomas was also good.

The program I followed for the day was:

Keynote: Clean Code, Robert C. Martin
The audience generally seemed to enjoy this presentation. I found the main points to lack justification (no the jury is not in on TDD) and the attempted emotional guilt trip by associating the points with professionalism unhelpful.

Building RESTful Services with Erlang and Yaws, Steve Vinoski
Steve talked about Erlang briefly and little more about Yaws. Most of the talk was about REST.

GData, Google, the Cloud, and You, Gregor Hohpe
Two interesting demos. Firstly the Google Mashup Editor and then the Google App Engine.

Language Orientated Programming with F#, Don Syme
There weren't many people in this session, which turned out to be great because Don made it more informal. Most of the session was centered around using F# for parallel and asynchronous tasks. The implementation is done using Monads (but don't tell anyone :-)). Don happily answered questions from people new to functional programming and others comparing with Haskell. He knows his stuff.

Multi-language Programming, Steve Vinoski
I wasn't in much of this session, but while I was there Steve talked about the Blub Paradox, languages suited for XML processing (Scala got a mention) and Concurrency. The problem of shared mutable state got raised again (amazing how often it pops up) and then Steve talked about Erlang using similar material to his previous session.

Overall, I enjoyed the conference and am very appreciative that Dave, Trifork, the speakers and everyone else involved brought JAOO to Brisbane.

Friday, May 30, 2008

JAOO Brisbane 2008, Day 1

The first Brisbane JAOO finished yesterday. This is the program I attended on Day 1 and some high-level thoughts.

Keynote: Why Functional Programming (Still) Matters, Erik Meijer
Erik argued that it will be critical to reduce side-effects (mutating state, IO, etc) and make the remaining explicit in our programming languages in order to succeed in a software world that has increasingly larger programs, is more connected, concurrent and asynchronous. IMHO this was the most valuable talk of the conference as most developers I meet don't consciously realise the impact of side-effects, as they are so used to them.

Designing for Scalability, Patrick Linskey
Given Erik's talk, it was interesting to observe that dealing with mutable shared state was an underlying theme.

Interaction Techniques Using the Wii Remote, Johnny Chung Lee
This was a fun talk to attend. The interactive whiteboard aspects of Johnny's work look very cool.

Enterprise Patterns, Martin Fowler
I went to this session primarily because I hadn't heard Martin speak before. He is a very strong and confident presenter. So much so, it was like an emotional steamroller. Trying to compel the audience by force of genuine belief, some anecdotal evidence or observations, but with little supporting rational was disappointing. To be fair, I could have given part of this talk about 3 years ago (perhaps not as eloquently) and would have used the same methods.

Introduction to F#, Don Syme
The material Don had to talk about was interesting, although I found it hard to get a feel for the language itself with the one large demo. I think it might have been a bit easier with a series of small demos that illustrate specific points. However, a colleague of mine remarked that it was a pleasant change to see a functional programming talk that didn't involve the fibonacci sequence.

Introduction to Real-time Programming on the Java Platform, David Holmes
I have never done anything close to real-time programming, so I went to this session to learn a bit about it. David really knows his stuff, so some of the content was lost on me. I did learn what priority inversion meant and how it affected the Mars Pathfinder mission.

Languages Panel, Don Syme, Joel Pobar, Wayne Kelly, David Holmes
Four australians, nice.

Keynote: Simplicity in Design, Erik Dornenburg & Martin Fowler
By this time, I was pretty tired. This session started out with a similar style to the Enterprise Patterns talk, so I ducked out early for a bit of a rest before the social event.

Social Event
Dinner was at the Belgian Beer Cafe Brussels. Met some more people and had some interesting discussions which was great.