BASIC is not BASIC anymore
BASIC is not BASIC anymore
I consider myself to be a bit of a dinosaur when it comes to programming in BASIC, never had functions in my day :), my code must look so ancient when it is read by others today. Am I not alone that in thinking that todays coding practices are a little harder to follow now, or am I just getting old :)
Re: BASIC is not BASIC anymore
Everyone is getting older, if you are lucky. FreeBASIC has indeed evolved to a more complex language, but you don't have to use all features. I have been using FreeBASIC for quite a while now (+10 years) and I also don't use all keywords. Proper functions and subroutines exist in BASIC for ~30 years (before that GOSUB and DEF FN). Try to make some programs without using #lang "qb" for some time and see if you like it. Concerning looks: if one does not use ALL CAPS keywords, no $%! symbols, no line numbers, minimal jump structures, and nice indenting, the code will look less scary for others. The more complex features are especially valuable for larger programs.
The biggest disadvantage of #lang "fb" is that you have to type more. Setting an integer to 1 (ignoring number of bits):
In "QB": a% = 1
In "FB": dim as integer a = 1
In "C" : int a = 1;
The biggest disadvantage of #lang "fb" is that you have to type more. Setting an integer to 1 (ignoring number of bits):
In "QB": a% = 1
In "FB": dim as integer a = 1
In "C" : int a = 1;
-
- Posts: 2958
- Joined: Jun 02, 2015 16:24
Re: BASIC is not BASIC anymore
Hi badidea,badidea wrote: The biggest disadvantage of #lang "fb" is that you have to type more. Setting an integer to 1 (ignoring number of bits):
In "QB": a% = 1
In "FB": dim as integer a = 1
In "C" : int a = 1;
you still can be lazy and just type:
Code: Select all
var a = 1
Re: BASIC is not BASIC anymore
I know var can make things easier, but then you have to guess what type a is, I prefer to be explicit and not leave anything to guesswork.
in this case, a could be of any numeric type
in this case, a could be of any numeric type
Re: BASIC is not BASIC anymore
I forgot about that one. Beats C by one character :-)Tourist Trap wrote:you still can be lazy and just type:That will do the job.Code: Select all
var a = 1
I prefer the 'verbose' style however. Edit: Agreeing with 'srvaldez' .
Re: BASIC is not BASIC anymore
Indeed. Var is most useful in situations where you don't have to guess the context (or read the manual to learn how var infers the type). Say:srvaldez wrote:I know var can make things easier, but then you have to guess what type a is, I prefer to be explicit and not leave anything to guesswork.
in this case, a could be of any numeric type
Code: Select all
var anInstance => MyClass( "Test" )
Re: BASIC is not BASIC anymore
There is a workaround using marcros.
Var is implicit and why was it added to FB? It is bad for code readability.
Code: Select all
#Undef Int' Already used in FB' polluted namespace :(
#Macro Int
Dim As Integer
#EndMacro
Int a = 10' C style define.
Print a
Sleep
-
- Posts: 783
- Joined: Jul 26, 2018 18:28
Re: BASIC is not BASIC anymore
Need to create such a bi file with all possible C macro commands. It will be useful to everyone. Who wants to can include this bi file their programShawnLG wrote:There is a workaround using marcros.
Var is implicit and why was it added to FB? It is bad for code readability.Code: Select all
#Undef Int' Already used in FB' polluted namespace :( #Macro Int Dim As Integer #EndMacro Int a = 10' C style define. Print a Sleep
Can call him "ccompat.bi"
Re: BASIC is not BASIC anymore
A little love for var.
var is one of my favorite features.
I think it's elegantly done, it's optional, and it's not that hard to remember:
var isint = 5 ' always integer
var isdbl = 5.0 ' always double
var issngl = cast(Single‚ 4.14) ' explicit
etc...
of course where it really is helpful is with UDT's and pointers to pointers and all the other stuff I'd rather let the compiler figure out.
But it's with more complex types that maybe you could argue that var is too implicit and confusing.
But I say who cares as long as the compiler is happy and keeping track?
var is one of my favorite features.
I think it's elegantly done, it's optional, and it's not that hard to remember:
var isint = 5 ' always integer
var isdbl = 5.0 ' always double
var issngl = cast(Single‚ 4.14) ' explicit
etc...
of course where it really is helpful is with UDT's and pointers to pointers and all the other stuff I'd rather let the compiler figure out.
But it's with more complex types that maybe you could argue that var is too implicit and confusing.
But I say who cares as long as the compiler is happy and keeping track?
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: BASIC is not BASIC anymore
BASIC was the first HLL that a novice could use to write programs that would run on different CPU's. Although line numbers and GOSUBS and short variable names were rather low level solutions for reasons of limited memory at the time. Before that I remember looking at Fortran code and thinking how great it was to see things written in a more natural readable language rather than the machine code I learned about when learning how computers worked at the level of logic gates, flip flops, program counter, instruction register, encoder and decoder networks and a master clock.
With FreeBASIC you can write some very C++ like cryptic source code which is compact and fast however I still like to at least write the first version of a program (and often the final version for me) in a very natural human like language first.
With FreeBASIC you can write some very C++ like cryptic source code which is compact and fast however I still like to at least write the first version of a program (and often the final version for me) in a very natural human like language first.