Language Syntax Honouring the name BASIC

Everything else that doesn't fall into one of the other PB categories.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Language Syntax Honouring the name BASIC

Post by Tenaja »

HanPBF wrote:Hello Tenaja,
What do You mean saying "grew out of that"? Maybe doing more the direct, very verbose PB way? Or using preprocessor?
I mean I quit trying to conform PB into some other language, and I now use it the way it was designed. Sure, I use macros a lot, but not to rename native commands like Procedure (function) or Protected (local). As others have said, autocomplete is there for a reason.

As much as we'd like to say PureBasic is for beginners, most of us come from some other language, usually another Basic. Almost all of us try to use macros to make it more like where we came from. Most of us grow out of that. That's just an observation from using it for about five years.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Language Syntax Honouring the name BASIC

Post by HanPBF »

I like macros with procedures using arrays.

Code: Select all

procedure test(Array Arr1.Struct1(1), Array Arr.Struct2(1))
; loop over the arrays and do something
endProcedure
If 'Struct1' and 'Struct2' would be based on structure 'Struct' and so would 'StructA' and 'StructB', 'StructOne' and 'StructTwo' and I would want to use the same algorithm on the base struct, I can not write a procedure like...

Code: Select all

procedure test(Array Arr1.Struct(1), Array Arr.Struct(1), DoSomething.PrototypeDoSomething)
; loop over the arrays and call DoSomething
endProcedure
...because types of arrays cannot be base type of contained struct elements as parameter.
It seems pretty straight, I guess the size of the arrays must be known at compile time.

If the algorithm for varying types of arrays is nearly the same, I consider this a good method to macro-ize any loop over the very both arrays.


"to conform PB into some other language" -> yes, I agree, that's very often the problem.
I also use doubled tab typing "ProcedureReturn" which I find not so bad.

Regards
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Frarth »

Tenaja wrote:Just remember, the design intent for BASIC was not to make it easy to type, but to make the code fit into ram-limited systems. As such, short or long commands have nothing to do with "honoring BASIC".

Also, +1 to TI-994a:
These in no way "honour" the original BASIC; most of them weren't even in the original language. :lol:
When I was a newbie to PB, I used numerous macros, myself, to make it more comfortable/familiar for me. Over a few months, however, I grew out of that and started using pure PureBasic. Within a few years, I even forgot those early months, until I went back and looked at my early code...and as I did, I wondered what the heck I was thinking. I know some of the old dogs on the forum are older than the one typing this, but still, embrace it purely, and it will be easier in the long run.
The title may be somewhat misleading. I put more emphasis on readability and being able to do fast typing. Also, I have been using PureBasic for many years using its native keywords. After being out of it for a while and having used Pascal for specific programming tasks I found myself returning to a somewhat verbose language. So don't think I'm a newbie just starting out with PureBasic. I like doing short coding while still readable and understandable. In the end it's everyone's personal choice.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Frarth »

Also, I don't think Purebasic is for beginners. You have to be pretty careful when using pointers. Allowing references to procedures is powerful and advanced programming, usually not found in other basic languages. I feel comfortable using Purebasic. I just like SUB / ENDSUB more than PROCEDURE / ENDPROCEDURE not to mention PROCEDURERETURN. Even with autocomplete on it is a whole lot of typing when programming full time.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Language Syntax Honouring the name BASIC

Post by HanPBF »

PASCAL:

Code: Select all

if (a=b) or (c=d) then begin
  ...
end else begin

end
One-liners for if are forbidden in any language... (IIf allowed)

PureBasic:

Code: Select all

if a=b or c=d
 ...
endif
C-like:

Code: Select all

if(a==b || c==d){
 ...
}
PureBasic does it as short as possible keeping it BASIC...
Source is >=95% of the time read not written; I can not see anything annoying in PROCEDURERETURN when reading it.

So, still a matter of taste...
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Frarth »

That is why I prefer Purebasic over Pascal and other languages, but sometimes you don't have a choice when doing shared projects. ;)
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
TI-994A
Addict
Addict
Posts: 2771
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Language Syntax Honouring the name BASIC

Post by TI-994A »

Frarth wrote:...I don't think Purebasic is for beginners...
Totally untrue. PureBasic offers such a range of diverse cross-platform functionalities that could aid and complement the novice programmer, while still catering to the needs of the professional.

Powerful versatility. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: Language Syntax Honouring the name BASIC

Post by Frarth »

TI-994A wrote:
Frarth wrote:...I don't think Purebasic is for beginners...
Totally untrue. PureBasic offers such a range of diverse cross-platform functionalities that could aid and complement the novice programmer, while still catering to the needs of the professional.

Powerful versatility. :wink:
I'm not saying beginners cannot start using Purebasic, but it requires some deeper thinking. It starts with procedure parameters and the lack of BYVAL / BYREF keywords. When passing structures you need to use @ or *, but an array of a structure does not require this because arrays are automatically by reference. When passing a single array element of a nested structure you do need the reference again. You may have grown accustomed to this, but when starting it can be pretty confusing. On top of that, sometimes @* is required, for instance when passing a structure member by reference. This is not easy for a novice programmer.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
TI-994A
Addict
Addict
Posts: 2771
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Language Syntax Honouring the name BASIC

Post by TI-994A »

Frarth wrote:I'm not saying beginners cannot start using Purebasic, but it requires some deeper thinking...
Just to clarify, ByVal and ByRef keywords are parameter functions. With the exception of the Array keyword, PureBasic passes all parameters by value; even pointers.

As with anything, beginners simply need to read the manual; no amount of deeper thinking is going to circumvent that.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 544
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: Language Syntax Honouring the name BASIC

Post by bbanelli »

TI-994A wrote:As with anything, beginners simply need to read the manual; no amount of deeper thinking is going to circumvent that.
"Painful" truth. If you accompany it with sentence "Computers always do what you tell them, seldom what you really want", and you've described the whole IT branch. :)
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
User avatar
Lord
Addict
Addict
Posts: 909
Joined: Tue May 26, 2009 2:11 pm

Re: Language Syntax Honouring the name BASIC

Post by Lord »

bbanelli wrote:... "Computers always do what you tell them, seldom what you really want" ...
But that they do damn fast. :D
Image
Post Reply