News for hackers. Stuff that matters.
Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by tombert on Saturday January 19, 2019 @07:23PM (#18950137)
I don't really know forth, but it seems like people who learn it really like it; can someone give me a high-level explanation to while it's easier to write Forth instead of C for low-level programming?
Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by 4thaccount on Saturday January 19, 2019 @10:07PM (#18950707)
I haven't written a Forth, but have read a lot about it.

Essentially you start out writing some assembly definitions as named routines and once those are defined you start using that. Forth doesn't have a compiler in the traditional sense. Rather it has a dictionary with stored definitions that you either run from or add to. Besides that, your main data structure is the stack. So your code reads from the stack, does some calculation, returns data to the stack, and calls the next word. This can be very powerful as the implementor can truly understand the entire language. Who can say that about C, Python...etc? With that being said, the whole thing is super Spartan, so unless you implemented a feature, it isn't there. So although Forth is cool, the scientific work I do with matrices would require me to rewrite all of that in my Forth, so it would be a non-starter. Forth really shines for hardware work in my opinion.

Look at JonesForth as an intro to building your own Forth, and Leo Brodie's books on how to use Forth. Every Forth system written probably shares the same core design, but they are all different and as unique as snowflakes. Look at 8th as an example of a very affordable commercial Forth based language written by one man that can cross compile to Windows, Linux, BSD, Mac, Android, & iPhone , has a built-in GUI, encrypted binaries, is pretty speedy and well supported with a small but happy user base. It is an interesting point that there are few languages with that level of features and stability that are not made from the work of lots of people.

Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by int_19h on Sunday January 20, 2019 @12:37AM (#18951387)
In addition to other comments, as I understand, bootstrapped Forth and similar languages usually compile down to code that is not optimal speed-wise, but a lot more compact that usual, because it's basically all CALL instructions (i.e. every word definition defines a function, and every use of the word inside the definition is a call to the corresponding function). This can be a desirable trade-off when you're dealing with a platform that has, say, 8 kilobytes of RAM to work with for all your code.
Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by vanderZwan on Sunday January 20, 2019 @05:44AM (#18952384)
> (i.e. every word definition defines a function, and every use of the word inside the definition is a call to the corresponding function)

Yeah, which supposedly brings one of the big downsides of Forth, which is that one easily ends up with a program that has been refactored too aggressively into smaller words.

Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by snazz on Saturday January 19, 2019 @08:09PM (#18950312)
Since you can bootstrap it in assembly and then gradually build up from there, you don’t need a compiler. The only platform specific code is the little bit of assembly used to get the most basic Forth words up and running, and then you can build everything with those building blocks, oftentimes on the target machine itself. In that regard, writing Forth feels like a combination of Lisp and assembly.
Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by nils-m-holm on Sunday January 20, 2019 @08:15AM (#18952895)
> Since you can bootstrap it in assembly

Assembly? You can bootstrap it in machine code! :)

http://t3x.org/bits/hypersol.html

Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by flohofwoe on Sunday January 20, 2019 @05:32AM (#18952352)
I wouldn't say it's easier to write Forth than C, but it's definitely more suited to resource-limited 8-bit systems with very little RAM.

IMHO Forth is more like an even more reduced Lisp, a "reverse Lisp" if you want, because of Forth's stack architecture (instead of (+ 1 2) in Lisp to add the number 1 and 2, you would write "2 1 +" in Forth, this puts the numbers 2 and 1 on the "stack", and then executes the word "+", which takes the topmost 2 numbers from the stack, adds them, and puts the result back on the stack.

So you get many advantages of Lisp (building complex programs incrementally from very simple building blocks), but in a much more reduced package which can even run on 8-bit computers with just a few KB of memory.

Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by roywiggins on Saturday January 19, 2019 @11:01PM (#18950944)
It's way easier to bootstrap a Forth interpreter on a weird, restricted system like a calculator than, say, a C compiler. You can't run a C compiler on a TI graphing calculator but a self-hosted Forth is totally non-insane thing to run on one.
Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by drb91 on Saturday January 19, 2019 @07:58PM (#18950268)
You can bootstrap a forth system with a few words. Very convenient for individual architectures.
Re:Zkeme80 – A Forth-Based OS for the TI-84+ Calculator by FatDrunknStupid on Saturday January 19, 2019 @09:00PM (#18950466)
Definitely easier in C but you literally create your own language for each problem. Mind was blown. Try it!