Top all-time · #3397
Trevor Jim
Personal blog · trevorjim.comprogrammingsystems
Trevor Jim's personal blog at trevorjim.com covers programming and systems. Since 2013, 23 different Hacker News readers have linked it 36 times, most often “Python is not context free (2012)”. The last post was in 2021, but the archive is still widely read.
Too few sampled comments (12) to say how often HN recommends it.?
Why HN links it
HN readers link Trevor Jim's blog as a reference on programming language theory: whether C, C++ and Python are context-free, Postel's law, Cyclone, and the history of Emacs versus Vim.
Summarised by Claude from a sample of 12 HN comments that link here. Each comment is marked recommending, critical or neutral (citing without judging); how this works.
Most-linked posts?
- Python is not context free (2012)4 people · 4 mentions · first linked 2013-11-13
- Cyclone, a Rust predecessor safe dialect of C, in a VM3 people · 4 mentions · first linked 2016-05-13
- How Emacs beat vi in the Editor Wars3 people · 3 mentions · first linked 2020-09-03
- C and C++ are not context free3 people · 3 mentions · first linked 2014-11-04
- Haskell is not context free – 20123 people · 3 mentions · first linked 2017-05-02
- Using an unsafe language is a design flaw2 people · 2 mentions · first linked 2022-09-20
- /postels-law-is-not-for-you/2 people · 2 mentions · first linked 2016-10-26
What Hacker News says?
Unless he means that Rust should be used on projects where the Rust compiler is available for all relevant platforms and C and C++ can be used otherwise, I disagree. In fact, until LLVM is replaced, C++ will probably be the language of choice for new languages. Even `rustc` requires a C++ bootstrap for that purpose. There are also other important C++ and C libraries that will continue to mean C and C++ may be better…
Comment linking /using-an-unsafe-language-is-a-design-flaw/
on “It's time to halt starting any new projects in C/C++”Submitted Python is not context free (2012) as a story · 73 points
HN discussionPerhaps "The Harmful Consequences of Postel's Maxim"?: https://news.ycombinator.com/item?id=9824638 If not, perhaps one of these: http://programmingisterrible.com/post/42215715657/postels-pr... https://bitworking.org/news/There_are_no_exceptions_to_Poste... http://trevorjim.com/postels-law-is-not-for-you/
Comment linking /postels-law-is-not-for-you/
on “Parsing JSON is a Minefield”Submitted Let’s sunset C/C++ as a story · 31 points
HN discussionI would be worried about handling the not-context-free parts of the language: http://trevorjim.com/c-and-cplusplus-are-not-context-free/ How would you handle these?
Comment linking /c-and-cplusplus-are-not-context-free/
on “C4 – C in 4 functions”Submitted The terrible beauty of C (2015) as a story · 6 points
HN discussionThe other big problem with Postel's law is that it makes enforcing security guarantees a nightmare. When each component in a system is "liberal in what it accepts", it's very easy to fall into a trap where component A thinks that component B is performing the security checks and component B thinks that component A is performing the check and as a result the security check is either never performed or trivially sides…
Comment linking /postels-law-and-network-security/
on “‘Laws’ of Software Development”Submitted A public health campaign to stop C/C++ as a story · 6 points
HN discussion> I think you should really be pushing more for SML or Haskell or something like that. There are two clues in this sentence (mentioning SML and not OCAML, "something like that") that suggest you do not regularly program in a "something like that" language. I wrote my first Haskell program over a decade ago. I find Haskell very hard to read. The grammar is very complicated[1] and is actually context-sensitive[2]. [1]…
Comment linking /haskell-is-not-context-free/
on “Not Lisp again (2009)”Submitted C doesn’t cause buffer overflows, programmers cause buffer overflows as a story · 5 points
HN discussionYou're missing high-level languages such as Modula-2 or Free Pascal that are safe-by-default while being close to the machine. They compile faster. They're easier to analyze. Someone who understands C could easily port it to one of these languages or even write a translator that converts them to C for easy integration of incrementally-rewritten pieces of the OS. They don't because they like C for non-technical reaso…
Comment linking /unfrozen-cyclone/
on “Integrating “safe” languages into OpenBSD?”Submitted How Emacs beat vi in the Editor Wars as a story · 4 points
HN discussionWhat an odd statement, in light of the innumerable deployments of Bison / ANTLR parsers you certainly use at least once a day (if you spend any time at all in a terminal). Which ones? Awk is one; in fact Awk was almost co-developed with yacc. But it gives generally bad error messages. (There are multiple implementations, but most of them use a yacc-style LR(1) grammar and give bad error messages.) I don't know of an…
Comment linking /is-java-context-free/
on “ANTLR Mega Tutorial”Submitted How Emacs beat vi in the Editor Wars (2020) as a story · 3 points
HN discussionThe two top answers are in conflict. The second answer with 43 points is closer to right: There are hardly any real-world programming languages that are context-free in any meaning of the word. The first answer with 41 points is totally wrong: The set of programs that are syntactically correct is context-free for almost all languages ----- A better source is this whole series by Trevor Jim, which has nice ways of re…
Comment linking /c-and-cplusplus-are-not-context-free/
on “The naked truth about writing a programming language (2014)”Submitted Cyclone, a Rust predecessor safe dialect of C, in a VM as a story · 3 points
HN discussion"until recently"? More than 10 years just going by HN. https://news.ycombinator.com/item?id=5161214 I think HTML showed the problem with Postel's principle. Quoting "Postel’s Law is not for you" at http://trevorjim.com/postels-law-is-not-for-you/ from 2011 > The next version of HTML, HTML5, should considerably reduce the problem of browser incompatibilities. It does this, in part, by rejecting Postel’s Law for brows…
Comment linking /postels-law-is-not-for-you/
on “OpenBSD now enforcing no invalid NUL characters in shell scripts”Submitted C and C++ are not context free as a story · 3 points
HN discussionYes, that is exactly what's mentioned here, on the same site that I linked: http://trevorjim.com/python-is-not-context-free/ (Are you the author? :) ) Why does this matter? Because AFAICT the current best practice for implementing languages is to 1) prototype the language with a tool, then 2) throw that out and write the parser by hand. If you skip step 1, then it will be unclear what language you've defined (and it…
Comment linking /python-is-not-context-free/
on “On the Complexity and Performance of Parsing with Derivatives”Submitted Lisp and C (2012) as a story · 3 points
HN discussionThe problem is that the languages people actually use are NOT context free. C and C++ are known not to be context free, and (somewhat surprisingly to me) it's not clear that Java and Python are context-free either. I also bet that JavaScript's semicolon insertion rule makes it not context-free (perhaps among other things). http://trevorjim.com/parsing-not-solved/ Just because you use yacc doesn't mean it's context f…
Comment linking /parsing-not-solved/
on “On the Complexity and Performance of Parsing with Derivatives”Submitted Using an unsafe language is a design flaw as a story · 2 points
HN discussionTrevor Jim revived it a bit with virtualization for those wanting to play with it: http://trevorjim.com/unfrozen-cyclone/
Comment linking /unfrozen-cyclone/
on “DARPA's “Unhackable” Computer”Submitted Python is not context free as a story · 1 points
HN discussionI don't think most languages in widespread use have lexers that are regular. Here the same author gives the example of Python's indentation requiring a stack: http://trevorjim.com/python-is-not-context-free/ Also Haskell: http://trevorjim.com/haskell-is-not-context-free/ I'm pretty sure in JavaScript that the /s+/ regex syntax can't be recognized with a regular language. Perl is of course insane -- it's not even sta…
Comment linking /haskell-is-not-context-free/
on “Scandalous Weird Old Things About The C Preprocessor (2015)”Submitted Haskell is not context free – 2012 as a story · 1 points
HN discussionFWIW, I haven't thought too much about the case of the preprocessor, but this series of blog posts might help: http://trevorjim.com/how-to-prove-that-a-programming-languag... My initial thoughts are that the property of being context-free only refers to a parser, not to the lexer. A lexer can be line-oriented, as mentioned. The blog post mentions the lexer issue. The definition of a context-free language is fuzzy be…
Comment linking /how-to-prove-that-a-programming-language-is-context-free/
on “Scandalous Weird Old Things About The C Preprocessor (2015)”A) Python is not context-free; this is a common misconception: http://trevorjim.com/python-is-not-context-free/ B) No one feature of a grammar provides context-freedom. It's not meaningful to compare Go's grammar to another grammar; it's meaningful to compare Go's grammar as-is to the way it would be if it allowed both forms. In this case, I believe the same-line braces rule is not strictly necessary by itself (they…
Comment linking /python-is-not-context-free/
on “Refactoring with go fmt”The author of Cyclone seems to suggest that Rust is the current path forward: http://trevorjim.com/unfrozen-cyclone/ > Cyclone was an early attempt to create a programming language at the level of C, combining manual memory management with complete static memory safety. You can think of it as one step on the path that Rust and other languages have continued, one that I believe will eventually replace C, eliminating…
Comment linking /unfrozen-cyclone/
on “QEMU: out-of-bounds memory access issue”Let's link to the actual article (the tweet is just a link): http://trevorjim.com/how-emacs-beat-vi-in-the-editor-wars/ https://news.ycombinator.com/item?id=24364437
Comment linking /how-emacs-beat-vi-in-the-editor-wars/
on “Emacs Won Out over Vim”