Wednesday, May 1, 2013

Marketing by 'N'

Hi all.

I've recently completed a new site for up and coming graphic-designer / photographer, Natalie Spa. The site is called Marketing by 'N' and was written in Ruby on Rails.


Marketing by 'N'


This project introduced me to the joys of ruby-gem conflicts in the way that only a bath of fire can. So many tears were shed at the hands of incompatible versions of rails, active-scaffold, acts-as-taggable-on, etc. I'm glad they all got sorted out in the end.

I'm sure you'll enjoy the services that Natalie is offering on this site if you take a look :-)

Saturday, April 13, 2013

Haskell

I want Haskell to be my primary language for new projects.

It isn't currently, and I don't think it will be for a while. This is due to difficulties I have with the libraries I need to get things done. Yesod is wonderful, but I don't fully grok it yet. I can almost always get web-development done faster in another language. A deep understanding is often required to make progress, this takes time. But still, I love it.

I feel that I'm on the edge of programming nirvana, with just a small deficit in my understanding preventing me from leveraging this language in order to be the most productive I've ever been. So... Why?


What is it about this language that keeps me coming back?



I first played with Haskell in first-year com-sci on my own time as I had heard that it was a really cool piece of technology. It was around the time that I was experimenting with all sorts of .... languages; From  Python to Prolog, Scheme to SML, BASIC to Brainfuck. I gave Haskell an ernest shot but I found it incomprehensible and impenetrable. It was mostly my own fault. When trying a new language there are two main ways to go about it -


  1. Take what you know from elsewhere and see how it fits, or
  2. Drink the Cool-aid


Unfortunately for me I tried the first option, one which Haskell doesn't lend itself to very readily. I would attempt things that I would often do in other languages, such as making heterogeneous lists, class-hierarchies, singletons, etc. While Haskell can do all of these things, they are usually used as intermediate techniques and not brought to bear on simple problems. So I looked at the code I wrote and thought - What is this ugly crap? Why does it have to be this complicated? This isn't intuitive at all.

I gave Haskell a break for the next two years.


Haskell Again


My next attempt at learning Haskell was to work through the Project Euler [2] problems. I blazed through the first 50 of these mostly by using brute-force solutions that were more than fast enough given Haskell's native speed. This time I started to understand the Haskell way of getting things done.

I've subsequently published about 35 Haskell repositories to Github [3] and contributed back to around 4 well known projects.


Why do I think Haskell's ideas will be part of the future of programming?



Haskell features several concepts that are just too good to ignore.


Static types


Haskell's type-system is second to none many research-languages, but is very good none-the less. After using Java, C, and C++ extensively in undergraduate studies, Ruby felt like programming nirvana to me and so I attributed this to the power of dynamic type-systems. My bad. In actual fact many languages have very primitive and prohibitively cumbersome type-systems. Haskell's is the complete opposite. Powerful, Terse, Expressive, and if needed, implicit.

Many fans of dynamic languages say that you don't gain anything from a static type-system as you should be unit testing your code. I don't disagree that tests are a very valuable tool, but types and tests do not fulfil the same role, although there is some overlap. A good design of your program's types will negate the need for many tests, and the ones that you do need to write will be assisted by having a strong static type system to help generate values, and guide the design of your tests.

I have found that my workflow is somewhat different when writing Haskell. I engage heavily in Type-Driven-Development. Writing out my program as a data-transformation pipeline and ensuring that the types of the segments line up, leaving the bodies undefined initially, filling in the pieces in the most-obvious fashion, then engaging in equational reasoning to refactor my source into a better form.


A good REPL


It's true that Haskell's REPL isn't as good as a good lisp's, but it is certainly better than the average REPL. The ability to test the types of ad-hoc values, browse module, and jump into an editor where required really speeds up your workflow. Also, the ability to script the REPL comes in very handy for writing Vim scripts, etc.


Laziness [4]


This is a contentious point, but the ability to not have to worry about the order of my source-code really frees me up in terms of concentrating on the obvious first. When I wrote a project in Clojure it was jarring having to declare my functions or write them in their dependent order. Even most OO languages are more flexible than this tanks to functions being grouped into classes.

Haskell is certainly the laziest language I've ever used, with perhaps the exception of Prolog. The canonical fibonacci definition of (fibs = 1:1:zipWith (+) fibs (tail fibs)) goes a ways to demonstrate the depth that this laziness descends to.


Good syntax


Some people consider syntax to be largely irrelevant to the quality of a programming language, I am not one of these people. I'm from that camp that the more often you use something, the better quality that thing should be. That's why I bought a good razor to shave with, etc. If I'm going to be battling with syntax every time I define a function, declare a type, construct a data-structure, meta-program, etc. I will GET PISSED OFF. Full stop. So far, Haskell's syntax has not pissed me off. This is a very good thing. GHC's extensions also go a long way to help with many sticking points: Just yesterday I discovered the View Patterns [5] extension that generalises pattern matching to abstract data. You could try a new extension every week for a year and still have some left over.


Speed


Haskell isn't the fastest language in the world, but it is fast. And you can tweak it to be very fast. And if you can't do that, then the FFI is first-rate. So far I haven't had any issues with speed, although obviously you're going to be mostly limited by the algorithm you use. Thankfully, in Haskell, refactoring your algorithms is pure joy!


A great compiler


GHC is possibly the world's most advanced compiler. Well, I jest, but it's up there with LLVM that's for sure. The optimisations that it performs are mostly high-level at this stage, but they can be quite amazing.


A great community


I have not yet come across any abrasive personalities from the Haskell community. Also, nobody is beyond reach. You can literally talk to anyone in the community without fear of rebuke (provided you're not totally out of line). There are great mailing-lists, irc-channels, Google Plus communities, etc. Everyone is super friendly and super helpful [6].

The only issue you will come across is the tendency of some people to offer up more general solutions than you might be looking for. This is usually a kind of humor, however, looking into the concepts alluded to is rarely a waste of time.


Links


  1. Haskell
  2. Project Euler
  3. Sordina's Github
  4. Lazy Evaluation
  5. View Patterns
  6. Trolling Haskell


Thursday, August 16, 2012

Meteor - An Exciting Development

If you haven't seen the Hacker News post about Meteor being funded $9M this month, then let me tell you a little about this framework since it is the first web-framework I have been excited to use in practice in a long time.

Rapidly develop Web-Applications

The premise is quite simple -

  • A pub/sub model
  • A (locally cached) DB API from the client
  • Template data-dependency driven updates

But what does that mean in practice?

  • Create Collection Objects (Mongo Tables) on your Server and Client
  • Create event hooks in your client code that update your DB and your Session appropriately
  • Define templates that render your objects (and others to render the page-chrome)
  • Create dynamic subscriptions to data
  • Create parameterised data publications on your server
That's about it for a basic app. I have created a small example app at mathfriends.meteor.com.

So what do each of these practical steps involve?

The MathFriends Example App

"Create Collection Objects (Mongo Tables) on your Server and Client"

This is achieved by using the Meteor API to create new Collection objects:

Defining 'Snippets' and 'Users' Collections


"Create event hooks in your client code that update your DB and your Session appropriately"

This involves listening for an event and updating your DB or Session accordingly. Logging out the current user is as easy as you might expect:

Listen for a 'logout' click - Set the user to null.


"Define templates that render your objects (and others to render the page-chrome)"

The templating engine used by default is Handlebars. The variable scope is determined by the data collections being looped over, and the functions bound to that template in your client-side js:

Showing the list of MathFriends users.

"Create dynamic subscriptions to data"

Subscriptions to data-sources can be handled manually, however, Meteor provides a way to automatically update the subscription when the dependencies change:

Adding a dynamic data-subscription.

"Create parameterised data publications on your server"

Every subscription references a corresponding publication. These may be parameterised arbitrarily:

Creating a data-publication parameterised by the currently selected user.



What does this buy us?

It means that when your data-store is updated, the changes are propagated to the clients and re-rendered automatically. Thanks to a local-cached subset of the data-store, interface affecting changes are re-rendered instantly on the client that made them.

Does this mean that your entire page is rendered every time you make a small change? No.

The changes are diffed against the dom and spliced in without updating large sections of the page unnecessarily.

Quite amazing.


There are currently a couple of major caveats, but the main one is:
  • Auth is a work in progress
This is currently being addressed in the auth branch on Github.


If you would like to take a look at the example site I was demonstrating, it is also available on Github.

Saturday, July 14, 2012

New Logo

Finally got around up updating the logo for this blog:


Mute - Signifies Minimalism

What do you think?

Priam Bacich - Musician

I have recently published a small static-site for musician - Priam Bacich in conjunction with Natalie Spa. For this project I've taken a back-seat in the design department as Natalie was keen to put her skills to the test, so I focused purely on the technical details.

This site was an entirely static affair, which allowed me more flexibility with how I generated the content. I explored several Ruby based static-site generation frameworks, however, I found that the most effective method for me was to reuse the dynamic-site frameworks using Sinatra I had previously developed and just crawl these locally with wget.

The result of this was that I could save development time by having the site update automatically for inspection during development without having to run an 'export' task between changes.

Priam Bacich on the Web

I've also begun experimenting with Clourflare to speed up load-times for static content. If you haven't used this service before I'd recommend giving it a try. There are few times that I've experienced a truly water-tight abstraction, but this is one of them. Absolutely, stunningly well done. The fact that this is offered for free boggles my mind.

I'll be writing a post about Cloudflare soon as I feel that I've just glimpsed the tip of the ice-berg here.

Saturday, March 10, 2012

Meta-Circular Startup

I'm investigating abstracting the process of bootstrapping by bootstrapping the process of abstraction introspectively. More to come.

Friday, December 9, 2011

A New Site - S.K. Dental

Sordina Productions is pleased to announce the arrival of a new site in our portfolio - S.K. Dental:

S.K. Dental's Homepage



Owned and run by Seng Kian Gan, S.K. Dental offers the latest in dental and periodontal care for Perth residents.

S.K, as he likes to be called, has been a wonderful client for Sordina Productions and together we are striving to ensure that your experience with S.K. Dental's new homepage is as smooth and enjoyable as possible.

For this site, Sordina Productions has chosen to use a combination of Ruby tools including:


  • Sinatra
  • Haml
  • Sass
  • Heroku
  • ... and many more.


This has enabled us to rapidly prototype new ideas, and in conjunction with the dead simple rerun gem and Git branches, the ability to switch a staging site between completely different designs with no downtime:

Rerun is used to unsure that the server is restarted when special resources are changed.

The site is currently rendering the 'Master' branch.

The branch is switched to 'Abstract Art'.

Upon refresh, the browser now displays the new branch.


Easy as pie!

I shouldn't neglect to mention that S.K. Dental is based in Forrestfield. Please consider them for your next dental appointment!