Can You Program Arduino in BASIC?

Compiles into a smaller program than the Arduino SDK.

Is there any benefit of programming in BASIC over using the Arduino IDE?

Depends on your programming skills and what you are trying to accomplish with your program.

The main reason Basic isn’t used in anything but introduction of languages, is mainly because it’s unstructured. It also creates a variable, so a typo could be a valid variable… of course the code isn’t going to execute properly.

He also mentions 32 compared to the 692 for the 328p. The number 32 is for words, the Arduino is bytes. Even still, there’s lots of other code, if you do any kind of i/o, that’s likely loaded.

If you run a stand alone piece of software you don’t need a lot of actual code and the Arduino carries a lot of overhead or code you may use, but may not need if it’s never called.


Since it goes from source code → compiler → assembler → linker → executable, there are lots of hidden steps the user never sees. It is wise to look at the assembler output to see what’s really compiling and loading. I know of no compilers that uses anything more than a software switch (semaphore) on the command line to tell some part not to delete the generated assembler file or any other files it has created.

I’ve built a number of stand alone Atmega controllers, and the byte count is relatively low as there is no i/o or floating point math used. I also have no need for a boot loader using one of Atmels programmers. Left Dragon is configured for an 8 pin package (Tiny85) and the right a full size 328p via it’s 8bit parallel loading.

If you want to learn how a computer works, then it might be smart to see what you can use for a debugger. You can get as intimate as you want with a good debugger, if you learn how to drive it.

Once you figure one or two of them out, it’s not really an issue switching between them although it’s better if you can use the same debugger. Learning languages become not so much of an issue as they all work the same, just in a different notation.

Hope this makes sense?

:grinning_cat:

You get replies such as BASIC is unstructured, one can be unstructured in most languages.

Your big problem is that BASIC is an interpreted language. This means that you need an interpreter to convert your tokens into action. This swells your code, especially if you want a GUI to rather than just a runtime module.

Additionally some people hate that it supports goto. (like many opcodes with jumps).

I would suggest IMHO that you try using the IDE. The learning curve is quite shallow…

I believe in the video, he advises it’s this compiles it, not interpret the source.


Taught a number of languages while teaching at a community college for over a dozen years. I know of no language, in popular use, that does not require you to define your variables before use. Even C won’t allow that, talk about an language that gives you enough rope to hang yourself. If you do, please enlighten me.

It might be nice to whip out a few lines of code for testing, but I’d have to go back and learn something that’s never really been useful except to learn computer basics, which was it’s original intention. Even generating a few lines of code for testing, then throwing it away to program in another language.

However, having worked in a shop that the in house written software was over 200,000 lines, basic is to be avoided.

This is likely why it’s usually avoided in the industry.

IMHO…

:grinning_cat:

Two of the most common languages in use today are concrete examples:

JavaScript and Python.

Both languages have options for declaring types; in the JavaScript ecosystem you can mix in TypeScript modules, and Python has optional type declarations that are a relatively recent innovation in the language. But those variations cover only the minority of use in each.

It’s not just interpreted languages, either. For example, in Go, you only need to declare variable types if the type can’t be inferred. In normal use, you foo := bar() and foo will be strongly typed to match the type that bar() returns. It won’t let you silently shadow it on the next line. If you foo := baz() later in the same scope, it won’t let you. To be clear := means “create and assign” and = means “assign to already created” — there’s no confusion that causes typos to spring into existence. And it’s not possible to declare a variable without a particular value; all variables are assigned their type’s “zero value” by default, unless another value is provided.

So, actually, it’s not usually avoided in the industry. Some of the most common languages in use do not require a separate definition from site of use. Instead, even in modern strongly-typed languages, separating definition from declaration is seen as a mild anti-pattern with respect to the “DRY” (Don’t Repeat Yourself) best practice. The value isn’t separating definition from declaration, but in providing strong typing and being clear somehow or another when you intend to create a new variable vs. accidentally creating one with a typo.

Yeah, we’ve had compiled BASIC for decades, but also to the point of your complaint, apparently many modern BASIC implementations have strong typing as well. No idea about this dialect in particular since I haven’t watched the video…

I am with you on disliking BASIC syntax in general, but today’s BASIC is not necessarily your Grandpa’s Oldsmobile BASIC. :rofl:

Probably true, I remember peak and poke from some of the early implementation. Maybe I’m getting too old for today’s standards.

I can understand this, all memory has a value. Even if junk from some other part of the software or dynamically allocated. Some languages specify this, other don’t specify too deeply how it’s implemented within a certain piece of hardware/os.

I’ve had a Raspberry PI around, it’s a Python Interpreter.

I understand that python and java script are used quite a bit.. I had a couple of failures when I ran the Eclipse IDE. Not that a compiled language would have been better, but most of the languages I use have some way to hook error, that are fatal, such as divide by zero. I’m sure these must have that ability or it could be used as a tool for security work.


Once you learn a few languages, all you need to know is the structure syntax of the what you want. My first language, in the real world was B.

As I stated earlier, you’re probably right and I should just keep quiet…

:grinning_cat:

Exactly. In C you can use calloc() to allocate a chunk of heap memory initialized with zero bytes instead of malloc() which is not defined to initialize to zero; there is no standard version of alloca() to allocate and zero memory on the stack. Go designers chose not to make zeroing the memory optional. So in declaring a variable of a type, you are implicitly assigning it its zero value, regardless of whether it’s a heap or stack allocation. I think it was a really smart choice. It has made Go a safer, more secure language.

Yeah, both JavaScript and Python have exception handling. Divide by zero and many other errors abort the entire thread of execution, unless explicitly caught and handled. Working with exception handling is a normal part of development in both languages.