Any wheels that need to be redesigned?

  • C++ Manual:

    • ISO/IEC 14882:2020 (Edition 6, 2020-12)
  • GCC 11.2.0:

    • C++17 (GNU++17, default)
    • C++20
    • C++23
  • LLVM 16.0.5:

    • C++17 (GNU++17, default)
    • C++20
    • C++23

You’re mixing the capabilities of separate but potentially intertwined projects. The YAB2C++ transpiler could be recoded as a 2-pass translator to XML, the XML transpiler/exporter could target D or C++ (separate transpilers), the GUI based editor and all the necessary locales for that (plus a few extras).

The extra locales mentioned above can replace technical jargon with more descriptive terminology. A loop repeats code so the simplified version could call it a repeater instead, for example. The goal is to lower the barrier to entering the art of programming.

I remember only an XML wrapper for Java. Were they open source? I can check my bookmarks too.

edit:

Was it http://www.o-xml.org/ by chance?

Please reply on the “XML Code format” thread

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.