top | item 36533947

Systems Programming with Racket

164 points| r_sz | 2 years ago |docs.racket-lang.org

23 comments

order

neilv|2 years ago

Instead of that `xml` library and format, many people use the SXML format defined by Oleg Kiselyov:

https://docs.racket-lang.org/sxml-intro/

SXML became the de facto standard in the Scheme community after Oleg and others developed some powerful libraries for it, starting with Oleg's SSAX parser. SXML is also better-suited to efficient manipulation of large HTML/XML when using immutable lists.

Also, if you're looking at code examples in TFA, and thinking that, even when composing HTML using lists rather than strings, it's still susceptible to injection programming errors, then one SXML-ish improvement is:

https://docs.racket-lang.org/html-template/

https://docs.racket-lang.org/rws-html-template/

gglitch|2 years ago

I had an xml problem to solve at work, and used sxml to prototype solutions in CL and Guile. The CL solution was much (much) faster, but I ended up using Guile because the libraries are built in. Maybe I should try a Racket version.

To your point though - sxml is fantastic.

mighmi|2 years ago

> SXML became the de facto standard in the Scheme community

Is there a good guide to this kind of stuff as someone new to Scheme? Like a community intro, showing what the core packages are etc.?

nighmi|2 years ago

I've been working on porting golang's net/http and gorilla/websocket libs to Racket for the past few months (I don't like the servelet model.) Does anyone have insight into how that model might not be optimal in a Scheme enviroment or how to better optimize it?

veqq|2 years ago

Huh, I've actually been doing the same. Is your project public yet?

Are you stating with RFC 6455's implementation and just changing the API or trying to approximate the implementations?

gus_massa|2 years ago

I'm using the Racket webserver, but each page is it own rkt file. I'm using no continuations, just storing and reading everything in the hard disk. (I'm not sure it's optimal, but I prefer that approach.)

_aaed|2 years ago

Looks like Lisp's back on the menu boys

bitwize|2 years ago

Always has been.

Guile is absolutely amazing these days: it has a JIT for speed, superb POSIX support, plus you can dynamic-link in any functionality you need from a C library.

philbo|2 years ago

Realistically, how much data is it practical to stash inside these continuations? It seems like it could get out of hand quite quickly for non-toy examples.

If you were propagating e.g. game state, you'd still want to stick that in a db, so the continuation would just be a session id?

sheenobu|2 years ago

A continuation is a function that, when called, jumps back to a specific part of the program that was frozen (meaning current memory, the call stack, the line number). So it can't really be stored. If your game state was stored in a db, you'd still have to load it memory to perform operations on it. Those operations, if using continuations, would then stick around in memory while waiting the continuation to be resumed. If it's a multi-player game, then you'd be in real trouble as your continuation could end up with stale data.

Game state has to be propagated from the server to the client so the player knows what is happening where-as continuations as used in this article are more about avoiding this propagation (the hidden field in the example is replaced by dispatch-table tag which acts as a session id / location in the dispatch-table for finding the continuation function)