Thinking functionally

125 views
Skip to first unread message

Tom Wieland

unread,
Oct 6, 2013, 10:25:12 AM10/6/13
to lives...@googlegroups.com
Hello.

I'm interested in learning Functional Programming and to add it to my tool set. I'm having problems, however, in approaching problem solving in a functional way rather then an object oriented way.

I can spend time (working through SICP at the moment) learning more about the algorithms and tools like currying, memoization, lazy evaluation (that we dont have in js land) etcetera, but most of the articles I read are written in an ideal situation where I would want the circumference or area of a circle... and not my situation where I want to make a program that does something actually useful to ME (Node.js servers). I don't understand well enough where to keep the larger pieces of data in functional programming.

The thing I want to make at the moment is a 'platform' of 10 or so HTTP/TCP servers that talk to eachother. I want to pull as much functionality out of a website into a stateless server on the network that I can call from any site.

In object oriented terms I would solve it somewhat like this:

    class Service extends EventEmitter
      (options) ->
        @name     = options.name
        @version  = options.version
        @registry = seaport.connect 'localhost', 9000
        @server   = net.create-server!
        @port     = null
        
      start: ->
      
      stop: ->

And then I'd subclass Service for different kinds of services I want and have a commandline / admin interface tool to spawn and start instances of these classes on a host/port on the network somewhere. Libraries already take care of most of the work so I'm just talking about where to keep and group the data in your program.

Tom Wieland

unread,
Oct 6, 2013, 11:56:24 AM10/6/13
to lives...@googlegroups.com
This is a first version with only functions, and a little bit of map


gr,

Tom

Felix Marx

unread,
Nov 22, 2013, 3:26:53 AM11/22/13
to lives...@googlegroups.com
Nice thanks for sharing. :)

I fell in love with livescript on first catch. Saw the the first lines of code and was reminded of some Haskell stuft from the past. Love to go functional.

Your post gave me a good point to enter
Reply all
Reply to author
Forward
0 new messages