DEV Community

Void
Void

Posted on

Arc v0.0.1-alpha - A Lightweight C-Based Programming Language

We are excited to announce the first alpha release of Arc, a lightweight, C-based programming language and interpreter designed for simplicity, performance, and educational clarity.

Version Overview

  • Version: v0.0.1-alpha
  • Status: Alpha (Experimental)
  • License: GPL-3.0

This initial release establishes the foundational pipeline of the Arc language, from lexical analysis to AST-based interpretation, featuring a robust set of core language constructs and a custom memory management system.

Key Features

Language Core

  • Variable System: Declaration and updates using the VAR keyword.
  • Functions: Support for custom functions (FN) with parameters and RETURN values.
  • Control Flow: Conditional branching with IF, THEN, ELIF, and ELSE.
  • Iterative loops with WHILE, FOR, and THEN.
  • Loop control with BREAK and CONTINUE.
  • Exception Handling: Graceful error recovery using TRY...CATCH blocks.
  • Data Types: Integrated support for Numbers (Integers/Floats), Strings, Booleans, and Lists.
  • Import System: Modularize projects by importing other .arc files using IMPORT.

Syntax Highlights

  • Case Sensitivity: Keywords (e.g., VAR, WHILE, IF) are case-insensitive.
  • Identifiers (variable and function names) are case-sensitive.
  • Operators: Comprehensive set of arithmetic (+, -, *, /, ^), comparison (==, !=, <, >, <=, >=), and logical (AND, OR, NOT) operators.
  • Comments: Single-line comments starting with #.

Built-in Standard Library

  • I/O Operations: print, get_input, open_file, read_file, write_file, close_file.
  • Data Manipulation: len_of, typeof, to_int, split_string, append_list, range.
  • Math Library: A comprehensive math.arc providing constants (PI, E) and functions (sin, cos, tan, sqrt, log, etc.).

Tooling & CLI

  • Arc comes with a powerful CLI and an interactive REPL:

  • Interactive REPL: Run code line-by-line with syntax highlighting.

CLI Options

--debug (-d): View tokens and AST tree during execution.
--code (-c): Execute a string of code directly.
--float-precision (-p): Control decimal output.
--mempool-size (-m): Tune the custom memory allocator.
--last-result (-l): Print the result of the last evaluated expression.
--disable-colored-formatting (-n): For plain text environments.

Architecture

Clean Pipeline: Modular separation of Lexer, Parser, AST, and Interpreter.
Memory Management: Implements a Memory Pooling system to minimize malloc/free overhead and prevent fragmentation.
Zero External Dependencies: Built entirely in standard C.

Getting Started

Prerequisites

  • GCC or Clang
  • Make

Build

make release
Run
./arc script.arc

Roadmap

  • Scoped environments for local variables.
  • Bytecode Virtual Machine (VM) for improved execution speed.
  • Expanded standard library (Networking, JSON support).
  • Enhanced REPL with history and auto-completion.

Arc is currently in alpha. We welcome feedback and contributions as we move toward a stable 1.0 release.

Top comments (0)