News for hackers. Stuff that matters.
Re:Designing a Language Without a Parser by mathisfun123 on Wednesday July 05, 2023 @04:11AM (#36597264)
>The "magic" of s-expressions is that they make it easy to operate on the source code of a program as a hierarchical data structure

where exactly is the magic? it's just tuple unpacking? like congrats you've constrained yourself to the absolute bare minimum and you've made it work. i mean i guess congrats for getting it to work at all but it's not magical, it's tedious. if you showed me a homoiconic language that did somehow pull off the magic trick of being more expressive than tuples then i would be indeed enchanted (mathematica at least manages to put lipstick on the whole exercise).

Re:Designing a Language Without a Parser by distcs on Wednesday July 05, 2023 @06:11AM (#36598232)
> i mean i guess congrats for getting it to work at all but it's not magical, it's tedious.

Magic lies in the eyes of the beholder. So you may not find it magical while I do. But I don't understand how you say that it is tedious.

With the homoiconicity of Lisp, you use the Lisp language itself to write macros and you manipulate the lists that make your Lisp programs directly.

Mainstream languages these days either need you to learn a special syntax for macros or they need you to learn their AST structures/classes and manipulate them or sometimes both. Isn't this more tedious? Isn't the Lisp way simpler and less tedious?

Re:Designing a Language Without a Parser by lisper on Wednesday July 05, 2023 @08:59AM (#36599805)
> where exactly is the magic?

There is a reason I put the word "magic" in scare quotes.

> it's just tuple unpacking?

It's not even that. S-expressions are just a serialization of linked lists. The "magic" happens because the details of the serialization happen to make them particularly good for writing code.

See my reply to /u/eru for more details. https://news.ycombinator.com/item?id=36599470

Re:Designing a Language Without a Parser by eru on Thursday July 06, 2023 @08:48PM (#36625500)
> It's not even that. S-expressions are just a serialization of linked lists.

Well, it's more like serialization of a binary tree. Cons-cells can branch in both the car and the cdr direction.

Re:Designing a Language Without a Parser by lisper on Friday July 07, 2023 @02:17AM (#36627895)
The distinction between a linked list and a binary tree is in the eye of the beholder. One of the brilliant things about s-expression syntax is that (a b c) is equivalent to (a . (b . (c . nil)))) so there is no distinction between binary trees and linked lists (whose elements can be other linked lists) other than that to be a "proper" list it has to be null-terminated.