Any wheels that need to be redesigned?

Looks like your sidenote pretty much describes the situation in my school days. I remember our modula 2 compiler had many faults for instance which for me meant I only used it minimally. Also I remember a VAX PDP 11 mainframe with discrete CPU’s in it that was never able to fully boot anymore. But I loved how they were able to build a computer that way with all these low integrated circuits, transistors and magnetic core memory…

We also did Motorola assembly along with a very detailed description in lessons of how that CPU was designed. After a year when I finally grasped the thing it became my first love… (6802, later on 6809 and a bit 68000)

Sorry for the sidenote extension in the thread… :wink:

2 Likes

Wrap Up

In order to break this up into separate threads for their respective parts, I think this thread should be spun down. After I’ve started the other threads, I’ll reserve this thread for other rants related to the original topic.

Thanks to all of you for civilized discourse!

You can use various strategies to limit or disable GC. Life in the Fast Lane | The D Blog

Or you can use the Better C dialect, (which is actually object oriented etc even though the name suggests otherwise). Better C - D Programming Language

2 Likes

XSLT<->XML. Lots of BASIC->C transpiler source code is avail so a YAB2C or YAB2C++ transpiler component seems possible in a short time…

1 Like

Replied in other thread.

Getting back to some C and C++ bashing, a discussion was brought up by some language lawyers about always using structured code constructs instead of non-structured state machines. This brings up a problem when translating non-structured or semi-structured languages like BASIC.

In the following example, scope rules prevent C from creating equivalent syntax:

PROC Z(X,Y)
   IF X=Y
      LET N=1
      LET Y=0
   ELSE
      LET N=2
      LET X=X+1
   ENDIF
   PRINT N,X,Y
ENDPROC

The equivalent C code would normally be:

void z(int x,int y) {
   if (x==y) {
      int n;
      n=1;
      y=0;
   } else {
      int n;
      n=2;
      ++x;
   }
   printf("%d/t%d/t%d/n",n,x,y);
}

This example is a little contrived but in C, the variable n goes out of scope in both the if and the else so it won’t even compile. When translating from BASIC to C, those curly brace scoping rules become a major pain! There are 2 ways to solve it but both are ugly.

One is to define preprocessor macro magic in a header file written concurrently to the C file so any variable declaration is moved to just inside the curly brace after the function definition.

The other is to reinvent the structured programming commands themselves using a non-structured state machine. I’ve explained this position in my YAB2C++ thread. This didn’t appease the language lawyers.

I had to get this off my chest or I wouldn’t sleep tonight. I just had reread the linked thread. Good-night all!

If you only problem is variable declarations, you can just move them all to the start of the function? But I expect there will be other similar problems if you do transpiling at a “surface” level like this. What you need to do is parse the languague into an abstract syntax tree and then apply transforms to that until you get something that can be generated in your output language.
Just like a compiler is converting C (or C++ or anything else) to assembler, for example. The input and output languages have little in common

4 Likes

There are non-structured commands and so on that need to use labels as the start of subroutines also. That’s why I abused the switch statement in a loop with loads of fallthrough conditions instead of using structured commands in C.

Why not

z (x, y)
int x, y;
{
  int n;

  if (x == y)
    n = 1, y = 0;
  else
    n = 2, ++x;

  foo (n, x, y);
}

?

Because n isn’t declared in the source language until after the if statement has been initiated. It would require the declaration of z() to be written to a preprocessor artifact and then expanded in the last code generation. BASIC doesn’t require declaration of variables in advance like C does. Without looking, I suspect Yab doesn’t support a DIM statement for local variables but even if it did, the source is not required to use it.

You can solve this with a data flow analysis, def use chain for example, then move the def to the common ancestor of all uses. As @PulkoMandy says, you need to get the AST and perform some analysis.

That would only solve one of 2 problems. The non-structured branching instructions wouldn’t benefit much from perfect syntax equivalence. It would only make things more complex in the end. I’ll have to show a better, if still contrived, example.

Yes another example would be good as I don’t follow. I’d have thought this can be solved with, in the worst case, dominator tree/AST/SSA and some simple enough transforms to check for invalid use-defs and correct them.

Thanks for bearing with me but the more I think about it, it is unlikely that I will finish my transpiler for Yab anyway. There are just too many differences between BASIC and C. I grew up using BASIC but now it is nearly a dead language.

Sad news. Why don’t you try to finish it. I even would use Basic for simple applications if I wanted.
e.g. for Game Launcher or for editing game design data or similar for our games in development.

1 Like

I dont know. I have been teaching my son (age 8) programming using qbasic (the modern qb64 variant). It is much more accessible than things like C and much less going on in terms of complex toolchains and lots of moving parts than scripting and web languages (which anyway I tend to stay away from, especially web). I learned to program with basic too (on an amstrad CPC).

3 Likes

Continuing the discussion from Any wheels that need to be redesigned?:

BASIC is not as popular as it was prior to Y2016 - but not nearly dead yet.

We can always address YAB pros/cons versus current C++ application development on Haiku.

Your project may suite a higher purpose.

1 Like

There is at least one project that is a higher priority than this one. Once I get that done, I may revisit my previous projects.

For thousands of years, a loaf of bread has always costed a few ears of corn. Bitcorn :corn::corn::corn: will lead the way.

I suspect the next generation will experience a renaissance in local trading and bartering in much the same way that the printing press quickened the already-in-progress Renaissance of the Middle ages. At some point in their lifetime one Bitcoin will be more than a single person will earn in their entire lifetime. Or could go to zero. Either way, I’m on.

Re:agriculture

Thanks, but I can’t afford a 48 row planter, a 400+ horsepower quad-track articulating tractor or a harvester with a 48 row header. The fine folks that rent the fields on the farm where I live lease a lot of their equipment. Once obsolescence factors in they can’t afford to keep it either.

Re:currency

Once the government starts cracking down on petroleum fuels, it’ll be back to the horse and buggy days around here. :horse_racing: Maybe we can plant seed by hand in small gardens when that happens. :seedling: Also, once the government starts cracking down on decentralized currencies insisting we use digital dollars, bartering will likely be the only option left. I’m not looking forward to days where a loaf of bread costs a day’s wage. :bread:

Re:cost of entry for software development vs. agriculture

Suffice it to say the cost of entry is much lower for software engineering than for agriculture. I intend to keep it that way. No VR goggles needed. No 600 watt PSU required. GPU can be hardware but depends on driver infrastructure. Cost of entry stays minimal that way. Otherwise multiple millions of investment dollars just to make labor an achievable goal remains a financial nightmare.

3 Likes