Mercurial Hosting > reactionary
annotate src/learn.html.luan @ 86:9b700f8d9610
learn java
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 21 Apr 2025 18:32:10 -0600 |
parents | c6d9fab4779a |
children |
rev | line source |
---|---|
40 | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | |
3 local pairs = Luan.pairs or error() | |
4 local Io = require "luan:Io.luan" | |
5 local Http = require "luan:http/Http.luan" | |
6 local Shared = require "site:/lib/Shared.luan" | |
7 local head = Shared.head or error() | |
8 local header = Shared.header or error() | |
9 | |
10 | |
11 local content = { | |
12 intro = { | |
52 | 13 title = [[Introduction]] |
40 | 14 content = function() |
15 %> | |
72 | 16 <p>Learning reactionary programming will give you a deep understanding of programming and will enable to you to write your own programs and websites. However this is not enough to get a job in depraved modern culture. Modern culture will expect you to use tools popular with them, so you would have to learn one of those. Probably the least horrible programming tool used by modern culture is <a href="python.html">Python</a>, so I would recommend learning that if you want a job.</p> |
40 | 17 |
64 | 18 <p>The next 4 lessons are basic computer literacy. Even if you are not interested in programming, these would be useful skills.</p> |
41 | 19 |
40 | 20 <p>I will develop this course incrementally based on demand. Whenever anyone completes the content here, I will add another lesson/section. This way I won't waste my time writing content that no one will use.</p> |
21 | |
22 <p>This course will be designed for you to learn reactionary programming in a logical sequence. I will focus on finding relevant resources, and I will only write explanations when nothing else is available on the subject. I will focus on web development since that is what I know best.</p> | |
23 | |
41 | 24 <p>I will often say "Do X" without saying how to do X. A big part of programming is figuring out how to do things. Your two main resources are Google and ChatGPT. If you get stuck, you can ask me.</p> |
40 | 25 |
26 <p>ChatGPT has become an essential programming tool. So the only task for this lesson is to play with ChatGPT. Later you can ask it technical questions.</p> | |
41 | 27 |
70
c934772a6c2e
remove discord and disearch
Franklin Schmidt <fschmidt@gmail.com>
parents:
67
diff
changeset
|
28 <p>If you have any questions, you can ask me on <a href="https://mikraite.arkian.net/Reactionary-Software-f1999.html">my forum</a>.</p> |
40 | 29 <% |
30 end | |
31 } | |
32 editor = { | |
52 | 33 title = [[Text Editor and JSON]] |
40 | 34 content = function() |
35 %> | |
72 | 36 <p>A text editor is a basic tool for reactionary programmers. We use simple flexible tools. Modern culture uses an <a href="https://en.wikipedia.org/wiki/Integrated_development_environment">IDE</a> which is big, <a href="https://mikraite.arkian.net/Changed-my-mind-about-IDE-s-tp2769.html">complicated</a>, and inflexible. We don't use such tools.</p> |
42 | 37 |
38 <p>I reviewed the available text editors and I think <a href="https://www.sublimetext.com/">Sublime Text</a> is the best one available. So please download it and learn how it works.</p> | |
39 | |
43 | 40 <p><a href="https://en.wikipedia.org/wiki/JSON">JSON</a> is the most popular text data format. I think JSON was the last good programming idea from modern culture, developed around 2001, before modern culture became fully depraved. Do your own research on JSON to understand it. It is fairly simple.</p> |
42 | 41 |
44 | 42 <p>I paired Sublime Text with JSON because Sublime Text uses JSON files for its <a href="https://www.sublimetext.com/docs/settings.html">settings</a>. (Actually not quite pure JSON because it includes comments which are lines starting with <code>//</code>.) Experiment with Sublime Text settings to learn more about both Sublime Text and JSON.</p> |
40 | 43 <% |
44 end | |
45 } | |
41 | 46 bash = { |
52 | 47 title = [[Bash - Command Line Shell]] |
41 | 48 content = function() |
49 %> | |
49 | 50 <p><a href="bash.html">Bash</a> is the other basic tool for reactionary programmers. I was hoping to just reference existing Bash tutorials in this lesson, but they are all horrible, so I am writing my own. So for this lesson, please read <a href="learn_bash.html">my tutorial</a>.</p> |
41 | 51 <% |
52 end | |
53 } | |
62 | 54 regex = { |
55 title = [[Regular Expressions]] | |
56 content = function() | |
57 %> | |
58 <p><a href="https://en.wikipedia.org/wiki/Regular_expression">Regular expressions</a>, or regex for short, are used for searching or matching text. Since this is such a common need, regex are found everywhere in programming. Since you just learned Bash, you can learn regex with the <a href="https://en.wikipedia.org/wiki/Grep">grep</a> command that uses regex.</p> | |
59 | |
60 <p>Unlike with Bash, there are a few decent grep tutorials, so I don't have to write my own. Here they are:</p> | |
61 | |
62 <ul> | |
63 <li><a href="https://vegastack.com/tutorials/regular-expressions-in-grep/">Regular Expressions in Grep</a></li> | |
64 <li><a href="https://cs.nyu.edu/~mohri/unix08/lect4">Regular Expressions</a></li> | |
65 <li><a href="https://www.gnu.org/software/grep/manual/grep.html">GNU Grep</a></li> | |
66 </ul> | |
67 | |
68 <p>I suggest that you just read through these tutorials so that you get a sense for how regex and grep work. You don't need to practice anything here. You can come back to these tutorials later when you have a real need for regex or grep.</p> | |
69 | |
84 | 70 <p>The details of regex vary by implementation. Luan uses <a href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/package-summary.html">Java regex</a>. |
83 | 71 |
62 | 72 <p>If you become a serious programmer, then you should have a deeper understanding of regex. In that case I recommend the book <a href="https://www.amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/">Mastering Regular Expressions</a>.</p> |
73 <% | |
74 end | |
75 } | |
41 | 76 hg = { |
52 | 77 title = [[Mercurial - Source Control]] |
41 | 78 content = function() |
79 %> | |
67 | 80 <p>Thankfully <a href="mercurial.html">Mercurial</a> is well documented. Read <a href="https://hgbook.red-bean.com/">Mercurial: The Definitive Guide</a> up to (and including) chapter 9.</p> |
54 | 81 |
82 <p>To get started with Mercurial, download Mercurial from <a href="https://www.mercurial-scm.org/">their website</a> and install it. Then do:</p> | |
83 | |
84 <code block> | |
85 ~/learn $ hg version | |
86 Mercurial Distributed SCM (version 5.2.2) | |
87 (see https://mercurial-scm.org for more information) | |
88 | |
89 Copyright (C) 2005-2019 Matt Mackall and others | |
90 This is free software; see the source for copying conditions. There is NO | |
91 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
92 ~/learn $ | |
93 </code> | |
94 | |
67 | 95 <p>If this works, it is installed properly. Next <a href="https://hgbook.red-bean.com/read/a-tour-of-mercurial-the-basics.html#sec:tour-basic:username">set up your Mercurial configuration file</a> which is <code>~/.hgrc</code> on a Mac or <code>/c/Users/$(whoami)/mercurial.ini</code> on Windows <a href="https://www.msys2.org/">MSYS2</a>. My <a href="https://www.mercurial-scm.org/doc/hgrc.5.html">hgrc</a> file looks like this: |
54 | 96 |
97 <code block> | |
98 [ui] | |
99 username = Franklin Schmidt <fschmidt@gmail.com> | |
100 | |
101 [auth] | |
102 hghosting.prefix = https://hg.reactionary.software/repo/ | |
103 hghosting.username = fschmidt@gmail.com | |
104 hghosting.password = xxxxxxxxxx | |
105 | |
106 [extensions] | |
107 hgext.extdiff = | |
108 | |
109 [extdiff] | |
110 cmd.dm = diffmerge | |
111 </code> | |
112 | |
56 | 113 <p>You should register on <a href="https://hg.reactionary.software/">our Mercurial hosting service</a> and use your email as the username and the assigned password in <code>.hgrc</code>. The last two blocks set up <code>hg dm</code> to call <a href="https://sourcegear.com/diffmerge/">DiffMerge</a> by using the <a href="https://wiki.mercurial-scm.org/ExtdiffExtension">Extdiff extension</a>.</p> |
54 | 114 |
115 <p>Now you can play with <a href="https://hg.reactionary.software/repo/test/">https://hg.reactionary.software/repo/test/</a> like this:</p> | |
116 | |
117 <code block> | |
118 ~/learn $ hg clone https://hg.reactionary.software/repo/test/ hgtest1 | |
119 no changes found | |
120 updating to branch default | |
121 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
122 ~/learn $ hg clone https://hg.reactionary.software/repo/test/ hgtest2 | |
123 no changes found | |
124 updating to branch default | |
125 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
126 ~/learn $ ls -Fd h* | |
127 hgtest1/ hgtest2/ | |
128 ~/learn $ cd hgtest1 | |
129 ~/learn/hgtest1 $ touch file.txt | |
130 ~/learn/hgtest1 $ e file.txt | |
131 ~/learn/hgtest1 $ cat file.txt | |
132 some text | |
133 ~/learn/hgtest1 $ hg status | |
134 ? file.txt | |
135 ~/learn/hgtest1 $ hg add file.txt | |
136 ~/learn/hgtest1 $ hg status | |
137 A file.txt | |
138 ~/learn/hgtest1 $ hg pull | |
139 pulling from https://hg.reactionary.software/repo/test/ | |
140 no changes found | |
141 ~/learn/hgtest1 $ hg commit -m 'add file.txt' | |
142 ~/learn/hgtest1 $ hg push | |
143 pushing to https://hg.reactionary.software/repo/test/ | |
144 searching for changes | |
145 remote: adding changesets | |
146 remote: adding manifests | |
147 remote: adding file changes | |
148 remote: added 1 changesets with 1 changes to 1 files | |
149 ~/learn/hgtest1 $ cd ../hgtest2 | |
150 ~/learn/hgtest2 $ hg pull | |
151 pulling from https://hg.reactionary.software/repo/test/ | |
152 requesting all changes | |
153 adding changesets | |
154 adding manifests | |
155 adding file changes | |
156 added 1 changesets with 1 changes to 1 files | |
157 new changesets aab34516d8dc | |
158 (run 'hg update' to get a working copy) | |
159 ~/learn/hgtest2 $ hg update | |
160 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
161 ~/learn/hgtest2 $ hg status | |
162 ~/learn/hgtest2 $ cat file.txt | |
163 some text | |
164 ~/learn/hgtest2 $ e file.txt | |
165 ~/learn/hgtest2 $ cat file.txt | |
166 some text | |
167 and more | |
168 ~/learn/hgtest2 $ hg status | |
169 M file.txt | |
170 ~/learn/hgtest2 $ hg pull | |
171 pulling from https://hg.reactionary.software/repo/test/ | |
172 searching for changes | |
173 no changes found | |
174 ~/learn/hgtest2 $ hg dm | |
175 ~/learn/hgtest2 $ hg commit -m 'and more' | |
176 ~/learn/hgtest2 $ hg push | |
177 pushing to https://hg.reactionary.software/repo/test/ | |
178 searching for changes | |
179 remote: adding changesets | |
180 remote: adding manifests | |
181 remote: adding file changes | |
182 remote: added 1 changesets with 1 changes to 1 files | |
183 </code> | |
184 | |
41 | 185 <% |
186 end | |
187 } | |
86 | 188 java = { |
189 title = [[Java 8]] | |
190 content = function() | |
191 %> | |
192 <p><a href="/java.html">Java</a> is not an easy language to learn and if you later use Python or Luan then you won't use Java much. So why learn it first? Because it will give you a core understanding of programming. Also, ChatGPT understands Java very well, so this can help you learn it. And lastly because Java will help you understand Luan.</p> | |
193 | |
194 <p>To learn Java, you will need the following resources:</p> | |
195 <ul> | |
196 <li><a href="https://docs.oracle.com/javase/8/docs/api/overview-summary.html">Java 8 API Specification</a> - This is the reference for the different types of Java objects and what they do. I will refer to this a lot.</li> | |
197 <li><a href="https://www.amazon.com/Java-Programming-Language-4th/dp/0321349806/">The Java Programming Language</a> - This is the core reference text for Java.</li> | |
198 <li>You should get a Java book for beginners. Unfortunately they are all horrible. Sorry, but you still have to get one and read it.</li> | |
199 <li>For desktop GUI programming, you will need <a href="https://docs.oracle.com/javase/tutorial/uiswing/">Creating a GUI With 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>.</li> | |
200 </ul> | |
201 | |
202 <p>I am not so sadistic as to have you start with straight Java. That would be too painful. Instead I will have you start with a gentler interface to Java called BeanShell. Here are the steps to learning Java:</p> | |
203 | |
204 <h3>Install Java 8</h3> | |
205 | |
206 <p>Download <a href="https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html">Java (JDK) 8</a> and install it. Your Java book for beginners may have more detailed instructions. Of just ask ChatGPT if you have trouble. After installing the JDK, you can check it like this: | |
207 | |
208 <code block> | |
209 ~ $ java -version | |
210 java version "1.8.0_241" | |
211 Java(TM) SE Runtime Environment (build 1.8.0_241-b07) | |
212 Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode) | |
213 ~ $ | |
214 </code> | |
215 | |
216 <h3>Learn BeanShell</h3> | |
217 | |
218 <p>As with Bash, I will write my own <a href="beanshell.html">BeanShell tutorial</a>. Read it.</p> | |
219 | |
220 <h3>Learn Java</h3> | |
221 | |
222 <p>Now it's time to read your Java book for beginners and try writing some Java programs. Refer to <a href="https://www.amazon.com/Java-Programming-Language-4th/dp/0321349806/">The Java Programming Language</a> for details and ask ChatGPT for explanations. You do not need to become a Java expert, so don't spend too much time on this. You just need to get the basic idea of Java.</p> | |
223 | |
224 <% | |
225 end | |
226 } | |
227 luan = { | |
228 title = [[Luan]] | |
229 content = function() | |
230 %> | |
231 <p>later</p> | |
232 <% | |
233 end | |
234 } | |
41 | 235 html = { |
52 | 236 title = [[HTML and CSS]] |
41 | 237 content = function() |
238 %> | |
59 | 239 <p>Google Chrome is the standard client-side web development tool. So the first step is to make sure that you have Chrome installed and running.</p> |
240 | |
72 | 241 <p>Using Chrome, on any page you can right-click in an empty area and from the menu select "View Page Source". This will show you the HTML for the webpage. If you try this on different websites, you will probably notice that my webpages are fairly short and well organized while the webpages of modern culture are unreadable. Another thing to try is to right-click anywhere in a page and select "Inspect". This should open the developer tools with the tab "Elements" selected. In this tab, you get the HTML organized as a tree that can be expanded to collapsed. The "Elements" tab of Chrome developer tools will be your core tool when you work with HTML and CSS. You should play with it and do your own research on it to learn how it works.</p> |
59 | 242 |
243 <p>The next step is to download this website like this:</p> | |
244 | |
245 <code block> | |
67 | 246 ~/learn $ wget -r -k https://www.reactionary.software/ |
247 --2024-01-15 01:31:20-- https://www.reactionary.software/ | |
59 | 248 ... |
249 ~/learn $ cd www.reactionary.software/ | |
250 ~/learn/www.reactionary.software $ ls -F | |
251 about.html hg_dev.html mercurial.html | |
252 bash.html index.html needed.html | |
253 books.html java.html nginx.html | |
254 discussion.html java_fork.html python.html | |
255 existing.html learn.html site.css | |
256 external_link.svg learn_bash.html this.html | |
257 freedit.html lucene.html wysiwyg.html | |
258 </code> | |
259 | |
260 <p><code>index.html</code> is the home page. Find it in Mac Finder or Windows File Explorer, and then drag-and-drop it into Chrome. You should see this website. You can open the files in a text editor to see the HTML. And you can edit these files to see how the web page changes.</p> | |
261 | |
262 <p>There is good documentation on HTML and CSS. Start with <a href="https://www.amazon.com/Cascading-Style-Sheets-Designing-Web/dp/0321193121/">Cascading Style Sheets: Designing for the Web</a>. This was written by the people who invented CSS and explains the core idea. Read the whole book. This book covers almost everything in this website. The only missing piece is <a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">flexbox</a>. Next get <a href="https://www.amazon.com/CSS-Definitive-Guide-Layout-Presentation/dp/1098117611/">CSS: The Definitive Guide</a>. You should also read this whole book, but you can do it slowly as you work with CSS. You don't need to read this book right now, you can wait until you have finished the next two lessons.</p> | |
263 | |
264 <p>Just play with HTML and CSS until you get a basic understanding of how they work. You should be able to understand the HTML and CSS of this website.</p> | |
265 | |
266 <p>I left out resources for HTML itself. You should just look up HTML tags with Google or ChatGPT as you encounter them. That is good enough to learn HTML.</p> | |
267 | |
72 | 268 <p>Ideally one should be able to look at web pages around the internet to learn. But unfortunately they are mostly overcomplicated crap that is very difficult to understand. You can try. My personal websites are like this one - very simple, so they don't look professional to modern culture. I can't link to my best commercial website because that would ruin its reputation (because I am infamous). But I can link to some of my old commercial websites <a href="http://test.tleggings.com/">here</a> and <a href="http://test.super-resume.com/">here</a>. These have reasonable HTML and CSS.</p> |
59 | 269 |
72 | 270 <p>I have a few general principles for working with HTML and CSS. First, modern culture claims that HTML is for content and CSS is for styling. This is nonsense. Both HTML and CSS are for layout, don't think of them as being conceptually different. Just use both in the simplest possible way to get the results you want. Don't bother with the useless new HTML5 content tags like <code>header</code>. Just use <code>div</code> and <code>span</code> for most things. Also I use HTML attributes as selectors, not HTML classes. This is just simpler. HTML classes are useless, leave them for modern culture.</p> |
59 | 271 |
272 <p>You will need HTML, CSS, Javascript, and Luan to make a website. So I suggest that you get a basic understanding of each of these and then go back later to study them in greater depth.</p> | |
41 | 273 <% |
274 end | |
275 } | |
276 js = { | |
52 | 277 title = [[JavaScript]] |
41 | 278 content = function() |
279 %> | |
280 <p>later</p> | |
281 <% | |
282 end | |
283 } | |
284 http = { | |
52 | 285 title = [[HTTP]] |
286 content = function() | |
287 %> | |
288 <p>later</p> | |
289 <% | |
290 end | |
291 } | |
292 lucene = { | |
293 title = [[Lucene]] | |
41 | 294 content = function() |
295 %> | |
296 <p>later</p> | |
297 <% | |
298 end | |
299 } | |
40 | 300 } |
301 | |
302 | |
303 local function show_toc(content) | |
304 %> | |
305 <ul> | |
306 <% | |
307 for id, info in pairs(content) do | |
308 %> | |
309 <li><a id="c_<%=id%>" href="#<%=id%>"><%=info.title%></a></li> | |
310 <% | |
311 end | |
312 %> | |
313 </ul> | |
314 <% | |
315 end | |
316 | |
317 local function show_content(content,h) | |
318 for id, info in pairs(content) do | |
319 %> | |
320 <div heading> | |
321 <h<%=h%>><a id="<%=id%>" href="#<%=id%>"><%=info.title%></a></h<%=h%>> | |
322 <a href="#c_<%=id%>">contents</a> | |
323 </div> | |
324 <% | |
325 info.content() | |
326 end | |
327 end | |
328 | |
329 return function() | |
330 Io.stdout = Http.response.text_writer() | |
331 %> | |
332 <!doctype html> | |
333 <html> | |
334 <head> | |
335 <% head() %> | |
336 <title>Learn Reactionary Programming</title> | |
337 </head> | |
338 <body> | |
339 <% header() %> | |
340 <div content> | |
341 <h1><a href="learn.html">Learn Reactionary Programming</a></h1> | |
342 <hr> | |
343 <h2>Contents</h2> | |
344 <div toc> | |
345 <% show_toc(content) %> | |
346 </div> | |
347 <hr> | |
348 <% show_content(content,2) %> | |
349 </div> | |
350 </body> | |
351 </html> | |
352 <% | |
353 end |