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.

2D Syntax

371 pointsby mr_tyzicalmost 8 years ago

23 comments

glangdalealmost 8 years ago
I just love this. For some reason, our ways of specifying what we want a computer to do (I don&#x27;t want to say &#x27;language&#x27;) remain mired the same territory we started in with punched cards (which I actually got to use as a 10 year old, which was fun).<p>I&#x27;m not sure if this particular cut is the right idea, but it&#x27;s good to see experimentation. A bias I have here is that I think these ideas should be rigorously separated from the concept that some sort of WYSIWYG editor will allow non-programmers to code.
评论 #14659586 未加载
评论 #14672018 未加载
nprescottalmost 8 years ago
Very neat, I really appreciate the Racket community&#x27;s willingness to experiment with syntax.<p>Looking at the examples reminds me of Julian Noble&#x27;s &quot;Elegant Finite State Machine&quot; in Forth[0], which takes a different approach to the same problem of creating a language to better specify a problem (in both cases graphically).<p>[0]: <a href="http:&#x2F;&#x2F;galileo.phys.virginia.edu&#x2F;classes&#x2F;551.jvn.fall01&#x2F;fsm.html" rel="nofollow">http:&#x2F;&#x2F;galileo.phys.virginia.edu&#x2F;classes&#x2F;551.jvn.fall01&#x2F;fsm....</a>
hyperion2010almost 8 years ago
It looks like this (e.g. `#2dcond`) implements a way to directly embed other languages in a racket file [0] and avoids the problems encountered when trying to do it using the `#reader` syntax [1] in a source file. Essentially letting you have multiple readtables in a file (probably not nestable though). I could be wrong about this (need to look more carefully when I have more time), but nonetheless could allow direct embedding of completely alternate syntax with the right setup.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;racket&#x2F;2d&#x2F;blob&#x2F;master&#x2F;2d-lib&#x2F;private&#x2F;readtable.rkt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;racket&#x2F;2d&#x2F;blob&#x2F;master&#x2F;2d-lib&#x2F;private&#x2F;read...</a> [1] <a href="https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;guide&#x2F;hash-reader.html" rel="nofollow">https:&#x2F;&#x2F;docs.racket-lang.org&#x2F;guide&#x2F;hash-reader.html</a>
评论 #14658678 未加载
ziotom78almost 8 years ago
I find this extremely interesting! In the last weeks one of my colleagues had to work to some legacy application that was developed using National Instrument&#x27;s LabView [1]. For those who do not know it, it is a visual language to develop interfaces to scientific instruments. Everything is done visually, including «if»s and «for» loops.<p>My colleague, which has large experience with languages like C# and Assembly, is extremely frustrated by this way of working. Everything must be done using a mouse, and even the simplest tasks require some thought in order to be implemented properly. (Although I must say that he praises LabView&#x27;s hardware support and its Visual Basic-like easiness in developing GUIs.)<p>I find Racket&#x27;s 2D syntax to be far more promising than LabView&#x27;s approach:<p>1. You can code it using a text editor: unlike LabView, no mouse is required;<p>2. Only a few classes of statements are affected by this (LabView forces you to do <i>everything</i> visually, even function definitions and mathematical operations);<p>3. You use this feature only if you think it helps; otherwise, plain text syntax is always available.<p>As a side note, I would like to give kudos to the Racket developers for this kind of gems. Racket really seems to be a language which makes language experiments easy to implement and try!<p>[1] <a href="http:&#x2F;&#x2F;www.ni.com&#x2F;en-us&#x2F;shop&#x2F;labview.html" rel="nofollow">http:&#x2F;&#x2F;www.ni.com&#x2F;en-us&#x2F;shop&#x2F;labview.html</a>
评论 #14661608 未加载
kazinatoralmost 8 years ago
I have some reservations about how this is designed.<p>All we need are columns labeled with conditions. We don&#x27;t need rows. And the matrix can just have true&#x2F;false&#x2F;don&#x27;t-care entries, with code assigned to rows.<p>Concretely, say we have these conditions:<p><pre><code> (&gt; x y) (stringp foo) (oddp n) </code></pre> Right? Okay, so now we can identify the combinations of these and assign them to code like this:<p><pre><code> (&gt; x y) (stringp foo) (oddp n) #t #t (whatever) #t #t (other-thing) #t #f (etc) </code></pre> There could be a way to mark some of the rows as having &quot;fall through&quot; behavior. If they match, the expression is evaluated (for its side effects, obviously), but then subsequent rows can still match.<p>This could be worked into a straightforward S-exp syntax without any diagramming shennanigans:<p><pre><code> (table-cond (&gt; x y) (stringp foo) (oddp n) #t () #t (let [...] (whatever)) () #t #t (other-thing) #t #f () (etc)) </code></pre> Here, don&#x27;t cares are denoted using (). Something else could be chosen.<p>A #f entry means &quot;must be explicitly false&quot;. A blank column entry is a &quot;don&#x27;t care&quot;; that condition is not taken into account for that row.
评论 #14661117 未加载
jacobparkeralmost 8 years ago
Nicely done!<p>Different but similar joke for C++: <a href="http:&#x2F;&#x2F;www.eelis.net&#x2F;C++&#x2F;analogliterals.xhtml" rel="nofollow">http:&#x2F;&#x2F;www.eelis.net&#x2F;C++&#x2F;analogliterals.xhtml</a>
评论 #14658676 未加载
评论 #14660135 未加载
评论 #14658548 未加载
评论 #14658550 未加载
hota_mazialmost 8 years ago
While I appreciate and respect Racket&#x27;s willingness to experiment and innovate, I&#x27;m a bit puzzled by this.<p>Tables are neat to read but pretty annoying to write, especially in ASCII form. It&#x27;s true that code is read much more often than written, but still, I wonder how useful this really is.
评论 #14661885 未加载
评论 #14661915 未加载
fao_almost 8 years ago
The reason why I think that this will not thrive, as other projects have not thrived, is because (at least initially) it adds to the mental burden. Scanning a cond for me is almost instantaneous. It took me a couple of very long seconds for me to figure out what was happening within that table, and even though I recognized it as a truth table, it was not easy to read. The information was too separate on screen to easily compare.<p>I think that were programming initially presented as such, this would not be a problem, but I expect that many developers are so finely attuned and specialized to text that other methods will not take off purely because of the learning curve.
评论 #14659932 未加载
评论 #14663132 未加载
sharpercoderalmost 8 years ago
Tables are generally a very good idea for languages. SpecFlow&#x2F;cucumber as most notable example, but I can see others benefitting greatly as well.
b123400almost 8 years ago
It reminds me of Funciton, <a href="https:&#x2F;&#x2F;esolangs.org&#x2F;wiki&#x2F;Funciton" rel="nofollow">https:&#x2F;&#x2F;esolangs.org&#x2F;wiki&#x2F;Funciton</a>
ooqralmost 8 years ago
Surprisingly exactly what the title makes it sound like. Very cool!
igraviousalmost 8 years ago
Nobody has mentioned the dependently type prog-lang Epigram† yet?<p>“Epigram uses a two-dimensional, natural deduction style syntax, with a LaTeX version and an ASCII version. Here are some examples from The Epigram Tutorial:<p>Examples<p>The natural numbers<p>The following declaration defines the natural numbers:”<p><pre><code> ( ! ( ! ( n : Nat ! data !---------! where !----------! ; !-----------! ! Nat : * ) !zero : Nat) !suc n : Nat) </code></pre> “The declaration says that Nat is a type with kind * (i.e., it is a simple type) and two constructors: zero and suc. The constructor suc takes a single Nat argument and returns a Nat. This is equivalent to the Haskell declaration &quot;data Nat = Zero | Suc Nat&quot;.”<p>Project lives here: <a href="https:&#x2F;&#x2F;code.google.com&#x2F;archive&#x2F;p&#x2F;epigram&#x2F;" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;archive&#x2F;p&#x2F;epigram&#x2F;</a> and the last commit on <a href="https:&#x2F;&#x2F;github.com&#x2F;mietek&#x2F;epigram2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mietek&#x2F;epigram2</a> is five years ago which leads me to believe that the project is abandon-ware.<p>† <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Epigram_(programming_language)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Epigram_(programming_language)</a>
oh_sighalmost 8 years ago
What editor do racketeers commonly use? I like the idea, but this seems like a burden for code editing in most normal editors except for perhaps emacs picture mode.
评论 #14659093 未加载
评论 #14659430 未加载
评论 #14659432 未加载
joshlemeralmost 8 years ago
If anyone wants to see some ascii-art in Scala, they just need to look at the Akka Streams-graph api (<a href="http:&#x2F;&#x2F;doc.akka.io&#x2F;docs&#x2F;akka&#x2F;current&#x2F;scala&#x2F;stream&#x2F;stream-composition.html#composing-complex-systems" rel="nofollow">http:&#x2F;&#x2F;doc.akka.io&#x2F;docs&#x2F;akka&#x2F;current&#x2F;scala&#x2F;stream&#x2F;stream-com...</a>)
agumonkeyalmost 8 years ago
Reminds me (again) of Jonathan Edwards research. He did many editors with tables as first class so that you can avoid boolean nestings, and simplify verification &#x2F; closure of your boolean mappings.<p>He published a video, sadly in flash <a href="http:&#x2F;&#x2F;www.subtext-lang.org&#x2F;subtext2.html" rel="nofollow">http:&#x2F;&#x2F;www.subtext-lang.org&#x2F;subtext2.html</a><p>Here&#x27;s an article about &quot;schematic tables&quot; <a href="http:&#x2F;&#x2F;aigamedev.com&#x2F;open&#x2F;review&#x2F;schematic-table-conditionals&#x2F;" rel="nofollow">http:&#x2F;&#x2F;aigamedev.com&#x2F;open&#x2F;review&#x2F;schematic-table-conditional...</a>
vidarhalmost 8 years ago
I love attempts at visual programming. As a kid I used to pour over the then-fashionable ads for CASE (Compater-Aided Software-Engineering) tools in DDJ and elsewhere and imagined them to do far more than they actually did... Also attempts like Amiga Vision [1]<p>One of the software engineers I like to go a bit fanboy-ish about is Wouter van Oortmerssen, who I first got familiar with because of Amiga E, but who has a number of interesting language experiments [2], one of which includes a visual language named Aardappel [3] that also used to fascinate me.<p>There are a number of problems with these that have proven incredibly hard to solve (that this Racket example does tolerably well on, probably because it doesn&#x27;t go very far):<p>1. Reproduction. Note how the Amiga Vision example is presented as a video - there is not even a simple way of representing a program in screenshots, like what you see for the examples of Aardappel, which at least has a linear, 2D representation. That made Amiga Vision work as a tool, but totally fail as a language. This is even a problem for more conventional languages on the fringe, like APL, which uses extra symbols that most people won&#x27;t know how to type. The Racket example does much better in that it can be reproduced in normal text easily.<p>2. Communication. We talk (and write) about code all the time. Turns out it&#x27;s really hard to effectively communicate about code if you can&#x27;t read it out loud easily, or if drawing is necessary to communicate the concepts. Ironically, if you can&#x27;t read the code out easily, it becomes hard for people to visualise it too, even if the original representation is entirely visual. This example does ok in that respect - communicating a grid is on the easier end of the spectrum.<p>3. Tools. If it needs special tools for you to be effective, it&#x27;s a non-starter. This Racket example is right on the fringes of that. You could do it, but it might get tedious to draw without tooling (be it macros or more). On the other hand the &quot;tool&quot; you&#x27;d need to be effective is limited enough that you could probably implement it as macros for most decent editors.<p>I spent years experimenting with ways around these, and the &quot;best&quot; I achieved was a few principles to make it easier to design around those constraints:<p>A visual language needs a concise, readable textual representation. You need to be able to round-trip between the textual representation and whatever visual representation you prefer. This is a severe limitation - it&#x27;s easy to create a textual representation (I had prototypes serialising to XML; my excuse is it was at the height of the XML hype train; I&#x27;m glad I gave that up), but far easier to make one that is readable enough, as people need to be able to use it as a &quot;fallback&quot; when visual tools are unavailable, or in contexts where they don&#x27;t work (e.g. imagine trying to read diffs on Github while your new language is fringe enough for Github to have no interest in writing custom code to visualise it; which also brings up the issue of ensuring the language can easily be diffed).<p>To do that in a way people will be willing to work with, I think you need to specify the language down to how comments &quot;attaches&quot; to language constructs, because you&#x27;ll need to be able to &quot;round-trip&quot; comments between a visual and textual representation reliably.<p>It also needs to be transparent how the visual representation maps to the textual representation in all other aspects, so that you can pick one or the other and switch between the two reasonably seamlessly, so that you are able to edit the code when you do not have access to the visual tool, without surprises. This makes e.g. storing additional information, such as e.g. allowing manual tweaks to visual layout that&#x27;d require lots of state in the textual representation that people can&#x27;t easily visualise very tricky.<p>Ideally, a visual tool like this will not be language specific (or programming specific) - one of the challenges we face with visual programming, or even languages like APL that uses extra symbols, is that the communications aspect is hard if we can not e.g. quickly outline a piece of code in an e-mail, for example.<p>While having a purely textual representation would help with that, it&#x27;s a crutch. To &quot;fix&quot; that, we need better ways of embedding augmented, not-purely-textual content in text without resorting to images. But that in itself is an incredibly hard problem, to the extent that e.g. vector graphics supports in terminals was largely &quot;forgotten&quot; for many years before people started experimenting with it again, and it&#x27;s still an oddity that you can&#x27;t depend on being supported.<p>Note that the one successful example in visually augmenting programming languages over the last 20-30 years, has been a success not by changing the languages, but by working within these constraints and partially extracting visual cues by incremental parsing: syntax highlighting.<p>I think that is a lesson for visual language experiments - even if you change or design a language with visual programming in mind, it needs to be sort-of like syntax highlighting, in that all the necessary semantic information is there even when tool support is stripped away. We can try to improve the tools, but then we need to lift the entire toolchain starting with basic terminal applications.<p>[1] <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=u7KIZQzYSls" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=u7KIZQzYSls</a><p>[2] <a href="http:&#x2F;&#x2F;strlen.com&#x2F;programming-languages&#x2F;" rel="nofollow">http:&#x2F;&#x2F;strlen.com&#x2F;programming-languages&#x2F;</a><p>[3] <a href="http:&#x2F;&#x2F;strlen.com&#x2F;aardappel-language&#x2F;" rel="nofollow">http:&#x2F;&#x2F;strlen.com&#x2F;aardappel-language&#x2F;</a>
kovekalmost 8 years ago
I wonder how nesting of tables would be like? I guess if you had function calls inside, it would look nicer than drawing a table inside a table.
niuzetaalmost 8 years ago
Okay. I love this and everything about this.<p>&gt; This notation works in two stages: reading, and parsing (just as in Racket in general). The reading stage converts anything that begins with #2d into a parenthesized expression (possibly signaling errors if the ═ and ║ and ╬ characters do not line up in the right places).<p>I&#x27;m cracking up, oh my god.
lispmalmost 8 years ago
Adding tabular display to Lisp is useful, IMHO. I was thinking about using something similar, but mostly where code looks like data or specifically for Lisp data. I would not be very interested to use tables for control structures, but would like more support for auto-aligned layout for control structures.
nemoniacalmost 8 years ago
Neat idea. It draws directly from the approach to learning functions of multiple complex arguments in www.htdp.org<p>Looking forward to 3D syntax for functions of 3 arguments.
GregBuchholzalmost 8 years ago
Yes, and next I&#x27;d love to see big parentheses:<p><pre><code> ⎛if ⎛&gt; (+ a b)⎞ ⎛case x ⎞ ⎛cond ⎞⎞ ⎜ ⎝ (- c d)⎠ ⎜ (1 &#x27;foo)⎟ ⎜ ((&gt; y 2) &#x27;quux) ⎟⎟ ⎜  ⎜ (2 &#x27;bar)⎟ ⎝ (t &#x27;error)⎠⎟ ⎝   ⎝ (3 &#x27;baz)⎠     ⎠ </code></pre> ((<a href="http:&#x2F;&#x2F;imgur.com&#x2F;oI0zVm3" rel="nofollow">http:&#x2F;&#x2F;imgur.com&#x2F;oI0zVm3</a>) if that isn&#x27;t rendering for your setup)
评论 #14661611 未加载
kv85salmost 8 years ago
RacketFunge?
ebbvalmost 8 years ago
This is not a good idea. That code is gross and illegible. There&#x27;s definitely better ways to handle anything where you think this is the solution.
评论 #14659372 未加载
评论 #14659786 未加载