Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>nynxy-compilerNew to Visual Studio Code? Get it now.
nynxy-compiler

nynxy-compiler

LaymGlitched

|
10 installs
| (0) | Free
A compiler for the nynxy language
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

NYNXY COMPILER

Nynxy Programming Language

Overview:

Nynxy is designed to be a blend of functional, declarative, and event-driven programming styles, with a syntax that emphasizes clarity and minimalism. It aims to encourage immutability, asynchronous operations, and seamless error handling. A unique aspect of Nynxy is its focus on context-awareness and interaction between code blocks (referred to as realms) that can influence each other.

1. Fundamentals

1.1) File Structure

Each Nynxy file represents a "Realm" which is a self-contained context of logic. The entry point of execution is denoted by @init. Code outside of a realm block will not be executed unless imported explicitly.

realm MyApp {
    @init {
        print("Welcome to Nynxy!")
    }
}

1.2) Variables & Constants

Variables are immutable by default and declared using let. Mutable variables must be explicitly declared with mut. Constants are declared with const and cannot be modified after initialization.

let name = "Nynxy"      // Immutable
mut counter = 0         // Mutable
const PI = 3.14159      // Constant

2. Data Types

2.1) Primitive Types

Number: Includes both integers and floating points. String: Denoted by double quotes. Boolean: true or false. Array: Declared with [ ]. Map: Declared with { key: value }.

let age = 25
let name = "Nynxy"
let isCool = true
let nums = [1, 2, 3, 4]
let data = { name: "Nynxy", version: 1.0 }

2.2) Custom Types

You can define new types using the type keyword, combining primitives or existing types.

type User {
    name: String,
    age: Number,
    active: Boolean
}

3. Functions

3.1) Basic Function Declaration

Functions are declared with the fn keyword. Parameters are typed, and return values are inferred unless explicitly stated. Functions are pure by default, with no side effects unless side is specified.

fn greet(name: String) {
    print("Hello, " + name)
}

fn add(a: Number, b: Number) -> Number {
    return a + b
}

3.2) Lambdas

Anonymous functions are created with -> syntax and can be stored in variables or passed around. nynxy

let square = (x: Number) -> x * x

4. Control Flow

4.1) Conditionals

Use if and else for conditional logic. Ternary expressions are allowed with ? :.

if age > 18 {
    print("Adult")
} else {
    print("Minor")
}

let status = (age > 18) ? "Adult" : "Minor"

4.2) Loops

Nynxy provides only for loops for iteration, discouraging traditional while loops to promote functional paradigms. You can iterate over ranges, arrays, or maps. nynxy

for i in 0..10 { print(i) }

for item in items { print(item) }

5. Concurrency & Async

5.1) Async Operations

Nynxy uses async and await for handling asynchronous functions. Any function can be marked async to indicate non-blocking execution.

async fn fetchData() -> String {
    return await networkCall()
}

5.2) Channels

Concurrency is handled using channels, allowing different realms to communicate asynchronously.

let channel = new Channel()

async fn sendMessage() {
    channel.send("Hello, World!")
}

async fn receiveMessage() {
    let msg = await channel.receive()
    print(msg)
}

6. Error Handling

Nynxy has a unique error-handling mechanism using try, catch, and handle. Errors are values in Nynxy and must be returned or handled explicitly.

fn divide(a: Number, b: Number) -> Result {
    if b == 0 {
        return Error("Division by zero")
    }
    return Ok(a / b)
}

let result = try divide(10, 0) catch {
    handle(error) {
        print("Caught error: " + error)
    }
}

7. Realms & Inter-Realm Communication

7.1) Realms as Modular Blocks

Each realm is isolated and encapsulates its own logic. Realms can communicate with one another using signals. Realms are initialized with @init and can emit or listen to events using on.

realm Game {
    @init {
        on("start") {
            print("Game Started!")
        }
    }
}

realm UI {
    @init {
        emit("start")  // This signals the Game realm to start
    }
}

8. Meta & Reflection

Nynxy allows for reflection using meta commands, allowing code to inspect or modify its own structure. meta blocks can be used to alter execution flow or introspect types.

meta {
    print(typeOf(name))  // Prints 'String'
}

Example Program: Simple Chat Application

realm ChatServer {
    let messages = []

    @init {
        on("sendMessage", fn (msg: String) {
            messages.append(msg)
            print("New message: " + msg)
        })
    }
}

realm Client {
    @init {
        emit("sendMessage", "Hello, Nynxy!")
    }
}

Unique Features of Nynxy

Realms:

Each file is a self-contained logic unit, making the language modular by design. Realms can communicate using events and signals, encouraging loose coupling and modularity.

Immutability by Default:

Emphasis on immutable data structures and pure functions to encourage functional programming practices.

Error as Value:

Errors are not exceptions but regular return values that must be handled explicitly.

Context-Aware Meta Programming:

Reflection and metaprogramming allow dynamic inspection and transformation of code.

Channel-Based Concurrency:

Asynchronous operations are made simple and safe through channels, avoiding race conditions. Nynxy combines the best aspects of functional and event-driven programming into a modern and safe language, designed for scalability and simplicity.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft