(vekatze.github.io) Overview - Neut Programming Language

ROAM_REFS: https://vekatze.github.io/neut/overview.html

Neut is a functional programming language with static memory management.

Its key features include:

Neut doesn't use GCs or regions. Instead, it takes a type-directed approach to handle resources.

** What Does it Look Like?

Like the following:

// the obligated hello world
define hello(): unit {
  print("Hello, world!
")
}

// algebraic data types
data my-list(a) {
| Nil
| Cons(a, my-list(a))
}

// a recursive function with pattern matching
define noisy-length<a>(xs: my-list(a)): int {
  match xs {
  | Nil =>
    0
  | Cons(_, ys) =>
    let my-message = "hey
" in
    print(my-message);
    add-int(1, noisy-length(ys))
  }
}

** Static Memory Management — But How?

Neut translates a type into a function that can discard/copy the values of the type. By using those functions, the compiler translates programs so that every variable is used exactly once.

For example, if a variable is used twice, a translation like the following will happen:

// (before)
let xs: list(a) = [value-1, value-2] in
some-func(xs, xs) // `xs` is used twice

// ↓

// (after)
let xs: list(a) = [value-1, value-2] in
let (xs1, xs2) = copy-list-a(xs) in  // `xs` is used once
some-func(xs1, xs2)

If you need more, see How to Execute Types.

You may wonder: "So we need to, for example, copy the whole list just to get its length? Isn't it the end of the world?". This topic is covered in Static Memory Management. As written there, Neut avoids such copyings by using the T-necessity operator in modal logic to achieve something like borrowing in Rust.

** How Fast is This?

Please see the benchmarks.

** List of Other Basic Characteristics?

** Anything Else?

You might also find Neut's module system interesting. It distinguishes modules using the digests (checksums) of tarballs and defines module identities using version information. Although this is not the main point of the language, it still might be of interest. This topic is covered in the tutorial.

Also, Neut includes an LSP server, which provides things like code completion, error reporting on save, etc. See Lovely LSP Showcase to see it in action.

Local Graph

org-roam 776affc8-2d5a-4df1-9d06-c51ac2399981 (vekatze.github.io) Overview - Neut P... //vekatze.github.io/neut/overview.html#neut-programming-language https://vekatze.github.io/neut/overview.html#neut-programming-language 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/overview.html#neut-programming-language //vekatze.github.io/neut/overview.html#what-does-it-look-like https://vekatze.github.io/neut/overview.html#what-does-it-look-like 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/overview.html#what-does-it-look-like //vekatze.github.io/neut/overview.html#static-memory-management--but-how https://vekatze.github.io/neut/overview.html#static-memory-management--but-how 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/overview.html#static-memory-management--but-how //vekatze.github.io/neut/how-to-execute-types.html https://vekatze.github.io/neut/how-to-execute-types.html 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/how-to-execute-types.html //vekatze.github.io/neut/static-memory-management.html https://vekatze.github.io/neut/static-memory-management.html 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/static-memory-management.html //vekatze.github.io/neut/overview.html#how-fast-is-this https://vekatze.github.io/neut/overview.html#how-fast-is-this 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/overview.html#how-fast-is-this //vekatze.github.io/neut/benchmarks.html https://vekatze.github.io/neut/benchmarks.html 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/benchmarks.html //vekatze.github.io/neut/overview.html#list-of-other-basic-characteristics https://vekatze.github.io/neut/overview.html#list-of-other-basic-characteristics 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/overview.html#list-of-other-basic-characteristics //llvm.org/docs/LangRef.html https://llvm.org/docs/LangRef.html 776affc8-2d5a-4df1-9d06-c51ac2399981->//llvm.org/docs/LangRef.html //en.wikipedia.org/wiki/Calculus_of_constructions https://en.wikipedia.org/wiki/Calculus_of_constructions 776affc8-2d5a-4df1-9d06-c51ac2399981->//en.wikipedia.org/wiki/Calculus_of_constructions //en.wikipedia.org/wiki/Algebraic_data_type https://en.wikipedia.org/wiki/Algebraic_data_type 776affc8-2d5a-4df1-9d06-c51ac2399981->//en.wikipedia.org/wiki/Algebraic_data_type //vekatze.github.io/neut/lovely-lsp-showcase.html https://vekatze.github.io/neut/lovely-lsp-showcase.html 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/lovely-lsp-showcase.html //vekatze.github.io/neut/rapid-prototyping.html https://vekatze.github.io/neut/rapid-prototyping.html 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/rapid-prototyping.html //vekatze.github.io/neut/overview.html#anything-else https://vekatze.github.io/neut/overview.html#anything-else 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/overview.html#anything-else //vekatze.github.io/neut/hello-external-world.html https://vekatze.github.io/neut/hello-external-world.html 776affc8-2d5a-4df1-9d06-c51ac2399981->//vekatze.github.io/neut/hello-external-world.html