3

I've heard a lot of talk about using lightweight data modeling as of late. Especially in relation to the Clojure programming language. What is it and how it differs from traditional classes regarding long term maintainability and flexibility of the design that relies on it?

user7610
  • 419
  • 4
  • 13
  • 1
    Essentially all data types are ADTs in FP though? – alternative Oct 18 '14 at 14:34
  • 1
    Not necessarily. You can do functional programming with objects. Or even with no data abstraction at all! Actually, since object-oriented data abstraction is all about behavioral abstraction, and in lambda-calculus, the only "building blocks" with which you can perform abstractions are functions (i.e. behavior), all data abstractions in lambda-calculus are necessarily object-oriented! (This astonishing fact was noted by William Cook.) In other words, the purest of all pure functional languages is at the same time the first object-oriented language! – Jörg W Mittag Oct 18 '14 at 15:58
  • @alternative: Oops, I got confused there. I was talking about Abstract Data Types. Where you talking about Abstract Data Types or Algebraic Data Types? I don't think all types are Algebraic Types in FP. Really, Algebraic Types are orthogonal to FP. You can easily model them with classical Java-style OO inheritance and generics, actually. (In fact, that's what Scala does.) Product types become containers with type parameters, sum types become sibling subtypes. – Jörg W Mittag Oct 18 '14 at 16:07
  • @Jorg Ahh, I don't really consider Scala to be FP, its more FP mixed with Procedural, which is why it carries over the Classes and such. I'm thinking in a pure FP environment, basically every type you have would be an ADT (Algebraic). – alternative Oct 18 '14 at 16:18
  • @alternative The original idea behind Scala (and F#) is slightly different, the people hoped that by combining functional and object oriented approaches in a single language they can create something "more than the sum of the parts". See for example slides 3 and 4 here http://lampwww.epfl.ch/~odersky/talks/google06.pdf “Scala goes further than all other well-known languages in fusing object-oriented and functional programming.” - Martin Odersky. Haskell still does not have paremetrized modules. Scala does, because it uses objects for it. – user7610 Oct 18 '14 at 18:44
  • 1
    @user7610 I don't really care. All I said is that Scala isn't purely functional, which is completely true. Therefore, my statement does not apply to it... – alternative Oct 18 '14 at 19:31
  • I hope the question is more clear now. – user7610 Oct 19 '14 at 21:58
  • recommended reading: **[What is the problem with “Pros and Cons”?](http://meta.programmers.stackexchange.com/q/6758/31260)** – gnat Oct 20 '14 at 06:52
  • 1
    @gnat I used [Q: Functional Programming vs. OOP](https://programmers.stackexchange.com/questions/9730/functional-programming-vs-oop) as a template. Your link suggests framing this as a design review question. I'll try to do that. If I can just avoid using all the trigger words like "pros and cons", hopefully this question will be sustained here. – user7610 Oct 20 '14 at 08:58
  • related question Q: [“Everything is a Map”, am I doing this right?](http://programmers.stackexchange.com/questions/208154/everything-is-a-map-am-i-doing-this-right) – user7610 Oct 22 '14 at 17:35

0 Answers0