Experience (so far) with Purebasic


I am a hobbyist. I do not make money from my programs, though I have tried,
and failed, in the past. :slight_smile:

I have had a Purebasic license for a few years but only in the last 4 months
or so have I really dived into it so I am by no means an expert and so some
of these observations may be totally wrong and I welcome anyone who knows
better to point them out.

And, as usual, your mileage may vary with Purebasic.


Supports OSX, Windows and Linux. It does not cross compile, you have to
compile for a platform on that platform. You can directly access a
platform’s API. For example, on OSX, you can use the CocoaMessage command
to access Cocoa methods and objects. Note: it does not work for everything
in Cocoa.

There is a web based version, called SpiderBasic, but it has not been
updated in quite some time so I do not know if its still supported.

A new version, 6.0 is currently in beta that has better support for the
M1 processor.

The Language

Purebasic (PB) is not object oriented though it does have modules which allow you
to sort of emulate it. It does support pointers, structures, dictionaries, linked lists
and arrays.

Syntax is a bit weird… to access fields in a structure you would use
StructureVariableName()\fieldname. Variable types are declared using Define
and then appending the type to it… e.g. “Define.s var” to declare a
string. If you do not specify a datatype it defaults to integer unless you
have a “$” at the end of variable name, which makes it a string.

Variables do not have to be explicitly defined unless you specify
“EnableExplicit” at the top of your program, which I highly recommend.

There is direct support of linked lists. You use NewList to automatically
create a list of structures and then there are commands for navigating,
adding and deleting items. Dictionaries (maps in PB) have a similar setup.

GUI Support

PB supports a number of standard controls (gadgets in PB). Strangely,
dialog windows have to be created using XML to describe them. Its the only
way proper way (as I far as I can tell) to create modal windows though you
can simulate it through other ways.

As far as I know, PB does use native controls whenever possible. That being
said, it will take a considerable amount of effort to create a modern
looking GUI. The controls are basic and don’t offer a lot of extended
functionality without having to dive into your platform’s API.

It also has a canvas gadget, similar to Xojo, which allows you to create new
GUI elements.

The GUI builder is adequate, at best. It works and does the job but that’s
about all you can say about it.

PB also includes support for the Scintilla text editing control.

Database Support

PB supports SQLite, Postgres, MySQL and ODBC. They are all supported
through the same set of commands. However, each result set must have its
own database connection. Something to keep in mind if you are accessing a
database with limited licenses/connections.

I have not done a lot with databases yet.


The IDE is simple and fast. It loads so much quicker than Xojo. The GUI
builder, as said before, is adequate.

Integrated debugger is quite good and it includes a command line one as well.

Project Types

You can build command line tools, GUI apps, DLLs and dynamic libraries.

Final program size is extremely small. A simple hello world program in Xojo
can be around 15mb whereas in PB it is less than 5mb! Command line programs
are even smaller.

Comparison to Xojo

PB is much faster, includes support for database and command line programs
and costs only $99 and that’s a one time fee. You get all updates for life.

The IDE starts in seconds, not minutes like Xojo and its compiler is
blazingly fast. The current version compiles to ASM code but the new 6.0
version in beta uses a C backend to support more platforms. I have not noticed any
significant different in performance with the C backend.

However, its GUI support is not nearly as good as Xojo and based on the
amount of activity on its forum, the user base is either just not that
active or is smaller. A lot of the add-on libraries (modules in PB) and 3rd
party tools are quite old and not updated so that tells me maybe PB’s usage is

I would say Xojo is capable of building far more sophisticated programs
mainly because of better 3rd party and platform API support. There is nothing
like the MBS or Einhugur plugins available, but it depends on what exactly you
want to do with it.


PB is a lean, mean, programming language. Executables are extremely small
and fast. The IDE and GUI builder is written in PB so you know the language
is quite capable.

PB is owned by a small company, even smaller than Xojo, I think there are
only 1 or 2 developers working on it. But they also are not trying to bite
off more than they can chew and keep their focus pretty tight. Bugs are
fixed quickly and the forum has areas for reporting them.

You are not going to create sophisticated GUI programs but PB is great for
small to medium projects that don’t demand big GUIs. Its also excellent for
command line based projects.


Cool - thanks for the write up
Sounds like it has its own niche

1 Like

Definitely a niche product, but so far it fills my niche. :slight_smile:

I enjoyed your write up :nerd_face: I’ve been playing with PureBasic (PB) myself off and on for about a year. It would appear that in the right hands, PB, can be very powerful, especially if one has a strong background in C. I’ve replicated some simple C code in PureBasic like this Struct test but I’m by no means an expert C programmer. :nerd_face:

I’ve played with pointers in PB to some degree.

But with great power comes … well having to handroll some of your own code like some of the nice syntactic sugars found in other languages. For example, there is no Trim (or Chomp) function built into PB to get rid of white space in a string. But fortunately one of the PB forum members coded a function for it.

; Attempting to add Trim function to my own code. It works! :->
; 04/04/2022 

;====================== Trim Macro ==============================
#WHITESPACE$ = " " + #TAB$ + #CRLF$

Declare.s LTrimAny (source$, charlist$=#WHITESPACE$)
Declare.s RTrimAny (source$, charlist$=#WHITESPACE$)
Macro TrimAny (_source_, _charlist_=#WHITESPACE$)
   ; removes from source$ any leading or trailing character which is contained in charlist$
   LTrimAny(RTrimAny(_source_, _charlist_), _charlist_)

;==================== Main =======================================
Define.s fname = "   Gary  "
Define.s lname = "  Smith   "

; Before trimming
Debug("Hello " +fname+ " " +lname+ "!")
fname = TrimAny(fname)
lname = TrimAny(lname)
; After trimming
Debug("Hello, " +fname+ " " +lname+ "!") ; it works :-> 

;================= Trim function definitions ======================

Procedure.s LTrimAny (source$, charlist$=#WHITESPACE$)
   ; removes from source$ any leading character which is contained in charlist$
   Protected p.i, *s.Character
   p = 1
   *s = @source$
   While *s\c <> 0 And FindString(charlist$, Chr(*s\c)) <> 0
      p + 1
      *s + SizeOf(Character)
   ProcedureReturn Mid(source$, p)

Procedure.s RTrimAny (source$, charlist$=#WHITESPACE$)
   ; removes from source$ any trailing character which is contained in charlist$
   Protected p.i, *s.Character
   p = Len(source$)
   *s = @source$ + (p-1) * SizeOf(Character)
   While p >= 1 And FindString(charlist$, Chr(*s\c)) <> 0
      p - 1
      *s - SizeOf(Character)
   ProcedureReturn Left(source$, p)

Also as an aside, pjsmith67, you can also use Define$ vs Define.s for strings. It’s not anywhere in the documentation … I just happened upon it by chance. :upside_down_face:

1 Like

hmmm… did not know that about define.

FYI - PB does have trim, ltrim and rtrim functions.


1 Like

You’re right! And I’m glad you are … I must have got caught up in an old thread about there not being any Trim functions: :nerd_face: I’ll know better to do a search in the help index next time. :upside_down_face: