Hacker News new | past | comments | ask | show | jobs | submit login

The telescope application was not very demanding real-time. It basically did slewing control, and you have sufficient overhead to do that in BASIC; milliseconds don't matter very much. Telescopes are a classic example of FORTH's success; the problem comes when you try to extrapolate from that into other problem areas.

The attempts I've seen to make FORTH work in a real-time game have all ended in failure. There are technical reasons for this (high cost of inner interpreter overhead, lack of dynamic memory allocation, program structure that makes it difficult to work in large teams) as well as social ones (mostly lack of objective evaluation of quality, and other immature engineering practices).




Dynamic memory allocation seems like something you'd generally want to avoid in real-time programs and games. Slab allocation is often used (I think that's the right term, allocate a large chunk of memory at startup, bump a pointer to allocate, reset the pointer to free all memory at once), and that's simple to implement in Forth.

If inner interpreter overhead is an issue, there are well known solutions to that as well. Subroutine threading removes the inner interpreter entirely, and makes it simple to implement inlining in the compiler, and then there's always the inline assembly approach.


FYI: it’s region, zone, arena, area, or memory context (https://en.wikipedia.org/wiki/Region-based_memory_management), not slab.

‘Slab allocation’ is an implementation strategy for a ‘normal’ memory allocator, where each block gets freed individually (https://en.wikipedia.org/wiki/Slab_allocation)


I thought I might have been wrong, but didn't bother looking it up. Thanks.


I'm using Forth for real-time data collection, and have been very pleased with it's speed. I'm able to reliably and consistently grab sensor readings over a 500 uS period with an average jitter below 1.2 uS on a Cortex M4. Yet I still get the flexibility of a dynamic language. It's a nice environment after the addition of some routines (coded in C) for dynamically allocated arrays with better safety mechanisms. In my case I'm not responding to various user inputs, etc, but the cost of the inner interpreter appears to be on par with - or better than - various bytecode interpreted languages.


”There are technical reasons for this (high cost of inner interpreter overhead, lack of dynamic memory allocation, program structure that makes it difficult to work in large teams)”

I think none of those have much to do with real time, per se.

Inner interpreter overhead may affect performance, but a real time game need not perform well.

Lack of dynamic memory allocation can’t be an issue, as one can always implement it in Forth.

I don’t contest that difficulty to work in large teams is an issue with Forth, but that doesn’t affect ability to write real-time games; it affects ability to write large/complex games.


http://forums.parallax.com/discussion/141061/tachyon-o-s-v3-...

That guy knows how to make Forth perform real time. He has a bit different take on how to build such a Forth.

Multicore too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: