2016-01-11 16:52:26 +03:00
# Carp
2016-01-11 16:55:03 +03:00
2016-01-18 20:15:58 +03:00
[![Join the chat at https://gitter.im/eriksvedang/Carp ](https://badges.gitter.im/eriksvedang/Carp.svg )](https://gitter.im/eriksvedang/Carp?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge& utm_content=badge)
2016-07-13 14:18:21 +03:00
< img src = "https://github.com/carp-lang/Carp/blob/master/img/carp_logo_300_c.png" alt = "Logo" align = "right" / >
2016-01-11 17:46:14 +03:00
2017-05-07 10:29:19 +03:00
< i > 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!< / i >
2017-05-07 10:27:19 +03:00
2017-11-26 11:53:25 +03:00
< i > Update (June 26, 2017): The total rewrite is now live; if you want to look at the old version, it's under the branch named "c" in this repository.< / i >
2017-05-07 10:29:39 +03:00
2017-05-07 10:30:01 +03:00
## About
2016-01-11 17:57:24 +03:00
Carp is a small programming language designed to work well for interactive and performance sensitive use cases like games, sound synthesis and visualizations.
2016-01-11 17:46:14 +03:00
The key features of Carp are the following:
2016-01-11 18:59:43 +03:00
* Automatic and deterministic memory management (no garbage collector or VM)
2016-01-11 18:55:41 +03:00
* Inferred static types for great speed and reliability
2017-11-26 11:53:25 +03:00
* Ownership tracking enables a functional programming style while still using mutation of cache-friendly data structures under the hood
* No hidden performance penalties – allocation and copying are explicit
* Straightforward integration with existing C code
2016-01-11 17:57:24 +03:00
2016-03-18 09:40:57 +03:00
## Learn more
2016-02-18 12:46:31 +03:00
2016-09-01 16:58:54 +03:00
* [Installation ](docs/Install.md ) - how to build the Carp compiler
2017-06-26 13:04:39 +03:00
* [The Compiler Manual ](docs/Manual.md ) - how to compile code and configure your projects
2016-09-01 17:00:59 +03:00
* [Carp Language Guide ](docs/LanguageGuide.md ) - syntax and semantics of the language
2017-11-26 11:53:25 +03:00
* [Libraries ](docs/Libraries.md ) - the various libraries that come built into Carp
2017-11-03 16:08:27 +03:00
* [Tooling ](docs/Tooling.md ) - supported editors
2017-06-26 13:14:04 +03:00
* [Game Example ](examples/game.carp ) - an example of how to use SDL with Carp
2016-01-13 16:12:42 +03:00
2017-11-26 11:53:25 +03:00
The Carp REPL has built-in documentation, run ```(help)``` to access it!
2016-01-13 16:12:42 +03:00
2017-06-26 12:22:55 +03:00
## A Small Example
2016-01-19 15:52:00 +03:00
2016-01-12 13:02:15 +03:00
```clojure
2017-09-06 15:43:41 +03:00
(use IO)
(use Int)
(use String)
2017-06-26 12:22:55 +03:00
(defn main []
2017-10-10 14:23:00 +03:00
(do (println "~ The number guessing game ~")
(print "Please enter a number between 1 - 99: ")
2017-06-26 12:22:55 +03:00
(let [play true
answer (random-between 1 100)]
(while play
(let [guess (get-line)
2017-10-10 14:23:00 +03:00
num (from-string & guess)]
2017-11-27 23:58:31 +03:00
(if (= & guess "q\n")
2017-06-26 12:22:55 +03:00
(do
2017-10-10 14:23:00 +03:00
(println "Good bye...")
(set! & play false))
2017-06-26 12:22:55 +03:00
(do
2017-10-13 10:10:29 +03:00
(cond (< num answer ) ( println " Too low . " )
(> num answer) (println "Too high.")
(println "Correct!"))
2017-10-10 14:23:00 +03:00
(print "Please guess again: "))))))))
2016-01-18 18:39:14 +03:00
```
2017-11-26 11:53:25 +03:00
To build this example, save it to a file called 'example.carp' and load it with ```(load "example.carp")```, then execute ```(build)``` to build an executable, and ```(run)``` to start.
2016-01-12 13:02:15 +03:00
2016-01-12 13:08:32 +03:00
2016-03-18 09:40:57 +03:00
### Contributors
2016-01-12 13:08:32 +03:00
2016-06-09 00:58:11 +03:00
* Erik Svedäng [@e_svedang ](https://twitter.com/e_svedang )
2016-03-18 09:40:57 +03:00
* Markus Gustavsson
2016-03-23 21:45:32 +03:00
* Fyodor Shchukin
2016-06-20 07:34:46 +03:00
* Anes Lihovac
2016-07-04 11:09:16 +03:00
* Chris Hall
2016-07-11 08:24:45 +03:00
* Tom Smeding
2016-07-11 08:33:48 +03:00
* Dan Connolly
2016-07-11 10:17:27 +03:00
* Reini Urban
2016-07-13 13:21:35 +03:00
* Anes Lihovac
2016-07-14 21:25:36 +03:00
* Jonas Granquist
2017-10-20 09:54:21 +03:00
* Veit Heller
2016-02-18 12:46:31 +03:00
2016-08-23 16:42:39 +03:00
2016-01-19 15:29:06 +03:00
## License
2017-06-26 12:22:55 +03:00
Copyright 2016 - 2017 Erik Svedäng
2016-08-23 16:42:39 +03:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
2016-01-19 15:29:06 +03:00
2016-08-23 16:42:39 +03:00
http://www.apache.org/licenses/LICENSE-2.0
2016-01-19 15:29:06 +03:00
2016-08-23 16:42:39 +03:00
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.