I can't recommend highly enough to implement a simple lisp (or a forth).
Illuminating experience and it will also help you see (among many other things) the parentheses in a different light.
stdatomic•48m ago
First day of paradigms course in the 2000s and prof says "if your opinion of Scheme is too many parentheses, then you're an idiot."
Needless to say that was my opinion and every day I think, more and more, how right he was.
(later I did make some gui apps that included scripting and chose s-expr syntax because of how simple it is to implement it)
NooneAtAll3•42m ago
main problem isn't brackets themselves - it's that they're too on the right
had brackets been displayed as curly braces in C - everything would look much more manageable
phpnode•19m ago
so, instead of
(foo (bar (1 2 3))
you'd prefer
{
foo {
bar {
1
2
3
}
}
}
is that right?
eska•14m ago
I changed my opinion about parens when I stopped formatting like C, and used indent rather than parens to denote blocks. That is, a large amount of them at the end is totally fine.
bananaflag•33m ago
There are two problems with Lisp parentheses in my opinion:
1) Humans are not that equipped to handle that level of nesting without some other aid, this is why Lisp code is usually indented.
2) Parentheses aren't just about grouping, and this is unintuitive. For example, x is not the same as (x). This is a bit like in set theory where x is not the same as {x}, but parentheses do not look like the kind of sign that would work like that.
urcite_ty_kokos•1h ago
Appreciated the title xD
e12e•1h ago
(2010)?
zahlman•59m ago
(how-to in-python (write (interpreter lisp)))
consumer451•12m ago
Yes, but to be fair, you only have a couple minutes to fight the HN title regex.
azhenley•47m ago
Writing a Lisp is one of my favorite projects. I try to do it every year or two, taking a different approach each time.
onraglanroad•8m ago
The one where you replaced parentheses with the crying laughing emoji was definitely the worst.
chombier•31m ago
If you ever wondered how to write a programming language, this is probably the best resource to get started (and then of course Crafting Interpreters).
There are edge cases where this fails, but `def parse(s): return json.loads('['+re.sub('([")])\s*(["(])','\g<1>,\g<2>',re.sub('[^()\s]+','"\g<0>"',s)).replace('(','[').replace(')',']')+']')` is a surprisingly robust lisp parser.
timonoko•10m ago
One of those exercises that are now just boring, because AI does it better.
Gemini did write Lisp-1 interpreter in Linux-assembly the other day. It was ready to implement garbage collection and compiler and all shit, but that was just depressing from human point of view.
tosh•1h ago
Illuminating experience and it will also help you see (among many other things) the parentheses in a different light.
stdatomic•48m ago
Needless to say that was my opinion and every day I think, more and more, how right he was.
(later I did make some gui apps that included scripting and chose s-expr syntax because of how simple it is to implement it)
NooneAtAll3•42m ago
had brackets been displayed as curly braces in C - everything would look much more manageable
phpnode•19m ago
eska•14m ago
bananaflag•33m ago
1) Humans are not that equipped to handle that level of nesting without some other aid, this is why Lisp code is usually indented.
2) Parentheses aren't just about grouping, and this is unintuitive. For example, x is not the same as (x). This is a bit like in set theory where x is not the same as {x}, but parentheses do not look like the kind of sign that would work like that.