Jump to content

User:Codyferd

From Wikipedia, the free encyclopedia
Donut
ParadigmMulti-paradigm: object-oriented, functional, expression-oriented
First appeared2025
Stable release
Concept
Typing discipline Static, Strong, type-inferred, null-safe
OSCross-platform (WORA)
LicenseUniversal Public Domain License
Major implementations
DonutSDK
Influenced by
Rust, Python, Kotlin, Dart, Haskell, Lua

Donut is a high-level, general-purpose programming language developed in 2025. It combines object-oriented and functional paradigms with a strong emphasis on immutability, safety, and simplicity. Donut code is executed on the DonutVM via just-in-time compilation and can be packaged into portable .bun archives for cross-platform distribution.

Design Goals

[edit]

Immutability by default: variables, structures, and functions are immutable unless explicitly marked !.

Static typing with inference: types are checked at compile time, with optional explicit annotation.

Null safety: nullable types are declared with ?.

Simplicity: Python-style whitespace syntax, no braces or semicolons, snake_case identifiers.

Performance & Safety: built-in garbage collection and memory safety on DonutVM.

Flexibility: Hybrid OOP (“everything is an object”) without enforced class hierarchy), expression-oriented design.


Syntax and Features

[edit]

Variables and Types

[edit]

Donut supports primitive and compound types with optional bit-precision suffixes:

var name = "Donut"  // Immutable string (inferred str)
var! count = 0// Mutable integer (inferred flo64 by default unless lit used)
var age: flo = 21.0// Explicit float
var maybe: str? = null// Nullable string

Bit-sizes: int32, int64, int128, flo16, flo32, flo64, flo128, str16, str32

Control Flow

[edit]

Conditionals:

 if x > 0 println("Positive") else println("Non-positive")

Loops:

 for i in 1..10 println(i)


for _ in 1... println("Forever")

=== Functions === Functions are immutable by default; use key fn to prevent redefinition or internal mutation.

 fn greet(name) return "Hello, $name"

key fn add(a: flo, b: flo): flo return a + b

Collections

[edit]

Lists (1-based, wraparound indexing):

 var! items = list(1, 2, 3) println(items[-1])  // 3

Hashmaps (index with [], key-access with ()):

 var map = hash("A" = 1, "B" = 2) println(map[2])     // 2 println(map("B"))   // 2


=== Input & Error Handling ===

 try var! x = io("Enter number: "): flo catch println("Invalid input")

=== Async/Await ===

 async fn fetch_data(url: str): str var! result = await http.get(url) return result

Tooling

[edit]

=== DonutSDK === The DonutSDK includes:

DonutVM (Rust): JIT compiler and runtime

CLI tools (Rust): donut, donut chocolate, donut vanilla

DonutDaemon: hot-reloading development server

GUI frontends (Flutter/Dart): visual wrappers for CLI commands

Package manager: donut chocolate add, repo add, fetch


Commands

[edit]

donut main.donut — run file

donut start main.donut — hot-reload mode

donut bun — package into .bun archive

donut bun extract <bun> <dir> — extract archive

donut bun key <bun> — show SHA256 signature

donut chocolate add <pkg> — add dependency

donut vanilla — compile to native binary


Project Structure

[edit]

A typical Donut project (optional layout):

.bunignore
lib/            → dependencies
main.donut      → entry point
main.yml        → manifest
main.lock       → lockfile
bun.key         → archive signature
.bunsettings    → package settings
.bundata        → metadata
readme.txt      → documentation
license.txt     → license

== Access Modifiers ==

public (default): visible & usable

key: immutable seal (no mutation)

lock: usage barrier (cannot be invoked externally)

private, pclass, pfn, pw: controlled visibility


Numeric System

[edit]

Default type: flo64 (unless preceded by lit)

Mixed intN + floM → flo of max bit size, capped to CPU width

Overflow splitting: large numbers split into native-sized chunks

Rounding cutoff: insignificant digits beyond float precision limit are rounded


== License == Donut is released under the Universal Public Domain License (2025).

See Also

[edit]

Garbage collection (computer science)

Just-in-time compilation

Functional programming

Object-oriented programming