This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
(defn send-repl [& [obj]] | |
(let [in-in (java.io.PipedInputStream.) | |
in-out (java.io.PipedOutputStream. in-in) | |
out-in (java.io.PipedInputStream.) | |
out-out (java.io.PipedOutputStream. out-in) | |
err-in (java.io.PipedInputStream.) | |
err-out (java.io.PipedOutputStream. err-in)] | |
(tap> {:repl/in (clojure.java.io/writer in-out) | |
:repl/out (clojure.java.io/reader out-in) |
This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
(ns clipboard.core | |
(:require [fipp.edn :as fipp]) | |
(:import (java.awt.datatransfer DataFlavor Transferable StringSelection) | |
(java.awt Toolkit) | |
(java.io StringWriter)) | |
(defn get-clipboard | |
"get system clipboard" | |
[] | |
(-> (Toolkit/getDefaultToolkit) |
(ns com-widdindustries-statsatom | |
"A drop-in replacement for clojure.core/atom | |
The difference is that this record the following stats, held in the atom's metadata: | |
- number of times updated via swap!/swap-vals! and | |
- number of attempts made to do those updates | |
Clearly these stats themselves need to be atomically updated so there's some overhead added there. | |
" | |
(:refer-clojure :exclude [atom]) |
javascript:(function() { | |
function copyToClipboard(text) { | |
if (window.clipboardData && window.clipboardData.setData) { | |
/*IE specific code path to prevent textarea being shown while dialog is visible.*/ | |
return clipboardData.setData("Text", text); | |
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { | |
var textarea = document.createElement("textarea"); | |
textarea.textContent = text; |
{ config, pkgs, lib, ... }: | |
{ | |
# This sway config is mostly based on https://nixos.wiki/wiki/Sway | |
# which integrates sway with systemd in the style described here | |
# https://github.com/swaywm/sway/wiki/Systemd-integration | |
# and the replies in https://github.com/NixOS/nixpkgs/issues/57602 | |
# with some individual packages added/removed and using sddm as the display manager. | |
# | |
# Take care to start the correct target as described by the sway proejct wiki. |
;; missionary solution to petrol pump example by Stephen Blackheath and Anthony Jones, ISBN 978-1633430105 | |
;; huanhulan's demo : [live](https://huanhulan.github.io/petrol_pump), [code](https://github.com/huanhulan/petrol_pump) | |
(ns pump | |
(:refer-clojure :exclude [first]) | |
(:require [missionary.core :as m]) | |
(:import missionary.Cancelled)) | |
(defn rising | |
"A transducer that outputs `nil` when the input switches from logical false to logical true." |
I'll preface this with three things. 1. I prefer schemes over Common Lisps, and I prefer Racket of the Schemes. 2. There is more to it than the points I raise here. 3. I assume you have no previous experience with Lisp, and don't have a preference for Schemes over Common Lisp. With all that out of the way... I would say Common Lisp/SBCL. Let me explain
Now as to why Common Lisp over Scheme
;; Comments | |
(comment (any-valid clojure-form :is fine?)) ; end of line comments | |
#_i-am-commented-out "but I am not" | |
;; Values | |
5 3 1/3 0.5 "hello" :keyword | |
;; Lists | |
[1 2 3] ;; Vector - Good for finite, short lists | |
'(1 2 3) ;; seq - Good for infinite, long lists |
;; use spec to define stateful protocols inspired by UBF(b) | |
;; https://ubf.github.io/ubf/ubf-user-guide.en.html | |
(require '[clojure.spec.alpha :as s] | |
'[clojure.core.async :as async]) | |
(defn ubfish | |
"Takes a protocol definition and four channels. Checks for protocol | |
violations while copying from-server to-client and from-client | |
to-server." |