annotate website/src/learn.html.luan @ 1927:1461449b6074 default tip

add learn.html
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 23 Apr 2025 20:06:58 -0600
parents website/src/install.html.luan@8c637b047a42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
1 local Luan = require "luan:Luan.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
2 local error = Luan.error
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
3 local Io = require "luan:Io.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
4 local Http = require "luan:http/Http.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
5 local Shared = require "site:/lib/Shared.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
6 local head = Shared.head or error()
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
7 local header = Shared.docs_header or error()
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
8
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
9
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
10 return function()
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
11 Io.stdout = Http.response.text_writer()
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
12 %>
1216
5dbb552075ff doctype
Franklin Schmidt <fschmidt@gmail.com>
parents: 793
diff changeset
13 <!doctype html>
391
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
14 <html>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
15 <head>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
16 <% head() %>
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
17 <title>Learning Luan</title>
391
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
18 </head>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
19 <body>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
20 <% header() %>
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
21 <div content>
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
22
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
23 <h1>Learning Luan</h1>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
24
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
25 <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>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
26
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
27 <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>
1924
Franklin Schmidt <fschmidt@gmail.com>
parents: 1891
diff changeset
28
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
29 <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>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
30
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
31 <code block>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
32 Luan_table.luan_function = JavaClass.javaFunction
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
33 </code>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
34
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
35 <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>
1323
3860ed4b8552 simplify website css
Franklin Schmidt <fschmidt@gmail.com>
parents: 1310
diff changeset
36
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
37 <p>Here are my suggested steps for learning Luan:</p>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
38
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
39 <ol>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
40 <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>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
41 <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>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
42 <li>Next read the short <a href="/tutorial.html">Luan Tutorial</a>.</li>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
43 </ol>
1924
Franklin Schmidt <fschmidt@gmail.com>
parents: 1891
diff changeset
44
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
45 <p>What comes next depends on whether you want to do web development or desktop development.</p>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
46
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
47 <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>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
48
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
49 <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>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
50
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
51 <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>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
52
1579
dd881eb03d87 yourkit link
Franklin Schmidt <fschmidt@gmail.com>
parents: 1577
diff changeset
53 </div>
391
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
54 </body>
2f5cc9c2cbf0 replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
Franklin Schmidt <fschmidt@gmail.com>
parents: 386
diff changeset
55 </html>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
56 <%
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
57 end