6 ms·
> In Forth there is only memory - word and byte-sized cells of storage in memory, and stacks. You step down on the level of assembly language which may sound da
by nvahalik 7y ago
> In Forth there is only memory - word and byte-sized cells of storage
in memory, and stacks. You step down on the level of assembly language
which may sound daunting, yet gives you full control over every aspect
of memory layout.
Other than in niche or pet projects, can this even work?
If you deal with any sort of multibyte data like Unicode, doesn’t this become way harder?
Or do you just punt and use ascii code pages?
- g82918 7y agoYou define words which are like functions which you could use to operate on multibyte data. Most forth code uses large dictionaries of words. So it will look like 'dosomething decode bytes' where bytes is your utf8 and decode is some utf8 decoder and so on. edit: see https://rosettacode.org/wiki/UTF-8_encode_and_decode#Forth https://rosettacode.org/wiki/UTF-8_encode_and_decode#Forth for a forth word for decoding utf-8
- majewsky 7y agoLooking at this Forth code as a programmer who has never written any Forth code, I can understand how "ordinary" code looks to non-programmers. That whole RPN business means I cannot even figure out where to start reading.
- coldtea 7y agoWell, being confused by RPN is a pretty low bar. Kids used to use it in their math class, on scientific calculators...
- NonEUCitizen 7y agoTake a look at the book Starting Forth: https://www.forth.com/starting-forth/ https://www.forth.com/starting-forth/
- stewbrew 7y agoOn a new OS, forth often has a "first mover" advantage. E.g. some of the first apps for MacOS were developed in forth. It's also useful when limited resources are available. OO forth is quite pleasant to work in, if you really want to. That said, I wish somebody would have created a statically typed forth.
- madhadron 7y ago> Or do you just punt and use ascii code pages? You're assuming that there's even ASCII. colorForth doesn't use it. It's all memory, but what happens is that you write a set of words that operate on the memory to form the abstraction you need, such as Unicode.
- LessDmesg 7y agoThis can work, but it's incredibly tedious and not worth the trouble. Writing in Forth is like writing in pure CIL or JVM bytecode (they're both stack machines like Forth). Sure, you can do it, but if it was so rewarding, people wouldn't be using Java or C#.
- kick 7y agoThat's not true at all. I know multiple people who are incredibly productive in Forth environments, though I don't use it myself. Pretending that it's like writing in JVM bytecode (despite some overlap between the two) is completely unfounded. Your claim that C# and Java won based on merits is similarly unfounded: they won because they have major corporate backing. There are countless languages before and after that did what they did, better. Limbo beats Java at almost everything Java aims to do, for example.
- LessDmesg 7y agoC# and Java won over CIL and bytecode because of corporate backing? You're ridiculous and can't even read. I didn't compare Java to Forth, I compared Java to pure JVM bytecode, both of which are backed by the same corporations. As to people being productive in Forth, that's singular cases and/or fairytales. Let's see some real, large, valuable software written in Forth. Browsers, web frameworks, GUI frameworks, text editors for God's sake. Can't think of any?
- dang 7y agoYou can't attack another user like that on HN, no matter how strongly you feel or disagree. Please make your substantive points thoughtfully in the future. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- kabdib 7y agoI've met a couple of really good FORTH programmers over the years. They were humble about it, were also happy to use other tools in their work, and they just happened to be working on projects that were really good fits for FORTH's strengths. I've met a lot more FORTH fanatics, people for whom FORTH was the answer no matter the problem; people who just would not shut up about how superior and fantastic it was, and have you seen the light, brother? Okay, most of them weren't that bad, but a few were (one guy I worked with got fired because (a) he told his boss that FORTH was all he was going to use, (b) the FORTH runtime was over half of his code budget and he had kinda been keeping that secret, and (c) none of that fantastically <insert some adjectives here> FORTH code was compatible with the ROM it needed to run on . . . so you can imagine that fun little tete a tete). Whatever the languages's wins or faults, it's still a great idea to write your own FORTH at some point. It's a ton of fun, and quite instructive when you've gotten a fully functional programming environment that fits in a few tens of kilobytes.
- coldtea 7y ago>Other than in niche or pet projects, can this even work? All kinds of projects have been written in Forth, so yes. Also, regarding "You step down on the level of assembly language which may sound daunting, yet gives you full control over every aspect of memory layout.", until around the 80s, tons of software, commercial or not, including full blown games like "Prince of Persia", was written in assembly, so again, yes....