docs: add language philosophy document and compiler integration
Write comprehensive PHILOSOPHY.md covering Lux's six core principles (explicit over implicit, composition over configuration, safety without ceremony, practical over academic, one right way, tools are the language) with detailed comparisons against JS/TS, Python, Rust, Go, Java/C#, Haskell/Elm, and Gleam/Elixir. Includes tooling audit and improvement suggestions. Add `lux philosophy` command to the compiler, update help screen with abbreviated philosophy, and link from README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
49
src/main.rs
49
src/main.rs
@@ -1,4 +1,7 @@
|
||||
//! Lux - A functional programming language with first-class effects
|
||||
//! Lux — Make the important things visible.
|
||||
//!
|
||||
//! A functional programming language with first-class effects, schema evolution,
|
||||
//! and behavioral types. See `lux philosophy` or docs/PHILOSOPHY.md.
|
||||
|
||||
mod analysis;
|
||||
mod ast;
|
||||
@@ -213,12 +216,15 @@ fn main() {
|
||||
// Generate API documentation
|
||||
generate_docs(&args[2..]);
|
||||
}
|
||||
"philosophy" => {
|
||||
print_philosophy();
|
||||
}
|
||||
cmd => {
|
||||
// Check if it looks like a command typo
|
||||
if !std::path::Path::new(cmd).exists() && !cmd.starts_with('-') && !cmd.contains('.') && !cmd.contains('/') {
|
||||
let known_commands = vec![
|
||||
"fmt", "lint", "test", "watch", "init", "check", "debug",
|
||||
"pkg", "registry", "serve", "compile", "doc", "repl",
|
||||
"pkg", "registry", "serve", "compile", "doc", "repl", "philosophy",
|
||||
];
|
||||
let suggestions = diagnostics::find_similar_names(cmd, known_commands.into_iter(), 2);
|
||||
if !suggestions.is_empty() {
|
||||
@@ -240,7 +246,12 @@ fn main() {
|
||||
|
||||
fn print_help() {
|
||||
println!("{}", bc(colors::GREEN, &format!("Lux {}", VERSION)));
|
||||
println!("{}", c(colors::DIM, "A functional language with first-class effects"));
|
||||
println!("{}", c(colors::DIM, "Make the important things visible."));
|
||||
println!();
|
||||
println!(" {} Effects in types — see what code does", c(colors::DIM, "·"));
|
||||
println!(" {} Composition over configuration — no DI frameworks", c(colors::DIM, "·"));
|
||||
println!(" {} Safety without ceremony — inference where it helps", c(colors::DIM, "·"));
|
||||
println!(" {} One right way — opinionated formatter, integrated tools", c(colors::DIM, "·"));
|
||||
println!();
|
||||
println!("{}", bc("", "Usage:"));
|
||||
println!();
|
||||
@@ -280,6 +291,8 @@ fn print_help() {
|
||||
c(colors::DIM, "(alias: s)"));
|
||||
println!(" {} {} {} Generate API documentation",
|
||||
bc(colors::CYAN, "lux"), bc(colors::CYAN, "doc"), c(colors::YELLOW, "[file] [-o dir]"));
|
||||
println!(" {} {} Show language philosophy",
|
||||
bc(colors::CYAN, "lux"), bc(colors::CYAN, "philosophy"));
|
||||
println!(" {} {} Start LSP server",
|
||||
bc(colors::CYAN, "lux"), c(colors::YELLOW, "--lsp"));
|
||||
println!(" {} {} Show this help",
|
||||
@@ -288,6 +301,36 @@ fn print_help() {
|
||||
bc(colors::CYAN, "lux"), c(colors::YELLOW, "--version"));
|
||||
}
|
||||
|
||||
fn print_philosophy() {
|
||||
println!("{}", bc(colors::GREEN, &format!("The Lux Philosophy")));
|
||||
println!();
|
||||
println!(" {}", bc("", "Make the important things visible."));
|
||||
println!();
|
||||
println!(" Most languages hide what matters most in production: what code");
|
||||
println!(" can do, how data changes over time, and what guarantees functions");
|
||||
println!(" provide. Lux makes all three first-class, compiler-checked features.");
|
||||
println!();
|
||||
println!(" {} {}", bc(colors::CYAN, "1. Explicit over implicit"), c(colors::DIM, "— effects in types, not hidden behind interfaces"));
|
||||
println!(" fn processOrder(order: Order): Receipt {} {}", c(colors::YELLOW, "with {Database, Email}"), c(colors::DIM, "// signature IS documentation"));
|
||||
println!();
|
||||
println!(" {} {}", bc(colors::CYAN, "2. Composition over configuration"), c(colors::DIM, "— no DI frameworks, no monad transformers"));
|
||||
println!(" run app() {} {}", c(colors::YELLOW, "with { Database = mock, Http = mock }"), c(colors::DIM, "// swap handlers, not libraries"));
|
||||
println!();
|
||||
println!(" {} {}", bc(colors::CYAN, "3. Safety without ceremony"), c(colors::DIM, "— type inference where it helps, annotations where they document"));
|
||||
println!(" let x = 42 {}", c(colors::DIM, "// inferred"));
|
||||
println!(" fn f(x: Int): Int = x * 2 {}", c(colors::DIM, "// annotated: API contract"));
|
||||
println!();
|
||||
println!(" {} {}", bc(colors::CYAN, "4. Practical over academic"), c(colors::DIM, "— ML semantics in C-family syntax, no monads to learn"));
|
||||
println!(" {} {} {}", c(colors::DIM, "fn main(): Unit"), c(colors::YELLOW, "with {Console}"), c(colors::DIM, "= Console.print(\"Hello!\")"));
|
||||
println!();
|
||||
println!(" {} {}", bc(colors::CYAN, "5. One right way"), c(colors::DIM, "— opinionated formatter, integrated tooling, built-in testing"));
|
||||
println!(" lux fmt | lux lint | lux check | lux test | lux compile");
|
||||
println!();
|
||||
println!(" {} {}", bc(colors::CYAN, "6. Tools are the language"), c(colors::DIM, "— formatter knows the AST, linter knows the types, LSP knows the effects"));
|
||||
println!();
|
||||
println!(" See {} for the full philosophy with language comparisons.", c(colors::CYAN, "docs/PHILOSOPHY.md"));
|
||||
}
|
||||
|
||||
fn format_files(args: &[String]) {
|
||||
use formatter::{format, FormatConfig};
|
||||
use std::path::Path;
|
||||
|
||||
Reference in New Issue
Block a user