What is wrong with the BASIC language?

General discussion for topics related to the FreeBASIC project or its community.
Imortis
Moderator
Posts: 1923
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: What is wrong with the BASIC language?

Post by Imortis »

Boris the Old wrote:...Like hammers and saws, programming languages are just tools that are designed to serve a particular purpose...
Preach on, preacher. If a language does not fit your needs, it is the wrong tool for the job. If it does, it is the right tool for the job.

When I was in college for programming, I had a teacher who was fond of the following phrase:
"What is the correct answer? The one that works. That is the only criteria for a correct answer."

To answer some of the other things in this thread, I have never understood language hate or language wars. It's like saying "I think everyone should use a nail gun because it is clearly superior to a hammer, and anyone who disagrees just doesn't know enough to have an opinion". It is short-sighted and kind of bizarre.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Post by caseih »

dodicat wrote:Some of these other so called up to date super languages python/Fpc e.t.c. are written in C anyway, so FreeBASIC is on the same route.
Actually most "up to date super languages" that require a compiler are self-hosted, which means written in the same language as the compiler compiles. The very first version has to be written in an existing language like C, but once that exists, the compiler can be developed in its own language.

From what I can see FreePascal (fpc) is self-hosted, but with the odd requirement that the compiler must be compiled by the same version of the compiler, which is a bit odd because it makes bootstrapping very hard. Most languages can be bootstrapped from older compilers.

I thought FB was self-hosted as well (written in FB). I know parts of the runtime are written in C, but now that FB is where it's at they could be written in FB as well I think. Because FB can emit C code, it's possible to bootstrap a new platform by generating the C intermediate code and compiling that on the new platform.

Even Python is moving towards self-hosting. PyPy, the next generation interpreter/JIT engine is written in Python itself.
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: What is wrong with the BASIC language?

Post by Boris the Old »

dodicat wrote:Old Boris, well, it's hard to tell if he has been over-exposed yet.
I don't expose myself too much these days, for fear of causing whiplash events in onlookers.
caseih wrote:Actually most "up to date super languages" that require a compiler are self-hosted, which means written in the same language as the compiler compiles. The very first version has to be written in an existing language like C, but once that exists, the compiler can be developed in its own language.
I have, in my library, a book that I purchased in 1970 -- "A Compiler Generator", by McKeeman, Horning, and Wortman, which describes in great detail how to bootstrap the creation of a compiler. It's interesting that these concepts were already well developed in the 1960's.

Rod
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: What is wrong with the BASIC language?

Post by marcov »

caseih wrote:
From what I can see FreePascal (fpc) is self-hosted, but with the odd requirement that the compiler must be compiled by the same version of the compiler, which is a bit odd because it makes bootstrapping very hard. Most languages can be bootstrapped from older compilers.
That's not correct . For FPC, The current development compiler must be compiled by the last release compiler (in practice the last two work without trouble, and usually the two before that with some tricks).

The current compiler must also be able compile itself, but only in the exact same version, since the compiler compiles itself as part of the bootstrap procedure.

A new release compiler must of course also be compilable by the last release compiler, building a chain that goes back to (protected mode) Turbo Pascal. And all this compilability can be aided with some version dependent IFDEFS of course

The same requirements go for the core RTL. The rest (packages/ etc) do not need to be compatible with multiple versions.
Last edited by marcov on Jan 21, 2024 11:26, edited 4 times in total.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: What is wrong with the BASIC language?

Post by fxm »

I think that the first FreeBASIC compiler version was written and compiled using QuickBASIC!
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Re: What is wrong with the BASIC language?

Post by anonymous1337 »

fxm wrote:I think that the first FreeBASIC compiler version was written and compiled using QuickBASIC!
http://forum.qbasicnews.com/index.php?topic=7142.0
v3cz0r wrote:freeBASIC will be released when it get to compile itself.. yes, that's right, the compiler was written 100% in QB (VBDOS to be exact, code is already 16k lines long). There are many runtime lib routines to implement, such as for files, console (including PRINT), some string functions and math. In some weeks i may release the version 0.01 for testing, we will see ;)
Ah, history :)

The day v1ctor dropped a nuke that eventually killed the QMunity. Jk jk.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: What is wrong with the BASIC language?

Post by BasicCoder2 »

Imortis wrote:To answer some of the other things in this thread, I have never understood language hate or language wars. It's like saying "I think everyone should use a nail gun because it is clearly superior to a hammer, and anyone who disagrees just doesn't know enough to have an opinion". It is short-sighted and kind of bizarre.
Which language was better was certainly not the intent of my original post. It was more about my annoyance at all these new languages instead of simply extending the power of the popular older BASIC and C++. Why can't I do the same things with BASIC that can be done with Python or Java? After all everything is ultimately reduced to machine code so there must be an assembler equivalent program whatever language you use.

The analogy with a hammer and nail gun isn't what I see as the issue. Why not extend BASIC or C++ into the nail gun without having to learn a completely different language.

There is a practical reason for this. I have a lot of source code written in FreeBasic and would be able to quickly translate it into C++ because using a subset of C++ a one to one translation is possible.

print "Hello World! "

becomes,

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World! ";
}


However the core commands in Python do not have a simple one to one translation with BASIC. Python seems to be list orientated with LISP like functions but that can surely be emulated with functions written in BASIC? I want my FOR command to act in a normal way not be hijacked to a completely different interpretation.

If beginners find Python easy to learn I would put that down to not having to unlearn anything.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Post by caseih »

Python really doesn't have a BASIC equivalent of FOR/NEXT. Python's "for" is really more equivalent to C#'s foreach statement. Or C++'s STL-based for_each construct. Even C's for() statement is very different from BASIC's for that matter. And in all these cases, the various forms of for are syntactic sugar for some setup followed by a while loop. But then again a while loop is syntactic sugar for an if condition then jump statement.

Any language has a few core things that may be different from other languages but once you grasp it and stop fighting it, you can learn it pretty well. For python this would be the list-based processing model (and dictionaries too) in lieu of the more traditional arrays, and white-space block syntax, to name couple. I know of more than a few beginners that learned Python and have become pretty fluent in it. There's something about it that deeply appeals to me. Perhaps it's the vague LISPness of its data structures that appeals to me. Apologies for anyone not familiar with LISP, but here's my all-time favorite take on LISP:
Image

Personally, at this stage of the game, I see FB as pretty much a 1:1 match for C. It's basically C with a friendlier syntax, and a nice and complete, beginner-friendly runtime library which includes some nice abstractions for dealing with dynamically-allocated and sized -strings. Once you get into OOP, though FB is certainly not 1:1 with C++ (having boolean support would be a good start for supporting Qt). And there's not much for OOP support in the standard runtime library at this point, so OOP in FB is kind of an island.

FB attracts me more for nostalgic reasons, and I have a lot of old QB and PB code from my youth that I can often get running in FB. I suspect many others are in a similar situation.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: What is wrong with the BASIC language?

Post by BasicCoder2 »

caseih wrote:... I know of more than a few beginners that learned Python and have become pretty fluent in it. There's something about it that deeply appeals to me. Perhaps it's the vague LISPness of its data structures that appeals to me.
LISP is an old AI language so there must be a reason it isn't mainstream. I found it too difficult to understand although part of the reason may have to do with lacking a mathematical background and access to tutorial and LISP writing tools. BASIC came with the early hobby computers and thus there wasn't really much option for me apart from Assembler which I really loved. Python is available to everyone and seems very well supported with importable extensions.
I think this explains the situation of old BASIC programmer very well,
http://www.paulgraham.com/avg.html
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Post by caseih »

Yes all the LISP sayings are a bit cliche. Good article, by the way. What I meant by saying I love Python because it's vaguely LISPish is not that the language itself resembles LISP, but it is that the idea of lists as a primary data structure is inherently powerful works very well with many algorithms. Back in my college days we spent a whole course in data structures, using conventional languages (C, C++, or Pascal). We made all sorts of trees, linked lists, etc. Turns out that lists as LISP defined them could emulate or form all of these data structures, and do it in a nice safe way too. It's possible that this is what made LISP so fast for the viaweb developers. Very rarely in Python do I need to implement a custom class-based data structure like I used to do in C or C++ (trees, linked lists).

I never cared for the syntax of LISP itself though. Which brings up the humorous point that LISP was always intended to have a more normal syntax, but the creators never got around to making a grammar or parser, and just used the intermediate list-based op form (there were LISP microprocessors at one time). And I don't think programmers need to learn LISP, but they should learn about the concepts of LISP. If only so they can understand the xkcd comic (look at all the cars!).

By the way, every FB programmer (or C programmer) should consider the GLIB library to be an essential data structure library. Hash tables, lists, trees, it has them all.
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: What is wrong with the BASIC language?

Post by ike »

Nothing is wrong with the BASIC language. FreeBasic is what it is -- and if it's not suitable for the job then a different language can be used.

Like hammers and saws, programming languages are just tools that are designed to serve a particular purpose.

Rod
You nailed it

If you can write a compiler in FreeBasic then there is nothing wrong with the Basic.

At this stage of developement FreeBasic (+FLTK) is a waaay more advanced than I will ever need. So, I will use it, and have no intention of learning anything else.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: What is wrong with the BASIC language?

Post by D.J.Peters »

The question is "what are wrong with BASIC users, to day." :lol:

BASIC as hobby is OK but in business you need at least.
C++, PHP, JavaScript and JAVA in automotive and financial environments.

( C/C++/PHP are 70% of all my job's as freelancer since last 28 years)

Of course as admin of Linux servers scripting like BASH is your primary tool.

Joshy

edit i forgot:
today more and more companies will ask for your skills at mobile apps too.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: What is wrong with the BASIC language?

Post by BasicCoder2 »

D.J.Peters wrote:BASIC as hobby is OK but in business you need at least.
C++, PHP, JavaScript and JAVA in automotive and financial environments.
So those languages provide something that FreeBasic is incapable of doing.
Over the last few days I have painfully being going through a Python for beginners book and writing a FreeBasic version of the simple program examples given.

Code: Select all

function raw_input(request as string) as string
    dim as string result
    print request;
    line input result
    return result
end function

dim as string  name1
dim as integer number1

name1 = raw_input("enter name: ")
print name1
number1 = int(val(raw_input("enter number: ")))
print number1
sleep

Code: Select all

sub printString(word as string, begining as integer, ending as integer)
    print mid(word,begining,ending-begining+1);
end sub

dim as string myWord
myWord = "THIS IS MY SENTENCE"
printString(myWord,3,7)

sleep
And it seems to me all the list processing is doable in FreeBasic.

But of course I can't duplicate programs that import things not available to FreeBasic!

eg.
from livewires import games

And it seems to me that is the real limitation of FreeBasic.
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Re: What is wrong with the BASIC language?

Post by anonymous1337 »

BasicCoder2 wrote:
D.J.Peters wrote:BASIC as hobby is OK but in business you need at least.
C++, PHP, JavaScript and JAVA in automotive and financial environments.
So those languages provide something that FreeBasic is incapable of doing.
I'm not sure that's the implication. I mean, again, Turing Completeness. Anything Turing Complete can compute anything computable (in theory, if there's unlimited time and memory).

But some languages are more succinct, productive, "expressive", etc. I mean, for example, one cool thing in Ruby is the method_missing method which is invoked if you try and invoke a method that doesn't exist. So even if the method isn't defined, you can do: HtmlGenerator.Div()

Div() is not found, but in method_missing you can get the name of the method, and then generate a "div" based on that. So you could do HtmlGenerator.Div().Textbox().Value("Hello, please enter something.") And get even the HtmlGenerator class written more quickly in Ruby than if you did it in FreeBASIC.

Time is an asset. It is a resource. Being able to do something in less time (even if it's writing the tools that make writing other things easier - FreeBASIC doesn't even have the tools) is valuable.

Not saying you couldn't write that HTML generator in FreeBASIC. In fact, that's one thing that's probably really easy to do with the vbcompat.bi file (so you can use string.format for string interpolation). Then just return the same HtmlGenerator object and you have a fluent API.

But still. Little things add up. They really do.
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: What is wrong with the BASIC language?

Post by marcov »

caseih wrote:
By the way, every FB programmer (or C programmer) should consider the GLIB library to be an essential data structure library. Hash tables, lists, trees, it has them all.
Why? FB is an OOP capable dialect nowadays, and doesn't need to emulate one using a library?

Apropos LISP: I never had much faith in a language named after a speech impediment.
Post Reply