I am not sure how many of you have ever tried Freebasic but it is a fantastic BASIC language. It is free and extremely powerful.
I have released a new version of FF for FB that corrects all of the previously generated compiler warnings. The designer itself is based on the current FF 3.5 for PB.
Webpage: http://www.planetsquires.com/firefly_freebasic.html
Not that people won't take your word for it when you claim FB is fantastic, but you gotta tease people a little. 8o)
For those whom can bother; http://freebasic.net/about
And those whom can't/won't, here are the headlines from that page:
• BASIC compatibility
• Clean syntax
• Thin bindings (header files) to existing C libraries and APIs
• Multi-platform (i386 on DOS, Linux, Windows and Xbox)
• Unicode support
• A large number of built-in data types
• User-defined types (UDTs)
• Default procedure parameter values
• In-line assembly Intel syntax
• Traditional preprocessor support
• Debugging support
• Create OBJ's, LIB's, DLL's, and console or GUI EXE's
• Optimized code generation
Header libraries available; http://www.freebasic.net/wiki/wikka.php?wakka=extlibtoc
Wow, Paul, wow!!!
Quote from: Haakon Birkeland on October 23, 2011, 08:39:49 AM
• Multi-platform (i386 on DOS, Linux, Windows and Xbox)
That would cost about $470 for PowerBASIC and you still won't have a
Linux version.
Quote
• Create OBJ's, LIB's, DLL's, and console or GUI EXE's
..and all in one compiler...not separate money grabs like PBWIN and PBConsole.
One cool thing with FB is when developing your Windows GUI application you can have the console window active and simply use PRINT statements to output messages to help with debugging.
A guy from France, SARG, has created a debugger for FB that is amazing compared to the one in PB. It is called FBDebugger and can be downloaded from the Projects section in the FB forums. Pretty cool project considering it was developed by only one person. You can also use the standard GNU debugger if you want to.
PB has a few more convenient built in string handling functions but it is nothing that hasn't already been replicated in FB by users in the community.
I still love and use PB, but if I hadn't already invested 15 years with PB then FreeBasic would be my choice.
Quote
One cool thing with FB is when developing your Windows GUI application you can have the console window active and simply use PRINT statements to output messages to help with debugging.
Do you know that I often use the PB console compiler to debug my PB GUI applications? If you aren't a DDT'er, you can use the console compiler for both console and GUI applications.
That's a neat way of debugging I suppose. How about the debugger "compared" to the old AntEater project?
As for you Jose, I've noticed much of your code samples, sometimes to my frustration, utilize the Console Compiler and the Print statement a lot.
Here is a small list of some of the things that I really find great about the FreeBasic compiler. Just imagine if there was a magnitude of developers dedicated to the project on a full time basis.
- You can declare and initialize a variable all in one statement. This has been requested in PB for a long time. PB's ARRAY ASSIGN was somewhat in that direction but you still need have that statement within the sub/function rather than on the same line as the DIM.
Dim st As String = "Paul Squires"
'' Declare an array of 2 by 5 elements
'' and initialize
Dim array(1 To 2, 1 To 5) As Integer => {{1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}}
'' declare a simple UDT
Type mytype
var1 As Double
var2 As Integer
End Type
'' declare a 3 element array and initialize the first
'' 2 mytype elements
Dim myvar(0 To 2) As mytype => {(1.0, 1), (2.0, 2)}
'' You don't even need to know the upper dimension of the array prior to initializing!! Simply use an ellipse.
Dim As Integer myarray(0 To ...) = {0, 1, 2, 3}
- The "+" operator will concatenate strings but the "&" will concatenate but also automatically convert numeric expression to strings.
eg. "Error number: " & nErrorNum & " occurred."
- You can use variable String data type in TYPEs.
eg. Type MyType
sMyText As String
End Type
- Allows With, End With
eg. With MyType
.CustName = "Paul Squires"
.Address = "Someplace somewhere"
.Postal = "a1a1a1a"
.telephone = "555-5555"
End With
PB's Prefix/End Prefix command works 'okay' but will fail on the above example because the lines starting with the period (.Address) will cause a compile error. Too bad, because in my many years of using Visual Basic we would always use the period to start the line.
- Allows you to pass the resource file (.rc) to the compiler without having to compile/convert it first. The compile takes care of handling it from there.
- "Classes" are handled by extending the TYPE structure. The variables in the TYPE can be Public, Private, Protected. You can have Functions/Subs/Property inside the TYPE. The TYPE can have a Constructor and Destructor.
- Functions can easily be overloaded.
'' The overloaded functions must be FIRST.
Declare Function ReturnTen Overload (a As Single) As Integer
Declare Function ReturnTen Overload (a As String) As Integer
Declare Function ReturnTen (a As Integer) As Integer
Print ReturnTen (10.000!) '' ReturnTen will take a single and return an integer
Print ReturnTen (10) '' ReturnTen will take an integer and return an integer
Print ReturnTen ("10") '' ReturnTen will take a string and return an integer
Function ReturnTen Overload (a As Single) As Integer
Return Int(a)
End Function
Function ReturnTen Overload (a As String) As Integer
Return Val(a)
End Function
Function ReturnTen (a As Integer) As Integer
Return a
End Function
- Parameters to subs/functions can be optional and given a default value.
Function TestFunc(P As String = "Default") As String
Return P
End Function
Print TestFunc("Testing:")
Print TestFunc
- Include the "vbcompat.bi" include file and you gain just about all of the functionality of the cool functions in Visual Basic such as the Date arithmetic library.
- FreeBasic allows for "NameSpaces" and "Naked" functions (PB now has naked functions in PB10).
- If you are into gaming then there are a lot of graphics commands and a dedicated graphic library.
- Notice in this next example two things. First, I can define the For/Next counter variable directly in the For/Next loop, and second, I can access the string's ascii values directly via pointer arithmetic without using a separate Byte Pointer.
dim st as string = "Paul Squires"
for i as integer = 0 to len(st) - 1
' print the ASCII code for each letter in the
' string by accessing the string directly via
' pointer arithmetic. No need to DIM a string
' or byte pointer first.
print st[i]
next
sleep
- It is cool that you call the file functions in function format so that you can directly test for success/failure (errors):
result = Open (filename, For Random, Access {Read|Write}, As filenumber [, Len = record_length] )
- or -
Open filename For {Input|Output|Append} As filenumber
- You can even specify the encoding type of the files you are reading or writing to:
Encoding "ascii" (ASCII encoding is used, default)
Encoding "utf8" (8-bit Unicode encoding is used)
Encoding "utf16" (16-bit Unicode encoding is used)
Encoding "utf32" (32-bit Unicode encoding is used)
- You can easily call/use any of the standard "C" library functions by including the application file from the /crt include folder.
- You have the option of not DIM'ing a variable prior to use. Simply use the VAR statement and the variable will be created based on the data that you initialize it with.
Var g = @c '' integer ptr
Var h = @a '' byte ptr
Var s2 = "hello" '' var-len string
Var ii = 6728 '' implicit integer
Var id = 6728.0 '' implicit double
That's about all I can think of at the moment. FreeBasic is not a toy or hobby language. It can easily compete with the big boys. The compiler emits ASM that is compiled by the GNU GAS compiler. The developers are also working on the "C" output that is compile with the GNU C compiler. That is mostly complete at this time and will allow a much greater cross platform ability for FB.
I will wait to see what the next version has to offer, because the current one is already obsolete for my system, and tools like the visual designer incorporated in FBEdit, unusable. The Windows API includes are a subset, like the current PB ones. Mine offer five times more.
Namespaces and other features that you mention are nice, and I would like to see them implemented in a future version of PB. But FB has some serious drawbacks. Being a one pass compiler, you have to use declares for your functions, as with older versions of PB, and there is not dead code removal, so you will have to deal with tons of one-function includes and .obj files to build fine-grained libraries. PB .SLLs have the same problem, and this is why I don't use them. Include files are more versatile because allow conditional compilation, although require a fast compier.
Low-level COM support is as primitive as it was in ansi C.
Quote
- You can easily call/use any of the standard "C" library functions by including the application file from the /crt include folder.
You can do the same if you use my headers, and they allow to use any version of the C standard libraries, not just the old and deprecated msvcrt.dll. The new version of my headers will have changes because M$ has changed again the rules. They first tried to avoid DLL hell adding a version number, e.g. msvcr71.dll, then side by side installation (versions 8 and 9), that needed the use of a manifest, and now they no longer require a manifest, but the msvcrt.dll that comes with Windows 7 is version 7, not the old one, that not only was unsafe, but lacked support for 64-bit.
So now we have a new msvcrt.dll and also a numbered version, depending on the version of Visual C++ installed.
Quite a few appealing features that ("lazy") VB'er should feel good about.
I for one where a seriously heavy user of the With structure in my VB days.
Thanks for balancing the information Jose. 8o)
Thanks Jose, I agree that FB has a long way to go but consider that it is an open source project and the few developers that work on it are part time then I consider it to be a huge accomplishment.
I think that PB wouldn't be where it is today without Jose's help. He has helped push COM forward in PB. Jose's headers are unmatched.
Dead code removal is not a deal breaker for me. Sure it would be nice to save a few bytes here and there in the program but a 1.9 meg program versus a 1.2 meg program is somewhat irrelevant this day and age given computer speeds and hard drive sizes. I guess it does make it easy for dealing with huge amounts of include files (Jose's includes) but other than that, it is just a nice to have feature.
I definitely agree that the COM support is lacking. How many PB'ers really utilize the full extent of COM in PB? I wonder. I bet that it would take only a couple of passionate COM FB programmers a few weeks to have it implemented if the desire was there. FB has a large following in Linux where there are few BASIC compilers.
Well I guess I have to add my few cents here as I've written many lines of FreeBasic code.
Paul has done an excellent job with the Firefly port to FreeBASIC.
I was a huge fan of FreeBASIC but I'm afraid that has diminished over the years as development petered out.
The c/c++ backend appears to have died. I tried it a while back and it was VERY buggy.
No 64bit support.
I am not doing any commercial contract work anymore so my PowerBASIC coding is minimal (It is the only language I use for $ work)
Some of you might know of my involvment with Bcx. To me it is the holy grail of Basics at this time. C++ with Basic Syntax. With the Ubx derivative I have Windows/Linux/Mac 32/64 and tons of libraries to choose. I lobbied Paul hard for a Bcx version of Firefly but....
James
And I keep hoping for Paul to win some lottery, so he'll do a PureBASIC version of FireFly... : )
More to delve into over there (Jose's forum);
FreeBasic vs. PowerBasic vs. Whatever - http://www.jose.it-berater.org/smfforum/index.php?topic=979.0
Cool, now I have more toys until I can buy newest PB version.