addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

How stateless can you go?

  • Apr 28, 2011 · 6:00 PM
  • The Scotsman

One benefit of learning functional programming languages is that they encourage you to rely less on state, instead using transformations and such. This makes for more robust code, since we then have fewer "moving parts" to worry about and get wrong.


The task for this dojo, lead by Thomas Kjeldahl Nilsson, would be to attack a small problem that seemingly requires a lot of mutable state, and reduce the number of variables, assignments etc as much as possible. Then possibly switch pairs and/or programming languages and try it a second time. How stateless can you go?


Please bring your own laptop. You can use whatever programming language you feel comfortable in. Also, we'll pair program - so either bring your own tango partner or find a friendly partner at the meetup. :)

http://kjeldahlnilsson.net/

 

Join or login to comment.

  • Ivar R.

    A more advanced Haskell solution: https://gist.github.com/950508

    May 1, 2011

  • Jon-Anders T.

    oppdater scala (+ clojure versjon med destructuring)
    https://gist.github.com/948337

    April 29, 2011

  • Geir A.

    I made an implementation with parameter list destructuring, but could find no other use for it than to separate the node from its children, and thus the pop'n'maprecurse solution is both simpler and more concise.
    Haven't given up on the idea, though; there should be a simpler way of collecting the indentation and newline tokens. Just not sure destructuring is a good fit for this problem.

    April 29, 2011

  • Johannes B.

    Did you get anywhere with the parameter destructoring of first/rest?

    April 29, 2011

  • Geir A.

    Using overloaded invoke methods, you don't need a separate helper function: https://gist.github.com/948247
    15 lines/288 characters/38 parentheses

    April 29, 2011

  • Johannes B.

    Clojure test and code - 17 lines including whitespace. 356 characters, out of which 40 (10%) are parenteses:

    https://gist.github.com/948150

    April 29, 2011

  • Geir A.

    Great fun!

    Very educational to step far out of one's comfort zone. Earned a few bruises and learned some hard lessons. Among them the importance of being very careful when expressing datastructures in a functional context.

    OTOH, every time we found ourselves in a hole, we stopped digging. ;P

    All in all, a great dojo experience, with a different practice target than we're used to.

    April 29, 2011

  • Geir A.

    GitHub organization for OCD created, and the repo forked: https://github.com/oslocodingdojo/osloCodingDojoApril2011

    April 29, 2011

  • A former member
    A former member

    Also, see this blog article series for deeper discussion of challenges in writing pure and stateless code: http://prog21.dadgum.com/23.html

    April 29, 2011

  • Ole Morten A.

    Jeg lærte scala, lærte ikkno clojure for jeg så bare paranteser. Fikk se haskell, C#, java og tøyd mine egne ruby-ferdigheter. Øl og koding, faaaantastisk!

    April 29, 2011

  • Anders N.

    This was fun!

    April 29, 2011

  • A former member
    A former member

    It was a nice practice and interesting to see the (so similar) solution in multiple languages. And it was very nice of everybody to speak English :-) Maybe it would be better to have a more complex example, we were done too soon (on the other hand thus we also had the chance to try it in C# & Groovy). I'd also appreciate a deeper discussion of what you need to program in the stateless way (language support?) and what challenges does it have and how people deal with them. The practice itself was nice but I'm not sure I've learned much. Anyway it was nice practice, nice people, nice place => a good evening :-)

    April 29, 2011

  • Carl-Erik K.

    Bra meetup! Veldig imøtekommende også for nybørjare :)

    April 29, 2011

  • A former member
    A former member

    Nice crowd, I had a lot of fun (though I didnt do any coding, myself :))

    April 29, 2011

  • A former member
    A former member

    I've put the slides and all the group solution code up as a github repo: https://github.com/thomanil/osloCodingDojoApril2011 Geir, maybe you want to create an official repo at Github or Gitorious for the meetup, and put a copy there?

    April 28, 2011

  • Jon-Yngve Skjeltorp B.

    Gah. Det ser ut til at jeg ikke rekker å bli med likevel. Det er dumt, for jeg har sett frem til å bli med på disse møtene, men får gjøre det neste gang i stedet for da... :-)

    April 28, 2011

  • Ole Morten A.

    Jeg tar heller ikke noen tango partner med i sekken og håper at jeg får parprogrammert med flere, for mest mulig variasjon =>inspirasjon :) Er det noen som "tar med" seg et funksjonelt språk? Eller blir det java, ruby, C# på alle?

    April 27, 2011

  • A former member
    A former member

    Som Siv sier så er det fritt frem. Kommer til å trekke frem funksjonell programmering som et eksempel på "stateless" approach, men selve oppgaven kan løses med hvilket som helst programmeringsspråk. :)

    April 27, 2011

  • Ellen W.

    Har bare får så vidt begynt å lære meg funksjonell programmering (kommer fra java verden). Er det uansett plass til meg i morgen, eller skulle en heller har litt mer erfaring? Har heller ingen "tango partner" ;)

    April 27, 2011

  • A former member
    A former member

    We tried to avoid the overlap once we discovered it. Unfortunately both meetups were unable to reschedule this time. Too much cool stuff going on in Oslo! :)

    April 27, 2011

  • Carl-Erik K.

    It would be nice if framsia and the coding dojo tried coordinating their activities since they are competing for much of the same audience. And the most interesting events always seem to coincide for some reason...

    April 22, 2011

  • Ole Christian R.

    Æsj. Kræsjer med framsia :(

    April 20, 2011

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy