On Friday, November 25, 2022 at 12:15:03 AM UTC+1, Zbig wrote:
> Besides: business prefers languages like C, that allows easier replacement
> of programmers, in case of need.
I know! I got a funny story on that one. I once worked for a joint that got spreadsheet
dumps from a multitude of branches every month. Sure, all of them sent slightly different
formats - and even the data (dates) inside were differently formatted. They had to be
merged, exceptions were to be logged, duplicate records had to be weeded out,
depending on their status, other data had to be spliced in and new identifiers needed
to be assigned on new items.
It took a guy a full day to merge them by hand - and the result was still abysmal. So I
told 'em I could write a program for all that in 5 workdays. They said it couldn't be done.
I bet them I could.
So I did. in 4tH. It did the entire job within 30 secs - without missing a beat. Full log and
a load of self-diagnostics to prove the integrity of the run. Made a nice Windows CLI
standalone executable for 'em - and wrote a nice user manual. Job done.
How did you do that, they asked. I used Forth, I answered. Why Fortran, they asked.
It's not Fortran - it's Forth, I responded. Let's see the source, they asked. So I gave 'em
the 64K source and all libs. That's gibberish, they said. No, it's Forth, I answered. But
we want C or C++, they said. That can be done, I answered.
4tH is capable of dumping the entire 4tH bytecode in C source format. Link it with the
lib and you can compile the whole darn thing with almost any C compiler. E.g. this is
"Hello world" (appended after this post).
So the local C guru took one look at it and said "What am I supposed to do with this"?
Write a functional design, they said. That'll take me a week, I said. So we'll see you
back in a week, they answered.
A week later I brought in my design - and they sent it of to some developer, asking for
an estimate. "About three months", he said.
Long story short - it ran until they rolled out a unified system and used it for one last
time to do the initial load. Never missed a beat. It was retired with full honors.
Hans Bezemer
/*
** This file was generated by 4tH
** Copyright 1997,2017 by J.L. Bezemer
*/
#ifdef USRLIB4TH
#include <4th.h>
#else
#include "4th.h"
#endif
#include <stdlib.h>
static dict CodeSegment [] = {
{'\x05', 0L}, {'\x02', 0L}
};
static char StringSegment [] = {
'\x48', '\x65', '\x6c', '\x6c', '\x6f', '\x20', '\x77', '\x6f', '\x72',
'\x6c', '\x64', '\x21', '\x00'
};
static Hcode Object = {
2, CodeSegment, 13U, StringSegment, NULL, NULL, NULL, 0, 0U, 0U, 0, 0, 0, TRUE
};
#ifndef ARCHAIC
int main (int argc, char **argv)
#else
int main (argc, argv) int argc; char **argv;
#endif
{
cell Result; /* holds the result of the program */
fflush (stderr); /* flush any messages */
/* now execute it */
Result = exec_4th (&Object, argc, argv, 0);
fflush (stdout);
if (Object.ErrNo) /* show exit messages */
fprintf (stderr, "Exiting; word %u: %s\n", Object.ErrLine,
errs_4th [Object.ErrNo]);
else
if (Result != CELL_MIN)
fprintf (stderr, "Exiting; result: %ld\n", Result);
return (Object.ErrNo ? EXIT_FAILURE : EXIT_SUCCESS);
}