What is wrong with the BASIC language?

For other topics related to the FreeBASIC project or its community.
BasicCoder2
Posts: 3357
Joined: Jan 01, 2009 7:03

What is wrong with the BASIC language?

Postby BasicCoder2 » Apr 16, 2015 0:49

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration - Edsger W. Dijkstra
What bad habits do you get from learning programming using the latest version of FreeBASIC?
Do modern BASICs like MS VB.NET still result in mental mutilation while using C# does not?
What can other languages do without imported libraries that a modern version of BASIC can't?
dafhi
Posts: 1238
Joined: Jun 04, 2005 9:51

Re: What is wrong with the BASIC language?

Postby dafhi » Apr 16, 2015 1:15

c++ wrecked it for me
Pritchard
Posts: 5492
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: What is wrong with the BASIC language?

Postby Pritchard » Apr 16, 2015 1:31

I have a long reply written to this, but let me summarize because I told about 10 different stories in my original draft:

* BASIC abstracts you away from the "turtles all the way down" nature of computing, without there being huge benefits (very high-level language features, such as exist in Python or Ruby) or easy ways to move past these abstractions (low-level system utilities, as would be expected in C, C++, etc.)

* BASIC is in a way because of this, sandboxed. You can become a VERY good BASIC programmer, build very useful apps, and still have no idea how computation or systems work. You just call a bunch of BASIC utility functions in some order, an app appears. Historically, BASIC users even had trouble with types and functions, let alone the memory management and OOP we have today.

Imagine hiring a great BASIC programmer for your company and a low-level utility malfunctions. There's a bug somewhere, but no one who can thoroughly debug and patch it because it's too "low-level" or requires intimate knowledge of low-level constructs, concepts (maybe raw OS concepts). As far as the BASIC programmer was aware, BASIC was their operating system. Anything less abstract than that was basically a mystery.

* About the sandboxing, FreeBASIC's inline ASM and pointers let us move past some limitations and manage our own memory, create complex constructs. While those are important features for the language to interface with other utilities and the system, they remove the "sandboxed" nature of BASIC. Now you're managing your own memory, worrying about all sorts of other things. You can get computer science exposure here - namely in data structures and algorithms - and gradually build bigger systems and even OOP, but it is a PAIN in my opinion. Even C++ has reference data types.

* As far as OOP is concerned, that's another thing that seems to force BASIC users out of their own little sandbox. I think by conforming to standard language patterns, now people using BASIC can learn about OOP, which is great, but in a way that might defy the BASIC philosophy.

So I think FreeBASIC is very interesting, and it suffices for teaching people how to use commands, and see the "reaction" on the screen or in a file, for example. But I think that historically popular utilities of BASIC - SCREEN, DATA, OPEN, INPUT, etc. - provide no fantastic utilities for related concepts, and also completely bury the extremely important nature of these utilities out of sight.
Pritchard
Posts: 5492
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: What is wrong with the BASIC language?

Postby Pritchard » Apr 16, 2015 1:44

As for your second question, here are things FreeBASIC can't do that other languages can without importing any additional utilities:

  • Closures / Lambdas
  • Functions as first-class citizens (with closure / state)
  • Regular expressions and advanced string processing (think PERL)
  • Automated property generation
  • Reflection
  • Dynamically typed variables
  • Anonymous types? (I know there was a cool type object instantiate syntax, but I don't know that types themselves can be anonymous.)
  • Reference types (Unless FB has these, now?)
  • Exception handling
  • Garbage collection
  • Generics (super, duper important for generalization of types / algorithms.)
  • Interfaces (Unless we have abstract methods / types, could probably satisfy some of the same needs, which we might)
  • Yield, iterators, generators
  • Ruby-like Symbols
  • Convention-based or indentation-based programming
  • Booleans
  • Class / type extension (FreeBASIC types / classes are always closed once defined?)
  • Static extension methods (C# ftw)
  • Message passing
  • Interpolated strings / values
  • Eval / exec
  • List comprehension
  • Probably a bunch others. There's a LOT of programming languages out there and they each serve a different purpose...

I mean, if you count adding your own runtime written in FreeBASIC sufficient to perform those things, then yeah maybe you have them (Turing completeness and all), but those would be features of the runtime you build, not the language. While it's true runtime information is required for most high level programming features, these features are often defined as being part of the language and require no additional utilities other than the default installation package.
caseih
Posts: 1354
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » Apr 16, 2015 2:09

BasicCoder2 wrote:It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration - Edsger W. Dijkstra
What bad habits do you get from learning programming using the latest version of FreeBASIC?
Do modern BASICs like MS VB.NET still result in mental mutilation while using C# does not?
What can other languages do without imported libraries that a modern version of BASIC can't?


Dijkstra's quote is hopelessly out of date. At best it refers to the time when BASIC lacked any sort of Pascal-like structure, so GOTOs were often used as a substitute, and most beginners used GOTOs very poorly, leading to the classic spaghetti code complaint often associated with BASIC. But since the mid to late 80s, this is no longer true. So I don't put any stock in the saying anymore. Modern BASICs like VB.NET do not result in metnal mutilation of the type that Dijkstra was thinking.

As for your other question, I suppose it's a matter of what you're trying to do. Imported libraries are essential in all languages, including FB. As far as "batteries-included" features of a programming language and environment, I have to say Python beats FB hands down. But there's nothing you can do in another language that you can't do in FB. Sometimes the lack of syntactic sugar makes it a bit more tedious and error-prone (the lambdas, closures, and other things mentioned in the other replies). And I maintain that any FB programmer that drops into inline ASM for speed is probably doing things wrong in 90% of cases.

My problem with FB going forward, besides the fact that it offers me very little that I don't already have in other languages I'm already comfortable in, is that the language syntax itself has become very bloated over the years. Most modern languages have at most 30-40 reserved keywords. FB has hundreds. And the syntax of certain legacy elements of FB are inconsistent. For example, PSET, LINE, GET, PUT all have weird syntaxes where some things are in lists inside parenthesis, and others tacked with commas. I haven't looked at FB's code, but I imagine the parser is pretty hairy and has to do a lot of look-ahead (having written a compiler in my younger days, I shudder at the thought of parsing full FB syntax). In reality, BASIC as a modern language only has 30-40 keywords. Everything else is really the runtime library, but with a special syntax in the compiler. The problem is well over half of FB users use FB precisely for the legacy syntax. So I can't argue for removing these special syntax elements and advocate calling the runtime functions directly (as C requires for things like printf). If you do remove special syntax, what about PRINT and INPUT? Not an easy question. I think FB is so much more than QB 5.0. On the other hand should it be a BASIC version of C and C++ or something different yet?
caseih
Posts: 1354
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » Apr 16, 2015 2:36

Pritchard wrote:I mean, if you count adding your own runtime written in FreeBASIC sufficient to perform those things, then yeah maybe you have them (Turing completeness and all), but those would be features of the runtime you build, not the language. While it's true runtime information is required for most high level programming features, these features are often defined as being part of the language and require no additional utilities other than the default installation package.


Such a distinction is near meaningless. The best languages are small languages, with few keywords. The runtime library is the proper place for additional functionality, not the language itself. Python is an excellent example of this. The language itself is very minimal, 33 keywords I believe. Yet it is dynamic and expressive, and the runtime library (mostly written in Python) is one of the most advanced and powerful out there. This contributes to Python's usefulness in a huge way. Placing constructs from the standard library into the language itself would add nothing but unnecessary parser bloat.[1]

Let's not kid ourselves here. All of the nice graphics functions in FB everyone loves so much are in the external, runtime library. The language syntax integrates them (in a way that is inconsistent in my opinion). If you are arguing that such integration makes a great language, compared to one where they are explicitly called by the programmer in the runtime library, then I disagree.

[1] For certain constructs including object-oriented programming, syntactic sugar is indeed desirable.
BasicCoder2
Posts: 3357
Joined: Jan 01, 2009 7:03

Re: What is wrong with the BASIC language?

Postby BasicCoder2 » Apr 16, 2015 4:43

Pritchard wrote:As far as the BASIC programmer was aware, BASIC was their operating system. Anything less abstract than that was basically a mystery.


Well there are levels of understanding. I understand computers at the level of logic gates and machine code as that was my introduction to computers. The mystery for me is the higher levels of abstraction like "message passing".

Perhaps it comes down to the language fitting the intellectual capacity of the programmer and how much formal education they have in math and software engineering.

Once programming was only something scientists and mathematicians could do but with the advent of the easy to learn and use BASIC language it was open for the ordinary man to do some programming. As versions of BASIC are still being developed for smart phones and tablets it appears that it is still taken to be the easiest way for the ordinary man to get a program up and running even if the language itself is too limiting for the software engineer.
marcov
Posts: 2752
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » Apr 16, 2015 7:46

BasicCoder2 wrote:It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration - Edsger W. Dijkstra


Mr. Dijkstra was talking about old interpreted basics. Goto, everything in one big chunks, poor datatyping.

What bad habits do you get from learning programming using the latest version of FreeBASIC?


All bad habits of C :-)

Macro use, weak module system, manual string types. FreeBasic has a string type, but I still see a lot what amounts to *char use.

Do modern BASICs like MS VB.NET still result in mental mutilation while using C# does not?


No, and VB.NET is 10 years old, and basically a miserable failure. VB6 captured the bulk of the MS-centric programmers at the time, and VB.NET hasn't been able to keep them. It was not distinct or productive enough compared to C# to sway people, even if they already were VB programmers.

What can other languages do without imported libraries that a modern version of BASIC can't?


More importantly, what can BASIC too that others can't? And don't come with the tired old "beginner friendly", since I don't buy that in the case of FB.

VB6 was horrible from a language point of view, but it was productive and well integrated. Most importantly it was a default choice of a major vendor, which is more and more important nowadays.

Not language related reasons are much more important nowadays than the details of the language itself, at least when the language is halfway decent. Mainly the quality and completeness of the development system as a whole, and who pushes it(vendor).

FB is still too Cish to make the halfway decent criteria though, at least from a IT manager perspective, and C++ is too entrenched for anyone to actively challenge it as 'lowlevel" language of choice.

I think it is wiser to discuss where FB should be in 5 (and 10) years, and forget World Domination.
RockTheSchock
Posts: 220
Joined: Mar 12, 2006 16:25

Re: What is wrong with the BASIC language?

Postby RockTheSchock » Apr 16, 2015 9:40

quality and completeness of the development system as a whole. I think it is wiser to discuss where FB should be in 5 (and 10) years, and forget World Domination.

That's excactly the point! Look at Lazarus. A powerful IDE with RAD and cross-platform support.
Pritchard
Posts: 5492
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: What is wrong with the BASIC language?

Postby Pritchard » Apr 16, 2015 10:58

caseih wrote:Let's not kid ourselves here. All of the nice graphics functions in FB everyone loves so much are in the external, runtime library. The language syntax integrates them (in a way that is inconsistent in my opinion). If you are arguing that such integration makes a great language, compared to one where they are explicitly called by the programmer in the runtime library, then I disagree.

I'm arguing that such integration makes BASIC what it has been, not that it makes a great language. I think BASIC is a terrible language, but that sort of integrate made it very fun and easy to play with. It has been tough finding a replacement language for rapid prototyping of game concepts, for example, even though I don't think BASIC is very good for that, either.

caseih wrote:Such a distinction is near meaningless. The best languages are small languages, with few keywords. The runtime library is the proper place for additional functionality, not the language itself. Python is an excellent example of this.
And BASIC is not an example of this at all. It has many keywords, and presents a system that is overall not at all very extensible.

BasicCoder2 wrote:As versions of BASIC are still being developed for smart phones and tablets it appears that it is still taken to be the easiest way for the ordinary man to get a program up and running even if the language itself is too limiting for the software engineer.

Maybe younger kids, or people used to BASIC, but the vast majority of people that I've seen (in reddit's programming subforum for learning programming, for example) have no problem learning JavaScript, Python or Ruby.

When you have an interactive, interpreted Python shell where you don't even need to setup a local IDE and compiler, you can get straight into the code. I personally don't like that level of abstraction. I think people should be OK dealing with files and passing or configuring simple commands through the command line, because it opens up the idea that your operating system / file system is also programmable.
marcov
Posts: 2752
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » Apr 16, 2015 13:01

RockTheSchock wrote:
quality and completeness of the development system as a whole. I think it is wiser to discuss where FB should be in 5 (and 10) years, and forget World Domination.

That's excactly the point! Look at Lazarus. A powerful IDE with RAD and cross-platform support.


For Lazarus the situation is pretty much the same. The only differences are that FPC is a few years further along and that it is somewhat closer in philosophy to the comparable product (Delphi) than FB is to VB. (though that might not matter for this discussion because of FB's game orientation)

But despite that in relation to the Visual Studio's or the Java's of the world, it doesn't matter.

Neither FB nor FPC/Lazarus will achieve World Domination, or only after a substantial period and several outright miracles.

Since we don't live forever and can't force miracles it is better to focus on achievable goals, and not World Domination. WD discussions will only lead to popular pressure for about desperate attempts in attracting more new users (that rarely materialize in real user numbers) and neglect the user base that actually does something NOW.

And in FB's case that would mean doing something with the game focus I guess.
Boris the Old
Posts: 132
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: What is wrong with the BASIC language?

Postby Boris the Old » Apr 16, 2015 15:07

This whole discussion is irrelevant. It's been around for more than 50 years and applied to just about all languages.

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
St_W
Posts: 1467
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: What is wrong with the BASIC language?

Postby St_W » Apr 16, 2015 15:09

Many years ago BASIC was a rather high-level language, abstracting many of the internal details going on under the hood. But years have passed and the majority of modern programming languages have gotten more and more abstract while FreeBASIC has kept the level of abstraction or even went the opposite direction towards "low-level" programming. That made a lot of sense at that time (since a lot of BASIC programmers wished to be able to use some fast and powerful features of Pascal/C; maybe you remeber something like DirectQB) but does not really make sense nowadays.

Often people connect BASIC with the ability to easily write games. I cannot see FreeBasic being really game-focused at all. The few 2D drawing abilities of FreeBasic where probably nice in the 1980s, but are completely outdated nowadays. To be game focused FreeBasic needs support for more recent features. This includes large feature areas like the whole 3D stuff, but on the other end begins with little features like PNG/JPEG support (formats that weren't even invented in the 80s).

@Pritchard: I really would like to see some of these features being implemented in FB, especially Generics, Interfaces and Lambdas. But I think your feature listing is a bit unfair. Even big popular compilers only implement a subset of these features and have a lot of developers while FB has basically just one. Some features would require a completely different foundation, e.g. making FB an interpreted language instead of a compiled language.
Pritchard
Posts: 5492
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: What is wrong with the BASIC language?

Postby Pritchard » Apr 16, 2015 16:26

St_W wrote:@Pritchard: I really would like to see some of these features being implemented in FB, especially Generics, Interfaces and Lambdas. But I think your feature listing is a bit unfair. Even big popular compilers only implement a subset of these features and have a lot of developers while FB has basically just one. Some features would require a completely different foundation, e.g. making FB an interpreted language instead of a compiled language.

I'm not criticizing the FB development effort when I mention features FB lacks. I think the devs are great.

FB wouldn't have to be interpreted for most of those features, and only some would require runtime compilation. But yeah, FB would need either an included evaluator package or a JIT compiler included with each EXE for some... Although, a really smart fbc could implement a lot of features without anything extra. It would just do through FBC what a lot of things could be done through macros or custom pre-processing tools now...

I think dkl has done a great job with the compiler in recent years and I feel as though his work (specifically, the refactoring and other improvements) could make modifying a release of FreeBASIC easier in the future. I should really consider it if I ever have the time, but let me save some money first :-/

St_W wrote:Often people connect BASIC with the ability to easily write games. I cannot see FreeBasic being really game-focused at all. The few 2D drawing abilities of FreeBasic where probably nice in the 1980s, but are completely outdated nowadays. To be game focused FreeBasic needs support for more recent features. This includes large feature areas like the whole 3D stuff, but on the other end begins with little features like PNG/JPEG support (formats that weren't even invented in the 80s).

Yeah, man. BASIC was great for game prototypes when tools to just make games appear out of thin air didn't exist. Now they do exist, and I feel a thorough evaluation of modern tools and education methods (specifically, human computer interaction) is needed to think more about how to "improve" BASIC.

This sort of contradicts my earlier comments, since I don't even think a lack of modern, useful functions is necessarily the problem with today's BASIC. It's a problem I'd love to give more thought.

Ultimately, I think BASIC's goals are different from FPC's goals, for example. So I do look at FPC for an idea of progress, but personally, I hope we find a different niche.
dodicat
Posts: 5819
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: What is wrong with the BASIC language?

Postby dodicat » Apr 16, 2015 21:41

Yea, I think that you are correct BasicCoder2, with your quote.
Too much typing in basic ruins your overall ability to use something else.

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.

Pritchard seems to use quite a few languages, but he has made computing/coding his trade.
I'm sure he would know for sure if BASIC is so destructive.

Old Boris, well, it's hard to tell if he has been over-exposed yet.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests