5 ms·
Tell me more about preventing 404 at compile time. I call http://www.yesodweb.com/bullshit http://www.yesodweb.com/bullshit
by rimantas 12y ago
Tell me more about preventing 404 at compile time.
I call http://www.yesodweb.com/bullshit http://www.yesodweb.com/bullshit
- chrisdotcode 12y agohttp://www.yesodweb.com/book/shakespearean-templates#shakespearean-templates_type_safe_urls http://www.yesodweb.com/book/shakespearean-templates#shakesp... If you're used to only programming in dynamic languages, it can be a shock, but yes, a good type system can do things you never thought possible. If you were the downvoter, I'll take my vote back now.
- theoh 12y agoI don't know who the downvoter is but I think it's a silly claim to be proud of. Anything more complex than a simple template system can enforce referential integrity of internal links by making the programmer refer to other pages on the site with some kind of handle. It's not rocket science and doing it with the (elaborate) type system isn't necessarily a selling point, in my opinion.
- grey-area 12y agoPresumably the idea is that you can prevent your site having broken internal links by constructing links with data types and checking the links when creating them at compile time. You could actually do something similar in most languages, even dynamic ones, so I don't see what is specific to haskell about it, e.g. rails has link_to and friends which require you to have a route set up in order to link to it (though not compile time). Golang has similar protection for XSS and reverse routes on routers if you require it so again not specific to Haskell. Clearly you won't be able to prevent (nor would you want to) links like yours above from being a 404, so perhaps no more internal 404s would be more accurate.
- dmit 12y agoLet's be fair here, while you can detect invalid internal links in dynamic languages at runtime, the end result is basically the same for the user - a 404 or a 503 are equally bad in this case. That's the advantage of compiled languages over dynamic ones in these kinds of scenarios: you sacrifice immediate feedback during development to gain a guarantee from the compiler that all invariants you embedded in the application uphold. And the more powerful the language/compiler combination, the more compile-time guarantees you can specify.
- grey-area 12y agoUsers of dynamic languages tend to use tests to check for errors that stronger types might catch (like broken links), but I agree having a formal guarantee is a slight advantage, though not specific to Haskell. Golang for example could easily provide similar checking. The linked website is beautifully done, and the language does look interesting, I just find the hyperbole about static types making websites magically secure a little over-egged - it's still easy to mess up security or create subtle bugs even if you have strong guarantees about some parts of your code at compile time provided by types.
- rimantas 12y agoWell, for me broken internal links and a claim that some framework magically avoids 404 errors are worlds apart.