4 ms·
Pascal is an extreme indeed, it is a large language and as such, unpractical. What is practical is embedding an imperative language with pointers and an unmanag
by sklogic 11y ago
Pascal is an extreme indeed, it is a large language and as such, unpractical. What is practical is embedding an imperative language with pointers and an unmanaged memory. And the practical value of such a language inside a meta-host is mostly as a building block for DSLs, not as something that end users would face directly.
It's really hard to convey the gigantic difference in expressive power between the meta languages and the primitive ones to those who never got even exposed to the higher level methodologies, who never built elaborate DSLs.
And no, you're wrong in assuming that there are "other extremes" providing a comparable expressive power at no runtime costs. There are none, provably. You mentioned implementing compilers or interpreters in any Turing-complete language - but it won't solve the interoperability issue between the host, the implemented new language and any languages you'd build on top, which may need to borrow semantic building blocks from your new language. As soon as you start to address these concerns, you'll end up turning your host into a proper meta-language (as I did with C, for example).
- GFK_of_xmaspast 11y agoPascal was your original example upthread, tho: "Now, the other way around: you've got an embedded Scheme, but you hate all that parentheses and want to just code in Pascal. Fine. Write a little macro which will translate transparently your Pascal into Scheme. No runtime cost whatsoever and all the interop done for free. See the difference now?"
- sklogic 11y agoYes, it was my example - exactly because there are multiple implementations of this very thing, this thread is littered with the links. My last remark was that the full, 100% standard-compliant Pascal, although impressive, is not very practical, and a lower level language is what is usually designed for this purpose.
- GFK_of_xmaspast 11y agoOK, so I'm looking at https://github.com/soegaard/minipascal https://github.com/soegaard/minipascal right now, and ok it looks like there's a couple thousand lines of racket code that will translate a very limited (no records, no reals, does not appear to be any pointers) pascal-like language. So presumably for this to be exciting, it would have to be executing in a larger environment where it's surrounded by racket code doing its own thing. But now I don't see what's so special about that, and why that's different from, say, a python script that takes a string of fake-pascal, turns it into python thru an internal processor, and then calls an eval.
- sklogic 11y agoThe value is in mixing semantic properties of multiple (dozens) of languages in your single environment. Building the first fundamental blocks may take time, for they are fundamental for a reason, but then adding new things on top is trivial. So, this is essential for building rich DSLs. See my framework as an extreme example of such an approach.