🙂 Joy to the web

Joy is a web framework written in janet for people who like lisp syntax, fast startup time and low memory usage.

Clojure-like syntax
Starts up fast, stays fast
New projects run in ~1 MB of RAM
  (import joy :prefix "")

  (route :get "/" :home)
  (defn home [request]
    (text/plain "You found joy!"))

  (def app (app))

  (server app 9001)
Installation on macOS
Janet can be installed with homebrew:
brew install janet
Then to install joy:
jpm install joy
More installation options for janet here
Data as html

Joy uses hiccup or html as data to render html. There is no separate template language to learn! You have all of janet's power when writing html!

    [:input {:type "text" :placeholder "Your name"}]]
    [:input {:type "email" :placeholder "Your email"}]
    [:input {:type "submit" :value "Submit"}]
    <input type="text" placeholder="Your name" />
    <input type="email" placeholder="Your email" />
    <input type="submit" value="Submit" />

There is a shorthand for css classes too! Great for atomic css!

    "You found joy!"]
  <h1 class="text-2xl text-gray-400">You found joy!</h1>

The real beauty of having a regular old data structure represent your html is that you can assign it to a variable and create your own names without changing the rendered html!

  (def h1 :h1.text-2xl.text-gray-400)

  [h1 "You found joy!"]
  <h1 class="text-2xl text-gray-400">You found joy!</h1>
Everything is a function!

Joy doesn't uses objects, classes or any other OOP-isms.

It's just functions (and some dynamically scoped vars). So when you organize your project in files and folders, there isn't this whole other set of organization on top.

In fact, unlike most web frameworks you can structure things how YOU want them. It's more like a grab bag of utility functions.

  # src/routes/todos.janet

  (import joy :prefix "")

  (route :get "/todos/new" :todos/new)
  (route :post "/todos" :todos/create)

  (defn todos/new [request]
    (form-for [request :todos/create]
      [:input {:type "text" :name "name"}]
      [:label {:for "finished"}
        [:input {:type "checkbox" :name "finished"}]
      [:input {:type "submit" :value "Submit"}]))

  (defn todos/create [request]
    (def {:body body} request)

    (def todo (->> (table/slice body [:name :finished])
                   (db/insert :todos)))

    (if todo
      (redirect-to :home)
      (todos/new (put request :error "There was a problem!"))))
Deploy a single binary

Say goodbye to complicated deploys that involve multiple runtime dependencies. Joy compiles to an executable.

Compile your code for the target machine, copy it over and start it up. Deploy finished.

  joy new easy-deploy
  cd easy-deploy
  jpm build
  ./build/easy-deploy # => Server listening on http://localhost:9001