On Thursday, August 17, 2023 at 3:42:59 PM UTC-7, Hans Bezemer wrote:
First, read "Starting Forth".
Don't read: "Starting Forth."
That book has turned a significant number of readers away from Forth.
Those who have stuck with Forth after reading this book have become
lifelong incompetents at Forth programming. The book doesn't make any
mention of structs, most likely because nobody at Forth Inc. knows what
a struct is. The book fails completely at showing the reader how to
implement general-purpose data-structures, which is the primary reason
why the "Starting Forth" enthusiasts are lifelong incompetents.
Don't pay attention to self-proclaimed Forth experts on the internet.
There are a lot more teachers of Forth than students of Forth, and the
teachers typically are the lifelong incompetents described above.
I can tell you my own experience with learning Forth (HES-Forth on the Vic-20). I wrote a program to generate the key patterns for a KwikSet master-key system. The program was full of bugs and didn't work. I became frustrated and considered
abandoning Forth and writing the program in line-number BASIC that I was familiar
with (of course, I was also familiar with the many design flaws of line-number BASIC,
especially the lack of local data, so I knew that there was no future in this path).
Then I remembered that the Forth programmers I knew had all said that interactive
debugging is the key to getting Forth programs to work, so I rewrote the program.
Instead of one gigantic function, I did bottom-up programming starting with short simple functions that I tested at the keyboard (the outer-interpreter). When
I got those functions to work I wrote higher-level functions that were also short and simple and I tested them until I got them working. Using bottom-up programming I got the whole program working in about two hours. This is the program that I had spent days trying to debug when it was one gigantic function.
I was impressed! Factoring code into small functions and using interactive testing
to get those functions working is strong magic! This really works!
I generally start with the difficult part of the program and get that working, then
move outward to the less difficult parts that are also less interesting. Generally
the difficult part of the program is where the design work needs to be done.
If you get that working, then you also have the design done --- the rest is gravy.
So, a good beginner project would be a KwikSet master-key system generator.
If I could do this at age 18 with only line-number BASIC background, you should be able to do it too. Use a prng so you don't get the same system every time. Be aware that you can't have excessively thin pins because they will fall over sideways inside of the cylinder and get jammed.
You also can't have an excessively jagged key cut-pattern because the key won't
go into the lock.
You don't want to have an excessively flat key cut-pattern either though, because that is too easy to pick open.
In my program I generated all possible key cut-patterns and then had a function that went through that lengthy list and excised everything that failed for one of
the above reasons (pins too thin, key too jagged or key too flat). This is easy!
Note that most locksmiths don't know enough programming in any language
to do this. They do it by hand. This is why every customer gets the same
master key, which is obviously insecure. lol Also, they don't make some master-key
cylinders high and some low. They simplify by making all of them low or all
of them high. This is why the master-key cut-pattern is almost flat, which makes
it easy to pick open. They aren't doing any thinking about the problem and how to
provide a secure solution --- they have never done any thinking --- they just learn
a crude technique when they are apprentices and then stick with that for decades.
It is really sad that common people don't know how to program computers, given that computers have been commonly available since the early 1980s.
Some locksmiths do use a computer --- they pay big money for a professionally done master-key generator with a snazzy GUI interface --- there is no guarantee
that the programmer who wrote this knew anything about the subject
(he was likely taught by some idiot locksmith with decades of experience
doing this by hand and doing it badly as described above). Computers haven't really worked out well for society --- in the 1980s there was a lot of expectation
that computers would be hugely helpful --- computers aren't helpful though.
The problem is too many smart phones and not enough smart people.
Nobody ever does any thinking!
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)