<veltas> nihilazo: This is roughly how I write forth over multiple lines https://pastebin.com/raw/1GUvETZg
<veltas> And yes you're right there is no 'standard' way, but if you look at people's code you'll definitely see some idioms
<f-a> ah, the stack contents under the instructions, nice tough
<f-a> *touch
<veltas> Also f-a and nihilazo, try writing Forth on paper if you feel like the stack is getting too much
<veltas> Just a weird thing I noticed that sometimes it was easier to write Forth on paper when I was new to it
<veltas> And not every word can be as elegant as : WASHER WASH SPIN RINSE SPIN ;
<veltas> f-a: I can't speak for every forther but I personally have to refactor and rewrite words often to get reasonable stack flow
<veltas> Sometimes writing forth feels a bit like trying to optimise register usage in assembly
<veltas> I'm just going to leave this here https://pastebin.com/raw/bCPuM5sT
<f-a> assembly is the demented little brother of forth
<f-a> I tried using r> >r but I think I did it with do and so screwed shit up?
<veltas> Yes, DO leaves its loop control on return stack, so you can't use previously stashed stuff
<veltas> Can probably factor what I've written for repeated squaring
elioat has quit [Quit: elioat]
<veltas> Okay this is a bit better IMO https://pastebin.com/raw/b5fBA5er
<f-a> rshift is…?
<veltas> rightwards bitshift
<veltas> I can't use 2/ because that preserves the highest bit
jedb_ has joined #forth
f-a has quit [Read error: Connection reset by peer]
f-a has joined #forth
kiedtl\x1b is now known as kiedtl
kiedtl is now known as kiedtl\0
boru` has joined #forth
boru has quit [Disconnected by services]
boru` is now known as boru
ornxka_ is now known as ornxka
f-a has quit [Quit: leaving]
dave0 has quit [Ping timeout: 240 seconds]
lispmacs has quit [Ping timeout: 256 seconds]
gravicappa has joined #forth
X-Scale` has joined #forth
X-Scale has quit [Ping timeout: 260 seconds]
X-Scale` is now known as X-Scale
sts-q has quit [Ping timeout: 272 seconds]
sts-q has joined #forth
dave0 has joined #forth
<proteus-guy> veltas, I like your code style. Mine is quite vertical as well.
xek has joined #forth
xek has quit [Remote host closed the connection]
xek has joined #forth
dave0 has quit [Quit: dave's not here]
dave0 has joined #forth
hosewiejacke has joined #forth
<veltas> proteus-guy: thanks
<veltas> I have tried writing more horizontal or idiomatic forth and it just never turns out as easy to read https://raw.githubusercontent.com/Veltas/aoc20/master/1-2-big.fs
<veltas> It become more vertical writing code designed to fit on the spectrum's 32x24 character display as well
f-a has joined #forth
X-Scale` has joined #forth
X-Scale has quit [Ping timeout: 246 seconds]
X-Scale` is now known as X-Scale
Zarutian_HTC has quit [Remote host closed the connection]
<nihilazo> in "starting forth", it says that a cell is 2 bytes, but that seems to be different on my system (CELL leaves 8 on the stack)
<nihilazo> is that because I'm on a 64 bit machine
<f-a> yeah cell abstracts AUs (which is really a fancy name for bytes, apparently)
<f-a> and yeah, because of different arch
<nihilazo> ok, that makes sense
<nihilazo> so a single-length number on my system is 8 bytes
<nihilazo> similar to what an int would be in other languages
<nihilazo> I suppose, if that is what one cell is, or are number lengths and cells different
<f-a> I would rather say an *address* length
<f-a> a number could the shorter
<f-a> think about it this way
<f-a> your machine is 64bit, right?
<nihilazo> yeah
<f-a> then it means that to address memory, you need a 64bit pointer (there is more to it, but let us cut some corners)
<f-a> that 64bit number, in bytes, is 8byte
<f-a> hence
<f-a> 1 cells . 8 ok
<nihilazo> yeah
<nihilazo> so how big are single-length numbers? (the book talks about single and double length numbers)
<nihilazo> signed 64 bit on a 64 bit system?
<nihilazo> they're 16 bit on a 16 bit system
<nihilazo> so I guess so?
<f-a> well
<f-a> in ans forth you have only (defined): cells, chars and AUs
<f-a> and no «types» as we know them
<f-a> so anything pushed on the stack will take 64bit
<f-a> (wait for someone more experienced to answer tho)
<nihilazo> ok
<f-a> when you *compile* definitions, you can of course get creative
<f-a> but that is up to you
<f-a> (say, instead of allotting a whole cell allotting 3 chars idk seems silly just to save some space — probably on older machines they did it)
<f-a> no wait I am *sure* someone did it
<f-a> that mad lad who ported a forth to the CHIP-8
<nihilazo> I want to try porting a forth to the TIC-80
<nihilazo> but I'm not sure how you would build a forth really
<f-a> well
<f-a> get yourself acquainted with forth
<f-a> and then
<f-a> 2. read JonesForth
<f-a> once you get «threaded model» (the «inner» interpreter) you are on the right path I think
<nihilazo> alright
<nihilazo> TIC-80 also uses a lua runtime so I'm not sure how to do performant implementations of things in that. It'd be a lot of learning
<nihilazo> still, a fun project probably
<f-a> http://angg.twu.net/miniforth-article.html if you want to take inspiration
<f-a> it is a nice article to read through and through
<nihilazo> thanks
<MrMobius> f-a, you should check out double numbers
<MrMobius> they take up two stack slots but are treated as one object by words like d+ or d-
<f-a> indeed indeed
<proteusguy> f-a have you decided on your threading model yet? ITC, DTC, etc? See http://www.bradrodriguez.com/papers/moving1.htm if you're not familiar with what these mean. DTC is probably the easiest that has decent performance, FYI.
jedb_ has quit [Ping timeout: 240 seconds]
<f-a> thanks!
proteusguy has quit [Quit: Leaving]
proteusguy has joined #forth
<f-a> thanks proteusguy
f-a has quit [Read error: Connection reset by peer]
f-a has joined #forth
elioat has joined #forth
jedb has joined #forth
<veltas> nihilazo: I still recommend Starting FORTH 1st ed, despite the many outdated things. You can ask about them in here or find out yourself referring to i.e. latest standard or your forth's reference.
<nihilazo> I'm reading it right now!
<nihilazo> I'm at the end of chapter 8
<veltas> When Starting FORTH was written I think most systems you would see Forth on were 8-bit, and it would generally implement 16-bit cells which would match the address size, and is a more convenient size for a general-purpose integer.
<f-a> the online version should be fixed though
<veltas> Unfortunately the online version seems to have issues
<veltas> I don't think it's a high-effort update
<veltas> And for accounting purposes or more accurate measurements you probably want 32-bit at least, hence double numbers
<elioat> I've been reading a lot about colorForth lately -- one thing I've never seen mention of is *how* you'd actually change the color when writing a program in it. Does anyone know what the interface was for that?
<veltas> I know that on some versions they have a special hardware button for it
<elioat> wild!
<elioat> thanks
<veltas> nihilazo: And for accounting purposes or more accurate measurements you probably want 32-bit at least, hence double numbers. 128-bit numbers now on 64-bit are overkill, and floating point numbers replace the need for those kinds of mostly fixed-point operations anyway.
<nihilazo> yeah, makes sense
Zarutian_HTC has joined #forth
<veltas> You still want fixed point in embedded or retro without an FPU
<nihilazo> yeah
<elioat> patrickg thanks! This is exactly what I was wondering about
jedb_ has joined #forth
jedb has quit [Ping timeout: 246 seconds]
<f-a> that is amazing and scary at the same time patrickg
<nihilazo> so, are items on the stack a cell long
<patrickg> yes
<nihilazo> ok
shmorgle has quit [Quit: [TalkSoup] via NEXTSPACE]
shmorgle has joined #forth
<nihilazo> is there any standard words for networking stuff in scheme or is it all down to the implementation?
<nihilazo> s/scheme/forth/
<nihilazo> my brain isn't working today with names lol
<veltas> No
<f-a> nihilazo: if you use gforth and similar stuff, you can somehow call C stuff
<veltas> It's not standard but there is definitely support for it (it's not standard in C or C++ either afaik).
gravicappa has quit [Ping timeout: 264 seconds]
<hosewiejacke> nihilazo: FORTH predates IP be >10 years ;)
<nihilazo> yeah I know, but standards have happened since then
* nihilazo told a friend he would write an IRC bot in forth, and now wants to do it even though other languages are a better choice
<veltas> I would advise writing stuff in forth, and not starting with an IRC bot
<veltas> I don't see the harm in trying but I just think you'd do a much better job after writing something else first
<veltas> Or you could do it and then post results in here and maybe someone will look at it and give suggestions for refactoring or taking advantage of forth's features better
<nihilazo> yeah
<nihilazo> I don't really know IRC either as a protocol
<nihilazo> so it'd be diving head first into two things
<hosewiejacke> veltas: agree. But having a project you are passionate about makes things more bearable.
<nihilazo> is there a way to get the length of a create/allot-ed array in forth?
<veltas> The IRC part is not too hard
<veltas> hosewiejacke: that's true
<veltas> nihilazo: No, not as far as I know. The technique is to use HERE at start and end of array and calculate, or use a word to automate that
<hosewiejacke> I started programming in Forth by writing a compiler for it :)
<veltas> Well rather if you're using CREATE, use HERE at end and name of the thing
<veltas> hosewiejacke: Me too, well after a bit of project euler. I can't say if that was the right thing to do, I think programming forth is different to programming with forth though
<veltas> nihilazo: e.g. CREATE ARR 1 , 2 , 3 , HERE ARR - 1 CELLS / CONSTANT #arr
<nihilazo> thanks
<veltas> Quite often CELL is defined as 1 CELLS
<hosewiejacke> veltas: seems to be a common pattern (writing an implementation before programming in it)
<hosewiejacke> mecrisp had a similar journey (I think)
<veltas> I think to do forth correctly you have to actually apply it to something, and I am trying to do that myself. I want to use my forth to create useful limited 80s-style business programs on the spectrum and write a manual with good examples containing that code
<f-a> veltas: for pleasure?
<veltas> For me programming is fulfilling, there are fleeting moments of pleasure. If I only pursue pleasure I will not be happy or fulfilled.
<f-a> sure!
<veltas> I think the spectrum is a valid small business machine for the 80s, and some people like games but I also happen to like useful software. I think things like accountancy and database software is useful
hosewiejacke has quit [Ping timeout: 240 seconds]
Zarutian_HTC has quit [Ping timeout: 246 seconds]
dave0 has quit [Quit: dave's not here]
crest has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
crest has joined #forth
Zarutian_HTC has joined #forth
elioat has quit [Quit: elioat]
f-a has quit [Quit: leaving]
elioat has joined #forth
Zarutian_HTC has quit [Ping timeout: 246 seconds]
<MrMobius> re financial software, i sure hope your not using floating point :P
Vedran has quit [Read error: Connection reset by peer]
Vedran has joined #forth
proteusguy has quit [Remote host closed the connection]
f-a has joined #forth
f-a has quit [Read error: Connection reset by peer]
f-a has joined #forth
bjorkintosh has joined #forth
<bjorkintosh> has anyone tried this? https://github.com/jamesbowman/swapforth
<f-a> nope
[1]MrMobius has joined #forth
MrMobius has quit [Ping timeout: 264 seconds]
[1]MrMobius is now known as MrMobius
<bjorkintosh> pity!
<f-a> I mean what is the selling point of this one
<nihilazo> running on FPGA CPUs I guess
hosewiejacke has joined #forth
hosewiejacke has quit [Client Quit]
<bjorkintosh> the selling point? 'because why not!'
<f-a> hehe true!
<nihilazo> that seems to be the selling point of basically all forth I've encountered so far
<nihilazo> "why forth?" "why not forth?"
<nihilazo> (well, there are obviously actual reasons why forth, but to me, I'm just having fun)
<f-a> that madlad at collapseOS liked forth for its qualities
<nihilazo> collapseOS is an interesting project to me tbh
<nihilazo> like, I don't really understand the point of it existing exactly (spend your time *trying to prevent* the collapse instead, lmao)
<nihilazo> and post-collapse humans, should a collapse happen, would probably make their own OS post-collapse to serve their post-collapse needs
<nihilazo> but still, building an entire new OS for improvised 8-bit hardware in the 2020s? Really awesome!
<elioat> yeah, I think it is an awesome project, but also wonder if doing something to cheap ARM processors, like those in android devices would be more pragmatic for the stated causes
<nihilazo> like, I feel like we should be doing more to prevent the collapse rather than giving in
<f-a> every prepper scenario is a very very narrow one
<f-a> but there are lot of them preppers
<f-a> so you believe in the end one will be lucky
<nihilazo> also yeah, I feel like what we will probably end up with in the case of a collapse is probably tons of bad smartphones
<nihilazo> rather than 8-bit hardware from the 80s
<elioat> exactly
<f-a> I wonder if z80 is more robust than new stuff
<f-a> but I habe kein idea
<nihilazo> I'm not a prepper but I super empathise with the "world's falling apart, we need to have working stuff then"
<elioat> 6502 processor are very low power, which is nice
<nihilazo> like, people with ham radios setting up comms for when the phone network goes down? That's legitimately practical and awesome
<f-a> nihilazo: me too, I suspect a slide ruler would be- yeah ham radio way more useful would be
<f-a> also simply some calculus books
<inode> but in a real post-collapse situation, can you realistically expect to do any computing/calculation besides the analogue sort using things like homebrew slide-rules?
<nihilazo> but society collapsing is going to be a slow burn of things starting to fail rather than straight back to mad max
<f-a> ↑
* nihilazo has never seen mad max and just hopes he got the reference correct via cultural osmosis
<nihilazo> I don't really see the collapse that preppers are planning for happening
<nihilazo> but I *do* see an imminent collapse of society in a less immediately drastic form
<elioat> yeah, so many preppers seem to like the idea of collapse since it puts them in a place of power
<elioat> I think when it does happen it'll be as you say, a slow burn where things just slowly fall apart
<nihilazo> like, I think what we need to be doing if we're actually prepping for a collapse is like, teach people how we can rebuild
<elioat> This podcast is about just that, http://www.liveliketheworldisdying.com
<nihilazo> if that makes sense. Like, build communities that can stick around with other stuff fails, and can provide for people's needs as we find our way around post-scarcity
<nihilazo> I'll check it out
<nihilazo> but hey, when we rebuild enough post-collapse to get power running again, I sure want to check out a weirdo forth OS on my 6502 machine :D
<nihilazo> I mean, I'd do the same pre-collapse, but either way
<elioat> right!
<elioat> I want it right now
<elioat> I'm watching this for sort of similar reasons, https://wiki.xxiivv.com/site/uxn.html
<elioat> sort of similar to freeputer if you are familiar with that
<nihilazo> uxn is cool, I've been kinda following devine on mastodon and they've been talking a lot about it there
<elioat> yeah, that is where I found it too!
<elioat> small world
<elioat> which makes sense for the forth irc channel, I suppose :P
<nihilazo> I'm gonna give live like the world is dying a listen
<nihilazo> I already listen to too many podcasts but one more can't hurt
<nihilazo> also yeah, I'm pretty sure a large amount of people who hang out in a forth IRC channel will know devine's work already, there seems to be a bit of a network between like, all kinds of miminal computing type things
<nihilazo> and forth is almost the ultimate in minimal computing things
<elioat> for sure
<kiedtl\0> I'm hard pressed to think of something more minimal :)
<kiedtl\0> Other than asm ofc
<veltas> Assembly is easier than forth sometimes, in my opinion
<veltas> People who wait for disaster are missing out 99 times out of 100, and not even that much better prepared when it happens
f-a has quit [Remote host closed the connection]
<veltas> I knew coronavirus was going to cause a lockdown while everyone including media was still saying it was 'just a cold', I bought a bit of long-life food before anyone else was 'panic buying'. Did this help? No, not at all, food wasn't even scarce.
<veltas> I didn't stock up on toilet roll, but I did take a last-minute holiday assuming it would be my last chance for a nice break in a while, that was good.
<nihilazo> yeah, the covid situation ended up a lot less dire for most people than some predicted it to be
<nihilazo> I mean, it's still really not great
<nihilazo> many, many preventable deaths. but still, it's not like
<nihilazo> the world didn't run out of food
<veltas> It's been dire for the economy, and it did still kill a bunch of people probably before their time. You're right though, it's no spanish flu, thank god
<bjorkintosh> veltas, install a bidet. they're cheap.
<veltas> I'm not installing a bidet in the house I'm renting :P
<bjorkintosh> you can take it with you. it's just an attachment.
<bjorkintosh> fits right on top of the seat or under it, and attaches to the existing plumbing.
f-a has joined #forth
<veltas> I don't have a problem with toilet roll and never ran out
<veltas> I don't imagine there will be another 'shortage' in my life
<veltas> But thanks for the suggestion
<bjorkintosh> it's really better. it's hygiene 2.0
<bjorkintosh> really cheap.
<bjorkintosh> :-)
<bjorkintosh> Life Changer, said a critic. Bad ass, unpunned another.
<nihilazo> I should get one
<veltas> By the way, the world doesn't need to "run out of food" before it becomes scarce in an area
<veltas> Supply chains aren't magic, they require society to be functioning at some level to work
<bjorkintosh> running out of access to it, is the trouble.
<veltas> Just because some people have the food you need doesn't mean you'll get it
<bjorkintosh> Just because some people have the money you need, doesn't mean you'll get it. FTFY :-)
<veltas> You can give people all the money in the world, if they can't buy food with it it's worthless
<bjorkintosh> buying is not the only option. there's hunter/gathering, and ... gardening.
<bjorkintosh> sure it takes a little bit of time, but it pays off.
<veltas> Yes let's tell millions of people to go hunter/gather in their suburbs :P
<bjorkintosh> Yes. Let's.
<f-a> sad
<f-a> tho I would like to tend a garden
<nihilazo> gardening is good
<veltas> You can tend a garden, but don't expect to get food out of it for a while, and you probably won't be able to live solely off of it.
<nihilazo> also elioat I just read that article and it mirrors my thoughts on a bunch of stuff, especially on how dumb individualism is in a time of crisis
<inode> doesn't hurt to find out about how to identify edible plants that grow in your area, if any, either
<nihilazo> veltas: but if many people start gardens, and we share food, we can live off what we each produce. And in a time of crisis, the skills we develop gardening can be put to use on a larger scale to rebuild farms etc
* nihilazo needs to go sleep
<veltas> That's not how it works lol
<veltas> If we all only tend gardens that are each too small for one household, then we will all starve.
<veltas> Case study WW2, Britain had smaller population and was dependent on merchant navy despite attempts to grow food absolutely everywhere and nationwide rationing
<veltas> And frankly I don't think our gov today would do a better job organising us
<f-a> we are prolly too much to tend our gardens
<f-a> but it does not hurt
<f-a> also to know the location of your fat neighbours
<veltas> I find it interesting how people say that like 90% of the useful functionality of computers today was possible on machines in the 90's, running 100 times slower with 100 times less memory etc etc
<veltas> And I think that's one of the reasons I'm interested in trying to get useful stuff running on the spectrum, because it seems like it could be capable of some useful stuff, although certainly not 90% of what people do.
<veltas> But it's a generally interesting question to me, what can you do with less, and forth is definitely involved in that question. A forth environment can be 1/100th of your average C compiler and have all the capability, but how much of the productivity?
<f-a> that is a super goal veltas
<f-a> and could be «academically» interesting too
<f-a> now then
<f-a> in jonesforth
<f-a> every dictionary entry has some flags added to the «length» character
<f-a> it seems very efficient
<f-a> but also maybe unneeded nowadays
<f-a> what do modern implementations like gforth do?
<f-a> I am browsing the code
<f-a> (the flags are «immediate» «hidden» )
<veltas> f-a: If nobody answers then ask on comp.lang.forth
<veltas> Anton Ertl I think is the maintainer of gforth and he reads/replies there regularly
<veltas> I will have a look at source code in case I can spot your answer, I'm not familiar but I do use gforth so it's not a waste of my time
<f-a> thanks veltas
<f-a> I will wait a bit and then fire in the group, forth simplicity really highlight different design choices
elioat has quit [Quit: elioat]
Zarutian_HTC has joined #forth
<f-a> https://mecrisp-stellaris-folkdoc.sourceforge.io/words.html apparently mecrisp uses the most straightforward path
<f-a> i.e. having flags not «mixed» with the number
<f-a> lots of flags tho
<patrickg> the flags are still necessary, and the spot there works as long as you don't intend to have words longer than 63 characters, so why change?
xek has quit [Ping timeout: 256 seconds]
<veltas> You could get away without the flags with a bit of creativity (like split word-lists into four lists for the 4 different flag states?)
<veltas> But why....
<veltas> I am reading gforth's source and struggling to find out dictionary format, it seems that some of it is built with GCC, and at least some parts like the threading model can be changed with build options (different threading model for gforth-fast maybe?)
<f-a> to boldly code as little I possible
<f-a> I wonder if .macro is turing complete
<veltas> I think you can save code using flags in the name size bits
<f-a> that is what jonesforth does
<f-a> (uses the unused bits of the «size» part (char?))
<veltas> And what's the point of saving code if not to save space?
<f-a> I will introduce you to my lazyness
inode has quit [Quit: ]
f-a has quit [Read error: Connection reset by peer]
f-a has joined #forth