Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitd649c570535f9702c13cbc7b872ddd66c564581c (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-04-13 13:49:54 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-04-13 13:49:54 +0300
Files19b59ff3d7c87633a770bd3e50e9da1d84523370
syndamia.com-d649c570535f9702c13cbc7b872ddd66c564581c.tar
syndamia.com-d649c570535f9702c13cbc7b872ddd66c564581c.tar.gz
syndamia.com-d649c570535f9702c13cbc7b872ddd66c564581c.zip
Parent2b2cbc4eb7cc6499327bee6b3ec19f1544c4f842 (diff)
[blog/seoc] Restructured layout into multiple page one
1 files changed, 12 insertions, 15 deletions
-rw-r--r--src/blog/sane-explanation-of-compilers/part-1.md (renamed from src/blog/sane-explanation-of-compilers/index.md)27
diff --git a/src/blog/sane-explanation-of-compilers/index.md b/src/blog/sane-explanation-of-compilers/part-1.md
index 21a6b64..250d9d2 100644
--- a/src/blog/sane-explanation-of-compilers/index.md
+++ b/src/blog/sane-explanation-of-compilers/part-1.md
@@ -1,4 +1,4 @@
-# Sane explanation of compilers
+# Sane explanation of compilers: Part 1
## Contents
@@ -18,18 +18,14 @@
3. [Implementing a front-end](#implementing-a-front-end)
1. [lex](#lex)
2. [yacc](#yacc)
-4. [II. How can we improve the code?]
-5. [III. Virtual machines]
-6. [Compilation schemes]
- 1. [AOT]
- 2. [JIT]
-
Recently I signed up for a small university course about compilers.
-The resources and lectors were good, but when studying I found most material online either deals with something on a very surface level or a very deep level.
-Before I've forgotten everything, I'll try to hit that middle spot, generally covering the most important corners of the subject.
+As I found out, most materials on the topic are either so surface level you barely learn anything, or so specific you need to already know the subject.
+My goal is to try and fill that void, explaning everything in a detailed way that is understandable for beginners.
-*P.S.* The course resources are available on [sofiacpp.github.io/IPL](https://sofiacpp.github.io/IPL/) with the underlying repo being [SofiaCPP/IPL](https://github.com/SofiaCPP/IPL).
+Originally I planned to put everything in one blogpost, but only this main component took me 2 weeks (slightly inconsistently) to write.
+Additionally, while doing research, I found out we actually skiped over a lot of important topics.
+Future parts will be linked right below the title at the very top, but it will probably be quite a while until I write them.
## Preface
@@ -45,6 +41,8 @@ This job is delegated to a special type of program, called a compiler[^how-did-w
2. Middle: does optimizations and simplifications, though this part is often inside the back-end
3. Back-end: generates the actual machine instructions
+In this post, we'll be looking only at the first one.
+
## I. How do we understand code?
Syntax in current programming languages can be quite sophisticated and ambiguous. For example (taken from [wikipedia](https://en.wikipedia.org/wiki/Most_vexing_parse)) this C++ snippet
@@ -832,12 +830,11 @@ A yacc file looks very similar to a lex one:
however rather than definitions you have settings, and the rules are in a completely different format (because they're grammars).
+## II. Virtual machines
-## II. How can we improve the code?
-
-
-
-## III. Virtual machines
+Let's skip over the middle layer for a second, and talk about machine instructions.
+It should come as no surprise that transforming an AST to specific instructions isn't very fast or simple.
+Additionally, there are thousands upon thousands of different
[^how-did-we-get-here]: Though it's obvious, I would like to point out that modern compilers are most often written in languages that are themselves compiled. You might ask yourself "where did the first compiler come from?" The answer is simple: it was written with "numbers", with direct instructions to the processor, from the time when computers were simple enough that *all* programming was done with CPU instructions.