2021-09-16 06:31:10 i coded today! 2021-09-16 06:31:54 i wrote "find" yesterday and today i optimized it 2021-09-16 06:32:19 i may have prematurely optimized it 2021-09-16 06:32:55 can you share it? 2021-09-16 06:33:04 but it's noticably faster on dosbox 2021-09-16 06:33:41 i suppose 2021-09-16 06:41:47 i gotta clean it up! 2021-09-16 07:00:16 https://termbin.com/pc6u 2021-09-16 07:00:53 it's not meant to be run, i assembled it by hand 2021-09-16 07:01:06 i jut added the comments then, they are pretty bad 2021-09-16 07:03:40 i have 16 pointers in context, where context 1 cells + is all words of length 1, context 2 cells + is all words of length 2, context len cells + for length in general 2021-09-16 07:07:28 i read some advice from a story on hacker news to do a little bit of coding every day 2021-09-16 07:07:36 so i tried it 2021-09-16 07:07:42 it works! 2021-09-16 07:10:54 i hand assembled it because the colon compiler doesn't exist yet, and in order to make the compiler, i need to be able to look up words :-) 2021-09-16 07:15:32 thanks 2021-09-16 07:16:34 it's pretty rough 2021-09-16 07:16:41 not good for much 2021-09-16 07:19:53 i thought i read a story that chuck moore said use dup and over, but don't use swap and rot ... the idea i got was if you have to explain what's on the stack, you're doing something wrong 2021-09-16 07:20:49 and only have a maximum of 2 or 3 values on the stack.. any deeper and you should refactor 2021-09-16 07:20:59 so i started using variables 2021-09-16 07:22:38 the compare word begs to get coded in assembly 2021-09-16 07:23:31 it has 3 values on the stack 2021-09-16 07:23:43 but on x86 there is hardware acceleration 2021-09-16 07:26:03 before i read what chuck said about dup and over, i would have put "name" on the return stack and juggled it with lots of >r and r> ... but a variable is so much nicer 2021-09-16 07:27:16 oh the trick of having an array of linked lists for the words, only takes 32 cells of memory 2021-09-16 07:27:32 but it's a lot faster 2021-09-16 07:28:29 because each linked list only consists of the same length words, it saves a comparison in the inner loop of find 2021-09-16 07:28:46 and i can cache the offset to the field of a word 2021-09-16 07:31:42 the reason the dictionary entry is laid out in a strange way (the name is at a negative offset) is so i can go from an xt to a word by subtracting a cell 2021-09-16 07:41:44 f-a: it's pretty awful code, right? :-) 2021-09-16 07:41:48 i'm a newbie 2021-09-16 07:42:10 i've been writing c for so long that it's worfed my brain 2021-09-16 07:43:06 not really awful 2021-09-16 07:43:22 but I need to read in vim, I am frankly unused to no syntax highlight 2021-09-16 07:44:09 does vim have a mode for forth?? 2021-09-16 07:45:13 not a mode, just syntax highlight 2021-09-16 07:45:29 which isn’t the fanciest syntax highlight but works for me 2021-09-16 07:46:40 f-a: have you made your own forth? 2021-09-16 07:47:32 I tried to make a forth for the CHIP-8, but failed 2021-09-16 07:47:38 well not a forth, a cross compiler 2021-09-16 07:50:55 it's hard 2021-09-16 07:53:09 Failed in the "give up" sense, or the "bored" sense? 2021-09-16 11:17:55 Would be kind of interesting to build a 'fantasy console' a-la TIC-80 or PICO-8 but use FORTH as the programming environment rather than Lua. 2021-09-16 11:18:06 that would be indeed lovely 2021-09-16 11:18:32 feoh: uxn 2021-09-16 11:18:48 https://wiki.xxiivv.com/site/uxn.html 2021-09-16 11:20:18 That looks like a very nifty project 2021-09-16 11:20:23 Thanks for the pointer! 2021-09-16 11:20:50 However have you looked at TIC-80? 2021-09-16 11:20:51 https://tic80.com/ 2021-09-16 11:21:07 very different aims and goals 2021-09-16 11:21:13 Yep 2021-09-16 11:21:25 let me find the creator's post about it, haha 2021-09-16 11:22:03 I'm suggesting something like TIC-80 that runs on modern hardware but presents a 'retro'-esque runtime environment, using FORTH as the programming language 2021-09-16 11:22:52 thats interesting but i dont think it neccessarily offers anything unique over tic-80 then? 2021-09-16 11:23:12 not that there's anything wrong with that ^^ 2021-09-16 11:23:25 but, where does forth's advantage set in here? 2021-09-16 11:24:50 I think it would be interesting because FORTH's stack based nature and use of dictionaries/words could be an interesting way to decompose the workings of a game. 2021-09-16 11:25:53 sounds perfect! 2021-09-16 11:26:13 i think you could take some inspiration from iKe here 2021-09-16 11:26:53 it's not a specifically retro styled thing, and it's more livecode-y than fantasy computer-y 2021-09-16 11:27:04 but it uses a more esoteric language 2021-09-16 11:27:06 that being, K 2021-09-16 11:27:54 https://github.com/JohnEarnest/ok/tree/gh-pages/ike#ike 2021-09-16 11:51:19 Neat, thanks! 2021-09-16 11:52:34 When I hear 'k' I think of the APL like language 2021-09-16 11:52:36 Same? 2021-09-16 11:53:20 yes, iKe is a K environment 2021-09-16 11:53:47 if you look at the gif(in the link!), you'll be able to see it in action ^^ 2021-09-16 11:55:31 Looks neat. Always had a hard time wrapping my brain around APL 2021-09-16 11:55:36 and APL like languages. 2021-09-16 11:56:05 it's difficult! 2021-09-16 11:56:14 im trying to get better at it 2021-09-16 11:56:47 my favourite piece of K code has been `(|+\)` as of late 2021-09-16 11:56:57 it's a nifty little thing 2021-09-16 14:42:12 h'lo folks 2021-09-16 14:43:21 what was the equiv of C's switch statement in many forths loosly following ansi forth "standard"? 2021-09-16 14:44:10 often gets compiled/translated to jump tables 2021-09-16 14:47:01 here we go http://lars.nocrew.org/dpans/dpansa6.htm#A.6.2.0873 2021-09-16 14:47:31 that type of translation is an optimization the C compiler does. not a lot of forths optimize so i wouldnt expect many to create a jump table 2021-09-16 14:49:35 well, some forths I have seen use a case variant of jump table 2021-09-16 14:51:01 something like (CASE) followed by a cell containing number of entries followed by the entries 2021-09-16 14:51:41 each entry being two cells, one for the selector value and one for the jump target 2021-09-16 14:54:27 the whole thing followed by the code for the default case then the code for each case 2021-09-16 14:57:22 neat 2021-09-16 14:57:29 you could set something like that up yourself 2021-09-16 14:58:06 i think C only makes the jump table though if it's a simple pattern it can recognize 2021-09-16 14:58:34 so you can calculate the jump address based on the index without having to do any comparisons 2021-09-16 14:59:26 yeah, one of the patterns is that the case selector value is less than 11 bits in size 2021-09-16 15:01:03 i mean a pattern such as 1,2,3 or 5,7,9. if you have cases with values like 2, 78, 104 then the C compiler wont find a pattern 2021-09-16 15:03:38 ... and the switch statement has a case for each possible value or near it then a jump table is made iirc 2021-09-16 15:06:52 right but with 2, 78, 104 the addresses need to be arranged in memory in some way that calculating the address to load from the table is faster than doing the comparisons 2021-09-16 15:07:08 Rest in peace, Sir Clive Sinclair 2021-09-16 15:07:09 so for that youd need about 100 empty entries in the table which the compiler would not do 2021-09-16 15:07:21 rip Clive 2021-09-16 15:14:06 I think they are probably smart enough to do a very basic hash and mask to allow unconditional jumping, only one way to find out though 2021-09-16 15:14:36 I would expect them to generate a perfect hash, but maybe I expect too much of them :P 2021-09-16 15:39:33 ive played around with it on godbolt before. its pretty slick: https://godbolt.org/z/Trf1G488s 2021-09-16 17:39:56 So are all you folks just hard core chips & bits types or do any of you use FORTH on vanilla 'modern' hardware like Factor and the like? 2021-09-16 17:42:23 There's a good mix in here I think 2021-09-16 17:42:58 The hardcore chips and bytes people tend to gravitate a bit more to #mecrisp 2021-09-16 17:43:42 I'm currently writing a Forth for x86-64 UEFI systems, not the first to write a x86-64 Forth in here 2021-09-16 17:44:01 Most people in here learning Forth will start with gforth 2021-09-16 17:44:50 never tried factor 2021-09-16 17:44:54 I use gforth 2021-09-16 17:45:03 but frankly the allure of forth lays in its simplicity I feel 2021-09-16 17:45:10 I need to get a frigging board and experiment 2021-09-16 17:45:11 im building a graphing calculator with a 1mhz 6502 which is forth based 2021-09-16 17:45:48 Whereas I have no idea what the allure of Factor is 2021-09-16 17:46:52 MrMobius: Why use a 6502 today? 2021-09-16 17:48:23 veltas, for this project there was a competition to build something with a 6507 2021-09-16 17:48:36 Ah 2021-09-16 17:48:57 but in general its one of the best choices in DIP if you need external bus 2021-09-16 17:49:40 14mhz with modern 65C02. maybe only 68000 or 65C816 are better 2021-09-16 17:55:48 I tend to be interested in things with a relatively high level of abstraction, but IMO that's one of the really cool things about Forth. The abstraction levels can go as high or as low as you want.