When is language-oriented programming valuable?
When you want to become rich enough to donate a building to your alma mater.
When you want to reduce the notation.
(seq bos "f" (+ "o") (* (submatch "bar")) eos)
#rx"^fo+(bar)*$"
#lang scribble/manual
@(require (for-label json))
@title{jsonic: because JSON is boring}
@author{Roxy Lexington}
@defmodulelang[jsonic]
@section{Introduction}
This is a domain-specific language
that relies on the @racketmodname[json] library.
In particular, the @racket[jsexpr->string] function.
If we start with this:
@verbatim|{
#lang jsonic
[
@$ 'null $@,
@$ (* 6 7) $@,
@$ (= 2 (+ 1 1)) $@
]
}|
We'll end up with this:
@verbatim{
[
null,
42,
true
]
}
#lang pollen
My DSL ◊link["https://pollenpub.com"]{Pollen} is a language for making online books. And never again typing angle brackets.
When you want enlarge the notation.
#lang pollen/markdown
I am **so** excited to be student #◊(* 6 7) at [Racket School]("https://school.racket-lang.org").
#lang brag
bf-program : (bf-op | bf-loop)*
bf-op : ">" | "<" | "+" | "-" | "." | ","
bf-loop : "[" (bf-op | bf-loop)* "]"
#lang typed/racket
(: gt : Integer Integer -> Boolean)
(define (gt x y) (> x y))
(gt 5.0 4.0)
See also: Unicode prep language
When the program is largely configurational.
#lang info
(define collection "jsonic")
(define version "1.0")
(define scribblings '(("scribblings/jsonic.scrbl")))
(define test-omit-paths '("jsonic-test.rkt"))
(define deps '("base"
"beautiful-racket-lib"
"brag"
"draw-lib"
"gui-lib"
"br-parser-tools-lib"
"rackunit-lib"
"syntax-color-lib"))
(define build-deps '("scribble-lib"))
#lang riposte
$productId := 41966
$qty := 5
$campaignId := 1
$payload := {
"product_id": $productId,
"campaign_id": $campaignId,
"qty": $qty
}
POST $payload cart/{uuid}/items responds with 200
$itemId := /items/0/cart_item_id
GET cart responds with 200
When you want to create notation usable by nonprogrammers (or lazy programmers).
#lang txtadv-demo
===VERBS===
north, n
"go north"
south, s
"go south"
get _, grab _, take _
"take"
===THINGS===—cactus—get
"You win!"
===PLACES===—meadow—"Welcome to the Cactus Game! You're standing in a meadow. There is a desert to the south."
[]
south
desert—desert—"You're in a desert. There is nothing for miles around."
[cactus]
north
meadow
===START===
meadow
Hybrids are possible.
#lang lindenmayer racket
## axiom ##
X
## rules ##
X -> F[+X]F[-X]+X
F -> FF
## variables ##
n=7
θ=20
=============================================
(require lindenmayer/turtle)
(provide (all-from-out lindenmayer/turtle) X)
(define (X turtles variables) turtles)
To computer scientists, notation is boring, because they study programs, not people. S-expressions often suffice.
In the real world, it’s important, because software is a tool, so the ergonomics matter. S-expressions often don’t suffice.