Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No good tutorial #19

Open
drozzy opened this issue Jul 30, 2012 · 9 comments
Open

No good tutorial #19

drozzy opened this issue Jul 30, 2012 · 9 comments

Comments

@drozzy
Copy link

drozzy commented Jul 30, 2012

There is no good starter tutorial on the net about Snap.
Things like template context variables, acid-state (database) usage, urls, etc.. are not clear how to use or where to stick them. The default/init site generated by Snap is confusing with three files: Application.hs, Main.hs, Site.hs - with no explanation of what file does what, and a bunch of weird looking code that does 'magic' (and uses symbols like [| ).

For a person just getting started with haskell I think it would be really useful to have a "for dummies" tutorial. And yes - it's possible, just look at Django docs.

Snap can have an advantage here, as no other framework (yesod or happstack) has a good beginner tutorial.

@drozzy
Copy link
Author

drozzy commented Jul 30, 2012

Oh, and there are no Snap experts on stackoverflow either, so most questions go unanswered.

@mightybyte
Copy link
Member

There's a reason none of the web frameworks "has a good beginner tutorial". Haskell is widely known for having a pretty steep learning curve. A large number of people have put thousands of hours into creating instructional materials for learning Haskell and people still consider it a difficult task. As Snap Framework authors with limited time and resources, we intentionally chose to not teach people Haskell in our tutorials and instead to focus specifically on Snap. You can't really compare Django's tutorials because Python is widely recognized has being very easy to learn.

I agree that we could certainly do a better job with our tutorials, but I also think that your expectations are a little unrealistic given the difficulty of learning Haskell, the maturity level of Haskell web frameworks, and the amount of manpower working on them. Also, there are multiple Snap developers active on StackOverflow. The majority of Snap questions have accepted answers, and the snap-framework tag has a 0% all-time unanswered rate.

@drozzy
Copy link
Author

drozzy commented Aug 6, 2012

You are right. But I would be glad if you could add more comments. For example, here:
https://github.com/snapframework/snap-website/blob/master/src/Main.hs

some functions like these are really complicated (for me):

undirify :: MonadSnap m => m ()
undirify = do
uri <- withRequest (return . rqURI)
if B.length uri > 1 && T.last (decodeUtf8 uri) == '/'
then redirect (B.init uri)
else return ()

@adinapoli
Copy link
Member

Hi guys, I was going to write about the very same topic, so I add my 2 cents here. As an external user, I've always found the hello world example in the Snap website disappointing, because it leaves me with wet lips but no idea about how proceed. It's true, you can search for tutorial or peek the site's source code, but I think that a tutorial-friendly approach would be awesome to have.

Personally, I'm a huge fan of Django, a Python framework, you may have heard about it. Back in the days of my bachelor thesis, I was able to learn Django in a couple of weeks also thanks to its outstanding tutorial:

Django tutorial

I suggest you peek the above link. It's divided in 4 part, at the bottom of each page there is the link for the next section. The tutorial guides you through model creation, DB fiddling and more. We could do a similar thing for Snap. I'm also available to do it myself, step after step: being myself a Snap beginner, who better than me could write a tutorial in the layman's terms? :)
Please let me know if the idea appeals you!

Cheers,
A.

@mightybyte
Copy link
Member

Of course the more tutorial material we have the better. However, with Snap we intentionally chose to make the core framework DB-agnostic. We view interfacing with a database to be orthogonal to the web framework. Yes, there will be some glue code that is helpful, but the core framework does not provide that glue code. We do something more general and provide a snaplet API that lets your DB glue code exist in a modular way as a snaplet.

If you want to make something like the Django tutorial, you will have to choose a database, and that choice is not something that we as the Snap Framework make for you. This is part of why we don't have such a tutorial. It wouldn't be a Snap tutorial. It would be a Snap+HDBC tutorial. Or maybe Snap+PostgresqlSimple, or Snap+AcidState.

So yes, we'd love to have tutorials like that. But they fall outside the umbrella of just Snap.

@adinapoli
Copy link
Member

I'm a completely newbie about the topic "Haskell and DB", I mean I know that exists a lot of db packages for interfacing with MySql, Postgres, Nosql ones etc as well as more recent EDSLs like Esqueleto. As you may know, what Django does is to offer an uniform interface (it offers an ORM to be precise) which uniforms the way the developer interact with the DB. This means that once you have choosen your DB in a setting.py project file, Django will do the heavy work for you. If you ask to save a blog post, for example, you simply invoke myobj.save() regardless the underlying DB.

Said that, I haven't understand if this approach in inapplicable for Snap for a design choice (i.e, keep it DB free) or for an intrinsic "limit" of the available Haskell packages for dealing with DB. I ask this only to know better the Snap philosophy and to understand how to attract more users towards it :)

@mightybyte
Copy link
Member

In my above comment, when I say "DB", I also mean ORM. Snap is ORM-agnostic.

@adinapoli
Copy link
Member

Got it :)

@GetContented
Copy link

I'm quite interested in building such a thing. There actually are a few pretty good resources around, but they require a reasonable amount of google-fu to discover..

http://learnsnap.chromaticleaves.com
http://snapforbeginners.com

Then there's my own personal quite-wrong-in-places snap_notes for "let's get started with the basics of SNAP", which is a broken-down version of Ryan Trinkle's "webcast" about a URL-shortener. As @mightybyte points out, Haskell itself takes quite a while to get fully to grips with, and Snap assumes intermediate Haskell. This is quite a good reason that most of the people in IRC don't recommend you start with a web app - there's a huge learning curve.

http://www.genericoverlords.com/snap_notes

I'm actually quite interested in starting to build some resources for getting going with Snap from nothing (but done better than those notes there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants