Hacker News new | ask | show | jobs
by neilv 1084 days 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/

2 comments

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.

It's hard to beat a skilled CL person who invests in making something fast.

But Scheme code can often be made faster, especially if you know the performance characteristics of the particular implementation.

Besides generally using good performance practices, know that Racket has some profilers that can be immensely helpful. (I once rigged up Racket's statistical profiler at the time to capture the data for each instance of certain kinds of very complicated Web requests in a production system, and used the reports to optimize the heck out of it.)

> But Scheme code can often be made faster,

I meant to say "But a given piece of Scheme code can often be made faster than it was before".

Is there an SXML library for CL? I wanted to build something like racket’s pollen in CL but couldn’t find an alternative for xexprs.
> 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.?

Great question. Not that I know of. (The SRFIs unfortunately aren't necessarily this.)

How it worked in the past was that people would ask or Web search as-needed, and then others would answer.

Unfortunately, with the demise of Usenet, there was fragmenting in where you had to go to ask, as a lot of people gravitated towards implementation-specific forums. For Racket (nee PLT Scheme), there was a wealth of good advise in the email lists, but at some point after hosting was moved to Google Groups, Google searches themselves seemed to stop finding many of the articles that were in Google's own archive, even when you explicitly directed the search.

I suppose the thing to do is to just ask on demand, in one of the forum for whatever implementation you're using. (The Racket community, for one, was exceedingly good at this, when I was more involved. And I suspect some of the other popular Scheme implementations are, as well.)