2024-10-07 17:23:18 I made a snake game in forth :0 2024-10-07 17:23:34 https://termbin.com/s9mx 2024-10-07 17:24:04 I'm not proud of the code since I'm just learning forth and it was an exercise, but I'm surprised that it "works" 2024-10-07 17:24:32 it uses gforth and the nice bindings it has 2024-10-07 17:24:34 https://termbin.com/63dh 2024-10-07 17:25:08 vms14: Nice. :-) 2024-10-07 17:25:50 I like the circular-increment and decrement words, they allow you to use an index in a circular way 2024-10-07 17:26:19 I did not want to move all the segments, only the tail moving to where the head would go is enough 2024-10-07 17:26:29 KipIngram how much it sucks this code? 2024-10-07 17:27:00 I do not feel comfortable with forth yet and I have a lot of things to learn, I only have scratched the surface 2024-10-07 17:29:19 well done vms14 2024-10-07 17:29:50 if you want to try it here is the both files concatenated without the include 2024-10-07 17:29:51 https://termbin.com/tlro 2024-10-07 17:29:58 gforth this.file 2024-10-07 17:31:15 but you need libtool. in debian is apt install libtool-bin 2024-10-07 17:31:20 but can move grow and die 2024-10-07 17:31:32 100% libtool-bin - Generic library support script (libtool binary) 2024-10-07 17:31:54 that's what gforth uses for the magic ffi 2024-10-07 17:32:06 I have never seen an easier ffi 2024-10-07 17:32:28 but it generates compiles and links c code everytime 2024-10-07 17:33:38 I keep thinking about forth and what I like from it 2024-10-07 17:33:57 I have to keep coding and learn the way forth likes to do things 2024-10-07 17:34:17 I would like to capture the essence of forth in my toy rpn lang, which I failed to do 2024-10-07 17:35:15 I like the "untyped" memory acces where I can decide what the objects are and add accessors that just increment a number on the stack 2024-10-07 17:35:44 also the stack gives you cool tricks sometimes, I understand why avoiding variables is good 2024-10-07 17:36:12 or at least try to make your words as generic as possible, which you achieve messing the stack 2024-10-07 17:36:39 btw if you play the game press n to stop 2024-10-07 17:36:47 exit* 2024-10-07 17:37:21 the game sucks and I would like to rewrite the code once I learn properly, but the snake does not give me enough motivation 2024-10-07 17:38:26 my thing with forth is about bottom up programming and whether I can convert it to my main development lang to do everything with it, but I have to keep learning to realize that 2024-10-07 17:39:18 I know some people would say forth is not for every task, but if I can capture the forth essence in some rpn implementation I can implement that in any language and steal all the features I want 2024-10-07 17:39:47 for example a js implementation for web applications, I could make one in python and steal all the libraries, etc 2024-10-07 17:40:34 but I keep thinking about the features I have to steal from forth to make a language that works with the forth philosophy 2024-10-07 17:41:25 I think memory access is more important than what I see, how you push a memory address on the stack, fetch, store and accessors that just modify that address number 2024-10-07 17:41:59 the ability to create your own data structures the way you want and the size you want 2024-10-07 17:42:36 this is important for bottom up programming 2024-10-07 17:42:46 mainly to extend the language 2024-10-07 18:00:43 i would say "bottom up programming" is not so much about the language or features of the language, it's more of a methodology. it's about writing the bottom layers first and testing them by mocking input. 2024-10-07 18:02:07 the problem that i have with bottom up development is that i tend to see bottom up developers violate the YAGNI rule. without the top-down big picture to guide them, they don't have a clear idea of exactly how the bottom layer will be used, so they implement every interface or feature they could imagine might be useful down the road. 2024-10-07 18:04:27 how could they, without a top-down big picture approach 2024-10-07 18:07:10 "i know we will need a driver for this i2c device, but i don't know exactly how we will use it, so i will support every feature i read about in the data sheet." and in the end, only one feature of the device is ever used. 2024-10-07 18:21:26 top down.. bottom up.. meh.. just go all in :) 2024-10-07 18:21:39 I call it 'poker programming' 2024-10-07 18:21:47 hehe 2024-10-07 18:22:04 20 CALL 2024-10-07 18:23:25 user51: you joke, but honestly that's a pretty good summation of my feeling about bottom-up-versus-top-down development. i feel like when i write something in c, it's more accurately described as top-down-back-up-in-multiple-passes development 2024-10-07 18:23:48 I believe that is true in many languages, zelgomer 2024-10-07 18:24:13 bar from some programs in some typed languages, where you really spend a lot of time up top 2024-10-07 18:24:31 right, sorry, i mentioned c because that's where i spend most of my life. i just meant to say "when i'm doing successful programming instead of struggling with forth" 2024-10-07 18:25:22 true true 2024-10-07 18:27:08 zelgomer: What do you think about when you program? Alternatively, how do programs look like for you? 2024-10-07 18:29:08 what do i think about when i program? how much longer before lunch, how annoying the leaf blowers outside are, my back hurts and i need to stand up 2024-10-07 18:32:29 I like to create my own operators and tools to make things easier, I have a problem where I would spend a lot of time making a tool for something I could do manually in no time 2024-10-07 18:32:54 vms14: That can be fun, for what it's worth. 2024-10-07 18:32:55 I like how forth allows me to create such tools 2024-10-07 18:33:43 zelgomer: Back pain is pretty serious business -- I've had an injury which thankfully healed and it was *very* painful. 2024-10-07 18:33:53 also I was thinking what I want from a language is as less limititations as possible, because limitations affect a lot on my creativity 2024-10-07 18:33:56 zelgomer: No more coding today! 2024-10-07 18:34:59 that's why for example I hate java and I like common lisp and perl, but with forth it feels like what I always wanted and I keep trying to understand why I seem to prefer forth to common lisp 2024-10-07 18:35:53 java: the kingdom of the nouns (and boilerplate!!!) 2024-10-07 18:36:03 but it's something I have to keep digging by learning forth properly and realize whether forth is my thing or not 2024-10-07 18:37:13 vms14: i've actually thought about this a lot, the removal of limitations. i actually think it may be counter productive for me. with a language like c, i know where my boundaries are, and i can focus on solving the problem within those boundaries. with forth, i've actually never generated a finished version of anything i've started, and i think it's because i easily get side-tracked exploring clever new 2024-10-07 18:37:19 ideas. 2024-10-07 18:37:51 like so much creativity distracts you from what you should be doing 2024-10-07 18:38:07 well I never finished anything in my life because of that 2024-10-07 18:38:16 https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html 2024-10-07 18:38:38 I loose motivation so fast that I need a language that allows me to create something before the motivation ends 2024-10-07 18:39:36 that's what i would say. but i could be wrong. i also have decades of experience with c, and so i take for granted that i have established patterns and coding styles and naming conventions that are all automatic today. with forth, i'm having to re-establish these things, and part of that could contribute to what i perceive as what i described above. 2024-10-07 18:39:38 anyways what I want is a language that allows me to handle complexity and I wonder why I'm telling myself forth could be that lang 2024-10-07 18:41:16 user51: after giving it some thought, i think my real answer to "what do you think about when you program?" would be: how is this going to hurt me later? 2024-10-07 18:41:36 i think that i've developed a very defensive programming style over the years 2024-10-07 18:41:58 i know what land mines usually catch me, and so my designs are influenced by avoiding them 2024-10-07 18:43:46 and it's usually a BSD-style "it should just do the right thing" type of philosophy. like my forth doesn't have a move, cmove, cmove>, cmove<, or whatever all of those stupid things are. i have a single move which just does the right thing depending on how its source and destination inputs relate to each other in memory 2024-10-07 18:54:54 actually i'll throw out one more, i think i've mentioned this before. for me, programming goes a lot better if i can reduce the amount of noise in my head. i like to compartmentalize things and then expose very limited interfaces to them. i'm sure this is just a conditioning thing, but i find c's headers perfect summaries of interfaces. it allows me to look at a header, see the interfaces i need to see, 2024-10-07 18:55:00 and it's not cluttered with implementation or private symbols. i also get to see structure definitions that i need to know about, and i don't have to see those that i don't need to know about. i struggle with this in just about every other language that doesn't have the source/header model. 2024-10-07 18:55:46 i suppose i could do the same thing in forth, just with text files that describe the public interfaces. but it doesn't force me to do it, so i haven't established a convention for it yet. 2024-10-07 18:56:35 my c usually has prototypes and very detailed comments in the public headers, and almost no comments in the source files themselves. 2024-10-07 19:02:49 zelgomer how forth allows you to handle complex tasks in a way other languages can't? 2024-10-07 19:03:18 or how forth would be a better choice for a complex task rather than other languages? is something I try to understand 2024-10-07 19:04:10 because something inside me is claiming forth is what I wanted for complex big programs and I wonder how much drugs did I take 2024-10-07 19:04:39 many* 2024-10-07 19:11:09 I think the bot nailed it 2024-10-07 19:11:10 https://pastebin.com/jgmh5Fmv 2024-10-07 19:22:29 vms14: congratulations on the snake game! 2024-10-07 19:28:25 vms14: I've been somewhat disappointed with GForth's FFI because it can't handle struct arguments or return values 2024-10-07 19:31:19 it says the "undocumented ffi" can, which is funny to have it undocumented for years 2024-10-07 19:31:23 funducumented :) 2024-10-07 19:32:41 if I had a computer I would bind the xlib library and have fun with it 2024-10-07 19:32:56 vms14: I think the Java vs. CL/Perl/Forth thing is mostly a liberal vs. conservative thing in Steve Yegge's terms: https://news.ycombinator.com/item?id=41766932 2024-10-07 19:32:58 I would end trying to make a wm 2024-10-07 19:33:09 and play with sdl 2024-10-07 19:33:25 I don't think Forth will help you with handling complexity though 2024-10-07 19:33:46 yeah I keep thinking what is making me like forth 2024-10-07 19:34:15 because my goal is to have a language I can use for everything, including complex software 2024-10-07 19:34:54 zelgomer: the reason cmove and cmove> have a defined copying direction is so that you can dup bl swap c! dup 1+ size cmove to fill an area with spaces, for example 2024-10-07 19:35:37 I do kind of like the source/header distinction in C 2024-10-07 19:36:12 in Forth you can put the implementation words and the interface words in separate vocabularies (wordlists) 2024-10-07 19:37:13 Xlib doesn't require struct arguments or return values, just pointers to them, which GForth's FFI handles fine; Xlib is from before all C compilers supported that 2024-10-07 19:37:36 vms14: I don't mean to say that you can't do complex software in Forth 2024-10-07 19:37:48 more that you have to handle the complexity yourself 2024-10-07 19:38:05 maybe even more than you would in other languages actually 2024-10-07 19:39:02 xentrac my main problem is that I loved common lisp because of metaprogramming and when I saw forth my interest in lisp went to 0, I'm trying to find an explaination to why I would prefer forth than common lisp, but I fail to. 2024-10-07 19:39:21 yeah, that tracks with the liberal/conservative thing 2024-10-07 19:39:45 Oh no, politics :D 2024-10-07 19:39:51 the fact I have no more interest in lisp anymore seems to state that forth is able to do everything I want to do in common lisp, which is something hard to believe 2024-10-07 19:39:57 not actual partisan politics, user51 2024-10-07 19:40:00 Steve Yegge's thing 2024-10-07 19:40:04 conservatives look at arbitrary compile-time computation and shit their pants thinking about pulling an allnighter to debug things 2024-10-07 19:40:18 liberal look at arbitrary compile-time computation and think "this is going to be so much fucking fun" 2024-10-07 19:40:41 *s 2024-10-07 19:40:42 you can certainly do everything in Forth that you can do in Lisp 2024-10-07 19:40:53 but I'm trying to realize what I like from it and whether I want to use it for everything or not, this is why I made the snake game to learn forth since is my first forth program xd 2024-10-07 19:41:27 I think the reason I don't use Forth for everything is that I'm not all the way over to the liberal end of the axis 2024-10-07 19:41:45 I think the reason I don't use Forth for everything is that I'm not all the way over to the liberal end of the axis 2024-10-07 19:42:17 and I notice that getting my Forth code to actually work does take more work than in, say, C 2024-10-07 19:42:35 but if i learn to capture the good things from forth into some rpn lang I can implement it in any other language, stealing its features or using other platforms 2024-10-07 19:42:42 xentrac: Now I'm scared saying things like "the right tool for the job" :D 2024-10-07 19:43:36 Wow, surprise Windows Phone mention. Now where did **that** go? 2024-10-07 19:47:08 vms14: btw I hear you can use Xlib inside VNC in Termux 2024-10-07 19:51:59 xentrac yeah but it sucks I'm going to stick with the terminal 2024-10-07 19:52:19 the way to make gui apps will be making web applications 2024-10-07 19:52:52 I like the illustrations https://ratfactor.com/forth/forth_talk_2023.html 2024-10-07 19:55:23 https://ratfactor.com/forth/talkimg/chuck_hero.png 2024-10-07 20:02:16 xentrac> I do kind of like the source/header distinction in C 2024-10-07 20:02:28 forth has caused me to appreciate c in a lot of ways 2024-10-07 20:02:51 vms14: web applications are pretty great 2024-10-07 20:02:55 things i previously had considered deficiencies, i now realize i wouldn't have a good solution for 2024-10-07 20:03:14 in C? 2024-10-07 20:03:18 yes 2024-10-07 20:03:25 Like what? 2024-10-07 20:03:28 Having to maintain source and header separately isn't great though 2024-10-07 20:04:42 I don't like it, usually 2024-10-07 20:05:03 a good example is compile-time execution. it's always irked me to write c that initializes complex data structures at startup. "why can't i have compile time execution! i can do it in forth!" obviously i never actually thought that one all the way through. you really can't support compile time execution and incremental compilation simultaneously. 2024-10-07 20:05:56 like i said before, i actually do like the headers. i like maintaining them separately. it gives me a place where i can forget about implementation and say "this is my interface." 2024-10-07 20:07:33 anyway, now that i realize why c can't support complex compile time execution, i'm feeling a little more tolerant of preprocessing :) 2024-10-07 20:07:59 not the c preprocessor, i mean, but using scripts to preprocess or generate c sources 2024-10-07 20:08:17 the c preprocessor is pretty weak as a macro system 2024-10-07 20:08:31 yes, it needs some love 2024-10-07 20:13:40 you know what it needs... #pragma FORTH : macro ... ; 2024-10-07 20:15:12 You could always write a pre-pre-processor-processor in Forth :P 2024-10-07 20:17:59 a frequent problem with compile-time execution is that your compile-time code can have bugs and need debugging 2024-10-07 20:18:11 the C preprocessor is weak on purpose 2024-10-07 20:37:25 i tried using that on my gym teacher but it didn't go over as well 2024-10-07 20:39:20 if you want complex compile-time execution in C, you can always use m4 2024-10-07 20:39:25 but don't say I didn't warn you 2024-10-07 20:40:04 ugh no 2024-10-07 20:40:52 i remember one of the early sentences in the m4 manual is something along the lines of "be careful, because once you learn to use m4 you will want to use it for everything!" 2024-10-07 20:40:55 fat chance 2024-10-07 20:42:11 I think m4 postdates C, but I think m6 predates it, and m6 is a reimplementation (in ASCII) of GPM, which definitely predates C 2024-10-07 20:42:33 and I think experience with systems like those informed the limitations of the C preprocessor 2024-10-07 20:43:14 aaah, didn't know that history. makes sense. 2024-10-07 20:43:26 still, you can do X-macros in the C preprocessor: http://canonical.org/~kragen/sw/dev3/binmsg_cpp.h 2024-10-07 20:44:24 well, maybe http://canonical.org/~kragen/sw/dev3/binmsg_cpp.c is a better place to start 2024-10-07 20:45:22 then you can look at the .h file to see what MESSAGE_TYPE expands to once you see what it's being used for 2024-10-07 20:46:09 I want to insert the contents of a text file into a string in another file which cpp still can't do :( 2024-10-07 20:46:24 MrMobius: oh, that got added 2024-10-07 20:46:36 Ooooh 2024-10-07 20:46:55 it did?? 2024-10-07 20:47:38 link? 2024-10-07 20:47:43 https://en.cppreference.com/w/c/preprocessor/embed 2024-10-07 20:48:20 yeah, #embed in C23 2024-10-07 20:49:44 thanks!!! 2024-10-07 20:50:55 yeah, finally no more generating c arrays of blobs 2024-10-07 20:50:55 JeanHeyd Meneide tells the whole saga in https://thephd.dev/finally-embed-in-c23 2024-10-07 20:51:29 looks like they added it to gcc last month so we'll be able to play with it on Debian in 2026 or so :P