eriksvedang / Carp
- четверг, 7 июля 2016 г. в 03:13:16
C
a statically typed lisp, without a GC, for high performance applications
WARNING! This is a research project and a lot of information here might become outdated and misleading without any explanation. Don't use it for anything important just yet!
Carp is a small programming language designed to work well for interactive and performance sensitive use cases like games, sound synthesis and visualizations.
The key features of Carp are the following:
(import gl)
(defn init []
0f)
(defn tick [state]
(+ state 0.15f))
(defn draw [state]
(let [t @state
steps 100
step (/ 1f (itof steps))]
(for (i 0 steps)
(let [r (* step (itof i))
r2 (+ r step)]
(draw-line (* r (cosf (* t r)))
(* r (sinf (* t r)))
(* r2 (cosf (* t r2)))
(* r2 (sinf (* t r2))))))))
(defn spin []
(glfw-app "Spin" init tick draw default-on-keys))
To build this example, save it to a file called 'example.carp' and load it with (load-lisp "example.carp")
, then execute (bake-exe spin)
to build an executable, or (spin)
to run the program directly from the REPL.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
© Erik Svedäng 2015 - 2016