Hacker News new | ask | show | jobs
by dmux 1648 days ago
I've been having a wonderful time spinning up small projects using Tcl, Wapp, and Sqlite. Tcl's quoting rules makes it really easy to embed HTML (or anything else, really) inline within a procedure. Simple example:

    # available at /style.css
    proc wapp-page-style.css {} {
        wapp-mimetype text/css
        wapp-cache-control max-age=3600
        
        wapp-trim {
            body {
                background: aliceblue;
            }
        }


    }

    # available at /hello
    proc wapp-page-hello {} {
        wapp-trim {
            <html>
            <head>
                <link href="%url(style.css)" rel="stylesheet">
            </head>
                <body>
                    <h1>Hello HN!</h1>
                </body>
            </html>
        }
    }
2 comments

This is great! I write a lot of one-off utilities that run on my main desktop as web applications backed by sqlite so you're really speaking my language here!

I enjoyed the little bit of exposure that I had to Tcl/Tk through EXPECT, I used to write a lot of embedded test scaffolding using it back in the 00s. I've also been interested in checking out Little Language [0].

Wapp looks like a great place to start with Tcl.

[0]: https://www.little-lang.org/

I loved Tcl way back before I switched to Perl. So cool seeing Tcl and HTML combined like this!
There are several examples of small applications in the Wapp repository: https://wapp.tcl.tk/home/file?name=examples/

I especially like the shoplist one. Such a simple application that's immediately useful.