7 ms·
Architecture of a Real World Haskell Application
- ixmatus 12y agoNot sure if "Architecture" is the right word here. More like, "How I built a Real World Haskell Application". When I read about how to "architect" something I'm think about how to structure my Cabal file (a common pattern in my apps is a "library" of types, parsers, and utilities that are jointly used by multiple executables of the same program). I also think about structuring my tests, the naming and structure of module directory hierarchies, maybe also how to structure the program around the Main entry point. I think there may also be a more interesting couple of "sub-articles" in this article: "How I built a server daemon in Haskell" and "How I built a GUI client in Haskell".
- Spearchucker 12y agoAgreed. I get this a lot, so have definitions ready - http://www.bredemeyer.com/whatis.htm http://www.bredemeyer.com/whatis.htm. If architecture in the computing world consists of a system’s elements; the relationships between those elements; the attributes of the elements; and the attributes of the relationships, then architecture is not a timeline, process or stack description.
- platz 12y agoalso: architecture implies that you had a variety of solutions to choose from, and that you made a choice from one of the possible solutions and are able to reason and talk about that choice, the pros and cons, etc. If you can't list the pros and cons relative to the other choices, I don't really consider that architecture - that's just doing what's familiar.
- tormeh 12y agoWhat if it's the first time you do something? You just figured something out and thought it looked OK. Isn't that architecture?
- ixmatus 12y agoNot quite, I would call that "solution".
- tormeh 12y agoAlso when you have code block, data flow and control flow diagrams? How well thought out does something have to be to be architecture?
- ixmatus 12y agoAn Architecture, to me, is an established and idiomatic process of applying solutions to produce a novel output. In the case of a computer program the "architecture" should be extremely well-thought out, idiomatic, and using established practices to produce a program that is easy to maintain, understand, and test. I don't believe you need diagrams but in the case of Haskell, the types (if you design type-first) serve as one piece of the blueprint that is to become your program, your cabal file, directory structure, documentation (both user docs and API docs), and tests are all part of that blueprint.
- z3phyr 12y agoIt is great to see Haskell being 'used' in the 'space-science industry' (please tell me a good word for this) I would love to read more about mainstream functional language being used in scientific domains like CERN, ESA, NASA or SpaceX.
- outworlder 12y agoThe industry appears to be very risk-averse (even though they have their reasons), so I'd be surprised to see a modern, functional language being used for critical tasks. However, C++ sometimes is used for those tasks, which boggles the mind. Then again, that might just be a wrong impression I got from reading, among other things, "Lisping at JPL" (http://www.flownet.com/gat/jpl-lisp.html http://www.flownet.com/gat/jpl-lisp.html)
- thu 12y agoA good use case for Haskell is to generate C code in a way that make it easier to assess its safety. See e.g. http://smaccmpilot.org/languages/ivory-concepts.html http://smaccmpilot.org/languages/ivory-concepts.html or Galois' work.
- davidkellis 12y agoI think you hit the nail on the head about the space industry being risk averse. I think that guides a lot of their decision making. I took a compiler class that was taught by the inventor (Dr. Daniel Cooke) of another functional language, SequenceL (see http://en.wikipedia.org/wiki/SequenceL http://en.wikipedia.org/wiki/SequenceL). Cooke had funding from NASA to develop SequenceL because evidently NASA was/is very interested in program correctness (it's hard to guarantee correctness of a C++ program) and a simplified programming model. The way Cooke explained it in class, SequenceL was born out of a desire for a simpler programming language (he believed that modern programming languages are too complex - so many require extra tooling to be productive) and a desire to make the implementation of a program as close as possible to the definition of the problem. He reasoned that if you could make an executable specification (i.e. the definition of the problem was executable), then all the mistakes that implementers make while implementing a program based on the problem specification/requirements would go away. In other words, since the definition of the problem would be the implementation, zero implementation mistakes would be made. Interestingly enough, the first SequenceL interpreter and compiler was written in Haskell.
- jarrett 12y agoAs the author says, there's quite a lot of imperative stuff in this design. I'm still on the fence about whether that's the best way to build large applications with GUIs, network access, etc. With the imperative approach, you make liberal use of the IO monad. There's a lot of explicit reading from and writing to mutable storage. If you're doing this approach right, you mostly just use the IO monad for actual IO and threading; most of the real logic of the program is kept pure. This approach has the advantage of being familiar. And more importantly, it just plain works. It's how I tend to do things. Yet I can't help but wonder if there's a better way. The above approach, while comfortable, leaves me with a bad taste in my mouth, like I'm somehow fighting against the language. I've often heard functional reactive programming (FRP) described as the best alternative. Though I remain skeptical. I'd be interested in opinions about the future of FRP.
- steveklabnik 12y agoAs FRP becomes more and more 'normal' in JavaScript land, I think it has a bright future.
- jarrett 12y agoAre you referring to the various databinding frameworks? So far, I've been somewhat skeptical of those--I worry they make too many assumptions and take away too much fine-grained control.
- brandoncapecci 12y agoThe amount of people I know who use functional frameworks (say Underscore) to build things but don't really know much about functional programming is astonishing. To be fair, a lot of frameworks that espouse "functional programming" do so just because it's popular and really push imperative concepts instead so it's easy to be confused on the "right way".
- jarrett 12y agoI love Underscore (and Haskell), but I wouldn't consider Underscore an FRP framework at all. It's functional, yes, in the sense that it provides some of the most common FP operations like map, filter, etc, using lambdas. But I don't see the reactive part. Maybe there's some kind of reactive feature tucked away in Underscore's rather large feature set, but I haven't seen it, and it's certainly not core to the library.
- egonschiele 12y ago> it could benefit from the lens library, but last time I tried it did have problems with compilation with profiling information In my experience, template haskell does not play well with profiling. If you were deriving lenses with TH, you could try writing them out yourself. That might solve this issue.
- dangirsh 12y agoVery cool to see Haskell being used more in the space space. I've recently built a command line tool in Haskell with a subset of these features for my team's testing:https://github.com/dangirsh/Auto https://github.com/dangirsh/Auto I agree that the existing tools are pretty limited
- deleted 12y ago[deleted]