WebBS | fur | |
---|---|---|
1 | 2 | |
50 | 0 | |
- | - | |
10.0 | 8.8 | |
almost 2 years ago | 11 months ago | |
JavaScript | C | |
MIT License | GNU General Public License v3.0 only |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
WebBS
-
Pratt Parsers: Expression Parsing Made Easy
A few years back I had to implement a new parser for a custom expression language to replace an old parser that didn’t giving very good errors and was hard to extend. I never did the traditional CS track so parsers were kind of mysterious black magic so naturally first thing I did was search HN.
I stumbled on an older parsing thread [1] with a link to a toy Prayt implementation [2] made by an HNer… and shamelessly ripped it off to write my own Pratt parser implementation.
Great success! Writing a Pratt parser by hand is a lot easier than I thought and like the comment says, adding type information was trivial.
[1] https://news.ycombinator.com/item?id=24480504
[2] https://github.com/mx-scissortail/WebBS
fur
-
Pratt Parsers: Expression Parsing Made Easy
I found this Rust tutorial[1] on Pratt parsers to be really easy to follow as well. I'm not a Rustacean but I didn't find not knowing Rust to be a barrier. I used that as a guide to write the parser for my experimental programming language Fur[2].
However, I'll caution anyone writing their own programming languages to read some wisdom from someone who has written a production-quality programming language[3]. Most programming language developers get bogged down in writing the parser and never even get into solving the real hard problems of language development, which are things like bytecode generation and garbage collection. The fact is, a naive recursive descent parser with some low lookahead number to handle left recursion will be performant and can be written in an afternoon for 99% of parsable languages. I'm not sure what it is about parsers that makes them susceptible to yak shaving, but it seems to be a trap a lot of people fall into (including myself!).
[1] https://matklad.github.io/2020/04/13/simple-but-powerful-pra...
[2] https://github.com/kerkeslager/fur/blob/main/parser.c
[3] https://craftinginterpreters.com/compiling-expressions.html#...
-
Strong typing, a hill I'm willing to die on
One might say that the embracing of reflection in Java and C# pretty much solidifies the case against static typing for complicated projects.
I'd tend to think the important feature here is strong typing, not static typing, and indeed TypeScript, which is hampered by the anemic type system of its parent JavaScript, it not the best example of strong typing.
Ultimately, strong typing is a hill I'm willing to die on, too. But a lot of people making arguments on this topic are conflating it with static typing, which just isn't the same thing. In general, that gives me the impression you haven't done enough work in enough different languages to really have an informed opinion.
Though uncommon, strong dynamic type systems do exist. This is the approach I'm taking with Fur[1]. Python is... stronger than many other popular languages (i.e. JavaScript), but still does a lot of coercion (particularly around truth-y/false-y values).
But perhaps more critically, weak static type systems also exist, such as C, which is the source of many of the world's most serious bugs. It's highly unwise to assume that static typing is strong typing.
[1] https://github.com/kerkeslager/fur
What are some alternatives?
pratt-parser-blog-code - The code to illustrate the pratt parser blog post for the desmos engineering blog.
gerbil - Gerbil Scheme
SICL - A fresh implementation of Common Lisp
clj-kondo - Static analyzer and linter for Clojure code that sparks joy
eastwood - Clojure lint tool
talk-transcripts - Transcripts of Clojure-related talks
FrameworkBenchmarks - Source for the TechEmpower Framework Benchmarks project
rescript-compiler - The compiler for ReScript.