Skip to content

Latest commit

History

71 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

NovaLang

NovaLang

English | 简体中文

BuildJitPackReleaseJava 8+Code SizeStars

Kotlin-inspired syntax · Seamless Java interop · Async/await · TypeScript-friendly

WebsiteFeaturesQuick StartExamplesDocumentationArchitecture


Features

Modern Syntax

Kotlin-inspired syntax that's concise, expressive, and easy to learn.

val name = "Nova"
var count = 0
fun greet(who: String): String {
return "Hello, $who!"
}
class Point(val x: Int, val y: Int) {
fun distance(): Double = sqrt(x * x + y * y)
}

Async/Await Support

Built-in asynchronous programming with async/await.

val result = async {
// concurrent computation
heavyComputation()
}
println(await result)

Java Interoperability

Seamlessly call Java classes and implement Java interfaces.

import java java.util.ArrayList
import java java.lang.Runnable
val list = ArrayList<String>()
list.add("Hello")
val runner = object : Runnable {
fun run() {
println("Running from Nova!")
}
}

Rich Type System

  • Classes, interfaces, enums, and objects
  • Generic types with reified type parameters
  • Extension functions
  • Nullable types with safe operators (?., ?:, !!)

Standard Library

Comprehensive stdlib with collections, I/O, JSON, HTTP, and more.

val numbers = [1, 2, 3, 4, 5]
val doubled = numbers.map { it * 2 }
val filtered = numbers.filter { it > 2 }
val json = parseJson("{\"name\": \"Nova\"}")
println(json["name"])

Multiple Execution Modes

  • REPL: Interactive shell for experimentation
  • Script: Execute .nova files directly
  • Embedded: Use as a library in Java/Kotlin applications
  • JSR-223: Standard scripting engine integration

Quick Start

Add Dependency (JitPack)

Gradle (Kotlin DSL)

repositories {
maven { url = uri("https://jitpack.io") }
}
dependencies {
implementation("com.github.CoderKuo.NovaLang:nova-runtime-all:v0.1.15")
}

Gradle (Groovy)

repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.CoderKuo.NovaLang:nova-runtime-all:v0.1.15'
}

Maven

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.CoderKuo.NovaLang</groupId>
<artifactId>nova-runtime-all</artifactId>
<version>v0.1.15</version>
</dependency>

Available modules:

ModuleDescription
nova-runtime-allFull runtime (interpreter + compiler + stdlib)
nova-runtime-apiRuntime API only (for plugin development)
nova-bukkitBukkit/Spigot integration
nova-json-gsonJSON provider — Gson
nova-json-fastjson2JSON provider — FastJSON2
nova-yaml-snakeyamlYAML provider — SnakeYAML
nova-yaml-bukkitYAML provider — Bukkit Configuration API

Prerequisites

  • JDK 8 or higher
  • Gradle 7.x (or use the included wrapper)

Build from Source

./gradlew build

Run REPL

./gradlew :nova-cli:run

Execute Script

./gradlew :nova-cli:run --args="path/to/script.nova"

Examples

Variables & Functions

val PI = 3.14159
var counter = 0
fun factorial(n: Int): Int {
if (n <= 1) return 1
return n * factorial(n - 1)
}
println(factorial(5)) // 120

Control Flow

// If expression
val result = if (x > 0) "positive" else "non-positive"
// When expression (pattern matching)
fun describe(n: Int): String = when (n) {
0 -> "zero"
1, 2 -> "small"
in 3..10 -> "medium"
else -> "large"
}
// For loop with range
for (i in 1..10) {
println(i)
}

Collections

// List literal
val items = [1, 2, 3, 4, 5]
// Map literal
val person = #{"name": "Alice", "age": 30}
// Set literal
val unique = #{1, 2, 3}
// Higher-order functions
val squared = items.map { it * it }
val evens = items.filter { it % 2 == 0 }
val sum = items.reduce { a, b -> a + b }

Classes & Objects

class User(val name: String, var age: Int) {
fun greet(): String = "Hi, I'm $name"
}
val user = User("Alice", 25)
println(user.greet())
// Singleton object
object Database {
fun connect() { println("Connected") }
}
Database.connect()

Enums

enum Color {
RED, GREEN, BLUE
}
fun paint(color: Color) {
when (color) {
Color.RED -> println("Painting red")
else -> println("Painting other")
}
}

Extension Functions

fun String.shout(): String = this.toUpperCase() + "!"
val msg = "hello"
println(msg.shout()) // HELLO!

Nullable Types

val name: String? = maybeNull()
// Safe call
val length = name?.length()
// Elvis operator
val len = name?.length() ?: 0
// Safe index
val first = list?[0]

Documentation

DocumentDescription
Syntax SpecificationComplete EBNF grammar
Usage GuideHow to use NovaLang
Java InteropJava integration guide
Standard LibraryBuilt-in modules
Reflection APIRuntime type introspection
Annotation SystemCustom annotations
Syntax ReferenceLanguage syntax with examples
ChangelogVersion history & release notes

Architecture

NovaLang
├── nova-runtime-api # Core types (NovaValue, NovaClass, etc.)
├── nova-compiler # Lexer, Parser, AST
├── nova-ir # HIR/MIR + Optimization passes
├── nova-runtime # Interpreter + Stdlib
├── nova-cli # Command-line interface
├── nova-script # JSR-223 script engine
├── nova-lsp # Language Server Protocol
└── vscode-nova # VS Code extension

Compilation Pipeline

Source Code → Lexer → Parser → AST → HIR → MIR → Interpreter
↓
Optimization Passes
(CSE, DCE, Inlining, etc.)

VS Code Extension

NovaLang provides a VS Code extension with:

  • Syntax highlighting
  • Code completion
  • Go to definition
  • Error diagnostics

Located in vscode-nova/ directory.


Security

NovaLang includes a configurable security sandbox:

# Run with sandbox
nova --sandbox STANDARD script.nova
# Sandbox levels
UNRESTRICTED # No restrictions
STANDARD # Block dangerous operations
STRICT # Minimal permissions

Project Status

NovaLang is under active development. Current version: 0.1.15

Visit the official website for interactive playground and documentation.


License

MIT License


Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

About

Drop-in scripting for JVM apps — Kotlin-like syntax, zero boilerplate, full Java interop.

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages