Semantic Domain
semantic-domain.blogspot.com · Personal blog · on HN since 2013
Semantic Domain is a programming languages researcher's blog on functional programming, verification, compilers, type theory, and regular expressions.
What HN saysCommenters recommend its posts on Antimirov derivatives for regex matching and on why functional programs are easier to verify than imperative ones.
32HN people shared it
11linked it in comments
32stories submitted
500story points
6 months agolast shared
2013people per year2026
Most-shared posts
- 1What Declarative Languages Are (2013)6 people · 44 points · first shared 2013 · 12 comments on HN
- 2The golden age of PL research4 people · 9 points · first shared 2022 · discussion on HN
- 3Thought Experiment: An Introductory Compilers Class3 people · 98 points · first shared 2020 · 22 comments on HN
- 4Are functional programs easier to verify than imperative programs? (2018)3 people · 9 points · first shared 2018 · 2 comments on HN
- 5How to implement a spreadsheet2 people · 177 points · first shared 2015 · 68 comments on HN
- 6The Relationship Between Static Analysis and Type Theory2 people · 5 points · first shared 2019 · discussion on HN
- 7Are functional programs easier to verify than imperative programs? (2018)2 people · 3 points · first shared 2018 · discussion on HN
- 8Error Handling in Menhir2 people · 2 points · first shared 2016 · discussion on HN
- 9Antimirov derivatives for regular2 people · first shared 2018
- 10Every Finite Automaton Has a Corresponding Regular Expression1 people · 94 points · first shared 2019 · 44 comments on HN
- 11The Worm Ouroboros1 people · 44 points · first shared 2018 · 12 comments on HN
- 12Linear-Time Parser Combinators1 people · 5 points · first shared 2023 · discussion on HN
- 13Antimirov Derivatives for Regular Expressions1 people · 2 points · first shared 2013 · discussion on HN
- 14Five (and a Half) Derivatives in Language Theory1 people · 2 points · first shared 2021 · discussion on HN
- 15How to Read Papers1 people · 2 points · first shared 2024 · discussion on HN
What HN people wrote when they linked it
dysoco · 2024-09-11
I remember John Carlos Baez having some interesting stuff: https://johncarlosbaez.wordpress.com/
Some other ones I had bookmarked the other day but haven't seen much in depth, mostly computer science based but more towards theory/math side:
https://blog.computationalcomplexity.org/
https://semantic-domain.blogspot.com/
https://greydanus.github.io/
Also go to Terry Tao's blog and look at the sidebar, there are a lot of links to external blogs there.
abecedarius · 2022-08-26
Nice! I should've expected this could be that short, but I didn't.
Here's my favorite approach to "rediscovering" efficient regex matching: https://semantic-domain.blogspot.com/2013/11/antimirov-derivatives-for…
It's implicit in the Thompson paper I linked above, but imo not obvious from it.
neel_k · 2018-11-12
Eleven years on, this remains one of my favorite papers!
There's a pretty variant of this idea introduced in 1995 by Valentin Antimirov called partial derivatives of regular expressions. His idea was to replace the single derivative with a set of partial derivatives that add up to the whole derivative. This simplifies the derivative algorithm quite a bit, and makes it possible to write amazingly concise and efficient regular expression matchers.
E.g., here's an implementation of a regular expression compiler that uses Antimirov derivatives to take a regexp and build a table-driven matcher in about 50 lines of code:
http://semantic-domain.blogspot.com/2013/11/antimirov-derivatives-for-…
nickpsecurity · 2019-01-07
An article you might find helpful is this one on why imperative algorithms are harder to mathematically verify than functional ones:
https://semantic-domain.blogspot.com/2018/04/are-functional-programs-e…
You don't need to be a mathematician to follow it with this excerpt summarizing its key point:
"The difficulty of imperative programming arises from the combination of state, aliasing and procedure calls. Any two of these features can be handled without that much difficulty, but the combination of all three effectively makes reasoning (nearly) as difficult as correct concurrent programming. "
The garbage-collected languages let you ignore the aliasing problems with a performance penalty. Rust in safe mode without GC forces you to (a) deal with it and (b) deal with it in a way that works for all inputs (type/memory safety). That usually requires mathematical verification using tools such as separation logic. Rust's method is much easier to use with tradeoff of limitations on expressing code in certain ways.
Folks that get along with the borrow-checker say it helps to design the program around data and easy methods of using it versus starting with control flow forcing it on a data structure. I'll also add that linked lists are inherently hard to get right on all inputs regardless of low-level language. They're actually a popular way to test new, mathematical methods for specifying and proving algorithms correct. Fortunately, Rust folks have a goto write-up on…
edwintorok · 2015-06-11
If I oversimplify I would say that due to pattern matching and functional nature of OCaml you can avoid
much of the boilerplate code needed for building tree nodes, or finding the node you want, allowing you to focus on the high-level task you want to actually achieve.
In fact one thing that you might notice in the beginning when reading OCaml is that the code seems more "dense".
In C I was used to reading code by skipping over large chunks of it (again I'm oversimplifying here) like the one below, and one of the things I had to get used to when learning OCaml was to slow down and avoid skipping large chunks of code:
if (some_complex_condition == failed) {
/* ... large block of code for error handling to ignore on first read .. */
}
result = malloc(...);
result->... = ...;
result->... = ....;
Here are some examples of what is possible with symbolic manipulation in OCaml, although I would recommend learning a bit of OCaml syntax and concepts from a book first
(such as Real World OCaml):
A short example of implementing regular expression matching using Antimirov's partial derivatives that illustrates symbolic manipulation:
http://semantic-domain.blogspot.ro/2013/11/antimirov-derivatives-for-r…
A step-by-step explanation of a DSL optimizer that doesn't use too many advanced notions of OCaml:
http://okmij.org/ftp/tagless-final/course/optimizations.html
A nice example of symbolic manipulation is this counter-example generator for regular…
spekcular · 2021-03-31
> I've pressed for details, and I've seen others do the same, but it never ends in anything concrete—just an implicit appeal to the new conventional wisdom that they do more harm than good.
Really? Merits of the criticism aside (I don't know anything about compilers, so I'm not capable of judging), the received wisdom seems to be that the Dragon book spends far too much time on parsing and not enough time on other, more important aspects of modern compiler development.
See, for instance, this blog post by a professor about teaching a compilers course: http://danghica.blogspot.com/2020/04/teaching-compilers.html.
Or this blog post (and the one it links in the first paragraph): https://semantic-domain.blogspot.com/2020/02/thought-experiment-introd…
nsajko · 2020-11-26
Maybe you should check out the Menhir parser generator instead.
Some links:
http://gallium.inria.fr/~fpottier/menhir/manual.pdf
https://semantic-domain.blogspot.com/2015/11/error-handling-in-menhir.…
https://baturin.org/blog/declarative-parse-error-reporting-with-menhir…
catnaroek · 2016-08-25
> declarativism
I'm not familiar with that term. Could you give a rigorous definition?
Anyway, after some googling, I found a very plausible definition that makes functional programming not a declarative paradigm: http://semantic-domain.blogspot.com/2013/07/what-declarative-languages…
vilhelm_s · 2014-12-28
Neel Krishnaswami wrote a quite readable description of the proof on his blog: http://semantic-domain.blogspot.com/2014/06/g-ontological-argument.htm…
primodemus · 2013-04-29
a few small anecdotes about him: http://semantic-domain.blogspot.fr/2013/04/john-c-reynolds-june-1-1935…
tel · 2019-02-07
"Declarative" programming has become something of a buzzword. This is unfortunate because it prevents finer distinctions between domain specific language techniques.
I think it achieved its buzzword status because it for a long time was something people clearly recognized but couldn't define. Fortunately, Neel Krishnaswami wrote a very cogent post putting his finger on the nerve.
https://semantic-domain.blogspot.com/2013/07/what-declarative-language…
With this definition we can see that (a) the author misses the boat on "declarative" in a concrete way and instead lands on something much closer to DSLs in general and (b) then only uses a narrow set of DSLs to provoke criticism and thus presents a very weak argument.
The powerful core of his argument—the "unfolding" principle—is not something I can claim to understand fully from this article, but it suggests something worrying: that every DSL must transparently resemble its interpretation. This makes it easy for a user of the DSL to recognize how it will be interpreted and thus achieve ease of understanding... but it gets dangerously close to banning abstraction all together!
In my opinion, the true measure of a DSL is the consistency and diversity of semantic interpretations (or "models") that are valid for the DSL and consistent with one another. This measure seems to establish the resilience and leverage a given DSL's topic might have.
Consider how SQL can describe set operations, an abstract search process,…