(04-09-2024, 06:27 PM)Tim Wrote: How is QB64 written? What coding language is used? And is it always the same one?
(04-09-2024, 06:33 PM)SpriggsySpriggs Wrote: The backend is written in C++ but the majority of the IDE is written in QB64 itself. Galleon basically used C++ until he could create something that could write itself.This is extremely common in programming language development. This solves the "chicken and egg" problem. (How do you get the "chicken" - i.e. the compiler - to produce the "eggs" - i.e. the executable programs, when you don't have the chicken in the first place?) When you don't have a compiler to compile the language, there are four possible solutions:
- On a different source environment (different processor and/or operating system) that does have a compiler for that language, you write the compiler to be able to compile itself, then once it works, you transfer the executable it creates to the target computer environment. All further improvements to the compiler can now be written using that compiler. (This is how the first compiler for a brand-new language has to be written.)
- On the same or a different environment, you use some other language to write the compiler. It really does not have to be complicated, it just has to have enough features to be able to compile a compiler written in the desired language, that can also compile itself. In effect, the compiler has to be written twice, once in the other language, and then itself. Given this to be the case, the first compiler written in the other language is really only intended to be used once, to compile the compiler that can compile itself. That program can be thrown away, as, in the previous example, further improvements to the new compiler can now be written using that compiler. (This was the method Nicklaus Worth used to create the first Pascal compiler, by writing it in Fortran.)
- The starting compiler in the second example is the compiler, it is not rewritten in the desired language. (This is how the Gnu Pascal Compiler operates. It is a program written in C/C++ which "compiles" Pascal code into C.)
- Some combination of the above. (QB64/QB64pe use this method.)
Before there were other programming languages, compilers were written using assembly language, using the 3rd method above. Then C and other languages were developed, and now people almost always use a high-level language to write a compiler.
(04-09-2024, 06:40 PM)Tim Wrote: So, any and all new features are written in QB64, then?
(04-09-2024, 08:12 PM)SpriggsySpriggs Wrote: Well, no. Not everything. It depends on what the feature is and how it would be best implemented.It also depends on the language. Some languages are capable of creating the entire executable. Others, like QB64/QB64pe are what are called "transpilers." A transpiler takes code in one language, and translates it into another language. The GNU Pascal compiler is also a transpiler. It does provide one advantage over a straight compiler: if the target language is sufficient to express every feature of the language, it becomes machine and/or operating system independent. This is why QB64(pe) can be used on Windows, Linux, and Mac.
(04-09-2024, 10:47 PM)SMcNeill Wrote: libqb.cpp and all the rest of QB64 contains the c-code which holds the libraries, routines, and such that actually compiles. They're located inside the internal/c folder, and the gcc compiler can be found one subfolder deeper than them, in the internal/c/compiler folder.Actually, it's not just the C/C++ compiler, it's the entire Gnu toolchain (which parts of it the C compiler needs anyway.) It includes:
- The C/C++ compiler
- The Gnu assembler
- The Gnu linker
- The Gnu archiver
- The Gnu Fortran compiler
- Several tools related to object management and debugging
- The MinGW environment, which is duplicating many utilities already in with the C compiler.
While 1
Fix Bugs
report all bugs fixed
receive bug report
end while
Fix Bugs
report all bugs fixed
receive bug report
end while