this post was submitted on 19 Apr 2023
3 points (71.4% liked)

General Programming Discussion

7803 readers
1 users here now

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

Systems

Functional Programming

Also related

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] yogthos@lemmy.ml 1 points 2 years ago

Yeah, I was curious about Lisp for a while, but just couldn't get into it until Clojure came out. I find the additional syntax for data literals makes a huge difference in readability. Janet takes a lot of the good parts of Clojure and packages them into a nice and small runtime.

Babashka is another similar project I can highly recommend. It's a Clojure runtime compiled against Graalvm, so it's also very lightweight and has instant startup. The nice part with Babashka is how batteries included it is. You have an HTTP server, you can connect to Postgres, parse JSON, etc. all works out of the box. And you can even do REPL driven development against it. You just run bb --nrepl-server and connect the editor to it. For example, here's a full blown HTTP server that can be run as a script:

#!/usr/bin/env bb
(require
  '[clojure.pprint :refer [pprint]]
  '[hiccup.core :as hiccup]
  '[org.httpkit.server :as server])


(defn handler [{:keys [uri server-name request-method]}]
  {:body
   (hiccup/html
      [:html
        [:body
         [:p "URI: " uri]
         [:p "server-name: " server-name]
         [:p "method: " request-method]]])})

(server/run-server handler {:port 3000})
(println "serving on port 3000")
@(promise)