A fast, friendly, functional language. Work in progress!
Go to file
Folkert de Vries feaf53371f
Merge pull request #3113 from rtfeldman/new-utable-copy
New utable variable copy
2022-05-21 18:17:56 +02:00
.cargo Add env var for workspace root and scaffold builtins fmt test 2022-05-18 14:30:03 -04:00
.github/workflows Turn on concurrency groups for GitHub CI 2022-04-19 21:21:11 -04:00
.reuse Add .reuse/dep5 2022-02-14 09:30:21 -05:00
ast Use [u8; 16] to avoid number alignment bumps 2022-05-21 00:53:47 -04:00
bindgen fix bindgen::types tests 2022-05-21 00:09:56 -04:00
ci cargo fix --edition 2022-05-16 17:04:17 +02:00
cli Revise error message for Not Found 2022-05-20 11:30:57 -04:00
cli_utils Merge remote-tracking branch 'origin/trunk' into test-bindgen 2022-05-19 14:10:53 -04:00
code_markup cargo fix --edition 2022-05-16 17:04:17 +02:00
compiler Merge pull request #3113 from rtfeldman/new-utable-copy 2022-05-21 18:17:56 +02:00
docs Ability docs 2022-05-19 18:21:38 -04:00
docs_cli cargo fix --edition 2022-05-16 17:04:17 +02:00
editor cargo fix --edition 2022-05-16 17:04:17 +02:00
error_macros Combine aarch64 and non-aarch64 mono size assertions 2022-05-21 00:53:47 -04:00
examples Remove encode examples for now 2022-05-19 18:21:44 -04:00
getting_started recommend using legacy linker for hello C and Zig for now 2022-04-22 08:57:47 +02:00
highlight cargo fix --edition 2022-05-16 17:04:17 +02:00
linker cargo fix --edition 2022-05-16 17:04:17 +02:00
meeting_notes Remove accidental trailing spaces 2022-01-18 22:25:46 -07:00
nightly_benches Remove unnecessary -> () function return types 2022-05-18 08:29:40 -04:00
nix Bump debugir to use LLVM 13 2022-05-10 09:19:40 -04:00
packages Opaques take @ : %s/\$\([A-Z]\)/@\1/g 2022-04-25 12:26:38 -04:00
repl_cli Upgrade const_format 2022-05-11 10:47:56 -04:00
repl_eval Use single-threaded builds in tests 2022-05-05 14:42:36 -04:00
repl_test add wasmer dependency again in the repl_test crate 2022-05-07 15:46:42 +02:00
repl_wasm Pass precompiled host bytes to gen_wasm in CLI 2022-05-15 11:11:08 +01:00
repl_www repl_www: match text styling to CLI 2022-03-17 10:40:47 +00:00
reporting Merge pull request #3108 from rtfeldman/check-derived2 2022-05-21 11:39:18 -04:00
roc_std Merge pull request #3112 from rtfeldman/roc-dec-alignment 2022-05-21 10:55:57 -04:00
test_utils Add env var for workspace root and scaffold builtins fmt test 2022-05-18 14:30:03 -04:00
utils cargo fix --edition 2022-05-16 17:04:17 +02:00
vendor Fix some size_hint calls to use lower bound 2022-05-16 11:59:41 -04:00
wasi-libc-sys cargo fix --edition 2022-05-16 17:04:17 +02:00
www Have www/build.sh use cargo run --bin roc-docs 2022-05-08 22:10:58 -04:00
.earthignore fixed dir copying issue, added earthignore, fixed typos, set up typo checking for CI 2021-06-07 14:55:35 +02:00
.gitignore Remove accidental trailing spaces 2022-01-18 22:25:46 -07:00
.llvmenv updated nix editor instructions 2022-05-10 14:25:13 +02:00
AUTHORS Add Drake Bennion to AUTHORS 2022-05-16 21:48:24 -04:00
BUILDING_FROM_SOURCE.md Merge pull request #3054 from rtfeldman/nix-editor 2022-05-11 16:06:49 -04:00
Cargo.lock Use [u8; 16] to avoid number alignment bumps 2022-05-21 00:53:47 -04:00
Cargo.toml Add docs_cli crate 2022-05-08 22:03:15 -04:00
CODE_OF_CONDUCT.md Rename CodeOfConduct.md to CODE_OF_CONDUCT.md 2022-04-10 19:06:05 +08:00
CONTRIBUTING.md Check clippy for --release warnings too 2022-05-18 08:19:21 -04:00
Earthfile workspace env on CI 2022-05-18 16:12:29 -04:00
FAQ.md Update FAQ.md 2022-04-10 19:36:41 +08:00
flake.lock updated zig and llvm for nix flake 2022-05-09 14:55:29 +02:00
flake.nix updated nix editor instructions 2022-05-10 14:25:13 +02:00
LEGAL_DETAILS remove unused install-ci-libraries.sh 2022-05-09 09:24:37 +02:00
LICENSE Use © instead of (c) for copyright symbol 2021-05-03 21:18:36 -04:00
name-and-logo.md Grammar edit 2022-04-08 23:54:11 -04:00
README.md Build builtin docs from builtins/roc 2022-05-01 15:30:50 -04:00
roc-for-elm-programmers.md Revise roc-for-elm-programmers.md 2022-04-25 17:04:34 -04:00
rust-toolchain.toml update rust toolchain file 2022-05-02 18:23:36 +02:00
shell.nix Merge remote-tracking branch 'origin/trunk' into update_zig_09 2022-05-07 19:38:04 +02:00
TUTORIAL.md Added typed, hexadecimal, and binary literals to tutorial. 2022-04-24 15:15:25 -07:00
version.txt Revise some CLI flag descriptions 2022-04-20 11:42:19 -04:00

The Roc Programming Language

Roc is a language for making delightful software.

The tutorial is the best place to learn about how to use the language - it assumes no prior knowledge of Roc or similar languages. (If you already know Elm, then Roc for Elm Programmers may be of interest.)

There's also a folder of examples - the CLI example in particular is a reasonable starting point to build on.

If you have a specific question, the FAQ might have an answer, although Roc Zulip chat is overall the best place to ask questions and get help! It's also where we discuss ideas for the language. If you want to get involved in contributing to the language, Zulip is also a great place to ask about good first projects.

State of Roc

Roc is not ready for production yet. You are likely to encounter bugs. Publishing packages or documentation is not yet supported. Many programs can however be compiled correctly. Check out examples and examples/benchmarks. There are minimal platforms for Rust, Zig, C, Swift and an HTTP server. We are hard at work to make programming in Roc a delightful experience!

Getting started

Examples

Run examples as follows:

cargo run examples/hello-world/helloWorld.roc

Some examples like examples/benchmarks/NQueens.roc require input after running. For NQueens, input 10 in the terminal and press enter.

examples/benchmarks contains larger examples.

Tip: when programming in roc, we recommend to execute ./roc check myproject/Foo.roc before ./roc myproject/Foo.roc or ./roc build myproject/Foo.roc. ./roc check can produce clear error messages in cases where building/running may panic.

Sponsors

We are very grateful for our sponsors NoRedInk and rwx.

NoRedInk logo      rwx logo

Applications and Platforms

Applications are often built on a framework. Typically, both application and framework are written in the same language.

  • Rails applications are written in Ruby, and so is Rails.
  • Angular applications are written in TypeScript, and so is Angular.
  • Phoenix applications are written in Elixir, and so is Phoenix.

Some programs support plugins. Often the plugins are written in the same language as the underlying program.

  • Webpack plugins are written in JavaScript, and so is Webpack.
  • Eclipse plugins are written in Java, and so is Eclipse.
  • Leiningen plugins are written in Clojure, and so is Leiningen.

All of these can be considered examples of a platform/application relationship. There is an underlying platform, and many applications are built on top of it. (Plugins are a type of application in this sense.)

Sometimes, platforms and their applications are written in different languages.

  • Neovim is written in C for performance, and its plugins can be written in languages such as Python, JS, and Ruby.
  • NGINX is written in C for performance, and its plugins can be written in a subset of JavaScript.
  • Unity is written in C++ for performance, and Unity applications (such as games) can be written in C#, Boo, or a JavaScript dialect called UnityScript.

Like in the previous examples, application authors building on these platforms get to use high-level languages with automatic memory management. They make no ergonomics sacrifices, and may not even be aware that the underlying platform is written in a lower-level language.

By using systems-level programming languages like C and C++, platform authors sacrifice development speed, but unlock the highest possible performance characteristics. This is a tradeoff many platform authors are happy to accept, for the sake of having applications built on their platforms run very fast.

Roc's Design

Roc is designed to make the "systems-level platform, higher-level application" experience as nice as possible.

  • Application authors code exclusively in Roc. It's a language designed for nice ergonomics. The syntax resembles Ruby or CoffeeScript, and it has a fast compiler with full type inference.
  • Platform authors code almost exclusively in a systems-level language like C, C++, Rust, Swift or Zig, except for the thin Roc API they expose to application authors. Roc application code compiles to machine code, and production builds of Roc apps benefit from the same LLVM optimizations that C++, Rust, Swift and Zig do. Roc application authors do not need to know this lower-level code exists; all they have to interact with is the platform's API, which is exposed as an ordinary Roc API.

Every Roc application is built on top of exactly one Roc platform. There is no such thing as a Roc application that runs without a platform, and there is no default platform. You must choose one!

The core Roc language and standard library include no I/O operations, which gives platform authors complete control over which effects they want to support. Some of the implications of this include:

  • A high-performance build tool (or text editor) written in Rust can be a Roc platform with a strong plugin security model. For example, it could expose only operations allowing plugin authors to modify the contents of certain files, rather than allowing plugins arbitrary read/write access to the entire filesystem.
  • A VR or Arduino platform can expose uncommon I/O operations supported by that hardware, while omitting common I/O operations that are unsupported (such as reading keyboard input from a terminal that doesn't exist).
  • A high-performance Web server written in Rust can be a Roc platform where all I/O operations are implemented in terms of Streams or Observables rather than a more traditional asynchronous abstraction like Futures or Promises. This would mean all code in that platform's ecosystem would be necessarily built on a common streaming abstraction.

Project Goals

Roc is in relatively early stages of development. It's currently possible to build both platforms and applications (see the examples folder for some examples that aren't particularly organized at the moment), although documentation is in even earlier stages than the compiler itself.

Besides the above language design, a separate goal is for Roc to ship with an ambitiously boundary-pushing graphical editor. Not like "an IDE," but rather something that makes people say "I have never seen anything remotely like this outside of Bret Victor demos."

One of the reasons this editor is coupled with the language itself is to allow package authors to include custom editor tooling inside packages.

A trivial example: suppose I'm writing a Roc app for an Arduino platform. I install a platform-specific package for displaying text on a grid of LEDs. Because I've installed this package, at the call site where I call the function to specify the color of the text on the LEDs, my Roc editor displays an inline color picker. As I move a slider around to try out different colors, not only does my code change to reflect that value in realtime, but the physical LEDs in my room change color in realtime as well. As the application author, all I did to get that experience was to install the "text on an LED grid" package, nothing else.

The goal is for this to be one of the most trivial, bare minimum examples of what the editor experience would be like. Hopefully, people in the future will look back on this example and say "that's so embarrassingly basic; why didn't you talk about one of the actually great things in the seamless editor plugin ecosystem?"

Finally, some implementation goals:

  • The web server for the package manager is written in Roc (with an underlying Rust platform for the web server, for example warp).
  • The editor plugins are written in Roc (with an underlying Rust platform for the editor itself, for example using gfx-hal).
  • The CLI (for building Roc projects on CI platforms) has its user interface written in Roc (with an underlying Rust platform for fast compilation and basic CLI interactions).

It's an ambitious project! It'll take a long time to get where it's going, but hopefully it'll be worth the wait.

Getting Involved

The number of people involved in Roc's development has been steadily increasing over time - which has been great, because it's meant we've been able to onboard people at a nice pace. (Most people who have contributed to Roc had previously never done anything with Rust and also never worked on a compiler, but we've been able to find beginner-friendly projects to get people up to speed gradually.)

If you're interested in getting involved, check out CONTRIBUTING.md!

If you're curious about where the language's name and logo came from, here's an explanation.