Proposal for the meeting on May 11, 2015

32 views
Skip to first unread message

Skottish

unread,
May 9, 2015, 8:42:18 PM5/9/15
to pdx...@googlegroups.com
Hi all,

As discussed a bit at the last meeting, I'd like to propose a talk for
this Monday demonstrating three tiny programs in three separate
languages: Haskell, Clojure, and OCaml.

For this first program, consider the following mathematical problem:

"[0..11] equals 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. There is a single
one in 1, plus a single one in 10, plus two in 11, so there are four
ones total when incrementing from zero up to 11. Find all occurrences
over the set of non-negative integers where all of the accumulated ones
from zero up to a number equals that number."

The Haskell and OCaml versions of this program can complete the problem
in ~5/1000 of a second. After the JVM gets it's sip of coffee, the
Clojure version completes almost instantly as well. I have an informal
proof of when no more answers are possible, as well as an explanation
of the math behind how all of this works.

The second program (which I'll explain in person) started off life when
I was first learning Haskell. I decided to tackle some random problems
and found one in a forum. At that time the fastest implementation was
written in C and took 10.1 second to complete over a test data set. My
first attempt took ~35 seconds using only higher order functions. Using
the same algorithm and implementing what I learned as I went along,
it's now at 5.6 seconds over the same data set. There are useful
lessons in this version for Haskell learners about fast file processing
and drawing to screen. It also gives some insight into just how amazing
of a job that the GHC devs have done with their compiler.

The same program in Clojure is currently running at ~3x the speed of
the Haskell using the same algorithm. This one has had many surprises
about Clojure and would really enjoy if any Clojure hackers came along
to share some insight.

The OCaml version is lazy throughout (BatEnum); mainly because I
couldn't see any other way to do it in the few days that I spent
learning the language. It's currently the slowest of the three -- a
situation that I may try to attempt to fix before Monday. As with
Clojure, if any OCaml hackers would like to show up, insight would be
appreciated.

The last program is a command line weather program that gives complete
current weather from in some cases weather stations in the local
neighborhood. It contains a detailed seven day forecast for both day and
night. As well, it dynamically allocates space for weather alerts. All
of this uses the JSON API from Weather Underground.

The Haskell version features Aeson including the ability to deal with
JSON that can and does regularly changes types. It uses quite a bit of
the capabilities of Data.Text.Lazy for comprehensive string-like
functions. It also features Data.Text.Format for type safe printf like
output.

The Clojure version features the 'json' library and like many things
Clojure, everything else is 'batteries included'. Also not too
surprisingly, it uses less code than the other two.

The OCaml version features Yojson. I ran into some issues with dealing
with UTF8 and not finding libraries that I was looking for, so it also
features me working around things... probably unnecessarily.

If anyone is up to this talk, I'd be glad to do it. If I do, I very much
welcome other's insight into simpler code that performs to a language's
capabilities.

Patrick Logan

unread,
May 9, 2015, 8:55:15 PM5/9/15
to pdx...@googlegroups.com
Aside: by far the better part of the Clojure startup time is booting the Clojure runtime. JVM startup time can be pretty quick with recent versions.



--
You received this message because you are subscribed to the Google Groups "pdxfunc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdxfunc+u...@googlegroups.com.
To post to this group, send email to pdx...@googlegroups.com.
Visit this group at http://groups.google.com/group/pdxfunc.
For more options, visit https://groups.google.com/d/optout.

Skottish

unread,
May 9, 2015, 9:14:31 PM5/9/15
to pdx...@googlegroups.com
On Sat, May 09, 2015 at 05:55:15PM -0700, Patrick Logan wrote:
>Aside: by far the better part of the Clojure startup time is booting the
>Clojure runtime. JVM startup time can be pretty quick with recent versions.
>
>http://blog.ndk.io/2014/02/25/clojure-bootstrapping.html

Thanks for this. It looks like a very well thought out piece and I'll
read more in depth.

The JVM only has about an 8/10 of a second startup time on my
workstation using OpenJDK. OpenJDK/Java is an excellent target for so
many domains, so hopefully I didn't come across as disparaging.

Lyle Kopnicky

unread,
May 9, 2015, 9:18:56 PM5/9/15
to pdx...@googlegroups.com
That sounds great, Skottish - go for it!

Skottish

unread,
May 9, 2015, 9:30:15 PM5/9/15
to pdx...@googlegroups.com
On Sat, May 09, 2015 at 06:18:35PM -0700, Lyle Kopnicky wrote:
>That sounds great, Skottish - go for it!
>

Thank you. Your welcome means a lot to me.

Skottish

unread,
May 9, 2015, 10:49:13 PM5/9/15
to pdx...@googlegroups.com
On Sat, May 09, 2015 at 06:30:13PM -0700, Skottish wrote:
>On Sat, May 09, 2015 at 06:18:35PM -0700, Lyle Kopnicky wrote:
>>That sounds great, Skottish - go for it!
>>

By the way, is the meeting going to be held at Collective Agency again?
Not that it matters too much, but if so, do you know if that projector
handles 1366x768 or something similar?

Leif Warner

unread,
May 11, 2015, 2:35:00 PM5/11/15
to pdx...@googlegroups.com, skotti...@gmail.com
It is going to be at Collective Agency again. I don't know if the projector supports that resolution - but I'd hope so.

Skottish

unread,
May 11, 2015, 2:40:23 PM5/11/15
to pdx...@googlegroups.com
Cool. The projector thing isn't a big deal either way, but it's helpful
to be prepared. See ya' this evening.
Reply all
Reply to author
Forward
0 new messages