2024-06-20 04:11:40 "meaningful" is pretty well defined in human business 2024-06-20 04:11:58 string processing, numerical processing, relational data 2024-06-20 04:12:09 and http :) 2024-06-20 04:12:15 pretty much covers the spectru 2024-06-20 04:12:17 m 2024-06-20 04:23:09 Where it gets difficult for me is the expectation of internet access, friendly UIs, that kind of thing. 2024-06-20 04:23:18 Something my girlfriend will use. 2024-06-20 13:18:28 in forth your programs are organisms because they are made with cells 2024-06-20 13:49:55 within cells 2024-06-20 14:03:21 traveler: There are forths with graphical interfaces, people have made windows-like UIs in Forth 2024-06-20 14:03:34 I'd like to do something like that myself 2024-06-20 14:41:06 i want to know how forth would be able to define dup and over in terms of pick by giving it a list of strings with "dup" and "over" that forth iterates and uses i 1+ pick to define the code of dup and over 2024-06-20 14:42:49 mainly how can i define a word from a string in memory or whatever and generate code from a loop 2024-06-20 14:43:57 EVALUATE is the standard word for interpreting a string 2024-06-20 14:44:00 i have to learn more so i can find ways of doing that, but this would be equivalent to a lisp macro 2024-06-20 14:44:59 There's a shortcut, use POSTPONE or COMPILE, 2024-06-20 14:46:36 Can also manipulate >IN 2024-06-20 14:46:41 There's many ways to skin a cat 2024-06-20 14:47:03 https://www.ultratechnology.com/scope.htm 2024-06-20 14:47:23 i should only have to compile a literal i guess 2024-06-20 14:47:39 which would be the i 1+ 2024-06-20 14:47:50 But why 'compile' a list of words at all? 2024-06-20 14:47:58 Just write a word that does the thing on execute 2024-06-20 14:48:16 veltas i just wonder about how can i have the same metaprogramming features i can have in lisp 2024-06-20 14:48:39 IMMEDIATE + COMPILE, + [COMPILE] I guess 2024-06-20 14:48:39 i assume forth is able to do metaprogramming, but i do not know the ways 2024-06-20 14:48:43 And/or >IN manipulation 2024-06-20 14:48:48 SOURCE 2024-06-20 14:48:54 CREATE DOES 2024-06-20 14:49:01 WORD PARSE 2024-06-20 14:49:04 Look all those up and understand them 2024-06-20 14:49:04 yeah i'm learning about create does xd 2024-06-20 14:49:20 i have to learn a lot of stuff 2024-06-20 14:49:21 A specific example might be better 2024-06-20 14:49:29 What's a metaprogramming thing you'd do in lisp? 2024-06-20 14:49:45 Assume I'm a lisp noob ... because I am 2024-06-20 14:49:50 https://github.com/ForthHub/ForthFreak/blob/master/FunForth 2024-06-20 14:49:54 for example to automate generating of functions that they have similar code but only a part changes 2024-06-20 14:50:24 like in the case of dup and over which they are n pick 2024-06-20 14:50:24 only n changes 2024-06-20 14:51:41 i will learn sooner or later, for now i have to go through the basics 2024-06-20 14:51:44 CREATE/DOES 2024-06-20 14:52:00 i have to get a good understanding on how to manipulate the dictionary 2024-06-20 14:52:39 how i give create the name from a string in memory? 2024-06-20 14:52:43 : PICKER ( n -- ) CREATE DOES> @ PICK ; 0 PICKER DUP 1 PICKER OVER 2024-06-20 14:54:17 You didn't save the value 2024-06-20 14:54:24 Sorry yeah 2024-06-20 14:54:28 : PICKER ( n -- ) CREATE , DOES> @ PICK ; 0 PICKER DUP 1 PICKER OVER 2024-06-20 14:54:32 Respect the comma! :P 2024-06-20 14:55:41 vms14: Do you know how to use DOES> ? 2024-06-20 14:56:13 i'm learning about it and how constant and variable can be created with it 2024-06-20 14:57:53 but i have yet to play with it 2024-06-20 14:59:51 The metaprogramming is incredibly powerful in Forth, because you have a lot of easy access to the compiler/interpreter 2024-06-20 14:59:58 So you can tap in anywhere 2024-06-20 15:00:10 But there's many ways to do things, and some are better for some things than others 2024-06-20 15:01:03 this is the hidden thing i feel in forth that makes me wonder whether it should my main dev language 2024-06-20 15:01:13 should be* 2024-06-20 15:01:59 i just need to get understanding of how to manipulate the dictionary at my will 2024-06-20 15:02:23 the dictionary is just a memory region with entries 2024-06-20 15:03:41 if i can have the same metaprogramming features i have in lisp, even if in a different way then forth has a lot of power i want to see 2024-06-20 15:05:11 if it's another approach to metaprogramming i want to learn it and discover things that i could only find there 2024-06-20 15:07:06 but i have to be patient and learn basics first xd 2024-06-20 15:09:38 i will start making data structures with create and does 2024-06-20 15:12:30 You can certainly do those things, but you may find that to do everything you want you have to learn your particular system's implementation details and exploit them. It's great to stay portable, but you can't necessarily do it in all cases, depending on what you're wanting to do. 2024-06-20 15:12:48 You CAN do anything, if you're willing to grab hold of the right parts of the system. 2024-06-20 15:24:40 I'm not saying it should be your main dev language 2024-06-20 15:25:02 I'm sure it can be used for that, but for most people that's probably a bad idea 2024-06-20 15:33:18 I like Forth as a main dev language, but wouldn't recommend it as such for most people 2024-06-20 15:35:15 why not 2024-06-20 15:35:23 just because it's missing libraries? 2024-06-20 15:36:04 Also is hard to get used to, and you probably won't be more productive in it than other languages, etc 2024-06-20 15:36:26 There are situations where it would be more productive, but that doesn't apply to most problems you'll have in business etc 2024-06-20 15:37:55 but once you are used to, it doesn't pay off? 2024-06-20 15:38:01 as veltas says, it's hard to get used to, there's a lack of libraries (in general, and documentation is often lacking 2024-06-20 15:38:15 isn't even forth better suited for large programs than python or alike? 2024-06-20 15:38:29 Of course it pays off, but you'll probably never 'beat' other languages like C for many things 2024-06-20 15:38:40 Python isn't suited to large programs 2024-06-20 15:38:50 Controversial but that's my opinion :) 2024-06-20 15:38:53 change it for java 2024-06-20 15:38:57 I think learning forth is beneficial, as it can make one a better programmer in general, even in other languages 2024-06-20 15:39:43 Forth is tiny, hackable, powerful, flexible, extensible, integrated, etc etc etc 2024-06-20 15:39:46 for me is like something is telling me forth can be the only language i would ever need 2024-06-20 15:39:48 It's unique among languages 2024-06-20 15:40:48 and once i have a proper understanding of it i could implement it or extend an existing implementation in some way like just using ffi 2024-06-20 15:41:11 so lack of libraries is not that scary 2024-06-20 15:41:21 It's really on you or anyone here to *prove* that it's sufficient, and there's not many who can claim this 2024-06-20 15:41:36 And lots of us have serious doubts 2024-06-20 15:41:46 yeah, i have to learn it properly and then i will know 2024-06-20 15:42:01 I *want* it to be sufficient, but I *doubt*, and yet still try to *prove* it's capable 2024-06-20 15:42:18 And dream of using it more 2024-06-20 15:42:30 But it's not easy, there's no guarantees 2024-06-20 15:42:42 So if you learn it, learn it because it's fun/interesting, is what I'm saying 2024-06-20 15:42:43 you can implement a forth in a language that has lots of libraries and inherit them 2024-06-20 15:43:00 it's a bit different because forth wants to be written in assembly 2024-06-20 15:43:13 but you might be able to have something 2024-06-20 15:43:21 Yeah I don't see the point of taking a rich language and trying to remove syntax 2024-06-20 15:44:15 I sort of see it, but I've noticed projects on here with assembly or custom VM forths go better than ones built on other high level languages 2024-06-20 15:44:28 I use forth for most of my programming, but do recognize that there are some things better suited to other languages 2024-06-20 15:46:11 I often do things like using pipes to communicate with external programs, letting me sidestep FFI issues and writing things in other languages when it makes sense 2024-06-20 15:47:15 (e.g., using sqlite3 for database access, and jq to operate on json data) 2024-06-20 18:48:44 crc: Do you think Forth could make a good shell script replacement? 2024-06-20 18:52:55 if in defining my word i have some difficult to image stack in mind, what is the best thing to do? split it into smaller words? 2024-06-20 18:53:30 There's no one way 2024-06-20 18:53:33 Spli 2024-06-20 18:53:41 Split* 2024-06-20 18:54:14 Or use return stack, simplify the problem, use variables, etc etc 2024-06-20 18:54:44 Variables is the best 'general' candidate to this problem 2024-06-20 18:54:59 Stack comments are good too sometimes 2024-06-20 18:55:55 yeah 2024-06-20 18:56:09 wait, stack comments? what is that? 2024-06-20 18:56:18 oh.. ( 1 2 -- x y ) 2024-06-20 19:13:40 Yeah. Of course, they don't actually DO anything - they just help you keep it straight in your head. 2024-06-20 19:14:07 I use forth for shell tasks, but haven't really written a good vocabulary for building shell pipelines yet. 2024-06-20 19:14:27 rendar: Yes, but stack comments also I mean keeping track within the word as well 2024-06-20 19:14:48 Like writing what's on stack at the end of a line 2024-06-20 19:16:30 yeah indeed 2024-06-20 19:20:42 re use in the shell, can I use gforth as a script interpreter? Here's my experiment: https://bpa.st/BDQA 2024-06-20 19:23:54 This does not work for me: 2024-06-20 19:23:57 #!/usr/bin/gforth 2024-06-20 19:23:59 ." hello world" cr 2024-06-20 19:24:03 bye 2024-06-20 19:24:19 It does find gforth, but then gforth says "interpreter not found." 2024-06-20 19:24:52 Oh, it's choking on the #!/usr/bin/gforth. 2024-06-20 19:25:09 https://gforth.org/manual/Running-Image-Files.html 2024-06-20 19:25:11 There's probably some simple way around that, but it's a bit like a catch 22. 2024-06-20 19:25:48 KipIngram: try `#! /usr/bin/env gforth` 2024-06-20 19:25:55 Ok, I used #!/usr/bin/gforth but it wants a space after #! 2024-06-20 19:26:08 That works, crc - I just found it myself thanks to thrig's link. 2024-06-20 19:26:26 I guess gforth treats #! as a nop. 2024-06-20 19:26:42 Yeah, seems to. 2024-06-20 19:26:56 Makes sense, I'll do the same 2024-06-20 19:27:13 Yes, me to - that's kind of handy. :-) 2024-06-20 19:27:30 #!/usr/bin/gforth -e ': #!/usr/bin/gforth refill drop ;' 2024-06-20 19:27:30 `: #! POSTPONE \ ; immediate` is how it's defined in my copy of gforth 2024-06-20 19:27:54 Awesome. Thanks, all. 2024-06-20 19:28:12 Thanks for bringing it up - I learned something new. 2024-06-20 19:28:20 Me too 2024-06-20 19:34:28 Oh, of course. Not a nop - if that's all it did gforth would choke on the path. The function of \ is exactly what you want. 2024-06-20 19:37:24 Getting stdin in a script: https://lists.gnu.org/archive/html/gforth/2020-02/msg00001.html