-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAEC_specification.html
executable file
·4084 lines (4059 loc) · 198 KB
/
AEC_specification.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html lang="en">
<head>
<meta charset="utf-8" />
<title>AEC Language Specification</title>
<meta
name="description"
content="Documentation for the ArithmeticExpressionCompiler programming language"
/>
<meta name="author" content="Teo Samaržija" />
<meta
name="keywords"
content="HTML, CSS, JavaScript, WebAssembly, Programming Language"
/>
<style type="text/css">
title {
font-family: "Courier New", monospace;
}
body {
background-image: url("background.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
header {
height: 200px;
line-height: 200px;
text-align: center;
color: darkblue;
font-weight: bold;
font-size: 36px;
font-family: Lucida;
}
aside {
width: 25%;
background: #aaaaff;
height: 100%;
float: left;
color: #aa4400;
overflow: auto;
}
aside a {
text-decoration: none;
}
section {
width: 25%;
background: #ffffaa;
height: 100%;
float: right;
color: purple;
text-align: center;
overflow: auto;
}
.main1 {
background: black;
color: darkgray;
width: 50%;
height: 100%;
overflow: auto;
font-family: Verdana;
}
.main1 table,
.main1 th,
.main1 td {
color: darkgray;
border: 1px solid darkgray;
}
.main1 a {
color: lightgreen;
}
.main2 {
background: black;
color: lightgreen;
width: 50%;
height: 100%;
overflow: auto;
}
.main2 table,
.main2 th,
.main2 td {
border: 1px solid lightgreen;
color: lightgreen;
}
.main2 a {
color: #00ffff;
}
.main3 {
background: #eeeeee;
color: #333333;
width: 50%;
height: 100%;
overflow: auto;
font-family: Arial;
}
.main3 a {
color: #00aaaa;
}
.main3 table,
.main3 th,
.main3 td {
border: 1px solid #333333;
color: #333333;
}
.main1 .inline_code,
.main2 .inline_code {
background-color: #333333;
}
.main3 .inline_code {
background-color: #bbbbbb;
}
.link1 {
text-decoration: none;
background: linear-gradient(to right, #111111, #333333);
height: 30px;
width: 100%;
color: #ff3300;
line-height: 30px;
text-indent: 10px;
font-family: Verdana;
text-indent: 5px;
}
.popup {
display: none;
background: black;
font-size: 14px;
line-height: 18px;
color: white;
opacity: 0.75;
position: absolute;
left: 25%;
border-width: 7px;
border-style: solid;
border-color: black;
max-width: 200px;
text-indent: 0px;
}
.popup::before {
content: " ";
}
.link1:hover {
background: darkGray;
color: black;
}
.link1:hover .popup {
display: block;
}
.link2 {
background: linear-gradient(to right, #333333, #111111);
color: #ff3300;
}
footer {
width: 100%;
height: 50px;
/*background: #aaffaa;*/
text-align: center;
color: #007777;
line-height: 50px;
}
pre {
overflow: scroll;
color: lightGreen;
font-size: 1em;
font-family: "Lucida Console", "Courier New", Courier, monospace;
background: #111111;
text-align: left;
margin-top: 3px;
margin-bottom: 3px;
padding: 3px;
}
.inline_code {
font-family: "Lucida Console", "Courier New", Courier, monospace;
font-weight: bold;
font-style: normal;
}
table {
width: 100%;
border-collapse: collapse;
}
.quotation {
margin-top: 5px;
margin-bottom: 5px;
display: block;
font-family: Times;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 5px;
padding-top: 5px;
background: #ffffdd;
color: black;
}
.quotation .quotation {
background: #cccc00;
}
.quotation .quotation .quotation {
background: #aaaa00;
}
.quotation .inline_code {
background: #ffee00;
}
.formula {
background: white;
color: black;
font-family: Times;
padding: 3px;
margin-top: 3px;
margin-bottom: 3px;
text-align: center;
white-space: nowrap;
overflow-x: scroll;
}
ol ol {
list-style-type: lower-alpha;
}
.LinuxShell a {
color: #00aaaa;
}
/* Generated by VIM */
.Constant {
font-weight: bold;
color: #ffa0a0;
}
.Statement {
color: #f0e68c;
font-weight: bold;
}
.Type {
color: #bdb76b;
font-weight: bold;
}
.Comment {
font-weight: bold;
color: #eeffff;
}
.Keyword {
font-weight: bold;
color: #ffccaa;
}
.Operator {
font-weight: bold;
color: #ffaaff;
}
.String {
color: #ffaa77;
}
.Parenthesis {
color: #aaaaff;
font-weight: bold;
}
/* Generated by Notepad++ */
.sc2 {
color: #ff8000;
}
.sc4 {
font-weight: bold;
color: #ffff80;
}
.sc6 {
font-weight: bold;
color: #4040ff;
}
.sc8 {
font-weight: bold;
color: #8080ff;
}
.sc9 {
font-weight: bold;
color: #ff7777;
}
</style>
</head>
<body>
<noscript>
<img
src="gornjiLijevi.svg"
style="
position: absolute;
left: 8px;
width: 25%;
height: 200px;
top: 8px;
-webkit-animation-name: animacija;
-webkit-animation-duration: 2s;
"
/>
<img
src="gornjiDesni.svg"
style="
position: absolute;
width: 25%;
height: 200px;
left: -webkit-calc(75% - 8px);
left: calc(75% - 8px);
top: 8px;
-webkit-animation-name: animacija;
-webkit-animation-duration: 2s;
"
/>
<img
src="donjiLijevi.svg"
style="
position: absolute;
width: 25%;
height: 50px;
left: 8px;
top: calc(100% + 200px - 8px);
top: -webkit-calc(100% + 200px - 8px);
-webkit-animation-name: animacija;
-webkit-animation-duration: 2s;
"
/>
<div
style="
position: absolute;
top: -webkit-calc(100% + 200px + 50px + 8px);
top: calc(100% + 200px + 50px + 8px);
width: 100%;
height: 50px;
font-size: 36px;
font-family: Arial;
text-align: center;
background: #333333;
color: #aaaaaa;
line-height: 50px;
"
>
Please enable JavaScript!
</div>
</noscript>
<header>
<svg
id="gornjiLijevi"
style="overflow: hidden; float: left; width: 25%; height: 200px"
></svg>
<svg
id="gornjiDesni"
style="overflow: hidden; float: right; width: 25%; height: 200px"
></svg>
<div
style="background: #ffaaaa; float: right; width: 50%; height: 100%"
id="naslov"
>
<div
style="
position: relative;
top: 50%;
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
"
id="titleContainer"
>
AEC specification
</div>
</div>
<script type="text/javascript">
var svgNS = "http://www.w3.org/2000/svg";
function nacrtajRubove() {
var crtanje = document.getElementById("gornjiLijevi");
while (crtanje.childNodes.length)
crtanje.removeChild(crtanje.childNodes[0]);
var visina = crtanje.clientHeight;
var sirina = crtanje.clientWidth;
if (!visina || !sirina) {
visina = crtanje.parentNode.clientHeight;
sirina = crtanje.parentNode.clientWidth / 4;
}
var elipsa = document.createElementNS(svgNS, "ellipse");
elipsa.setAttribute("cx", sirina);
elipsa.setAttribute("cy", visina);
elipsa.setAttribute("rx", sirina);
elipsa.setAttribute("ry", visina);
elipsa.setAttribute("fill", "#ffaaff");
crtanje.appendChild(elipsa);
for (var i = 0; i < 30; i++) {
var kut1 = (270 + i * 3) / 57.3;
var kut2 = (274 + i * 3) / 57.3;
var x1 = Math.round(sirina - Math.cos(kut1) * sirina);
var x2 = Math.round(sirina - Math.cos(kut2) * sirina);
var y1 = Math.round(visina + Math.sin(kut1) * visina);
var y2 = Math.round(visina + Math.sin(kut2) * visina);
var trokut = document.createElementNS(svgNS, "polygon");
trokut.setAttribute(
"points",
x1 + "," + y1 + " " + x2 + "," + y2 + " " + sirina + "," + visina
);
trokut.setAttribute(
"fill",
"rgb(" +
Math.round(255 - i * 2.83) +
",170," +
Math.round(170 + i * 2.83) +
")"
);
crtanje.appendChild(trokut);
}
crtanje = document.getElementById("gornjiDesni");
while (crtanje.childNodes.length)
crtanje.removeChild(crtanje.childNodes[0]);
var elipsa = document.createElementNS(svgNS, "ellipse");
elipsa.setAttribute("cx", 0);
elipsa.setAttribute("cy", visina);
elipsa.setAttribute("rx", sirina);
elipsa.setAttribute("ry", visina);
elipsa.setAttribute("fill", "#ffffaa");
crtanje.appendChild(elipsa);
for (var i = 0; i < 30; i++) {
var kut1 = (i * 3) / 57.3;
var kut2 = (4 + i * 3) / 57.3;
var x1 = Math.round(Math.cos(kut1) * sirina);
var x2 = Math.round(Math.cos(kut2) * sirina);
var y1 = Math.round(visina - Math.sin(kut1) * visina);
var y2 = Math.round(visina - Math.sin(kut2) * visina);
var trokut = document.createElementNS(svgNS, "polygon");
trokut.setAttribute(
"points",
x1 + "," + y1 + " " + x2 + "," + y2 + " 0," + visina
);
trokut.setAttribute(
"fill",
"rgb(255," + Math.round(255 - i * 2.83) + ",170)"
);
crtanje.appendChild(trokut);
}
}
nacrtajRubove();
window.addEventListener("resize", nacrtajRubove);
</script>
</header>
<aside>
<br />
<center><b>Here are my online publications:</b></center>
<br />
<b style="margin-left: 5px">HTML5 stuff:</b>
<a href="sat.html"
><div class="link1">
<div class="popup">
A simple "grandfather clock" animation made in Javascript.
</div>
Analog Clock
</div></a
>
<a href="calculator.html"
><div class="link2 link1">
<div class="popup">
A simple HTML5 online calculator. Can solve parentheses!
</div>
Calculator
</div></a
>
<a href="fraktal.html"
><div class="link1">
<div class="popup">
A spiral fractal I've made by modifying the "Dragon Curve".
</div>
The Dragon Curve
</div></a
>
<a href="pacman.html"
><div class="link2 link1">
<div class="popup">
A Pacman game playable on touch screens. Made in Javascript using
the SVG graphics.
</div>
PacMan
</div></a
>
<a href="etymologist.html">
<div class="link1">
<div class="popup">
A flashcard game in which the goal is to guess the etymologies of
the words in simulated languages.
</div>
Etymology Game
</div></a
>
<br /><b style="margin-left: 5px">Webpages on this website:</b>
<a href="index.html"
><div class="link1">
<div class="popup">A webpage with a bunch of links.</div>
Homepage
</div></a
>
<a href="libertarianism.html"
><div class="link2 link1">
<div class="popup">What do I think about politics?</div>
Libertarianism
</div></a
>
<a href="vegetarianism.html"
><div class="link1">
<div class="popup">Why I don't eat meat.</div>
Vegetarianism
</div></a
>
<a href="Simulation.html"
><div class="link2 link1">
<div class="popup">Could the universe be a giant computer?</div>
Digital Physics
</div></a
>
<a href="linguistics.html"
><div class="link1">
<div class="popup">
Why I like languages.<br /><br />
See also:<br />
<u
style="color: #0077ff"
onclick="window.open('http://flatassembler.github.io/toponyms.html'); window.close();"
>Croatian Toponyms</u
><br />
<u
style="color: #0077ff"
onclick="window.open('http://flatassembler.github.io/Indo-Austronesian.html'); window.close();"
>Indo-Austronesian</u
>
</div>
Linguistics
</div></a
>
<a href="informatics.html"
><div class="link2 link1">
<div class="popup">Why I like computers.</div>
Informatics
</div></a
>
<a href="pseudosciences.html"
><div class="link1">
<div class="popup">
My advice on how to recognize and deal with false sciences.
</div>
Pseudosciences
</div></a
>
<br /><b style="margin-left: 5px">On Internet forums and blogs:</b>
<a href="http://linguistforum.com/outside-of-the-box/croatian-toponyms/"
><div class="link1">
<div class="popup">
The forum thread in which I explained my linguistic theories in
detail.
</div>
Croatian Toponyms
</div></a
>
<a href="https://atheistforums.org/thread-50241.html"
><div class="link2 link1">
<div class="popup">My parody of the conspiracy theorists.</div>
Airplanes Don't Exist
</div></a
>
</aside>
<section>
<p style="margin-left: 5px; margin-right: 5px">
<br />
I've started a discussion about AEC
<a href="https://www.forum.hr/showthread.php?t=1125353">on</a>
<a href="https://atheistforums.org/thread-57848.html">many</a>
<a href="https://philosophicalvegan.com/viewtopic.php?f=15&t=4429"
>Internet</a
>
<a
href="https://www.theflatearthsociety.org/forum/index.php?topic=85381.0"
>forums</a
>, including
<a
href="https://www.reddit.com/r/ProgrammingLanguages/comments/iehbmj/my_programming_language_can_now_run_in_a_browser/?utm_source=share&utm_medium=web2x&context=3"
>Reddit</a
>,
<a
href="https://www.reddit.com/r/croatia/comments/piirms/je_li_još_netko_ovdje_izradio_svoj_programski/?utm_source=share&utm_medium=web2x&context=3"
>Croatian Reddit</a
>
and
<a
href="https://discord.com/channels/530598289813536771/847014270922391563/847016574421958686"
>Discord</a
>.<br />
</p>
<br />
<a id="loptica" href="#vrh" style="position: absolute">
<svg width="100" height="100">
<defs>
<radialgradient id="modrozelen">
<stop offset="0%" stop-color="#00FFFF" />
<stop offset="100%" stop-color="#0000FF" />
</radialgradient>
<radialgradient id="ljubicastoplav">
<stop offset="0%" stop-color="#FF00FF" />
<stop offset="100%" stop-color="#0000FF" />
</radialgradient>
</defs>
<circle cx="50" cy="50" r="50" fill="url(#modrozelen)" />
<polygon
points="50,25 25,50 38,50 38,75 62,75 62,50 75,50"
fill="url(#ljubicastoplav)"
/>
</svg>
</a>
<script type="text/javascript">
var udaraca = 0;
var loptica = document.getElementById("loptica");
var pocetna = loptica.parentNode.clientHeight + 200 - 100;
loptica.style.top = pocetna;
loptica.style.right = loptica.parentNode.clientWidth / 2 - 50;
var h = 0;
var gk = 1;
var v = 10;
window.setInterval(pomakniLopticu, 80);
window.addEventListener("resize", promijeniPocetnu);
function promijeniPocetnu() {
pocetna = loptica.parentNode.clientHeight + 210 - 100;
loptica.style.top = pocetna;
loptica.style.right = loptica.parentNode.clientWidth / 2 - 50;
h = 0;
gk = 1;
v = 10;
}
function pomakniLopticu() {
h += v;
v -= gk;
if (h < 0) {
v = -v * 0.75;
h = 0;
udaraca++;
if (udaraca > 20) {
udaraca = 0;
v = 10;
}
}
loptica.style.top = pocetna - h;
}
</script>
</section>
<main class="main1" id="glavni" style="display: block">
<a name="vrh"></a>
<h2 style="text-align: center">AEC Specification</h2>
<div
style="
text-align: justify;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 25px;
"
>
<b>Contents</b><br />
<ol>
<li>
<a href="#aec_logo">Logo of my programmming language</a>
</li>
<li>
<a href="#Introduction">Introduction</a>
<ol>
<li>
<a href="#compilers_doing_too_much"
>Compilers trying to do too much</a
>
</li>
<li>
<a href="#special_insight"
>How making a programming language is insightful</a
>
</li>
<li>
<a href="#language_related_bugs"
>Programming in your programming language avoids many bugs</a
>
</li>
<li>
<a href="#other_programs"
>How knowing compiler theory helps with writing other types of
programs</a
>
</li>
</ol>
</li>
<li>
<a href="#Platforms">What platforms can be targeted now</a>
<ol>
<li>
<a href="#why_WebAssembly"
>Croatian text that explains why WebAssembly is an
exceptionally easy target for compilers</a
>
</li>
</ol>
</li>
<li>
<a href="#HowToCompile">How to use the compilers</a>
<ol>
<li>
<a href="#AEC_to_x86">Original ArithmeticExpressionCompiler</a>
</li>
<li><a href="#AEC_to_WebAssembly">AECforWebAssembly</a></li>
</ol>
</li>
<li><a href="#Comments">Comments</a></li>
<li>
<a href="#Constants">Constants</a>
<ol>
<li><a href="#multiline_strings">Multi-line strings</a></li>
<li>
<a href="#underscores_inside_number_literals"
>Underscores inside number literals</a
>
</li>
</ol>
</li>
<li><a href="#Variables">Variable declarations</a></li>
<li><a href="#Arrays">Arrays and pointers</a></li>
<li><a href="#Assignments">Assignments</a></li>
<li>
<a href="#Operators">Operators</a>
<ol>
<li><a href="#chained_comparisons">Chained comparisons</a></li>
</ol>
</li>
<li>
<a href="#Branching">Branching</a>
<ol>
<li>
<a href="#ternary_operator_bug"
>Caveat about the ternary
<span class="inline_code">?:</span> operator</a
>
</li>
<li>
<a href="#left_hand_side_conditional_operator"
>Left Hand Side Conditional Operator</a
>
</li>
</ol>
</li>
<li><a href="#Loops">Loops</a></li>
<li>
<a href="#Functions">Functions</a>
<ol>
<li>
<a href="#namedArguments"
>Named function parameters (named arguments)</a
>
</li>
</ol>
</li>
<li><a href="#Structures">Structures</a></li>
<li><a href="#Assembly">Inline assembly</a></li>
<li><a href="#Builtin">Built-in functions</a></li>
<li><a href="#String">String manipulation</a></li>
<li><a href="#AdvancedArray">Advanced array manipulation</a></li>
<li>
<a href="#DifferencesInDialects"
>Example program in both dialects of AEC</a
>
</li>
<li><a href="#Conclusion">Conclusion</a></li>
<li><a href="#stuxxnet">Stuxxnet's comments</a></li>
<li><a href="#dealing_with_trees">Dealing with trees</a></li>
</ol>
<b id="aec_logo">Logo</b><br />
Here is a quick-and-dirty logo I made using GIMP and LibreOffice Calc:
<img
src="logo.PNG"
alt="ArithmeticExpressionCompiler logo"
style="
max-width: 100%;
margin-left: auto;
margin-right: auto;
margin-top: 5px;
margin-bottom: 5px;
display: block;
"
/>
I hope it is good enough, I am not an artist...<br /><br />
<b id="Introduction">Introduction</b><br />
<span id="compilers_doing_too_much"
>Compilers these days, even C compilers, have lots of features and are
often smarter than the programmer when it comes to things they are
made to do. While this is usually very useful, sometimes it's
counter-productive. Suppose that you are writing a program in Assembly
and want to do something high-level (because correctness is way more
important than speed). You can't tell your C compiler to simply output
the code to assign <span class="inline_code">sqrt(a*a+b*b)</span> to
<span class="inline_code">c</span>, if you try to, it will complain
those variables aren't declared and that you aren't in a C function. C
compilers have ideas how to declare functions and variables in
assembly. While these ideas usually work, sometimes you are writing
something where the assembler will complain if you give it the code
that C compilers produced for those things, and there is no way to
modify the code the C compiler outputs for declaring a function in C.
So, sometimes, compilers, while they could come useful for some task,
are trying to do too much and are thus counter-productive. In my
opinion, this is especially true for the mainstream compilers
targetting <a href="https://youtu.be/cbB3QEwWMlA">WebAssembly</a>, but
<a href="#about_emscripten">more on that later</a>. Also, compilers
are buggy, and nearly all compiler bugs are in the optimizer. Can we
have a language with a compiler that does only what you told it, in a
very predictable way? Well, that's what inspired me to create
<i>Arithmetic Expression Compiler</i> (AEC) a few years ago. The first
programming language I learned was
<a href="https://smallbasic-publicwebsite.azurewebsites.net/"
>Microsoft Small Basic</a
>, I have made a
<a href="https://github.com/FlatAssembler/Labyrinth"
>Labyrinth game</a
>
in it, and it has influenced a lot the decisions I made when designing
my programming language. Microsoft Small Basic is a simplified
programming language that compiles to .NET bytecode (the same one that
C# compiles to), and it is the only language that compiles to .NET
bytecode that I have managed to learn so far.</span
><br /><span id="special_insight"
>I have also always been interested in languages, both natural and
artificial (such as programming languages), and making a programming
language will certainly give me a lot better insight into how
programming languages really work. That is not quite true for natural
languages: if you try to make your own constructed language to be
spoken by humans (similar to Esperanto), and you do not know about
<i lang="la">consecutio temporum</i>, you will most likely not specify
how <i lang="la">consecutio temporum</i> is supposed to work in your
language and you will probably not even realize your grammar has a
huge hole in its specification (You will assume it is understood by
itself it will be done the same way as in your native language,
thinking, like I used to think before learning about
<i lang="la">consecutio temporum</i> in English, that the way tenses
are put together in complex sentences in your native language is based
on logic, rather than that the rules for that are
essentially-arbitrary. And in case you think all languages with tenses
follow either the Croatian-like
<i lang="la">consecutio temporum</i> or the Latin-like
<i lang="la">consecutio temporum</i>, like I used to think until
recently, read
<a
href="https://www.reddit.com/r/EnglishLearning/comments/150dcm7/comment/js2k9x0/?utm_source=share&utm_medium=web2x&context=3"
>this Reddit answer to my question about accusative with infinitive
and <i lang="la">consecutio temporum</i> in English</a
>. If you use accusative with infinitive in English, you should use
Croatian-like <i lang="la">consecutio temporum</i>, even though, if
you use indirect speech with object clauses, you should use Latin-like
<i lang="la">consecutio temporum</i>. And you don't even need complex
sentences to show that tenses work very differently in different
languages, even related ones. In English, an adverbial phrase such as
"<i>every evening</i>" puts the verb in a simple tense. You
say "<i>He comes here every evening.</i>", and "<i
>He is coming here every evening.</i
>" is ungrammatical, or is perhaps grammatical for the meaning
that the speaker is annoyed by him coming. In Croatian, exactly the
opposite is true: an adverbial phrase such as "<i
>svaku večer</i
>", meaning "<i>every evening</i>", puts the sentence
in a continuous tense. You say "<i
>On dolazi ovdje svaku večer.</i
>", and "<i>On dođe ovdje svaku večer.</i
>" sounds very ungrammatical, or is perhaps grammatical for the
meaning that it is going to happen in the future even though it is not
happening yet. I have asked a
<a href="https://latin.stackexchange.com/q/20898/8533"
>StackExchange question about how it is in Latin</a
>, another natural language I know somewhat. You will probably not
realize that such things differ between languages by making your own
language similar to Esperanto.). But it is true that making a
programming language gives you a special insight into how programming
languages, and computers in general, work. Especially if you are
writing everything yourself (like I am doing), rather than using
frameworks for tokenizing, parsing and compiling. To be clear, I am
not saying making your programming language gives you some special
insight into how languages in general work. Although in
<a href="Fonoloska_evolucija_jezika.docx">papers</a>
<a href="Karasica.doc">I</a>
<a
href="https://github.com/FlatAssembler/ArithmeticExpressionCompiler/raw/master/seminar/PojednostavljeniSeminar.pdf"
>have</a
>
<a href="PicoBlaze/PicoBlaze.rtf">written</a> I have often made
comparisons between human languages and programming languages, I am
not entirely convinced the similarity between human languages and
programming languages is anything more than superficial (Look up
"<i>pseudo-coordination</i>" - it is a grammatical
construction found in many languages, including English, which can
hardly be explained by structural or generative theories of the
syntax. Or, probably a less extreme example, "<i
><a href="https://languagedesign.stackexchange.com/q/1461/330"
>Donkey Sentences</a
></i
>".).</span
><br />
<span id="language_related_bugs"
>Also, I think programming in a programming language you have made
yourself is a good idea because it avoids the bugs that come from
misunderstanding the programming language you are using. I think that
is a major source of bugs in programs, yet one that is talked about
very little. Most of the bugs I've run into came from me
misunderstanding the language I was using. Quite a few languages, most
notably JavaScript, try to fix syntactically incorrect programs by
inserting a semi-colon <span class="inline_code">;</span> according to
some rules. Sometimes the result of that is really what the programmer
intended, but quite often it is not. I have run into that problem, not
in JavaScript, but in Octave, when I was writing
<a href="toponyms.html#correction"
>a program to study the relationship between the Shannon entropy and
the collision entropy</a
>. It was only when I tried running my program in MatLab (another
implementation of the same programming language) that I even realized
there was a bug. Had I used my programming language instead of Octave,
something like that simply could not have happened to me. And when
writing my AEC-to-WebAssembly compiler in C++, C++ has surprised me
quite a few times, and once made a very hard-to-trace bug (you can
read about it in the <a href="#Structures">Structures section</a>). So
has JavaScript surprised me a few times when I was writing my
PicoBlaze assembler and emulator in JavaScript. For example, what do
you think happens if you pass a string with an invalid number (for
example, with a letter inside a decimal number, or a digit bigger than
1 in a binary number) to the JavaScript function
<span class="inline_code">parseInt</span>? If you have answered that
it throws an exception, you are wrong. In fact, it returns
<a href="https://en.wikipedia.org/wiki/NaN">a not-a-number</a>. I
guess it is because the first versions of JavaScript didn't have
exceptions, but I suppose they did have
<span class="inline_code">parseInt</span>, which had to signal error
somehow differently, so that weird way of signalling an error was kept
because of compatibility. Wrongly thinking it throws an exception
<a
href="https://github.com/FlatAssembler/PicoBlaze_Simulator_in_JS/issues/27"
>caused my assembler to fail silently in case somebody writes an
invalid decimal or binary number</a
>. Had I written the assembler in my programming language, such a bug
would be impossible, because I would know how the equivalent of
<span class="inline_code">parseInt</span> signals an error. When
programming in a programming language you have made, you understand
how the tools you are using work, and you have an at least basic
understanding how the environment you are targetting works (to make a
compiler targetting WebAssembly, you need to have at least basic
understanding how modern browsers work), so you are not doing
bloodletting. WebAssembly is designed to be an exceptionally easy
target for compilers, so now you can easily program in a programming
language you have made and make the programs you have written in it
run in modern browsers.</span
><br />
<span id="other_programs"
>I also think that having some experience writing compilers can help
you write other types of programs more effectively. If I didn't know
as much about compiler theory as I know, I think I would have much
more trouble writing the
<a href="PicoBlaze/PicoBlaze.html"
>web-based PicoBlaze assembler and emulator</a
>, if I would even succeed at it at all. My PicoBlaze Simulator solves
a real-world issue: PicoBlaze is a small computer produced by Xilinx
that we are using as an example of a simple computer at our Computer
Architecture classes, and my Computer Architecture professor Ivan
Aleksi asked me to create it so that laboratory exercises can be done
from home (in case real laboratory exercises need to be canceled due
to the pandemic).</span
><br />
<br /><b id="Platforms">What platforms can be targeted now</b><br />
Right now, I've written two compilers for the AEC language. First, I
wrote one targeting x86 processors (AMD and Intel). That one is written
in JavaScript and the <a href="compiler.html">core of it</a> can be run
in browsers that have basic support for JavaScript (even in Internet
Explorer 6). To use all the features, one needs to use
<a href="https://nodejs.org/en/">NodeJS</a> or
<a href="https://duktape.org/">Duktape</a> with it, to enable it to
access the file system. Thanks to
<a href="https://www.vogons.org/viewtopic.php?f=31&t=74881"
>the help I received from people on VOGONS forum</a
>, my AEC-to-x86 compiler outputs assembly code that runs on both i486
in 32-bit mode and on x86_64 processors in 64-bit mode, with no
modification (it uses <span class="inline_code">ebx</span> register for
indexing arrays, which is allowed (although not recommended) in 64-bit
mode, and it does not push and pop 32-bit values from the stack, it only
pushes and pops 16-bit ones, which is allowed in both 32-bit and 64-bit
mode, and so on..). When I started studying at the university, many
professors were impressed by my AEC-to-x86 compiler. My Algorithms and
Data Structures professor Alfonso Baumgartner urged me to write a
<a
href="https://github.com/FlatAssembler/ArithmeticExpressionCompiler/raw/master/seminar/PojednostavljeniSeminar.pdf"
>
paper</a
>
about it which got published in Osječki Matematički List. The
compiler targeting x86 is around 2'000 lines of code (excluding the
example programs). So, I decided to extend it so that my language can be
used to target JavaScript Virtual Machine using WebAssembly (the
JavaScript bytecode, which Mozilla has been pushing to get standardized,
so that people can run programming languages better than JavaScript in a
browser), and not only x86. As targeting WebAssembly is easier than
targeting x86 (or probably any physical processor, as WebAssembly was
designed to be an easy target for compilers, rather than to be easily
implemented in hardware or easy to write assembly-language code for
manually), I was able to add many new features. However, I think it's
still not nearly as
<i>intrusive</i> as C compilers are.
<a href="https://emscripten.org/" id="about_emscripten">Emscripten</a>
(the primary C and C++ compiler for WebAssembly, a modified version of
the <a href="https://clang.llvm.org/">CLANG</a> compiler) always assumes
the standard C library is present on the JavaScript Virtual Machine when
compiling any kind of program, so it's an overkill for most cases when
it could come useful. The
<a href="https://github.com/FlatAssembler/AECforWebAssembly"
>AEC-to-WebAssembly compiler</a
>
has around 5'500 lines of code, and it's written in C++ (a language much
more suitable for writing compilers than JavaScript). <br />
WebAssembly is one of the reasons I am a libertarian, because it shows
that, when a private company makes a mistake, no matter how hopeless the
situation seems, there will come a solution... from capitalism itself.