Live data from Hacker News

An attempt to articulate Forth's practical strengths and eternal usefulness

im-just-lee.ing

11–20 of 68 posts

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#11
post #9

Earlier quoted context omitted.

It's complete in sofar as being capable of compiling C programs, but it has a few quirks. https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/co...

Possibly this is why it wasn't mentioned? There are enough differences in that list that I can't imagine any existing C library would compile unchanged.

After using cc<< for non-trivial programs, it's about as quirky as the Plan 9 C compiler, the lack of multi-dimensional arrays is the one thing that trips me up the most with cc<<

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#12
post #10
post #8

Earlier quoted context omitted.

By design, it's not a fully compliant ANSI C compiler, so it's never going to be complete, but it's complete enough to, for example, successfully compile Plan 9's driver for the Raspberry Pi USB controller with a minimal porting effort. So, Dusk's compiler is not apple-to-apple comparable to the other, but comparable enough to give a ballpark idea that its code density compares very, very favorably.

It can be hard to tell how much extra complexity would be introduced by unimplemented features.

Indeed, and it might be why the author didn't try, but I still find it odd to not at least mention how small this C compiler is, even if it is to say that it's not apples-to-apples comparable. I mean, 8x smaller than the smallest C compiler listed is still something notable...

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#13
post #12
post #10

Earlier quoted context omitted.

It can be hard to tell how much extra complexity would be introduced by unimplemented features.

Indeed, and it might be why the author didn't try, but I still find it odd to not at least mention how small this C compiler is, even if it is to say that it's not apples-to-apples comparable. I mean, 8x smaller than the smallest C compiler listed is still something notable...

It certainly sounds like a perfectly usable C dialect.

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#14
post #3

This is a pretty good explanation. I think it maybe undersells the importance of the REPL a bit. (I'm not a Forth expert, but I did write StoneKnifeForth, a self-compiling compiler in a Forth subset, and I've frequently complained about the quality of Forth explainers.)

>I think it maybe undersells the importance of the REPL a bit.

Howo? Or would you agree that value is perhaps a more suitable word than importance? For me I think these articles have such a tendency to fixate on the strengths of Forth to the extent that they have reduced Forth to those strengths in the eyes of many. TFA does a fair job of avoiding this and shows Forth more as a powerful and flexible general purpose language than a very niche language, but I think it still focuses a bit much on the strengths at cost of the general.

You are a Forth expert compared to me and probably most of HN, so try and keep that in mind with your response if you could.

Edit: I am probably asking for insight into your workflow with Forth, but maybe not?

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#15
What I like about Forth is that it can be expressed at the lowest level of computation, and that it can be used to bridge that to the highest level of computation. For example, Forth only requires about 12 opcodes to run, which can be implemented in a few dozen chips. But now that you have that, since it's Turing-complete, you can now pull across a lisp or C compiler, and build a working operating system from there. Granted, that would be a lot of work, but it's relatively straightforward work, and that's always impressed me.

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#16
post #5
post #4

I like the spirit of this article, but I find it strange that they open their article by quoting me, but then don't include Dusk OS's C compiler in the list. Fairly counting SLOC is a tricky problem, but my count is 1119 lines of code for the C compiler (written in Forth of course), that's less than 8x the count of chibicc, described as the smallest.

That's a good point, thanks. How complete is it?

From what I can tell chibicc, unlike tcc, is not a complete c compiler in and of itself. Looking at its source code, it relies upon external tools for both x86_64 code gen and linking: https://github.com/rui314/chibicc/blob/90d1f7f199cc55b13c7fd...

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#17
post #5

Earlier quoted context omitted.

That's a good point, thanks. How complete is it?

It's complete in sofar as being capable of compiling C programs, but it has a few quirks. https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/co...

> The "&&", "||" and "?:" operators do shortcutting.

is shortcutting different from short circuiting?

Re: An attempt to articulate Forth's practical strengths and eternal usefulness

#18
post #16
post #5

Earlier quoted context omitted.

That's a good point, thanks. How complete is it?

From what I can tell chibicc, unlike tcc, is not a complete c compiler in and of itself. Looking at its source code, it relies upon external tools for both x86_64 code gen and linking: https://github.com/rui314/chibicc/blob/90d1f7f199cc55b13c7fd...

It does rely on binutils, but by this standard GCC is not a complete C compiler either.
Post reply on HN