Learning to code using the WIN32 the easy way, using BASIC
One of the challenges which I have felt made the WIN32 API dfficult to learn is that it leaned heavily on C and as a long time BASIC programmer, I always felt the C language syntax was terse in nature and that it lacked the natural syntax of languages like BASIC. Just look at C and other languages like it and the use of the curly brackets. Why does a programming language need curly brackets to indicate blocks of code ? It doesn’t. Likely the curly bracket was helpful to the compiler to make things easy on the compiler rather than the programmer. Today’s programmers may not appreciate this, but old time programmers like myself who date back to the days of early computers may. In the old days, computers were very slow and it took a very long time just to compile a decent sized program. Programmers joked about taking a coffee break while their code compiled. Likely many a programming language syntax had more to do with making it easier and faster for the compiler rather than make life easier for the programmer. Amazingly BASIC as a language stuck to the old credo of “keep it simple” and advances in computer technology have benefited BASIC.
BASIC, your fathers BASIC and more.
There are two types of BASIC. One group which follows the object oriented path, such as classic Visual Basic and the other which follows the procedural path like old time C does. OOP hides the roots of Windows behind classes and objects, while languages like C (not C++) bring programmers closer to how Windows really works. If you want to write the smallest and best performing application for Windows, you use pure C. But what if BASIC could do what C does ? Actually it can. The beauty of BASIC over the years has been that it wasn’t afraid to borrow the best from other languages. BASIC quickly borrowed from Pascal with true subroutines and functions. Some versions of BASIC have borrowed heavily from C with low level functionality like code and data pointers, etc. BASIC at times has even borrowed from Assemblers by adding inline assembly code support. Now imagine what a WIN32 programmer can do with BASIC. With all the fuss about IOT (Internet of Things) and x86 based mobile devices (aka. small tablets) today, being able to write those amazingly fast and tiny applications using a fast BASIC compiler makes a lot of sense.
Where does one start ?
Are you interested in learning how to code using the WIN32 API, but using BASIC rather than C ? Well, first off you need to start with a decent native code BASIC compiler for Windows. There are a few I will mention, but one stands out in my opinion (which I will get to later).
- FreeBasic
The first to mention is FreeBasic (for more info see website) . FreeBasic is a powerful compiler which supports what you need to work with the WIN32 API, including pointers and inline assembler. The best thing about it is that it is free.
- PureBasic
Next is PureBasic. Purebasic is cross platform and even supports 3D via an open source 3D engine integrated into it. PureBasic is well supported and is well suited to building WIN32 applications. ( for more info see website ).
- Oxygen
This is an unusual compiler in that it can be embeded into other applications to add compiling capabilities to your application. While the feature list is limited, it can be used to create applications which generate executables. It is often used in combination with a great BASIC interpreter called ThinBasic. (for more info about Oxygen see website ).
- PowerBasic
PowerBasic is unique among BASIC compilers for a number of reasons. First it has the longest history of any Windows BASIC compiler. PowerBasic dates back to Borland International’s famous TurboBasic and back in the day it was the only other BASIC compiler which came close to competing with Microsoft QuickBasic. Because of its long history it has one of the best syntaxes for a BASIC because it has maintained much of BASIC’s original flavor (started by Microsoft QuickBasic), while borrowing from other languages but with the original BASIC mindset. Second, unlike many of the current generation BASICs still available, it is not simply a code generator using another language as a backend, but it is a true 100% compiler generating directly to machine code. The compiler itself was written in assembler so it compiles at lightning fast speed, even on old hardware (don’t need the lastest and best PC just to get decent compiled speeds). It was designed specifically for Windows and Windows only and does not have to deal with all the cross platform issues. It was also designed specifically for coding using the WIN32 API. While it is a commercial compiler, the company has just recently turned their previous version compiler into a freeware product, which means like Freebasic and Oxygen it can be gotten for free. The 9.0 compiler version is extremely powerful. I could do most anything I wanted with the WIN32 API with as old as their 6.0 version, so the 9.0 free version is plenty for any budding WIN32 programmer. (see website for more info ) (to get free version of PowerBasic go here )
Yes, the BASIC compiler offerings for budding WIN32 programmers is currently quite rich. In future articles I may try to highlight some of the other lesser known BASIC’s. Also in future articles I will hopefully discuss how to code for the WIN32 using BASIC. Here are a few Codeproject articles to help you get started:
Getting started with the PowerBasic compiler -Part 1
Getting started with the PowerBasic compiler -Part 2