Hacker News new | ask | show | jobs
by davidhs 1032 days ago
After taking a compiler course in uni I found the emphasis on dealing with syntax mostly a waste of time. To begin with, do yourself a favor and use S-expression syntax (like Lisp) for your language. They're dead simple to parse. With the syntax out of the way, you can get to meat and potatoes of implementing a language. Later on you can always define a "look" for your language, and you can spend an inordinate amount of time on that.
2 comments

> After taking a compiler course in uni I found the emphasis on dealing with syntax mostly a waste of time. To begin with, do yourself a favor and use S-expression syntax (like Lisp) for your language. They're dead simple to parse. With the syntax out of the way, you can get to meat and potatoes of implementing a language. Later on you can always define a "look" for your language, and you can spend an inordinate amount of time on that.

I maintained same attitude for years.

I've changed my mind now. Anything feature I want already exists in some programming language. The only distinguishing feature I can offer when designing a new programming language is "very readable", so syntax matters more than I used to think.

Whether you get traction or not depends a lot on syntax - if your syntax is too much of an outlier compared to mainstream languages, your features don't matter.

My suggestion was more for people who are starting out developing a programming language. It's the over-emphasis on the syntax so early on I find to be suboptimal. I also find that slapping on a more human readable or aesthetically pleasing syntax afterwards to be relatively easy.
I agree, so much in fact, that this past weekend I wrote a program to translate s expressions to html.

Because I got tired of writing my htmx stuff as a tag tree.

I should probably post a show HN here.

I feel like you're discounting the importance of syntaxes. Python is as popular as it is because the syntaxes is so simple. Lisp isn't as popular because prefix notation doesn't make intuitive sense to beginners. I would argue that syntax is probably the most important feature of a language
The problem I find with parenthesized languages is the amount of visual noise coming from the parentheses. If you're learning how to write your first interpreter or compiler I kind of assume you already know how to program and understanding S-expressions is not too difficult. Personally, I would have liked to learn and implement closures, continuations, macros, garbage collection, type systems, etc. earlier, and then going deeper into syntax.
Python is popular because of the ecosystem that’s been built around the language.
Partly, but also because of the beginner-friendly syntax
Python languished in obscurity for about a quarter century before taking off in popularity. The tide didn't turn because of changes in syntax.

Python's syntax inspires imitations that you will never hear about in spite of their syntax.

C doesn't have beginner-friendly syntax, yet it succeeded over languages like Pascal and Modula. C++ enjoys great popularity in spite of a mind-numbingly large grammar full of arcane syntax, which grows worse as time passes. There is a lot interest in Rust, which has tons of bizarre syntax to learn.

Poorly-considered, simplistic hypotheses connecting syntax with popularity simply don't hold up to even a modest amount of scrutiny.

I contend that your hypothesis is equally simplistic and poorly considered. How would Python get an active community and ecosystem in the first place, if it languished for a quarter of a century?

> C++ enjoys great popularity in spite of a mind-numbingly large grammar full of arcane syntax, which grows worse as time passes. There is a lot interest in Rust, which has tons of bizarre syntax to learn.

C++ becomes less popular as its syntax becomes more arcane. Rust is a recent language and its long term survival remains to be seen. Languages are like memes: they come and they go. BASIC used to be the beginner language, now it's Python. Lua is popular due to its syntax and ease of embedding. We'll see what simplistic whitespace syntaxes come out within the next 25 years. I predict many language which exist today will fall by the wayside while newer ones replace them

> How would Python get an active community and ecosystem in the first place, if it languished for a quarter of a century?

Development on Python started in 1989 and it was evidently released in 1991. The popularity didn't take off until well past Y2K. During all those intervening years, it had a small number of users, characteristic of an unpopular language.

If MicroPython is Python, i dissagree. It spelled syntax error where there was any and indentation makes it very hard to distinguish code blocks especially by beginners and especially on windows where the font is not proportional in the interpreter.
Why do you think it was built around that language?