4 ms·
Maybe the real question here is why we don't use standard parsers everywhere all the time? Well, for some data formats we usually do - take JSON for example. (Y
by skybrian 10y ago
Maybe the real question here is why we don't use standard parsers everywhere all the time? Well, for some data formats we usually do - take JSON for example. (You can do a lot with jq.)
I think the problem is that for most languages, the AST is very complex, and writing a transformation pass isn't something you do as a one-off hack.
Lisp famously keeps things simple. I think we could do better than that on syntax, but designing a language with an AST designed for hacking still seems like a good idea.
But there are other ways a language can be easier to hack on. The gofmt tool can do a search and replace on Go expressions and also write the output in Go's standard format. This builds on the language's strengths: (1) having a standard format (2) mostly unambiguous references to imported symbols, so you don't need type-checking to disambiguate. This makes it much easier to find all references to a function.
- open_bear 10y agoTake a look at how Smalltalk does this (try Pharo, for example). You don't edit code as a whole: you add classes, methods, fields and edit them separately. This has several benefits: changes are isolated - easier to reason about and track in version control system, refactoring is easier.
- skybrian 10y agoInteresting. Is Pharo image-based like SmallTalk used to be or does it use something else? Programmers are just about the last people who work with filesystems directly. I expect git will be used for sharing for a while, but I wonder what it will take to move beyond checking out code into local working directories to a more cloud notebook-style approach? (There are lots of experiments but it's not mainstream.)
- open_bear 10y agoImage-based, as Pharo is a close fork of Smalltalk. I've been thinking about a source control system, that will track functions/classes, instead of bytes. You could track who changed that helper method and not be distracted by moving classes between files.