News for hackers. Stuff that matters.
Re:Thinking Forth: A Language and Philosophy for Solving Pro... by OldGuyInTheClub on Wednesday February 07, 2024 @10:54PM (#39297862)
"In fact, you shouldn’t write any serious application in Forth; as a lan- guage it’s simply not powerful enough. What you should do is write your own language in Forth (lexicons) to model your understanding of the problem, in which you can elegantly describe its solution."

I've enjoyed reading about FORTH and LISP over the years and I think LISP advocates have a similar philosophy. What Leo Brodie states so nicely is very hard for me to actually do. I think that's what separates the people who "get" computing from those (like me) who glue bits of various libraries together to get past the problem of the moment.

As an HP calculator lover (I wore the ENTER > = t-shirt 40 years ago) I understand the stack and RPN but have no idea how I'd write a trig or stat function if it weren't already built in!

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by bitwize on Wednesday February 07, 2024 @11:42PM (#39298252)
> I've enjoyed reading about FORTH and LISP over the years and I think LISP advocates have a similar philosophy.

Want to make a hacker laugh? Say "Forth is the dual of Lisp" to someone familiar with both languages. It seems they reach the same goal of a totally programmable programming language through completely opposite approaches.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by OldGuyInTheClub on Thursday February 08, 2024 @12:16AM (#39298514)
Well, I hope I don't shanked by one or both sets of advocates.

Years ago I made it partway through this early LISP manual co-authored by a young John McCarthy before his move to Stanford: http://www.softwarepreservation.org/projects/LISP/book/LISP%...

I remember thinking:

1) They did not mess around in the 1960s. No "Hello World," no promises, no sales pitch. Just an in-yer-face "Here's how we do things downtown"

2) They defined a language in terms of itself. I still don't get all that implies but, damn, they can do that?

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by rcbdev on Thursday February 08, 2024 @02:42AM (#39299386)
> They defined a language in terms of itself.

Reminds me of the plethora of compilers written in the languages they're meant to compile. (Roslyn, Java compiler, F# compiler, etc.)

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by dreamcompiler on Thursday February 08, 2024 @06:33AM (#39300743)
But of course it's not the same thing.

The spec for a language is harder to define than the compiler for it. The spec for Lisp is written in Lisp. And it's about half a page of Lisp code. And it's executable, which is not usually true with specs.

This is why reading the Lisp spec feels like reading "the Maxwell's equations of software" (to quote Alan Kay). It's a whole other fundamental model of computation, every bit as fundamental as a Turing machine, but much more practical. Nobody builds serious computing engines out of pure Turing machines, but people do it all the time with McCarthy machines.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by LAC-Tech on Thursday February 08, 2024 @12:57AM (#39298759)
The LISP 1.5 Programmers manual! Love this one. Your 2) is what Alan Kay called "Maxwell's Equations of Software".

And you're right, there's absolute magic in old computing papers. They were pioneers. I wish we could see more of this pioneering spirit combined with todays silicon and ease of international communication.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by OldGuyInTheClub on Thursday February 08, 2024 @01:05AM (#39298809)
I imagine my 2012 Macbook Pro feels like Marvin the Paranoid Android given the stonking gap between its capabilities and my actual use of it.
Re:Thinking Forth: A Language and Philosophy for Solving Pro... by packetlost on Wednesday February 07, 2024 @11:58PM (#39298385)
I've thought this same thing before. About the only thing they really agree on is minimal syntax and an implicit stack
Re:Thinking Forth: A Language and Philosophy for Solving Pro... by coldtea on Thursday February 08, 2024 @03:26AM (#39299619)
And creating a DSL for your problem, and user functions being identical to build in functions, and being able to fully extend the language yourself, to the point of adding custom conditionals or whatever, and several other things....

Aside from the functional vs concatenative paradigms, they share a lot of development philosophy, and give a lot of the same superpowers to the developers.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by flohofwoe on Thursday February 08, 2024 @02:59AM (#39299474)
In my mind, Forth is a "reverse Lisp". Not sure why that's funny though :)

They're both the same basic idea, just that Forth is a much more radical low-level implementation of that idea (e.g. it was just perfect for minimal 8-bit home computers).

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by ctrw on Thursday February 08, 2024 @04:07AM (#39299878)
Lisp is syntax which happens to be executed.

Forth is execution that happens to have some syntax.

If you want a dual of lisp you need to look at Joy or Factor.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by edanm on Thursday February 08, 2024 @03:08AM (#39299518)
> As an HP calculator lover (I wore the ENTER > = t-shirt 40 years ago) I understand the stack and RPN but have no idea how I'd write a trig or stat function if it weren't already built in!

From talking to several people who've implemented things like this, I think they would've said the same thing before.

Nobody walks around knowing how to implement these kinds of things. If you need it, you just start trying, learning, reading, etc, until eventually you do it.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by abecedarius on Thursday February 08, 2024 @10:41AM (#39303211)
Anecdote about people at different stages of that learning:

I worked at FORTH, Inc. one summer in the 80s before starting college. They sold a Forth system which they were converting to a new language standard, which (among other things) had changed the canonical booleans from 1-for-true to -1. One day I noticed the trig functions were giving wrong answers.

So I bring up the code with my boss, and it's pretty hard for us to figure out -- compact, no explanation, tables of random-looking numbers. Someone stops by (Dean Sanderson? iirc), we tell him what's up, he looks at the screen, and almost right away he's like "Oh, this is easy! All you need to do is swap the lines in the tables."

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by OldGuyInTheClub on Thursday February 08, 2024 @10:14PM (#39310947)
FWIW, I did try. Many languages now have websites where one can experiment with an interpreter or compiler. I've used them for playing with JavaScript, APL, Python, etc. Strangely, there does not seem to be one for FORTH. SwiftForth from forth.com does not work with 64-bit Intel Mac OS-es like Catalina which is what I have [1].

I tried gForth as well but during the installation, it invoked HomeBrew which gave a series of hostile messages that my system is obsolete and to not bother asking for any help or support. See [2] and the output provided by the poster - it is what I saw in my case.

[1] https://www.forth.com/download/

[2] https://superuser.com/questions/1767114/is-it-that-bad-to-us...

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by coldtea on Thursday February 08, 2024 @03:22AM (#39299598)
>but have no idea how I'd write a trig or stat function if it weren't already built in!

Well, that's not really about programmings skills though. That's math.

You could write a decent approximate SIN using the taylor series formula [1]. It's pretty easy, you don't even need to know math, can just look the formula up and translate it to an algorithm. Real world language SIN methods use more efficient and accurate methods, but it's still about knowing the math or looking up common such algorithms.

Or you could just invoke the libc (standard C library) SIN from Forth or whatever language you're using. That's what Python and other languages do.

The quote is more about the approach of writing an application by writing a DSL for the application, than about starting from zero and re-doing all the low level libraries like trig yourself.

[1] https://en.wikipedia.org/wiki/Taylor_series

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by OldGuyInTheClub on Thursday February 08, 2024 @10:50PM (#39311176)
Fair enough. I certainly understand Taylor series. 40+ years ago I experimented with series approximations using the programmable HP calculators of the day to see how my functions compared to the builtins. I intended to say that I would struggle to write something worth using. Poor wording to say the least.

I had no idea FORTH could invoke libraries from C. I got the impression it would be used on systems where space is at a premium precluding the installation of other higher-level languages.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by coldtea on Friday February 09, 2024 @03:08AM (#39312579)
Yeah, it can, via it's favorite method for everything: adding params to the stack, and getting the return value there! Here's for GForth for example:

https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Cal...

There are even bindings to C/C++ GUI libraries and so on. Running at constrained systems is just a common deployment scenario, but nothing in Forth necessitates it. You can even run it under Windows.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by PeterStuer on Thursday February 08, 2024 @03:44AM (#39299732)
The DSL approach to Lisp programming was mainstream in the 80's. It comes natural to any system that has enough frictionless syntactic plasticity and expressiveness.
Re:Thinking Forth: A Language and Philosophy for Solving Pro... by zelphirkalt on Thursday February 08, 2024 @04:47AM (#39300130)
These days it still exists in Racket (and possibly others), see language oriented programming ideas.

I would like to add though, that "language" does not have to mean macros and DSL. It can also simply mean what kind of things one considers primitives for the problem to solve. Those primitives can be built in already, they can be user defined functions (or words) or macros or whatever else makes an identifier or thing one can reference later when solving the actual problem.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by crq-yml on Thursday February 08, 2024 @06:58AM (#39300935)
Agreed that the semantic of language-oriented is sometimes hard to disentangle from the aesthetic of "parsing and compiling". In a majority of cases you can go part of the way in that direction by overlaying a FSM, stack machine or a trivial string parser onto whatever feels cluttered and obnoxious to keep track of.

If you want to do the parsed exterior DSL thing today, the magic wand that probably does it the best is Raku and its souped-up grammar system. I actually am exploring that now and I think it has a good toolkit for prototyping anything resembling a textual interface.

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by DonHopkins on Thursday February 08, 2024 @07:43AM (#39301265)
PostScript is kind of like a cross between Forth and Lisp. But it's actually a lot more like Lisp than Forth: high level, polymorphic, homoiconic, etc.

on: What are the enduring innovations of Lisp? (2022):

https://news.ycombinator.com/item?id=36159999

>PostScript is as truly homoiconic and polymorphic and interactive as Lisp.

on: Masterminds of Programming: Chuck Moore (2009):

https://news.ycombinator.com/item?id=21964186

on: Sun's NeWS was a mistake, as are all toolkit-in-server windowing systems (2013) (utoronto.ca):

https://news.ycombinator.com/item?id=22456471

    FORTH ?KNOW IF
        HONK!
    ELSE
        FORTH LEARN!
    THEN
https://news.ycombinator.com/item?id=29261771

on: Forth vs Lisp:

https://news.ycombinator.com/item?id=29261810

NeWS PostScript stuff:

https://news.ycombinator.com/item?id=22456831

Lisp in Forth:

https://news.ycombinator.com/item?id=26882117

Re:Thinking Forth: A Language and Philosophy for Solving Pro... by fuzztester on Thursday February 08, 2024 @10:22AM (#39302946)
Re the HONK! snippet:

Can't resist reposting this:

https://news.ycombinator.com/item?id=39109122

3rd comment down the subthread.