Gambas command-line programming

Post your Gambas programming questions here.
Post Reply
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Gambas command-line programming

Post by stevedee »

I have been looking at Gambas command-line programming recently, as an alternative in situations where I would previously have used Python. Although Gambas is primarily presented to the world as a graphical/visual programming language, it has a lot to offer when programming on headless systems, such as low power boards like the Raspberry Pi.

For young people in particular, Gambas cli is a good starting point, or as the next step on from Scratch. In contrast to Python, the Basic syntax of Gambas is easier to understand and remember. And the Gambas IDE allows users to single step through programs, set break-points and view available methods & properties via "IntelliSense" type methods of code completion.

While I don't have a problem with Python, from my previous work in education I think it was a bad choice of programming language/environment for many young secondary school children (11+ year olds). Those that already had a strong interest in programming were able to adapt. But many were confused by the syntax, version differences (v2.x/3.x) or stumped when their programs just didn't work.

I like event-driven languages like Gambas, and was pleased to find that I could still implement a timer on cli, rather than having to create a hideous program loop.

Here is a trivial example;
Public hTimer30s As Timer

Public Sub Main()
 	hTimer30s = New Timer as "Timer30sec"
	hTimer30s.Delay = 30000
	hTimer30s.Start()

End

Public Sub Timer30sec_Timer()
	
	Print "I'm still here!"

End
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Gambas command-line programming

Post by jornmo »

I think that Gambas could reach very far if the documentation had been better. Take Arch Linux for example. The wiki outshines most other documentation I've ever read. If the Gambas wiki had been more elaborate and included more example code, I guess Gambas user number would take off a lot more, both for children and adults :)
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Gambas command-line programming

Post by stevedee »

I think VB6 had the best help system. Most pages included an example, along with a description of the method, property or whatever the subject was. (Whereas help on VB.Net seemed to just point to stuff on the internet, so you had to trawl through loads of linked pages to find anything helpful).

Stability has been another issue. When the Gambas package is included in the repository of a new OS release (e.g. Ubuntu 17.04) it needs to work, even if it is an older version than the latest release. The Debian system is a good one, where they have a stable release, a release candidate, and a cutting-edge unstable version. I think most users will want the stable version, most of the time.

Some of the syntax also seems strange to me. The only example I can think of at the moment is the one in my post above for the Timer;

First the timer declaration:-

Public Timer30sec As Timer

...then I would expect to create a new instance using the declared name: Timer30sec:-

Timer30ses = New Timer

...and then use Methods, Properties & Events for Timer30sec:-

Timer30sec.Delay = 30000
Timer30sec.Start()

...and then the Event:-

Public Sub Timer30sec_Timer()

...which seems more logical to me.
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Gambas command-line programming

Post by jornmo »

I am not sure I follow you on the syntax critique? Is it the naming convention? Or that you have to declare an event name at object instantiation?
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Gambas command-line programming

Post by stevedee »

jornmo wrote: Thursday 6th April 2017 7:37am ...or that you have to declare an event name...
Yes, it is having to declare an event name, in addition to the name declared and used for properties & methods.
Post Reply