TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Syntax Design (2014)

220 pointsby memorableover 2 years ago

15 comments

djedrover 2 years ago
Very nice little article! Learned some new terms.<p>To anybody dabbling as I do in syntax design, who may be looking for an extremely minimal representation for trees (even more minimal than S-exprs!) I would like to introduce my little project called Jevko: <a href="https:&#x2F;&#x2F;djedr.github.io&#x2F;posts&#x2F;jevko-2022-02-22.html" rel="nofollow">https:&#x2F;&#x2F;djedr.github.io&#x2F;posts&#x2F;jevko-2022-02-22.html</a><p>It is pure distilled treeness. Its grammar fits into one line, if compressed well:<p><pre><code> Jevko = *(&quot;[&quot; Jevko &quot;]&quot; &#x2F; &quot;`&quot; (&quot;`&quot; &#x2F; &quot;[&quot; &#x2F; &quot;]&quot;) &#x2F; %x0-5a &#x2F; %x5c &#x2F; %x5e-5f &#x2F; %x61-10ffff) </code></pre> This took me years of syntax golfing to figure out. I think it&#x27;s turned out pretty nice. It&#x27;s complete, formally defined, with a few simple parsers written, except it has no users. ;D<p>To relate back to the article, an interesting and AFAIK original feature of this syntax is that newlines or other whitespace are neither significant nor insignificant nor &quot;possibly significant&quot; in Jevko. I&#x27;d call it whitespace-agnostic. Various whitespace rules can be laid on top of it, producing for example a Lisp-like language with native multiword identifiers with spaces, e.g.:<p><pre><code> define [sum primes [[a][b]] accumulate [ [+] [0] filter [ [prime?] enumerate interval [[a][b]] ] ] ] </code></pre> here &quot;sum primes&quot; and &quot;enumerate interval&quot; are two double-word identifiers. It&#x27;s the only right_solution to the identifierWars, I-tell-you!
评论 #33250859 未加载
评论 #33259770 未加载
评论 #33253475 未加载
评论 #33257432 未加载
评论 #33252735 未加载
评论 #33255960 未加载
评论 #33256066 未加载
thrtythreefortyover 2 years ago
I find the section on &quot;syntactic salt&quot; interesting:<p>&gt; The opposite of syntactic sugar, a feature designed to make it harder to write bad code. Specifically, syntactic salt is a hoop the programmer must jump through just to prove that he knows what’s going on, rather than to express a program action.<p>This is perhaps an uncharitable way to describe it, but the concept does ring a bell. Rust&#x27;s unsafe {}, C++&#x27;s reinterpret_cast&lt;&gt;(), etc - all slightly verbose. More important than jumping through hoops, the verbosity helps when <i>reading</i> code to know that something out of the ordinary is going on.
评论 #33248343 未加载
评论 #33252255 未加载
评论 #33249138 未加载
评论 #33250151 未加载
评论 #33250961 未加载
评论 #33251320 未加载
评论 #33252738 未加载
mncharityover 2 years ago
Another exploration of syntax: <a href="http:&#x2F;&#x2F;rigaux.org&#x2F;language-study&#x2F;syntax-across-languages.html" rel="nofollow">http:&#x2F;&#x2F;rigaux.org&#x2F;language-study&#x2F;syntax-across-languages.htm...</a>
评论 #33251250 未加载
samsquireover 2 years ago
I began designing a language that handled recursion and iteration as relations between variables which are topologically sorted to determine control flow.<p>Each function is a toplogical graph of stream functions so it is similar to a data flow language or reactive programming language. The goal is that you should express the critical insight of the algorithm to work out what to write and the code is not nested so there is very little tree structure.<p>Algebralang is rough notes on how it would appear.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;algebralang" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;algebralang</a><p>Example programs in the repository are binary search, btrees, a* algorithm.<p>I wrote a multithreaded parallel actor interpreter in Java and it uses an invented assembly language which doesn&#x27;t have a bytecode, it&#x27;s just text.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;multiversion-concurrency-control#parallel-interpreter" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;multiversion-concurrency-contro...</a><p>I like the ideas behind ani language <a href="https:&#x2F;&#x2F;github.com&#x2F;waves281&#x2F;anic" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;waves281&#x2F;anic</a>
评论 #33250485 未加载
tabtabover 2 years ago
I actually like the VB-style, but VB did it mostly wrong: if you start the block with X, you should always end it with &quot;End X&quot;. Thus, you&#x27;d have While ... End While instead of crap like &quot;Wend&quot; and &quot;Next&quot; (in For...Next).<p>It&#x27;s more legible to know what block is being ended. C-style continually frustrates me that area. The End-X style just never found a nice way to wrap text for longer statements.<p>C-style also has a problem in that there is no way to define arbitrary blocks: it relies too much on key-words. I&#x27;m trying to remedy this with &quot;Moth&quot; syntax:<p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;ProgrammingLanguages&#x2F;comments&#x2F;ky22dx&#x2F;simplified_take_on_moth_colonfree&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;ProgrammingLanguages&#x2F;comments&#x2F;ky22d...</a><p>It&#x27;s LINQ-esque but without the bloated Lambda conventions, and influenced by XML in that you have a simple syntax pattern that can &quot;implement&quot; many domains&#x27; needs. It started with an attempt to merge the best of Lisp and C-style. (Whether it succeeded or not is hotly contested. I welcome other attempts.)
评论 #33249829 未加载
评论 #33252304 未加载
评论 #33251619 未加载
Arch-TKover 2 years ago
&gt; Because C does not have real arrays<p>C does have real arrays, they just get implicitly converted to pointers to their first element in a lot of cases (for a multitude of reasons in part having to do with simplifying the language), A[B] is defined as such so it works with normal pointers and arrays-converted-to-pointers in the same manner.<p>Try using an array with sizeof, unary &amp;, or in the form of a string literal used to initialise an array. In those situations it suddenly stops behaving like a pointer to its first element and definitely behaves like something which is unlike anything else in C (hint: it&#x27;s an array).
Existenceblinksover 2 years ago
Fun read. I would love to read what if it&#x27;s not text based, is it going to be different? Visual programming seems to suffer from composability and it&#x27;s also bounded to be using human language as well, box with border is hard to comprehend, can get messy easily.<p>I mean, visual but text-like theme. It seems to be in sweat spot. Only fix some downside&#x2F;limit of text.
评论 #33248436 未加载
评论 #33248463 未加载
JohnDeHopeover 2 years ago
I enjoy this sort of &quot;one example, multiple different lenses&quot; style of discussion. It reminds me of this book... Exercises in Programming Style by Cristina Videira Lopes.
评论 #33257582 未加载
kragenover 2 years ago
Another interesting weird syntax I ran across a few years ago is OGDL: <a href="https:&#x2F;&#x2F;ogdl.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ogdl.org&#x2F;</a><p>It&#x27;s sort of an alternative to S-expressions with much less punctuation, but the data model is slightly different — in S-expressions you label the leaves, and in OGDL you label the nodes. In other contexts these node-labeled trees are sometimes called &quot;rose trees&quot;; they are the basic data model of, for example, Prolog. Labeling nodes is almost equivalent to labeling arcs, but OGDL does support multiple references, so not quite.<p>The OGDL proposal was intended for data, like XML, not programs. They started out by trying to simplify YAML, which has arrays and dicts, and they simplified it by unifying them into a single structure.<p>Here&#x27;s one of their examples:<p><pre><code> network eth0 ip 192.168.0.10 mask 255.255.255.0 gw 192.168.0.1 hostname crispin </code></pre> This is not quite just an edge-labeled digraph because, as in S-expressions, the order of arcs within a node is significant; you can have multiple edges with the same label in the same node, and you can select edges by ordinal rather than, or in addition to, label.<p>This is of course amenable to use as a programming syntax.
adamnemecekover 2 years ago
Seems down <a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20221018135106&#x2F;https:&#x2F;&#x2F;cs.lmu.edu&#x2F;~ray&#x2F;notes&#x2F;syntaxdesign&#x2F;" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20221018135106&#x2F;https:&#x2F;&#x2F;cs.lmu.ed...</a>
Archelaosover 2 years ago
I wonder what would be possible if we could move away from the text editor and code with an e-pen on a tablet, the way mathematicians use a black board, where the parsing is not from left to right, but follows specific paths in two dimensions (like the notations for fractions, square roots, sums, integrals, etc. we learned at high school). -- Has this been tried out recently?
wodowover 2 years ago
I really like the term &quot;Sugary Functional Style&quot; -- sweetening pure functional programming with faux procedurality.<p>Looks like it&#x27;s a (three word) Google Whack at the time of writing: <a href="https:&#x2F;&#x2F;www.google.com&#x2F;search?hl=en&amp;q=%22Sugary%20Functional%20Style%22" rel="nofollow">https:&#x2F;&#x2F;www.google.com&#x2F;search?hl=en&amp;q=%22Sugary%20Functional...</a>
bhauerover 2 years ago
It&#x27;s awesome to see an article from Dr. Ray Toal on HN this morning! In my biased opinion, the excellent tenured professors at LMU&#x27;s CS program make it a stand out for its size.
emmelaichover 2 years ago
&gt; [mark the end by] .. spelling the initial word backwards<p>This reminds of the quirk in shell. if&#x2F;fi, case&#x2F;esac but ... do&#x2F;done?<p>It might be because `od` was taken for octal dump.
hzhou321over 2 years ago
The `infix` syntax is missing from the major items. Without infix syntax, all languages are just variations of LISP -- I guess that was all the article is about.