Page 1 of 1

Gambas command-line programming

Posted: Monday 3rd April 2017 7:44am
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

Re: Gambas command-line programming

Posted: Monday 3rd April 2017 1:03pm
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 :)

Re: Gambas command-line programming

Posted: Tuesday 4th April 2017 1:50pm
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.

Re: Gambas command-line programming

Posted: Thursday 6th April 2017 7:37am
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?

Re: Gambas command-line programming

Posted: Friday 7th April 2017 11:03am
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.