What is wrong with the BASIC language?

For other topics related to the FreeBASIC project or its community.
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Re: What is wrong with the BASIC language?

Postby anonymous1337 » Apr 24, 2015 12:44

marcov wrote:And euh, it is 2015 now. We should be talking about making it generic classes or not instead of discussing if it is a class or not :-)

This. Even if it's nothing more than the equivalent of a macro that provides better error message than macros and less hassle.

var personList = new List<Person>()

Please.
caseih
Posts: 1554
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » Apr 24, 2015 13:33

marcov wrote:Nice is relative, since it delivers an external dependency that must be deployed (since afaik it is LGPL and not GPL-with-static-linking exception?)

Nothing in the LGPL prohibits static linking. But a shared library has distinct advantages.
IMHO any sane language should strive to deliver this in its RTS using its own OO system.

FB doesn't offer generics in OOP (and do you really want templates on FB?). Furthermore more FB programmers do not use OOP very much. For most, FB is either a BASIC version of C, or a alternative to old-school QB.
And euh, it is 2015 now. We should be talking about making it generic classes or not instead of discussing if it is a class or not :-)

Sure but like I said, FB doesn't offer typesafe generics anyway, and OOP adds overhead. Sometimes all you need is a linked list with pointers you can traverse and a nice automatic way to clean them up.
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Re: What is wrong with the BASIC language?

Postby anonymous1337 » Apr 24, 2015 13:40

caseih wrote:FB doesn't offer generics in OOP (and do you really want templates on FB?).

Generics =/= C++ Templates

https://msdn.microsoft.com/en-us/library/c6cyy67b.aspx
http://stackoverflow.com/questions/1208 ... -templates
http://stackoverflow.com/questions/3169 ... emplates-i

You can pick and choose, based on the needs of the language and its users, what features or syntax you want for generics. C++ templates are apparently scary. I haven't made heavy use of them (and when I did, I thought it was cool), but I've seen a lot of veteran programmers complain about their over-use. (Then again, these capabilities help make C++ very powerful.)

I would be fine with Java-ish or C#-like generics. The simpler to start off, the better, IMO.

caseih wrote:Furthermore more FB programmers do not use OOP very much. For most, FB is either a BASIC version of C, or a alternative to old-school QB.

This is how I tried to use it, but it was such a pain trying to make even a basic game engine in FB that I stopped. Zamaster recently posted some super cool code: viewtopic.php?f=7&t=23502

Note the size of his utility and hashtable files. (He writes stuff mostly in ASM, so maybe it's not that much code.)

Just having to implement and re-implement this stuff in FB because someone else's solution just doesn't fit your programming style / pattern is really annoying. Also, the syntax and (sometimes) lacking safety for using stuff based only on pointers is equally frustrating. It somehow makes things more fragile.

But last I checked, we had the features now in the latest FB release to build some pretty awesome macro'd types that would suffice for a lot of CS data structs and algos. I forgot all about those since the release...
Boris the Old
Posts: 139
Joined: Feb 04, 2011 20:34
Location: Ontario, Canada

Re: What is wrong with the BASIC language?

Postby Boris the Old » Apr 24, 2015 14:55

St_W wrote:However, changing the FreeBasic language in a way so that no backwards compatibility is given could also be a risk.............This could especially be a problem for BASIC, as there are many elder people using it, who are often more skeptical regarding changes of well-known things / introducing new things - compared to young people.


You mean I have to give up my punched cards and punched paper tape? I'm not sure that all this newfangled stuff is of any use. I'm only just getting the hang of this GOTO statement -- it's really useful, I can jump all over my code.

If all these fancy features, like templates, are so great, why is modern code full of security holes and buffer overflows. I have customers who have been using my business applications for over 25 years -- no bugs, no crashes -- no templates, no OOP. :-)

Rod
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: What is wrong with the BASIC language?

Postby ike » Apr 24, 2015 15:47

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


Yes, Rod, but you must know canadian saying:

"When you got a hammer, evrything looks like nail"


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


I dont let my client decide what tools I use. If I have to go to interview and answer questions like: "What is your 5 yr goal" I will go and look for work as geologist
caseih
Posts: 1554
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » Apr 24, 2015 19:15

Reading the thread backwards, so forgive replies that go back a ways.

RockTheSchock wrote:Maybe with fbc 2.0 there have to be another break. "-lang fb2" No more quirk syntax at all. Maybe with a seperate 2-pass-compiler from scratch which supports class keyword. No more type/ class aliases needed.


Why would it need a 2-pass compiler? If you declare variables before use, and disallow forward references, a single pass compiler works very well.

I'm in favor of taking all the syntax fluff and sticking it in a standard library. Inconsistent and non-standard syntaxes like line and circle drawing, or get and put for images. Reduce FB keywords down to a more manageable number, say 40 or 50. The core language isn't that complex. It's the legacy stuff that makes it unwieldy. Still good stuff, but it doesn't belong in the language..
caseih
Posts: 1554
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » Apr 24, 2015 19:24

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.


It all depends on your job needs. If you're doing anything web-related, then you probably will want to pick Python, PHP, or Java. Though you probably could do a web page in FB very well, if someone made some nice classes to abstract CGI handling or HTTP handling, and implemented a template parser. Nothing would prevent a FB program from serving web pages via an apache proxy. If all you knew was FB, it might be faster than using a different language.

Some languages make it fast and easy/dirty, like PHP. And Python's dynamic nature lends itself very well to web programming.

But for a desktop app, there's no reason why FB couldn't do everything that C can, and most of what C++ can. In fact if Qt bindings existed for FB, FB/Qt would be a clear winner for desktop app development (better than GTK), especially for Windows and Mac.

For me, every time I get excited about a new language, I end up coming back to what works the absolute best for me, which is Python.
BasicCoder2
Posts: 3589
Joined: Jan 01, 2009 7:03
Location: Australia

Re: What is wrong with the BASIC language?

Postby BasicCoder2 » Apr 24, 2015 19:50

@ike wrote:
"When you got a hammer, everything looks like a nail".


A computer language is more like a tool box which can contain all sorts of tools.

Like any other program it can have its tool set added to or changed to suit.
Last edited by BasicCoder2 on Apr 26, 2015 6:21, edited 10 times in total.
marcov
Posts: 3019
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » Apr 24, 2015 20:43

caseih wrote:
marcov wrote:Nice is relative, since it delivers an external dependency that must be deployed (since afaik it is LGPL and not GPL-with-static-linking exception?)

Nothing in the LGPL prohibits static linking. But a shared library has distinct advantages.


That's playing with words. Other "relinking" solutions also need multiple files to be distributed. Or am I mistaken (search for "relinking" in the license text)

FB doesn't offer generics in OOP (and do you really want templates on FB?).


I'm not a real FB user, (I'm more following the project because of general interest in RTS/RTLs) but if I were, yes, ultimately I would want that yes. Typesafe container objects being the primary reason, but there are others (like generic sorting, binary search etc)

Furthermore more FB programmers do not use OOP very much. For most, FB is either a BASIC version of C, or a alternative to old-school QB.


OO with FB is just starting. It took a while for FPC for the masses to migrate too. OTOH, new people came in from Delphi rather than TP, that helped too.

So maybe wonder why doesn't FB attract VBers ? :-)

Sure but like I said, FB doesn't offer typesafe generics anyway, and OOP adds overhead. Sometimes all you need is a linked list with pointers you can traverse and a nice automatic way to clean them up.


Sometimes all you need is asm. But only very, very rarely :-)

I held off OO for years too, but when programs started to grow, and I had to adapt to requirements for the software being set externally (rather than me and some friends being the only users), things changed, and more productivity and flexibility was needed.
caseih
Posts: 1554
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » Apr 25, 2015 6:29

marcov wrote:That's playing with words. Other "relinking" solutions also need multiple files to be distributed. Or am I mistaken (search for "relinking" in the license text

Actually it's not just playing with words. Section 4, if I'm not mistaken, makes it very clear.
marcov
Posts: 3019
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » Apr 25, 2015 12:12

caseih wrote:
marcov wrote:That's playing with words. Other "relinking" solutions also need multiple files to be distributed. Or am I mistaken (search for "relinking" in the license text

Actually it's not just playing with words. Section 4, if I'm not mistaken, makes it very clear.


(Section 4 of what version?)

Anyway the question is how you are going to satisfy the relinking requirement without distributing additional files outside the binary (since the point was getting rid of the dll by static linking), or limiting what you link into the rest of the binary more than LGPL.

Maybe you could just explain what you have in mind there (how you are doing that or why you don't need to), we can always go back to the license text if we disagree, but now I'm mostly curious about what you are hinting at?
caseih
Posts: 1554
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » Apr 26, 2015 2:29

Section 4, subsection d, item 0 of the latest LGPL (which glib is released under, since it has the "or later version" clause) speaks to the static vs shared linking bit. Though it is true that there are some caveats with regards to either providing the source or the linkable object files (on demand would be good enough) so that the user can replace the LGPL'd portion in some fashion. So you ultimately you could be correct in your interpretation, from a practical standpoint. I personally don't see the value in a big statically-linked executable in a larger application, so to me bundling glib isn't a big deal and gives me a lot of utility.

Anyway, I think you're reading too much into my "standard equipment" claim, so I'll retract it. Suffice it to say, glib is an excellent library that has many uses for general programing, and would be of great value to some FB programmers. We don't always need a OOP, and writing one's own hash table algorithm is tricky.
marcov
Posts: 3019
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » Apr 27, 2015 19:07

anonymous1337 wrote:
caseih wrote:FB doesn't offer generics in OOP (and do you really want templates on FB?).

Generics =/= C++ Templates


(Generics is more than just C#. E.g. Ada. However in general it does seems to be a bit more declarative then C++ templates. I usually use generics for the general term, and templates for the C++ implementation specifically)

You can pick and choose, based on the needs of the language and its users, what features or syntax you want for generics. C++ templates are apparently scary. I haven't made heavy use of them (and when I did, I thought it was cool), but I've seen a lot of veteran programmers complain about their over-use. (Then again, these capabilities help make C++ very powerful.)


I'm no real expert (let alone knowing implementation details), so the below is more an summary of impressions than cold hard facts:

The core problem is that if you have a something<bla>, where bla is an abstract generic type and in some generic method do bla+bla, where and how is the operator defined? Must the operator be defined and declared when the generic is defined, or must it only be defined in the context of the specialization?

Afaik the aversion against C++ templates is that templates must be based on token replay (since the template declaration is not declarative enough to do much typechecking), so more (usage/specialization moment) context dependent. This makes implementation costly, compilation slow etc, unintentional sideeffect likely etc. It also makes reusing already generated code hard if the template is differenly declared but generates the same code (e.g. a container<child> and container<parent>).

That is what most online resources rave about, but mostly from the viewpoint of python or C#/Java.

The trouble is that the C#/Java Generics model also has sides that are a bad fit for FB because:

- FB is a compiled language and compilation speed is less important than with JITs.
- Java and C# have a mostly single rooted type system based on a root class, and valuetypes are autoboxed to class equivalents. They have no pointer types, and struct types are limited (and very class like or autoboxed again as needed). Note that class types are automatically reference types in these languages.

The last bit makes it fairly easy to have generics with class as base entity (iow you can only specialize a generic with a class and other types are autoboxed if necessary). But the FPC, C++ and I assume FB too typesystems don't work that way. Value types and non class aggregate types play a vital role in the language.

Delphi went the (C#/Java) generic way, and the implementation feels toothless and the worst of both worlds. On the other side I get the feeling that many devels shy away from the massive complexity of the C++ combination of typesystem and templates.

I would be fine with Java-ish or C#-like generics. The simpler to start off, the better, IMO.


I think the first goal should be typesafe container types, though so forms of type coercion go a long way for that too.
Last edited by marcov on Apr 29, 2015 10:52, edited 1 time in total.
ike
Posts: 387
Joined: Jan 17, 2011 18:59

Re: What is wrong with the BASIC language?

Postby ike » Apr 28, 2015 3:52

agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Re: What is wrong with the BASIC language?

Postby agamemnus » May 01, 2015 3:40

anonymous1337 wrote:Dude, v8 is f*ing fast these days :)

http://benchmarksgame.alioth.debian.org ... &lang2=gcc

Considering most people are processing server-side js using v8 + node.js (which then hands execution off to async c++ modules), those benchmarks are not bad at all given everything JavaScript can do.


Javascript is far faster to code with than many other languages. But still, static typing and weak garbage collection will always be faster than non-static typing and automatic garbage collection... right?

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests