Dartmouth basic compared with arduino

here is a program using a gosub statement. compare with Arduino.

  1. no declarations.
  2. no return type.
  3. no void loop, void setup
1.LET A=5
2.GOSUB 5
3. LET Y=X+0 
4.
5. X=(2*A)
6. RETURN

don't remember what the multiply sign was. Isn't this much simpler than Arduino.

..so, run BASIC on your Arduino

  1. Subroutines don't have descriptive names
  2. Subroutines can't return values
  3. You can't add lines in the code without breaking it
  4. All variables are global
  5. Libraries are not supported

So, simpler, but less useful than Arduino, but feel free to use BASIC if you want to

4 Likes

Depends on what you're trying to do. I'd soy for most applications that have multiple time-sharing tasks, that basic would make things much more difficult.

1 Like

Only as long as you don't need more than 10 or 20 lines ...

Try to debug a programm of this kind that is some 100 lines long ( or more ). :roll_eyes:

1 Like

I am surprised that @petercl14 is not advocating the use of goto to make sketches simpler

2 Likes

Yes, for a 6 line program.

But for a 60 line program? I doubt it.

For a 600 line program? No way!

1 Like

Well BASIC was designed to be simpler than FORTRAN. And the B in BASIC stands for "Beginners". However, as others have noted, BASIC does not scale well, and the idea was that once you have learned the basics, you take off the training wheels and use a proper grown up language like... FORTRAN IV.

More modern variants like "BBC BASIC" are probably better for larger projects.

The simplicity of BASIC partly explains a whole bunch of "retro" projects building on 6502 or Z80 computers of the past, there is even one which is kinda like an Arduino, https://www.olimex.com/Products/Retro-Computers/AgonLight2/open-source-hardware.

BTW, your BASIC sketch had a few errors: try

10 LET A=5
20 GOSUB 50 
25 PRINT A; " "; X
30 LET A=A+1 
40 GOTO 20
50 LET X=2*A
60 RETURN

Try it here http://www.quitebasic.com/

Can you use BASIC with Arduino? Not that I would recommend it, just curious.

The first MCU I programmed since taking up the hobby was a PICAXE which is essentially a PIC family MCU that you problem with BASIC. The BASIC code gets semi-compiled into a series of byte-codes which then get uploaded to the MCU and interpreted by the PICAXE firmware already on the chip.

The performance was absolutely lousy. For many projects, that doesn't matter very much. But for anything that needs to run reasonably quickly like multiplexing a display or scanning a keypad, it was noticeably slow, even though the PIC was running at 64MHz versus an Arduino running at 16MHz.

The PICAXE BASIC was very basic indeed, if you are familiar with BBC BASIC or Windows Visual BASIC For Applications (VBA). No named functions/procedures etc.

Maybe

1 Like

There are a few BASIC interpreters. I worked on one myself. Generally, you just need a tokenizer, like the infix to postfix tokenizer standard project, that also checks syntax. In addition, an evaluation stack and the simplest of heaps. A skilled programmer could write one in a few days.

The coolest part of BASIC on Harvard Architecture is that it allows for truly self-modifying code.

The drawback is that you are programming in BASIC.

2 Likes

Yes but what is your point?
Are you saying that Arduino is too hard to learn?

It sure is! It's like a bicycle with one fixed gear.

But as someone saddled with line number Basic for almost my first year of coding almost every day I can tell you that it is limiting as to what one can cleanly express. Even beginners can outgrow it.

Don't get me wrong though, I think that learning different programming languages opens a coder up quite well.

The place I worked got me compiled Basic about the same time as I took a free course in Tutor at the local Uni where I used that to write chemistry lessons for the chem dept TA's. I learned some interesting things in Tutor that helped me advance my User IO routines at my regular job, I improved the company business code a whole lot, saved the office workers a lot of time with it.

If you have time for Basic, try Forth! At Forth dot com you can get a free Forth and a PDF of Starting Forth, a book/course in what is a small and compact language. I had it on a game cartridge for my VIC-20 and bought that book in my 3rd year of coding, it changed how I coded no matter what language since, it set me free!

don't languages like Basic, Python, Pascal, Java require an Interpreter running on the processor to execute the program commands

while C is compiled into processor op-codes (assembler codes) loaded into Flash/Ram executed directly by the processor

Pascal is a compiled language. Some later BASICS could be compiled.

1 Like

Based on petercl14's topics, yes.

1 Like

We need a new badge Neanderthal

1 Like

although the Java Compiler) Javac compiles into bytecode the JIT converts the bytecode into machine code at runtime
has an advantage that the bytecode files (.class) can be ported between computers with different architectures and executed, e.g. I often port code between Windows PCs and Raspberry Pi 4 micros

You, alone, are the cause of your issues with programming. Every topic of yours goes on about nothing working, and the dozens of replies showing you where you are wrong are ignored.

Read a book and practice. You will eventually see how wrong you have been.

Take a look into this tutorial:

learn to program Course

It has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.