Close

Upcoming refactoring

A project log for Terminal-BASIC

Language interpreter for uC-based systems

Andrey SkvortsovAndrey Skvortsov 01/02/2019 at 22:323 Comments

Some OpenSource/DIY software projects, containing legacy C code have been rewritten into C++. There is no any reasons to stay on C if C++ available on target platform. It has everything that C has and many "free" features, which cost 0 extra bytes and 0 extra instructions.

But I think Terminal-BASIC must  go through a reverse transformation. I'm rewriting core components in pure C.

The 8-bit AVR microcontrollers were primary target at the project starting point. G++ supports this architecture, as well as 32-bit ARM versions of Arduino DUE, etc.

But many interesting architextures do not support C++.  I think about running Terminal-BASIC on Z80 with SDCC, PIC uCs and... SEGA Genesis consoles (MC68000 has G++ port, but  the popular SDK SGEN does not support C++).

Discussions

Ken Yap wrote 01/03/2019 at 00:11 point

>It has everything that C has and many "free" features, which cost 0 extra bytes and 0 extra instructions.

Not quite. Some features of C++, such as constructors and destructors, in particular for static objects, require extra runtime code to support. But if you were to do something equivalent in C, it might come out to be the same. It might not matter, since modern processors have a lot of code space. The older ones are more constrained.

  Are you sure? yes | no

Andrey Skvortsov wrote 01/15/2019 at 08:37 point

You are right, but I mean a truly free language elements: namespaces, functions and operators overloading, strict type conversions, templates and deduced types.

These can't make the code more compact or fast, but make it more robust, readable and cross-platform.

  Are you sure? yes | no

Ken Yap wrote 01/15/2019 at 08:44 point

Sure, after all the first C++ compiler targetted C code. I feel old.

  Are you sure? yes | no