NYNXY COMPILERNynxy Programming LanguageOverview: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. Fundamentals1.1) File StructureEach 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.
1.2) Variables & ConstantsVariables 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.
2. Data Types2.1) Primitive TypesNumber: Includes both integers and floating points. String: Denoted by double quotes. Boolean: true or false. Array: Declared with [ ]. Map: Declared with { key: value }.
2.2) Custom TypesYou can define new types using the type keyword, combining primitives or existing types.
3. Functions3.1) Basic Function DeclarationFunctions 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.
3.2) LambdasAnonymous functions are created with -> syntax and can be stored in variables or passed around. nynxy let square = (x: Number) -> x * x 4. Control Flow4.1) ConditionalsUse if and else for conditional logic. Ternary expressions are allowed with ? :.
4.2) LoopsNynxy 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 & Async5.1) Async OperationsNynxy uses async and await for handling asynchronous functions. Any function can be marked async to indicate non-blocking execution.
5.2) ChannelsConcurrency is handled using channels, allowing different realms to communicate asynchronously.
6. Error HandlingNynxy has a unique error-handling mechanism using try, catch, and handle. Errors are values in Nynxy and must be returned or handled explicitly.
7. Realms & Inter-Realm Communication7.1) Realms as Modular BlocksEach 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.
8. Meta & ReflectionNynxy 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.
Example Program: Simple Chat Application
Unique Features of NynxyRealms: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. |