3 ms·
> This is like C vs JavaScript. And you'll notice that C isn't a very powerful language. > Does it still look neater when you use the syntax you've defined?
by James_K 2y ago
> This is like C vs JavaScript.
And you'll notice that C isn't a very powerful language.
> Does it still look neater when you use the syntax you've defined?
No because in CL you would define a with- macro that syntactic enforces equal nesting. So the CL version is:
(defmacro {} (&rest args) `(progn ,@args))
I thought that would be too trivial demonstrate though. If you really don't like how it looks, you can fix it with two more lines of reader macros. The result would be a nicer syntax as you wouldn't have to put spaces around the braces.
> Yes but in a few lines of simple code, and the result is actually a syntax that looks nice to use.
Those are a few lines of highly complicated code that does something very simple and just happens to use the short function names { and }. The actual implementation of those functions is easier to write in almost any other language, which is what I was demonstrating with the CL example. If you want to make the case that Forth is powerful, you need to do more to prove it than show you can hack together a half-solution for a problem Forth created. Forth simply isn't a powerful language when counting matching braces is a difficult problem.
- veltas 2y ago> C isn't a very powerful language. Okay. > I thought that would be too trivial demonstrate though. If you really don't like how it looks, you can fix it with two more lines of reader macros. The result would be a nicer syntax as you wouldn't have to put spaces around the braces. The example is 'trivial' though. Also compare how big Forth is against CL, I mean Forths are often well under 10KB. I've written a Forth like this. I've never written a CL. Have you? > Those are a few lines of highly complicated code that does something very simple and just happens to use the short function names Just because you're incredulous doesn't mean that's not a feature. > easier to write in almost any other language, which is what I was demonstrating with the CL example CL isn't 'any other language' though, lisps specifically have quite powerful reflection. > hack together a half-solution for a problem Forth created Hacky half-solutions are charming, and Forth didn't create the 'problem' of structured syntax, it just didn't provide a solution out-of-box. That's one of the very explicit tradeoffs of the language.
- James_K 2y ago> Also compare how big Forth is against CL I would say a lot of this is because CL has a large standard library, but not much of that is primitive. Even then, I would say the CL standard lacks many things, so it is too small for general use rather than too large. From a perspective of implementation, I would almost always choose a small Scheme over Forth or something Forth-like. > CL isn't 'any other language' though, lisps specifically have quite powerful reflection. Those functions don't use reflection. > Forth didn't create the 'problem' of structured syntax, it just didn't provide a solution out-of-box. That's one of the very explicit tradeoffs of the language. It created the problem of not having structured syntax and that's a trade-off that you lose as soon as you write more than a maybe a hundred lines of code.
- veltas 2y ago> Those functions don't use reflection. Sorry I mean macros / or whatever. You know what I mean(?). > that's a trade-off that you lose as soon as you write more than a maybe a hundred lines of code And yet you can have braces with e.g. 2-3 lines of code. Anyway this is beyond tedious now, sorry for provoking you with my code, or my opinion that Forth is interesting, or with the praise I received, or that Forth kicked your dog or something; I'm not really sure what did it. I have talked with you in good faith to try and help you understand why it's interesting to me, I don't claim it's an absolute good or even necessarily practical in most situations.
- James_K 2y agoYou misrepresent me here. I never claimed that Forth is uninteresting, just that your code was. The statement I take issue with is that Forth is powerful. In reality, it is useful only because it is not powerful and hence is easier to implement. > yet you can have braces with e.g. 2-3 lines of code You can't really. You'd be better off treating braces as whitespace than having them check the stack depth before and after each function call. They wouldn't even be correct then because you could make multiple calls within the same set of them. If you want to implement braces properly, you'd need a way to introspect how many arguments a function takes, but Forth is not powerful enough to do this.