Live data from Hacker News

Low-level web programming in Racket and a wiki in 500 lines

matt.might.net

11–20 of 29 posts

Re: Low-level web programming in Racket and a wiki in 500 lines

#11
post #4

This is very useful. I'm in the middle of a Racket web project right now and I got hung up on parsing/processing form data. The Racket docs are very thorough, but they can be confusing if you don't know what you're looking for. If anyone here has experience with web stuff in Racket, I've set up a small skeleton for Racket web projects: https://github.com/samertm/web-project-bootstrap.rkt Right now it contains skeleto…

How exactly are you hung up with form data? Its low level, so you certainly can't get validation out of box, but otherwise in my experience getting form data out is fairly straight forward. I recently wrote my first Racket web app. Its not pretty or following best practices but you can take a look. https://github.com/vishesh/whalebin

Thank you! Your project was helpful to skim through. Do you have any additions to the web-project-bootstrap.rkt project?

BTW, this is what I mean by form bindings being confusing: according to the docs, request-bindings is dangerous and shouldn't be used http://docs.racket-lang.org/web-server/http.html#%28mod-path... . That's kind of confusing, because request-bindings is used in the tutorial docs: http://docs.racket-lang.org/continue/#%28def._%28%28lib._web...

And the function that Matt Might uses, request-post-data/raw, isn't even in the docs! Haha, so handling forms has been a bit of a pain for me :)

Re: Low-level web programming in Racket and a wiki in 500 lines

#12

Earlier quoted context omitted.

How exactly are you hung up with form data? Its low level, so you certainly can't get validation out of box, but otherwise in my experience getting form data out is fairly straight forward. I recently wrote my first Racket web app. Its not pretty or following best practices but you can take a look. https://github.com/vishesh/whalebin

Thank you! Your project was helpful to skim through. Do you have any additions to the web-project-bootstrap.rkt project? BTW, this is what I mean by form bindings being confusing: according to the docs, request-bindings is dangerous and shouldn't be used http://docs.racket-lang.org/web-server/http.html#%28mod-path... . That's kind of confusing, because request-bindings is used in the tutorial docs: http://docs.racket…

Good to know! I followed the tutorial and they were using it there, and didn't see the docs after that. I see that the Matt's blog handles the problem with request-binding himself, by doing ensuring encoding conversions, and gets over the file uploading problem. So I would replace my code with the way he does.

For your boilerplate, you may want to add bunch of options to serve/servlet such static files path, stateless? (to not use continuations) etc...

Re: Low-level web programming in Racket and a wiki in 500 lines

#13
post #8

Just being exposed to Racket last month I was extremely surprised at how well it clicked with me as opposed to Haskel which I tried to learn for a few months on my own and just tried out SML and it moved to Racket. Can't put a finger on it but Racket just makes sense to me.

Have you tried python..? You might like it

Re: Low-level web programming in Racket and a wiki in 500 lines

#15
post #3

I'm glad to see someone talking about using the lower-level web libraries in Racket. The high-level continuation-based ones are ridiculously unsuitable for actual web programming (they store full state on the server at all times, and the URL gives you full access to the session, among other issues), but the lower-level ones actually look pretty clean and modern. And yet all the documentation keeps talking about the c…

Indeed. I have fun making little web apps which serve a small single purpose and can be run from a single script[0] - templating using response/xexpr with paredit is.. well.. fun! Speed isn't a problem since I cache the result behind nginx - these aren't mission critical apps.

[0] Tokyo Art Parties parsed out of Tokyo art beat events xml - https://github.com/minikomi/tokyoartparties-rkt/blob/master/...

Re: Low-level web programming in Racket and a wiki in 500 lines

#17
post #13
post #8

Just being exposed to Racket last month I was extremely surprised at how well it clicked with me as opposed to Haskel which I tried to learn for a few months on my own and just tried out SML and it moved to Racket. Can't put a finger on it but Racket just makes sense to me.

Have you tried python..? You might like it

I was trying to get exposure to functional programming. Yes I use Python (less and less) for many years, but I certainly wish there was a python when I was a teenagers.

Re: Low-level web programming in Racket and a wiki in 500 lines

#18

Earlier quoted context omitted.

How exactly are you hung up with form data? Its low level, so you certainly can't get validation out of box, but otherwise in my experience getting form data out is fairly straight forward. I recently wrote my first Racket web app. Its not pretty or following best practices but you can take a look. https://github.com/vishesh/whalebin

Thank you! Your project was helpful to skim through. Do you have any additions to the web-project-bootstrap.rkt project? BTW, this is what I mean by form bindings being confusing: according to the docs, request-bindings is dangerous and shouldn't be used http://docs.racket-lang.org/web-server/http.html#%28mod-path... . That's kind of confusing, because request-bindings is used in the tutorial docs: http://docs.racket…

The problems are not really Racket specific. They arise from trying to validate, parse, and execute upon the arbitrary input that can be passed in request bindings. The fact that all values are turned into lower case bit my as I worked on my first web-app. Getting bit by a cross site scripting [XSS] attack would have been worse. There's just a lot of work that goes into producing production quality webb apps when the app is worth producing that can't be covered in a tutorial. The Continue tutorial is a high level overview of the tools Racket provides (e.g. interfacing with persistant storage). The More tutorial gets deeper under the hood and covers dispatching on URI's with a server. Dispatching is generally going to provide simpler contexts for dealing with user data.

Re: Low-level web programming in Racket and a wiki in 500 lines

#19
post #13
post #8

Just being exposed to Racket last month I was extremely surprised at how well it clicked with me as opposed to Haskel which I tried to learn for a few months on my own and just tried out SML and it moved to Racket. Can't put a finger on it but Racket just makes sense to me.

Have you tried python..? You might like it

Racket and Python aren't even remotely comparable as languages. Python is a far less sophisticated language with far richer libraries, and Racket is vice versa.

Re: Low-level web programming in Racket and a wiki in 500 lines

#20
post #3

I'm glad to see someone talking about using the lower-level web libraries in Racket. The high-level continuation-based ones are ridiculously unsuitable for actual web programming (they store full state on the server at all times, and the URL gives you full access to the session, among other issues), but the lower-level ones actually look pretty clean and modern. And yet all the documentation keeps talking about the c…

The continuation-based libraries are the simplest, easiest, quickest way to get a program off the ground. They make interactive Web programming just as easy as writing “scanf” or its equivalent, _and_ are safe in the face of various browser interactions. Therefore, they're a good default for prototyping. However, I agree that they also have issues, and the documentation should not over-emphasize them, but rather indicate what they are suitable for and what not and make clearer to readers a transition path out of there.
Post reply on HN