3 ms·
Forth is quite interesting, and cool in its own way, but: how can anything where you have to remember what is supposed to be on the stack 'high level'?
by davidw 13y ago
Forth is quite interesting, and cool in its own way, but: how can anything where you have to remember what is supposed to be on the stack 'high level'?
- Jtsummers 13y agoAs I understand it, the ideal in Forth is to build up a base that hides those complexities in a domain appropriate API. You don't throw 3 numbers onto a stack and leave them on the stack to represent a vector, you wrap that up with a call to 'make-vector', and from there on you're dealing with 'vectors' as a unit rather than '3 points on the stack'. Or if you don't, you develop an API that deals with them sensibly so that every routine that operates on vectors doesn't have to get into the nitty-gritty. Write a routine that represents the common operations (add-vectors, multiply-by-scalar, dot-product, etc) and build your complex routines on those, so that vector projection could be: : project-a-onto-b (a b -- c) swap rot dot-product swap scalar-mult; Ok, 3 stack manipulations but someone who's done more than just toy programs in RPL and Forth might be able to come up with some other routines that can hide those as well. EDIT: And once written, the user of the routine needs to know, "put the two vectors onto the stack, the first one is what I'm projecting, and the second is what I'm projecting onto". Another point to consider, dynamically typed languages suffer a similar 'failing' if they're to be considered 'high level'. How can they be 'high level' if you can add 1+"b"? (in code, won't work in runtime unless it's weakly typed, similar to having too few items on the data stack). How can any language be considered 'high level' if you have to remember how many parameters, their types and in what order for every function call?
- csmuk 13y agoNice to see a mention of RPL. Still use an RPL machine daily (HP50g)
- Jtsummers 13y agoTragically, my HP48G+ (?? I know this model exists, may have been mine, sounds right) bit the dust a few years back (water damage, think it happened while stuff was in storage between residences). It wouldn't be particularly useful in my day-to-day stuff, but RPL is probably the main reason Forth seemed so natural to me when I played around with it a few years back.