Mercurial Hosting > luan
changeset 1927:1461449b6074 default tip
add learn.html
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 23 Apr 2025 20:06:58 -0600 |
parents | 4206242c7a13 |
children | |
files | website/src/docs.html.luan website/src/index.html.luan website/src/install.html.luan website/src/learn.html.luan |
diffstat | 4 files changed, 60 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/website/src/docs.html.luan Wed Apr 23 15:34:48 2025 -0600 +++ b/website/src/docs.html.luan Wed Apr 23 20:06:58 2025 -0600 @@ -22,6 +22,8 @@ <h1>Luan Documentation</h1> <ul links> + <li><a href="install.html">Installation</a></li> + <li><a href="learn.html">Learning Luan</a></li> <li><a href="tutorial.html">Tutorial</a></li> <li><a href="pil.html">Programming in Lua (book)</a></li> <li><a href="manual.html">Reference Manual</a></li>
--- a/website/src/index.html.luan Wed Apr 23 15:34:48 2025 -0600 +++ b/website/src/index.html.luan Wed Apr 23 20:06:58 2025 -0600 @@ -26,7 +26,6 @@ <ul links> <li><a href="why.html">Why Luan?</a></li> <li><a href="docs.html">Documentation</a></li> - <li><a href="install.html">Installation</a></li> <li><a href="https://hg.reactionary.software/repo/luan">Source</a></li> <li><a href="support.html">Support</a></li> <li><a href="goodjava.html">The goodjava Library</a></li>
--- a/website/src/install.html.luan Wed Apr 23 15:34:48 2025 -0600 +++ b/website/src/install.html.luan Wed Apr 23 20:06:58 2025 -0600 @@ -4,7 +4,7 @@ local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() -local header = Shared.header or error() +local header = Shared.docs_header or error() return function()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/website/src/learn.html.luan Wed Apr 23 20:06:58 2025 -0600 @@ -0,0 +1,57 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Shared = require "site:/lib/Shared.luan" +local head = Shared.head or error() +local header = Shared.docs_header or error() + + +return function() + Io.stdout = Http.response.text_writer() +%> +<!doctype html> +<html> + <head> +<% head() %> + <title>Learning Luan</title> + </head> + <body> +<% header() %> + <div content> + +<h1>Learning Luan</h1> + +<p>To understand the idea behind Luan, you must read <a href="/scripting.pdf">Ousterhout's paper</a>. In terms of this paper, Luan is the scripting language and Java is the system programming language. In other words, these two languages are a pair of tools that work together. Luan is the tool for writing applications, and Java is the tool for writing libraries.</p> + +<p>No other modern scripting language (except Tcl) follows this model. This means that you are limited to whatever functionality the scripting language provides. Of modern scripting languages, only Python is big enough to really have enough functionality through libraries. But tiny Luan has as much functionality as Python does because Luan has access to all of the functionality available in Java.</p> + +<p>It is the tight integration of Luan with Java that makes this possible. Often, making a Java function available in Luan is as simple as:</p> + +<code block> +Luan_table.luan_function = JavaClass.javaFunction +</code> + +<p>In other cases, there is a very thin layer between Luan and Java. And if you know Java, then this code is easy to read. This means that the Luan source code is actually perfectly suitable documentation for the Luan API. If I was to document all of the Luan API, I would actually be mostly duplicating the <a href="https://docs.oracle.com/javase/8/docs/api/overview-summary.html">Java API documentation</a>. So while I will continue to expand the <a href="/manual.html">Luan Reference Manual</a>, this is not my top priority. To use Luan, you must get <a href="https://hg.reactionary.software/repo/luan/">the source</a> and get a basic understanding of the API which is in <a href="https://hg.reactionary.software/repo/luan/file/tip/src/luan/modules">luan/src/luan/modules</a>.</p> + +<p>Here are my suggested steps for learning Luan:</p> + +<ol> + <li>Follow my <a href="https://www.reactionary.software/learn.html">Learn Reactionary Programming</a> course up to and including <b>Java 8</b>.</li> + <li>Read <a href="/pil.html">Programming in Lua</a>. It is actually an excellent book which means that I don't have to write an extensive Luan tutorial. Then read <a href="/diff.html">How Luan differs from Lua</a>.</li> + <li>Next read the short <a href="/tutorial.html">Luan Tutorial</a>.</li> +</ol> + +<p>What comes next depends on whether you want to do web development or desktop development.</p> + +<p>For web development, start by looking at the example in <a href="https://hg.reactionary.software/repo/luan/file/tip/examples/blog">luan/examples/blog</a>. This is a minimal website. Next look at <a href="https://chat.luan.software/about.html">Luan Chat</a>. Get the source. It uses <a href="https://en.wikipedia.org/wiki/Server-sent_events">server-sent events</a> which is implemented in Luan with <code>Http.push</code>. Luan Chat is fully functional and is what I use to chat with people. So this code is an example of a complete website.</p> + +<p>For desktop development, you need to learn the relevant Java tools which include <a href="https://docs.oracle.com/javase/tutorial/uiswing/">Swing</a>, <a href="http://www.miglayout.com/">MigLayout</a>, <a href="https://www.formdev.com/flatlaf/">FlatLaf</a>, and <a href="https://docs.oracle.com/javase/tutorial/2d/">2D Graphics</a>. Then you can look at examples in <a href="https://hg.reactionary.software/repo/luan/file/tip/src/luan/modules/swing/examples">luan/src/luan/modules/swing/examples</a>. And then get <a href="https://hg.reactionary.software/repo/editor/">Luan Editor</a>. This is a fully functional text editor. It will show you how to use Swing in Luan.</p> + +<p>With popular programming languages, you can get help from ChatGPT. But ChatGPT doesn't know Luan. ChatGPT can help you understand Java, but that's all. So for Luan questions, just <a href="/support.html">contact me</a>.</p> + + </div> + </body> +</html> +<% +end