
1x Forth (1999) - pointfree
http://www.ultratechnology.com/1xforth.htm
======
massung
Forth is awesome. Simple as that. But it's important for people (especially
those just being exposed to it) to completely understand why, and what it's
done for everyone.

The indirect threading model was absolutely brilliant. Almost every bytecode
VM in existence today owes Forth (and Moore) a giant "thank you." If you never
write a lick of Forth code ever, you'll be a better programmer just by
researching how its put together.

Forth also pushed for simplicity before it was fashionable. Most "modern"
languages pride themselves on their landing-page code samples:

sum = fold (+) 0

But, again, this is old hat for Forth programmers. Languages today use a lot
of great, new ideas to accomplish this: FP, pattern matching, closures, etc.
But Forth was pushing - back in 1970 - for all functions to "do one thing"
succinctly. If it can't be done in one line, you needed to factor the code
some more. And, it's not just that the result is one line, it's that _anyone_
can look at it and know what it does instantly. Remember, this was back when
BASIC and FORTRAN ruled with GOTO.

Finally, I feel that Forth programmers learn - early on - something I don't
see many (very good) programmers learning today: instead of constantly
abstracting and obfuscating to try and "simplify" a solution, take a step back
and try and simplify the _problem_ so the solution is obvious. For example,
this is what I feel the Rust team has done with memory management. Instead of
just throwing more brain cells and cycles at trying to improve old-hat
solutions, turn the problem upside-down and - in essence - remove it entirely.

~~~
dewster
>Almost every bytecode VM in existence today owes Forth (and Moore) a giant
"thank you."

Funny, I see bytecode VM as one of the things that's fundamentally wrong with
computing. It's one more layer of unnecessary crap that doesn't even remotely
resemble the underlying hardware.

~~~
vanderZwan
> _that doesn 't even remotely resemble the underlying hardware._

And that is what makes the code portable and re-usable. See also Rob Pike's
Eulogy on Dennis Ritchie[0], where he explains the true strengths of C and
Unix:

> In the late 1970s, Dennis joined with Steve Johnson to port Unix to the
> Interdata. From this remove it's hard to see how radical the idea of a
> portable operating system was; back then OSes were mostly written in
> assembly language and were tightly coupled, both technically and by
> marketing, to specific computer brands. Unix, in the unusual (although not
> unique) position of being written in a "high-level language", could be made
> to run on a machine other than the PDP-11. Dennis and Steve seized the
> opportunity, and by the early 1980s, Unix had been ported by the not-yet-so-
> called open source community to essentially every mini-computer out there.
> That meant that if I wrote my program in C, it could run on almost every
> mini-computer out there. All of a sudden, the coupling between hardware and
> operating system was broken. Unix was the great equalizer, the driving force
> of the Nerd Spring that liberated programming from the grip of hardware
> manufacturers.

> The hardware didn't matter any more, since it all ran Unix. And since it
> didn't matter, hardware fought with other hardware for dominance; the
> software was a given.

[0]
[https://plus.google.com/u/0/+RobPikeTheHuman/posts/33mmANQZD...](https://plus.google.com/u/0/+RobPikeTheHuman/posts/33mmANQZDtY)

~~~
dewster
The true strength of C is being a good fit to the underlying hardware.

And hardware still very much matters, even if it's running Unix, because of
binary compatibility.

I still don't get the VM thing. I mean, I get it from a portability
standpoint, but in practice it's been a pretty horrible thing because a stack
machine of all things is often picked as the virtual target. Why not a generic
register based machine, like most hardware actually is these days? My feeling
is the people doing the implementing are infected with the Forth virus, and a
stack based VM is one of the few ways they can force their crazy ideas on the
rest of us.

~~~
vanderZwan
You do understand that hardware development has been shaped by C being the
defacto standard low-level language? That is, if new hardware isn't easy to
code for with C it has little chance of it catching on, unless it's so
incredibly low-level and minimal that ASM is the most complicated language you
need.

And while I'm no compiler writer, I suspect stack machines are a great choice
for modelling an _intermediate_ language because converting it to optimal
register use is fairly simple, yet at the same time is completely agnostic
about how many registers an underlying machine has.

~~~
dewster
>You do understand that hardware development has been shaped by C being the
defacto standard low-level language?

No, I don't understand that, and honestly have no clue what you're talking
about. C is about as simple as things come, and it doesn't necessarily make
strange demands on the hardware. It may seem that I'm contradicting my
previous statement, but C working well with hardware doesn't necessarily mean
it is a force for shaping modern hardware.

Three operand register-based load / store machines make too much sense from a
variety of angles for many (any?) other configurations to touch them, that's
why they're everywhere.

Stack machines are inherently less efficient, and you only see a bunch of
designs (mostly as amateur soft cores) to this day because they are almost
trivial to for enthusiasts to implement, not because they kick ass.

~~~
vanderZwan
> No, I don't understand that, and honestly have no clue what you're talking
> about.

Clearly.

[https://en.wikipedia.org/wiki/Lisp_machine#End_of_the_Lisp_m...](https://en.wikipedia.org/wiki/Lisp_machine#End_of_the_Lisp_machines)

~~~
dewster
But we don't do this anymore, we don't build processors to cater to the
particular needs of a particular high level language because we know now this
approach to speeding things up is fundamentally misguided. Hardware is
designed based on the types of calculations it is intended to do (DSP, GP, FP,
GPU) and that's it. To do otherwise would be inefficient.

------
richard_todd
I tried Forth for the first time three years ago, and it's been a kind of
guilty pleasure ever since. Even though I can write a program about 3x as
quickly in a mainstream language, I sometimes reach for Forth because I think
it's so much _fun_. People don't often mention this aspect of it. There's
something satisfying -- in the same way that proving a theorem or solving a
riddle is satisfying -- about finding a minimal way to coordinate the data
flow on the stack. And, no matter how well you do, it seems you can always
stare at it the next day and find a tiny improvement.

When I read Moore's material, I feel like he fell into that positive feedback
loop in some kind of pathological way... He keeps rebuilding and rebuilding
basically the same CAD hardware/sw system, recreating it simpler and more
elegant in his eyes every time. For years and years.

Building a forth system from scratch really is an eye-opener... Many have
written about how strange and beautiful it is to take your base language and
then _add_ the ability to make comments and perform if-then control flow from
_inside_ the language. You build it up from nothing but it's a functioning
language/interpreter the whole time. Very cool.

------
brandonmenc
I could listen to Chuck Moore all day long.

Here's my favorite - demonstrating his CPU CAD software back in the early 90s,
written in Forth and running on a PC. Quite impressive for back then.

Part 1:
[https://www.youtube.com/watch?v=B_cf8n58Ews](https://www.youtube.com/watch?v=B_cf8n58Ews)

Part 2 (the meat of the presentation):
[https://www.youtube.com/watch?v=Dbd7Xu0ibJM](https://www.youtube.com/watch?v=Dbd7Xu0ibJM)

------
pointfree
[https://www.youtube.com/watch?v=NK0NwqF8F0k](https://www.youtube.com/watch?v=NK0NwqF8F0k)

"Chuck Moore, the inventor of Forth and ColorForth programming languages,
gives a presentation on writing "1x software," or how to avoid common sources
of bloat in software. Topics covered include: what it means to be Forth (as
distinct from other languages), how ColorForth is simpler still than Forth,
how common system services such as files, windows, and even local variables,
complexify (complect) the software, the impact of bloat, maintenance on that
bloat, etc. And, as is usual for Chuck, deeply philosophical thoughts as
well."

~~~
white-flame
Basically, you can build a cathedral per project. It will be elegant, all
parts will be purely sufficient and focused on getting the pieces of that
particular project working.

But when the project changes in certain ways, that bespoke foundation no
longer suffices. Time to take the wrecking ball to it and start building a new
cathedral.

It is technically true that you can reduce the sheer amount of code involved
with a running program, but I for one would not wish to. I would rather
inherit the problem-solving, optimization insights, and compatibility tackling
of others inherent in OS modules and libraries (along with their "bloat" and
complexity), than carry all the weight of non-project-specific development
from bare metal. This is a statement of scope and time as well of that of
surface of opportunity for bugs and weaknesses.

~~~
to3m
I think the point is more that you don't build a cathedral at all.

Another article, more interesting in my view than this one, about the apparent
mindset: [http://yosefk.com/blog/my-history-with-forth-stack-
machines....](http://yosefk.com/blog/my-history-with-forth-stack-
machines.html)

~~~
white-flame
I would still point out that that article focuses on bringing everything into
the small. Redefine problems so you're not tackling large monstrosities, but
simplified versions. Make it so that it neatly fits in little bits of code
that directly computes simple things.

That's all well and good, but some people are building web browsers, or
distributed AI databases, or even large chip development suites that do things
that certainly wouldn't fit in 500 lines of Forth. Forth is a great expression
evaluator, and has actual compile-time metaprogramming features, which is
nice. But it doesn't solve actual large problems for you. It asks you if you
can solve a non-large problem, and if you can, you're happy with Forth.

It's sort of like retro programming. You can work in a small (architecturally
conceptual) scope that handles a few things elegantly, and implement some cool
project within those constraints and building blocks. But it's still building
a little cathedral per project.

~~~
astrobe_
For "large" projects you do as every other language does: you link/FFI to the
C library that does the heavy lifting for you. It's kind of unfair to say
"forth can't do browsers" when all browsers are implemented in C/C++ at the
core.

~~~
white-flame
You link to C when you need speed, and that's not even usually necessary
anymore in languages like JavaScript or Lisp. Linking to C doesn't let your
code somehow abstract higher, to deal with larger projects and larger
architectural scopes.

~~~
alexdowad
It may allow you to take advantage of existing libraries, however.

------
flogic
Forth's simplicity is very beautiful. But that simplicity is also why it's a
dead end. Simplicity is not a worthwhile goal in and of itself. People use
computers to get things done. Ultimately the goal is to empower people. All
those complicated bits are part of what empowers people. We need things like
filesystems, network stacks, operating systems and standards to tie it all
together. Foregoing all of that in the modern age effectively leaves you with
a computer that might as well be a cog. Which may be fine for some classes of
embedded systems but that is increasingly not enough.

~~~
nprescott
I think I would disagree. I don't know that I had the same read on the article
as you, but it didn't seem Moore was advocating simplicity for simplicity's
sake, but as a means to and end (where the end is robust, maintainable
software).

 _> > If it were a lot simpler I would have a lot more confidence that the
technology would endure into the indefinite future._

I think he is (correctly) speaking to the byzantine systems which have been
propped up (successfully!) to engineer the kinds of applications we are
accustomed to (terminal emulators spanning hundreds of thousands of lines of
code, web browsers spanning tens of millions etc.). It seems (from what I've
read from and about Moore) his idea of empowering people is simplifying the
surface area of a problem, rather than simplifying an interface to the problem
(for lack of a better phrase).

People can't really use the solutions he presents or advocates to solve the
kinds of problems they face with computers _as they are being used_ but the
argument might be made that they're solving the wrong problem. I think that
we'll eventually come around to some diluted, almost unrecognizable conclusion
along these lines - see the number of people advocating a "burn it all down
and start over" approach after just half a century of computing. See also the
amount of work spent on maintaining compatibility with relatively ancient
systems in spite of these arguments.

~~~
microcolonel
I take this approach personally. I make it a rule to run as little software as
possible. Sadly, every business seems to want an "app" for everything: I know
this from being in the applications business. Even if I wanted to, I couldn't
get away from the web browser, and it has to be Chromium.

I dream of a future where my bank (for example) publishes API documentation
which can be used to successfully implement a working first-class client. That
client can then be an actually-good piece of software.

The web is an awful platform for applications, and the only reason for its
success in this space was ubiquitous and consistent deployment.

------
Lerc
I have a hard time imagining how some tasks could be managed while using the
disciplines that make Forth useful.

What are some examples of highly complex tasks that have had Forth programs
written for?

Something like Starcraft in Forth. Or perhaps the most complicated Paint
Program written in Forth.

~~~
polm23
Philae, the probe that landed on a comet, used Forth.

[https://en.wikipedia.org/wiki/RTX2010](https://en.wikipedia.org/wiki/RTX2010)

ChipWits was a programming game written in MacFORTH.

[https://en.wikipedia.org/wiki/ChipWits](https://en.wikipedia.org/wiki/ChipWits)

------
dewster
Is there some level of art in CS and processor design? Yes, because there is
no one clearly "right" answer to larger problems. CM speaks eloquently, and
presses a lot of my buttons (i.e. I agree with him) regarding what is "wrong"
with how the industry approaches computing. But he then goes on to so strongly
advocate for his own stuff that he makes it sound like a panacea for all
computing ills. He comes across as an underdog with the solution to everything
that the world is unjustly ignoring, which is a little weird IMO. He would
make a great counter-culture guru.

I wanted to love Forth, but it's a cumbersome tiny language tied to a couple
of stacks that you have to micro manage. DUP, DROP, SWAP, etc. are
inefficient, much like copying a value from one register to another, which is
why most modern processors are 3 operand (to include the copy/move in the
operation). And running a stack-based language like Forth on a register-based
processor is a poor fit and inefficient, but that isn't necessarily a reason
to build custom hardware that fits the language (we don't really do that
anymore). This Emperor has no clothes.

Cue the true believers.

------
dewster
Forth is maybe one step up from an assembly language for a stack machine. Is
Forth difficult to master? Yes, partly because the target hardware is alien,
but mostly because you're doing things in glorified assembly posing as a
higher level language than it really is. And the syntax is screwy.

No wonder it's a massive struggle to do anything more than trivial projects in
Forth, writing assembly is always a huge pain in the ass.

We need to get past Forth's exoticism and see it for what it really is:
assembly + a huge dose of obfuscating downtrodden underdog philosophy.

