annotate website/src/learn.html.luan @ 1929:31f006c64782

translation
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 01 May 2025 18:31:05 -0600
parents 1461449b6074
children 047e4dde22b4
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"
1929
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
4 local Site_translator = require "luan:gpt/Site_translator.luan"
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
5 local get_lang = Site_translator.get_lang or error()
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
6 local text_writer = Site_translator.text_writer or error()
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
7 local Shared = require "site:/lib/Shared.luan"
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
8 local head = Shared.head or error()
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
9 local header = Shared.docs_header or error()
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
10
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
11
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
12 return function()
1929
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
13 Io.stdout = text_writer()
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
14 %>
1216
5dbb552075ff doctype
Franklin Schmidt <fschmidt@gmail.com>
parents: 793
diff changeset
15 <!doctype html>
1929
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
16 <html lang="<%=get_lang()%>">
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
17 <head>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
18 <% head() %>
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
19 <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
20 </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
21 <body>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
22 <% header() %>
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
23 <div content>
1927
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 <h1>Learning Luan</h1>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
26
1929
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
27 <p>To understand the idea behind Luan, you must read <a href="scripting.html">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>
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
28
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
29 <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
30
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
31 <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
32
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
33 <code block>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
34 Luan_table.luan_function = JavaClass.javaFunction
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
35 </code>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
36
1929
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
37 <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
38
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
39 <p>Here are my suggested steps for learning Luan:</p>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
40
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
41 <ol>
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
42 <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>
1929
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
43 <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>
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
44 <li>Next read the short <a href="tutorial.html">Luan Tutorial</a>.</li>
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
45 </ol>
1924
Franklin Schmidt <fschmidt@gmail.com>
parents: 1891
diff changeset
46
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
47 <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
48
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
49 <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
50
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
51 <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
52
1929
31f006c64782 translation
Franklin Schmidt <fschmidt@gmail.com>
parents: 1927
diff changeset
53 <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>
1927
1461449b6074 add learn.html
Franklin Schmidt <fschmidt@gmail.com>
parents: 1924
diff changeset
54
1579
dd881eb03d87 yourkit link
Franklin Schmidt <fschmidt@gmail.com>
parents: 1577
diff changeset
55 </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
56 </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
57 </html>
1651
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
58 <%
5b8f056527a3 docs work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1579
diff changeset
59 end