[HN Gopher] Rubysyn: Clarifying Ruby's Syntax and Semantics
___________________________________________________________________
Rubysyn: Clarifying Ruby's Syntax and Semantics
Author : petalmind
Score : 69 points
Date : 2026-04-01 09:54 UTC (4 days ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| Smalltalker-80 wrote:
| I prefer the postcard ;-) https://richardeng.medium.com/syntax-
| on-a-post-card-cb6d85fa...
| pansa2 wrote:
| Yes, Smalltalk's syntax fits on a postcard - and it's possible
| to go even more minimal than that, e.g. Lisp or Forth.
|
| OTOH Ruby doesn't need a postcard, it needs a full poster.
| amomchilov wrote:
| I never understood the appeal of this talking point. It's just
| an accounting trick that moves the complexity to the standard
| library.
|
| For example, SmallTalk is a class based OO system, yet this
| postcard doesn't slow you how to create a class.
| petalmind wrote:
| Yeah, I was also going to say that conflating trivial syntax
| and "supremely easy to learn" is a very weak flex.
|
| The first Smalltalk-80 book you randomly find is 560 pages.
|
| Also, there is a weird bargaining with "but not block
| temporaries" and "not an instance variable". Why not? Half of
| the postcard is basically empty. Also, "except primitives" --
| how many primitives are there?
| amomchilov wrote:
| Next up: "all the characters you need fit on a single
| keyboard!"
| chihuahua wrote:
| I hope it's not an APL keyboard
|
| https://en.wikipedia.org/wiki/APL_(programming_language)#
| /me...
| Smalltalker-80 wrote:
| The appeal of having a very simple, base syntax and almost
| everything in the library / primitives, would be that code
| is always easy to read and write, also on the 'reflection'
| level, where most languages have specific keywords that
| cannot be used 'first class' with the rest of the language.
| E.g: Types next to class objects or operator overloading,
| look at Swift.. (Of course the complexity of a full working
| system (library) does not disappear in Smalltalk, it's just
| easier to read and modify. :)
| petalmind wrote:
| > on the 'reflection' level, where most languages have
| specific keywords that cannot be used 'first class' with
| the rest of the language.
|
| In Ruby this is also the other way around, and it's one
| of my pet peeves.
|
| `Kernel#callcc` looks like a method (arguably, of a
| special class), yet it's impossible to re-implement
| directly in the language, as far as I can tell.
|
| Same with `raise`, I keep forgetting that it's not a
| keyword even.
| decasia wrote:
| Yeah, I just discovered this and was also amazed.
|
| https://decasia.org/tech/2026/02/raise-not-a-reserved-
| word.h...
|
| This being said, I don't think there is any requirement
| technically that every core method can also be re-
| implemented in Ruby... There are so many methods that are
| just thin interfaces to something written in C, whether
| because they are touching VM internals, or for perf
| reasons, or because they make system calls or call
| external libraries.
| petalmind wrote:
| You reimplement `while` in terms of `loop`, but do you
| know that `loop` is also a method :)
| SeriousM wrote:
| > This is an experiment in clarifying some aspects of Ruby syntax
| and semantics. For that we're going to introduce an alternative
| Lisp-based syntax for Ruby, preserving Ruby semantics.
|
| Lisp? Then I would use Lisp...
|
| > The goal is to define a comprehensive, trivially-parsable and
| sugar-free syntax.
|
| Ruby has syntax sugar, no need to remove the funny parts.
| petalmind wrote:
| > Lisp? Then I would use Lisp...
|
| Lisp has completely different runtime semantics. Even the
| lexical scope in Ruby is extremely peculiar. One of the hard
| parts of writing this document was to remove the intuitive
| influence of Lisp because it just doesn't make sense for Ruby.
| petalmind wrote:
| > Ruby has syntax sugar, no need to remove the funny parts.
|
| This is just an intermediate representation, it's not meant to
| be used directly (even though you can do that, of course).
| lifthrasiir wrote:
| S-expression is a standard representation for syntax-free
| semantics. For example, PLT Redex [1] is a DSL for programming
| language semantics and built on top of Racket which uses
| S-expressions.
|
| [1] https://redex.racket-lang.org/
| petalmind wrote:
| Even Ruby `parser` gem uses S-expressions in their
| documentation: https://github.com/whitequark/parser/blob/mast
| er/doc/AST_FOR...
| petalmind wrote:
| Do you know if Redex could be a tool that would be useful in
| my situation?
|
| Claude suggests it, but I need to learn a lot of Redex to
| understand how to apply it.
|
| I have a general understanding of what operational semantics
| is. Or maybe, are there any Redex implementations for common
| programming languages? \lambda_v is a bit too abstract.
___________________________________________________________________
(page generated 2026-04-05 23:02 UTC)