Live data from Hacker News

Forth: The programming language that writes itself

ratfactor.com

41–50 of 174 posts

Re: Forth: The programming language that writes itself

#41
post #36

I used to be a fan of these languages like Lisp and Forth and Joy (and Factor and Haskell), but then I found that what I a really long for is just (untyped) lambda calculus (as a universal language). (Combinatory logic is just a similar representation of lambda calculus, but the differences go away quickly once you start abstracting stuff.) I think expressing semantics of all (common) programming languages in lambda…

Why specifically untyped?

Because it is the simplest thing we have, and has a pretty straightforward self-interpreter.

It feels like you need a lot more metamathematics to deal with typed lambda calculus than with untyped one, and types are something that comes without a justification.

Anyway, the idea is, if you have a language, you can think of source code written in the language as a giant lambda term, where you have all lambdas upfront and only composition in the body. A tree of symbols to be composed, essentially. And then to interpret this source code in a language, you supply definitions of the language's primitives as arguments to the source code term.

Now if your language is typed, the primitives need to be chosen in such a way, so that the interpreted term (the source code applied to language primitives) fails to normalize if the program is not typed correctly.

You can then have a correspondence between the primitives of the typed language that typecheck and simpler set of primitives of the same language used purely for computation, used under the assumption that the program typechecks. This correspondence "defines" the typing mechanism of your language (in untyped lambda terms).

Re: Forth: The programming language that writes itself

#42
post #15
post #7

Earlier quoted context omitted.

One simpler explanation: in forth you are forced to keep the stack, and modifications to the stack, in your short term memory, albeit only really three numbers in most cases. Whereas with C et al you simply look down the page at the variables, far less taxing on your short term memory. Well-written and designed high-level forth words often transcend that and tend to be, quite literally, readable however, in a way tha…

This is probably why you see things like locals get used a lot as modern Forth programs grow. It doesn't have to be brutal early days Chuck Moore genius programs, but I guess you start getting away from the original ethos.

I think even with locals you're still mentally dealing with a few items on the stack in each word usually. But, yes, locals do help you from passing around items from word to word: you see the usage of the local far easier than you see the location of the stack elements.

Re: Forth: The programming language that writes itself

#43
post #26
post #11

Earlier quoted context omitted.

HTML uses a ton of SGML features not part of XML (sometimes erroneously though to be non-standard ‘tag soup’, not to mention self-closing tags). You need either a specialized parser or an SGML processor + DTD.

Wasn't HTML4 the last one defined as a SGML DTD? 5 and on is its own beast. (rip XHTML)

You are right. There is a third-party DTD that should be mostly compatible (https://sgmljs.sgml.net/docs/html5.html).

In reality, HTML4 was never implemented to the letter by user agents, because people do things like putting -- inside comments.

Re: Forth: The programming language that writes itself

#44
post #9

Earlier quoted context omitted.

What I heard is with Forth, basically no 2 environments are alike, but highly customized, meaning every forth programmer creates his own language in the end for his custom needs. So collaborating is a bit hard like this. The only serious forth programmer that I know, lives alone in the woods doing his things. So from a aesthetic point of view, I really like the language, but for getting things done, especially in a c…

This is not a real issue, because the same thing can be said about C. No two C projects are the same, each has its own set of libraries, macros, types, etc. I think the main problem is that Forth systems don't have a standard way of creating interfaces like C and other languages have. So the diversity of environments becomes a big issue because it's difficult to combine libraries from different sources.

I think it goes beyond that no, because you can do meta programming with Forth

Re: Forth: The programming language that writes itself

#45
post #32
post #5

Many people glorify the simplicity of Lisp as an interpreter, but Forth is similar and underappreciated. Sadly, the only code I've written in Forth is... PostScript. Yeah, PostScript is a dialect of Forth. As a child, I really was amused by the demo of GraFORTH on Apple ][, which included 3D wireframe animations, which at the time were magical.

> As a child, I really was amused by the demo of GraFORTH on Apple ][, which included 3D wireframe animations, which at the time were magical. I originally wrote GraFORTH ( https://archive.org/details/a2_GraFORTH_1981_Lutus_Paul ) to escape the slow world of integer BASIC on my first computer (an Apple II). Because it relied on large blocks of assembly code to produce nice graphics, it perhaps misled people about wha…

Someone mentioning childhood tech and the creator showing up is peak HN, in the best possible way. I love little threads like this... I never used a Forth as a child, but I recall reading about it and marvelling over it at a time when getting hold of huge amounts of pirated games was easy, but finding anywhere to even buy more serious tools could be challenge... I think it was probably 20+ years before I actually ended up trying a Forth.

Re: Forth: The programming language that writes itself

#46
post #3

Why is it that languages like this don't scale? It's not the first time I see a powerful language that got forgotten. Other examples include SmallTalk and Common Lisp (tiny community). It is because some languages are "too powerful"? What does that say about our industry? That we're still not that advanced of a specie to be able to handle the full power of such languages? I say that because it seems languages that ar…

One thing I note is that all of the languages you name are very far from the machine. Also Forth is not close to the modern machine. Note that it only has two integer types and the larger one can be aligned either way you make sure it is not.

Re: Forth: The programming language that writes itself

#47
post #36

I used to be a fan of these languages like Lisp and Forth and Joy (and Factor and Haskell), but then I found that what I a really long for is just (untyped) lambda calculus (as a universal language). (Combinatory logic is just a similar representation of lambda calculus, but the differences go away quickly once you start abstracting stuff.) I think expressing semantics of all (common) programming languages in lambda…

Why specifically untyped?

The typed lambda calculus is not Turing complete.

Re: Forth: The programming language that writes itself

#48
post #46
post #3

Why is it that languages like this don't scale? It's not the first time I see a powerful language that got forgotten. Other examples include SmallTalk and Common Lisp (tiny community). It is because some languages are "too powerful"? What does that say about our industry? That we're still not that advanced of a specie to be able to handle the full power of such languages? I say that because it seems languages that ar…

One thing I note is that all of the languages you name are very far from the machine. Also Forth is not close to the modern machine. Note that it only has two integer types and the larger one can be aligned either way you make sure it is not.

> One thing I note is that all of the languages you name are very far from the machine

Common lisp is one step away from assembly - you disassemble any function and it is, in fact, a valid strategy of one wants to check the compiler optimizations.

Re: Forth: The programming language that writes itself

#49
post #16

If you like Forth, but find it challenging to build real stuff with, Factor ( https://factorcode.org/ ) is most or all of the good stuff about Forth designed in a way that's much easier to do things with. It was designed by Slava Pestov (who I think had a big hand in Swift), and honestly it's a lot of fun to build webapps and other programs with, and much less brutal to read than Forth can be.

I have very fond memories of programming in PostScript within NeWS/HyperNeWS - it did quite a few things that I've never seen in any other environment.

Edit: To be fair relying on PostScript probably did limit the appeal, but I actually really liked it.

Re: Forth: The programming language that writes itself

#50
post #36

I used to be a fan of these languages like Lisp and Forth and Joy (and Factor and Haskell), but then I found that what I a really long for is just (untyped) lambda calculus (as a universal language). (Combinatory logic is just a similar representation of lambda calculus, but the differences go away quickly once you start abstracting stuff.) I think expressing semantics of all (common) programming languages in lambda…

I implemented the Calculus of Constructions in untyped lambda calculus in order to shorten the 643 byte C program computing Loader's Number to 1850 bits (under 232 bytes) [1], as one of the milestones reached by my functional busy beaver function [2].

[1] https://codegolf.stackexchange.com/questions/176966/golf-a-n...

[2] https://oeis.org/A333479

Post reply on HN