diff --git a/website/lux-site/README.md b/website/lux-site/README.md new file mode 100644 index 0000000..5075b43 --- /dev/null +++ b/website/lux-site/README.md @@ -0,0 +1,72 @@ +# Lux Website + +## Testing Locally + +The website is a static HTML site. To test it with working navigation: + +### Option 1: Python (simplest) +```bash +cd website/lux-site/dist +python -m http.server 8000 +# Open http://localhost:8000 +``` + +### Option 2: Node.js +```bash +npx serve website/lux-site/dist +# Open http://localhost:3000 +``` + +### Option 3: Nix +```bash +nix-shell -p python3 --run "cd website/lux-site/dist && python -m http.server 8000" +``` + +### Option 4: Direct file (limited) +Open `website/lux-site/dist/index.html` directly in a browser. Navigation links will work since they're anchor links (`#features`, `#effects`, etc.), but this won't work for multi-page setups. + +## Structure + +``` +website/lux-site/ +├── dist/ +│ ├── index.html # Main website +│ └── static/ +│ └── style.css # Styles +├── src/ +│ ├── components.lux # Lux components (for future generation) +│ ├── pages.lux # Page templates +│ └── generate.lux # Site generator +├── LUX_WEAKNESSES.md # Issues found during development +└── README.md # This file +``` + +## Building with Lux + +Once the module system is working (fixed!), you can generate the site: + +```bash +./target/release/lux website/lux-site/src/generate.lux +``` + +The HTML module is now functional and can render HTML from Lux code: + +```lux +import stdlib/html + +let page = html.div([html.class("container")], [ + html.h1([], [html.text("Hello!")]) +]) + +Console.print(html.render(page)) +// Output:
- Effects are explicit. Types are powerful. Performance is native.
+ Algebraic effects. Behavioral types. Schema evolution.
+ Compile to native C or JavaScript. One language, every platform.
fn processOrder(
- order: Order
-): Receipt
- with {Database, Email} =
-{
- let saved = Database.save(order)
- Email.send(
- order.customer,
- "Order confirmed!"
- )
- Receipt(saved.id)
-}
+ Lux solves problems other languages can't even express
+Side effects in the type signature. Swap handlers for testing. No dependency injection frameworks.
No surprises. No hidden side effects.
+Prove functions are pure, total, deterministic, or idempotent. The compiler verifies it.
+Built-in type versioning with automatic migrations. Change your data types safely.
+Same code compiles to native C (via GCC) or JavaScript. Server and browser from one source.
+Beats Rust and Zig on recursive benchmarks. Zero-cost effect abstraction via evidence passing.
+Package manager, LSP, REPL, debugger, formatter, test runner. All built in.
Every side effect is tracked in the type signature
+fn processOrder(
+ order: Order
+): Receipt
+ with {Sql, Http, Console} =
+{
+ let saved = Sql.execute(db,
+ "INSERT INTO orders...")
+ Http.post(webhook, order)
+ Console.print("Order {order.id} saved")
+ Receipt(saved.id)
+}
+ No surprises. No hidden side effects. Ever.
+Swap effect handlers at test time. Same code, different behavior.
+// Production: real database, real HTTP
+run processOrder(order) with {
+ Sql -> postgresHandler,
+ Http -> realHttpClient,
+ Console -> stdoutHandler
+}
+ // Test: in-memory DB, captured calls
+run processOrder(order) with {
+ Sql -> inMemoryDb,
+ Http -> captureRequests,
+ Console -> devNull
+}
+ No Mockito. No dependency injection. Just swap the handlers.
+Prove properties about your functions. The compiler enforces them.
+// The compiler verifies these properties
+
+fn add(a: Int, b: Int): Int
+ is pure is commutative = a + b
+
+fn factorial(n: Int): Int
+ is total = if n <= 1 then 1 else n * factorial(n - 1)
+
+fn processPayment(p: Payment): Result
+ is idempotent = // Safe to retry on failure
+ ...
+
+fn hash(data: Bytes): Hash
+ is deterministic = // Same input = same output
+ ...
+ Side effects are tracked in the type signature. Know exactly what every function does.
+No side effects. Safe to memoize.
Full type inference with algebraic data types. Catch bugs at compile time.
+Always terminates. No infinite loops.
Compiles to native C via gcc. Matches C performance, beats Rust and Zig.
+Run twice = run once. Safe for retries.
+Built-in type versioning. No more migration headaches.
+type User @v1 { name: String }
+
+type User @v2 {
+ name: String,
+ email: String,
+ from @v1 = {
+ name: old.name,
+ email: "unknown@example.com"
+ }
+}
+
+type User @v3 {
+ firstName: String,
+ lastName: String,
+ email: String,
+ from @v2 = {
+ firstName: String.split(old.name, " ").head,
+ lastName: String.split(old.name, " ").tail,
+ email: old.email
+ }
+}
+ Load old data with new code. The compiler ensures migration paths exist.
+Compile to native C or JavaScript from the same source
+# Compile to native binary (via GCC)
+lux compile server.lux
+./server # Runs natively
+
+# Compile to JavaScript
+lux compile client.lux --target js
+node client.js # Runs in Node/browser
+ fib(35) benchmark — verified with hyperfine
+ Zero-cost effects via evidence passing — O(1) handler lookup
Swap effect handlers at test time. Same code, different behavior.
+Everything you need, ready to use
+print, readLine, readInt
+read, write, exists, listDir
+get, post, put, delete
+listen, respond, routing
+query, execute, transactions
+exec, env, args, exit
+int, float, bool
+now, sleep
+Modern tooling, built-in
// Production
-run processOrder(order) with {
- Database -> postgresDb,
- Email -> smtpServer
-}
+ # Package manager
+lux pkg init myproject
+lux pkg add json-parser
+lux pkg install
+
+# Development tools
+lux fmt # Format code
+lux check # Type check
+lux test # Run tests
+lux watch app.lux # Hot reload
+
+# LSP for your editor
+lux lsp # Start language server
// Testing
-run processOrder(order) with {
- Database -> inMemoryDb,
- Email -> collectEmails
-}
+ # Install via Nix
+
+ # Install via Nix (recommended)
nix run github:luxlang/lux
# Or build from source
@@ -173,9 +368,55 @@ cd lux && nix develop
cargo build --release
# Start the REPL
-./target/release/lux
+./target/release/lux
+
+# Run a file
+./target/release/lux hello.lux
+
+# Compile to native binary
+./target/release/lux compile app.lux --run
+
+
+ // hello.lux
+fn main(): Unit with {Console} = {
+ Console.print("Hello, Lux!")
+}
+
+run main() with {}
+
+ Algebraic effects instead of monads. Same power, clearer code. Weeks to learn, not months.
+No borrow checker to fight. Automatic memory management. Still native performance.
+Real type safety. Pattern matching. No nil panics. Effects track what code does.
+Sound type system. Native compilation. Effects are tracked, not invisible.
+Compiles to native, not just JS. Server-side, CLI apps, anywhere.
+Higher-level abstractions. Algebraic types. Still fast.
+