10 ms·
Snap for Beginners: Haskell Web Development
- boothead 13y agoCurrently heading up a team of awesomely smart people building our back end in Haskell on snap. AMA!
- bwilliams 13y ago"the development SPEED of ruby with the SAFETY of STATIC TYPING" sounds kind of sketchy. Would you say that title is true?
- ixmatus 13y agoNot only true but faster because less time spent debugging.
- joehillen 13y agoAnd it's faster and easier to add new features because you can refactor without fear.
- bwilliams 13y agoI don't refactor with fear in my Rails apps since they have pretty good test coverage. I'm not saying it's perfect, but I've never had slow development because I wanted to refactor in this context.
- ixmatus 13y agoIt's been slower for me, personally. I write half the tests in Haskell than I had to in Python which means less updating of tests as requirements change. It won't feel slow to you until you've written productive (beyond beginner) software in Haskell.
- pekk 13y agoOnly if you don't count debugging whatever the fancy type system is doing vs. what you need the behavior to be
- chc 13y agoWhat does this mean? I don't think most Haskell users spend a lot of time debugging the type system.
- dllthomas 13y agoNew Haskell developers spend a bit of time figuring out why the types of an expression aren't what they think they are, especially when wading into using some of the libraries with more sophisticated use of types.
- hamidr 13y agoNow, It's "New Haskell developers" vs "New Ruby/RoR developers". Isn't it?
- dllthomas 13y agoI'm not certain what you're asking. If you mean it's unfair to compare experienced Ruby developers to new Haskell developers I agree, I was just explaining where the sentiment was coming from (insofar as it was legitimate).
- coldtea 13y agoWell, New Ruby developers doesn't have the same problem. They can move much faster than the initial uphill struggle that is Haskell. Essentially, there are three sitations: a) Everything is of the same difficulty. b) Haskell is more difficult than Ruby. c) Ruby is more difficult than Haskell. I'd say (b) is a much saner conclusion.
- hamidr 13y ago
- boothead 13y agoWhat you find if you're doing it right is not only that you get the safety of static typing, but also that the types often lead you towards to solution. Abstractions in Haskell are smaller, more universal and composable than those of say ruby or python. For example the very simple idea of a Monoid (essentially concatenation) can be found in most places either explicitly or if you squint a bit, and once you recognise it a whole set of properties and behaviours can be reused. Also once the structure is in place, they types make for very safe re-factoring and assurance that you haven't broken anything. The only thing that's probably slower than ruby in Haskell is, unfortunately, learning it in the first place :-)
- fractalsea 13y agoAs someone who is quite familiar with abstract algebra, but who has not used much Haskell, I'm curious about why you think of monoids as simply concatenation? Is this the only, or primary, way they are used in Haskell? A monoid could also be the natural numbers combined with addition for example. Would this not be as useful?
- tel 13y agoHaskellers just call them Monoid and happily include anything that's associative+identity. When talking to people not yet familiar with Haskell or abstract algebra, it's commonly a good idea to simplify the notion and call Monoid the same as concatenation. That's all. newtype Sum = Sum { getSum :: Int } instance Monoid Sum where mempty = Sum 0 mappend (Sum a) (Sum b) = Sum (a + b)
- deleted 13y ago[deleted]
- carterschonwald 13y agoyes, thats a commutative monoid. Thinking of a monoid as "concatenation" is much more general concept that includes that one
- judk 13y ago
- msluyter 13y agoHow long do you think it'd take for a reasonably decent developer with no prior experience to pick up and become competent with Haskell and Snap?
- deleted 13y ago[deleted]
- copergi 13y agoI don't have a lot of data points, but for the one PHP developer I had learn haskell by writing a webapp in it, 6 months from "never seen haskell before" to "feels comfortable working solo and doesn't need help". The first 80% comes pretty quick, but not needing someone to answer questions takes a while.
- IanCal 13y agoThis is helped by the fantastic haskell community. The IRC channels are great.
- nnutter 13y agoHow do you plan to deploy your backend? Are there tools to do it? Is it just rsyncing a cabal sandbox to another machine? What about compiling and stuff? (I've barely made my way through LYHGG.)
- copergi 13y agoI used to just scp the binary up to the servers. They don't need any haskell stuff installed or anything like that. Recently I made it so they grab the latest binary off of S3 on bootup and when I run an update script. So now I just upload the binary to S3 instead.
- begriffs 13y agoYou can deploy Snap apps to Heroku pretty easily. https://github.com/begriffs/heroku-buildpack-ghc https://github.com/begriffs/heroku-buildpack-ghc
- boothead 13y agoSo we started with a git subtree merge of all the dependent projects and then a script to build a docker container, with physical infrastructure managed by ansible. It now looks more like we're going to use NixOs and NixOps - which are awesome!
- nnutter 13y agoAre there (good) tools to help with refactoring Haskell? To me this seems like one of the benefits of a statically typed language (I've almost entirely worked in Perl).
- tinco 13y agoNot as good as for example for C#, but not as bad as for example Ruby. I have a plugin for Sublime that complains when something is broken, or a dependency is missing. The typesystem is so strong that usually when it compiles, it works. So my process for refactoring is basically changing typesystems, and having the compiler check my changes until it works again. Note that this thinks of Ruby as bad only in IDE aspect. Refactoring Ruby is actually quite enjoyable as Ruby is so friendly to unit testing. You just move your code and run your tests again.
- judk 13y agoLook up [HaRe the Haskell refactorer]
- jcampbell1 13y agoAre there any open source Snap projects that are good to learn from the code?
- biscarch 13y agoThere is a list of some people using Snap here[1] and some of them are open source. The book also has approximately 8 pre-coded projects that come with it and correlate to the chapters. [1] http://snapframework.com/faq#is-anyone-using-snap-in-production http://snapframework.com/faq#is-anyone-using-snap-in-product...
- rgbrgb 13y agoPlease consider changing the title font. It is very hard on my eyes.
- yeukhon 13y agoAnd also the color contrast.
- andrewflnr 13y agoAs long as we're talking about the appearance, I had to zoom out to be able to see the text with Firefox 27, and then stuff started moving around like some pieces of it were centered with different methods or something.
- BadassFractal 13y agoAnybody know of solid super-entry level tutorials for starting Web Development with Haskell with less opinionated libraries like Scotty? Something that shows you how to slap together a solid cabal sandboxed ready-to-deploy application that's a mix of Scotty/Persistant/Esqueleto and all the other basics? Clojure has "Web Development with Clojure" which is basically what I listed above, except for Clojure rather than Haskell.
- klrr 13y agoThere is this tutorial: http://adit.io/posts/2013-04-15-making-a-website-with-haskell.html http://adit.io/posts/2013-04-15-making-a-website-with-haskel... Although it uses virthualenv instead of a cabal sandbox.
- chrisrogers 13y agoI read that article a few weeks ago in order to get a basic personal site server running on Heroku. I used a standard cabal setup and updated a few things. end result here, which I think should serve as a good starter point for developing with Scotty: https://github.com/chrissrogers/chrissrogers.com https://github.com/chrissrogers/chrissrogers.com For Heroku builds I used the following excellent buildpack https://github.com/begriffs/heroku-buildpack-ghc https://github.com/begriffs/heroku-buildpack-ghc
- mark_l_watson 13y ago+1 thanks! Nice example. Scotty is appealing to me because it has a Sinatra like feel to it.
- gcb0 13y agofor a true beginner, it starts with an outdated cabal definition for virthualenv/hsenv that has specific old versions. nobody will be able to just copy and paste trhu the tutorial. but it seems well written if you can get past that point. Most beginners won't though.
- egonschiele 13y ago
- sssilver 13y agoThe typography makes my eyes bleed.
- houzi 13y agoDid you have problems with extremely ugly typefaces in the sample chapter? I had horrible typefaces with bold ligatures. It seemed as if my hinting and sub-pixel rendering had stopped working. There were many errors and warnings in the debugging console as well.
- egonschiele 13y agoFinally! Snap is a great framework but it's been missing a good guide for a while.
- MaxGabriel 13y agoCool, this is really good for Snap. I heard good things about Snap, but a major reason I went to Yesod instead was that it had a book that I could work through (For a Haskell beginner like me, having some structure was important).
- codygman 13y agoI was about to use Yesod instead also, then I came across OP's book.
- maxharris 13y agoHow does this compare with Meteor? I love Haskell, and if Snap can do the same kind of magic that Meteor does, I'll switch.
- codygman 13y agoMeteor is more for front-end right? I think Snap is mostly for the backend portion of that, however there are some Haskell to Javascript libraries which may enable functionality you get with Meteor (as well as the type safety most know and love).
- kazagistar 13y agoMeteor is for both ends at the same time. Most of your code on front end and back end is shared, including database queries, in a safe way.
- cies 13y agoCheck out Fay (Haskell to JS). You can scaffold up a test site with Yesod where it integrates with Fay. https://github.com/yesodweb/yesod-scaffold/tree/postgres-fay https://github.com/yesodweb/yesod-scaffold/tree/postgres-fay It's not quite Meteor (then I dont believe it is so great), but works today and gives you Haskell from front-to-back. The Haskell Center IDE of FPComplete is build with Yesod and Fay -- and that is a serious application.
- cgag 13y agoI just started playing with Scotty while I learn, but I'm beginning working on a web app in Haskell and was leaning towards using Snap. I'll almost certainly pick this up. That new IO manager is a beautiful thing.
- kayloos 13y agoThere's a new web library that extends Scotty with basic session and authenticiation support, called Spock. I used it for a personal project of mine, which is creating an rss reader resembling the now dead iGoogle (which I loved), and although I had to read a lot of source code to get it to work, I really enjoyed how I worked with it, after figuring out the patterns on how to use it. It definitely isn't finished, it could use some love by some eager developers, but in my opinion it has the potential to be the best framework out there. - It extends scotty, so defining routes and control logic is fast and simple - It does not cage you in with a template language, or libraries that you don't want thrown in your face. For example, I used Scotty with my own templating language I made for fun (hemplate), as well as a validation library I made, which I hope to finish in the near future, (after I get a job). http://hackage.haskell.org/package/Spock http://hackage.haskell.org/package/Spock
- sudeep1 13y agowhy anyone would want to build with snap leaving RoR behind.
- copergi 13y agoYes, leaving RoR behind is certainly one reason for some people to use snap. But even for people who didn't fall into the rails trap, haskell is much nicer for web development than most languages (PHP, python, java, C#, etc).
- deleted 13y ago[deleted]
- acconrad 13y agoIs there a site analogous to the Rails Tutorial e-book, but for Haskell?