My thoughts about FreeBasic and "Object Oriented code&a

For other topics related to the FreeBASIC project or its community.
Nexinarus
Posts: 146
Joined: May 28, 2005 6:08
Location: Everywhere
Contact:

My thoughts about FreeBasic and "Object Oriented code&a

Postby Nexinarus » Sep 29, 2008 6:04

It struck me today that as FreeBasic is pushing further and further towards supporting OO, this may be wonderful - but will also have very dramatic side-effects if OO is ever implemented. Some of these side effects could be seen as both positive and negative.

For instance, previous to today I was thinking when freebasic has OO support it will simply increase the version number, you know FB 0.3, or 1.0, whatever. But a quick recall of history shows that when the C language supported OO, the whole language forked to a seperate language, C++. Will this likely fork FreeBasic? Definately (imo). And heres why I think it will:

With OO capabilities, all of the FB-OO users will crave for an OO-made standard library, otherwise what would be the point of having all this power to only use a procedural library. Then FB without OO support will not be able to use this standard library, thus creating a divide. If it did support the OO lib i.e. no fork and just implement into core of FB, then the "pure" FB users won't be able to understand how to use it all, and will create a fork of the old FB version.

Now im not saying OO will be a bad thing, I would personally love it. But what do you guys think the real implication will be? Will new programmers in school / noobs be able to use an OO language? How will it sit with the "pure" basic users? What do you guys think?

EDIT: Also, if it was to happen, who decides what the syntax is? Will it be C++ style or JAVA style? A new style?

</ end of rant>
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Postby anonymous1337 » Sep 29, 2008 6:42

You can look at the freebasic todo list (located under src\compiler) for information on how v1ctor wanted to do OO. A bit of Java, some C++. Inspiration taken where he could get it.

I personally don't believe that FreeBASIC's advancement will cause any problems until we remove compatibility with older versions. When our OO is done properly, since FreeBASIC is done on essentially the same level of C/C++, we can just use the c stdlib and the c++ template library, along with a host of OO libraries and patterns to aide development. I see no reason for a fork, but I do see the potential for beginners to get lost, but with good coding practice, tutorials, and organization methods, even advanced OO concepts should be easy enough to melt into.
Nexinarus
Posts: 146
Joined: May 28, 2005 6:08
Location: Everywhere
Contact:

Postby Nexinarus » Sep 29, 2008 8:03

Ah - I will look at that ;).

So you are saying that, there will be several standard libraries to choose from? So if you wanna use procedural standard fb lib, dont do anything. If you wanna use FB-OO standard lib, include one of the objects you want?

I suppose that would work.
Imortis
Moderator
Posts: 1725
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Postby Imortis » Sep 29, 2008 10:55

Nexinarus wrote:Ah - I will look at that ;).

So you are saying that, there will be several standard libraries to choose from? So if you wanna use procedural standard fb lib, dont do anything. If you wanna use FB-OO standard lib, include one of the objects you want?

I suppose that would work.


That is the way I understood it to work. Don't you include "std" is C++?
fabrizio
Posts: 73
Joined: Sep 29, 2006 13:39
Location: Roma, Italy

Postby fabrizio » Sep 29, 2008 11:47

Myself, I'm curious as to what effect it will have in the development of FB.

Will it be rewritten in the then available OO paradigm? Or will it remain wholly procedural underneath, without taking advantage of the new capabilities? Or will it sport a combination of the two, becoming more complex to maintain?

In any case, apart from inheritance, what is the difference between a module and a class, anyway?
angros47
Posts: 1670
Joined: Jun 21, 2005 19:04

Postby angros47 » Sep 29, 2008 13:11

I think that the best solution would be an option to have semi-OOP (like in RapidQ) even in FBLITE.

My idea was to have, in Fblite, OOP without operators, and with simplified constructors: in that way GUI programming would be a lot easier, but the rest of the program wouldn't need changes (because implicit declarations and suffix should still work)
jevans4949
Posts: 1153
Joined: May 08, 2006 21:58
Location: Crewe, England

Postby jevans4949 » Sep 29, 2008 15:01

Ummm, to what extent do you expect OO to change FB - apart from a few new keywords?

After all, C++ compilers still support official C standards.
Deleter
Posts: 975
Joined: Jun 22, 2005 22:33

Postby Deleter » Sep 29, 2008 16:56

Any simple functions can be written with OO or without it easily. Anything complicated won't really be needed by beginners in the first place, and thus if its only available in OO form I don't see that being a problem. And if fb continues the basic mantra of making things, well, basic, then I don't see why it can't be extended to oop. Sure there might be complicated power functionality (templates? etc), but I think oop can be made easy to understand even to beginners, it will simply be the next step:

series of instructions only -> +procedures -> +types -> +oop

It was natural enough when I learned it...
angros47
Posts: 1670
Joined: Jun 21, 2005 19:04

Postby angros47 » Sep 29, 2008 18:41

I think that OOP is very useful when building GUI apps: maybe FB should have built-in objects (like FORM, BUTTON, CHECKBOX, RADIO...) to help programmer in this task, and to make portability easier (built-in commands are platform-independent).
In fact, tha main advantage of FreeBasic over C/C++ is that, having built-in graphic commands, you don't need to rely of platform-dependent features like API, Ints, third parts libraries... when building a graphic application: so why not using a similar solution for GUI interface?
When OOP features will be complete, a standard library integrated in the compiler should be easy to do: it'd have to be loaded only when needed (like FBGFX is), and there should be an option to disable it (if the programmer needs the reserved keywords to re-define them.

The only trouble is, OOP shouldn't force the use of a new coding style: what I liked about RapidQ was the "hybrid" syntax, that offers a lot of freedom: I was able to code in "classic" basic, and use OOP only for GUI, graphics, and a few of other things.
I'd like to see a similar feature in FreeBasic (after all, the "freedom" of coding styles has decreted the success of QB and RapidQ)

I understand that with a real, full supported OOP some features must be changed (without explicit declarations, maybe class operators would be too ambiguos), but a "OOP lite" in FBLite could give some of the advantages of object programming, without the disadvantages: also, it will help programmers to migrate towards OOP (I learned a lot about OOP reading the "custom controls creation" chapter in RapidQ manual: it's a lot easier than the abstract examples in C++ tutorials)
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » Sep 29, 2008 19:33

It seems to me that OO techniques are always taught along with the basics of programming in a course that starts with an OO capable language. I think this is a bad thing because complex OO features are not always necessary for a problem. We've been using only basic OO (like TYPEs) for decades, and we have come up with some amazing programs.

So... the reason why people teach OO and basic programming at the same time (which again, I think is bad) are:

1) Time -- prof/teacher wants to teach two things at once.
2) Lack of defaults. If you want to even add, make a "math" object that uses a math library function. If you want to print, use a "text" object that uses a basic screen output library function.

For Freebasic to be successful in adding OO, we certainly can't change the first item there. We can definitely change the second one, and I think Freebasic is on the right track:

Freebasic keeps default libraries hidden from view -- you don't have to include them explicitly. At the same time, you may opt to exclude them, and they are not abnormalities as they are simply the "default" namespace.

If the devs:

*maintain the ability to create simple programs without a lot of preparation, while...
*allowing programmers to inject object-oriented programming into their functions in a stand-alone way in the same manner as the default functions-- allow a function or piece of code to use OO without complicating the current language.

...then I think the inclusion of complex object-oriented programming will be a great success.
angros47
Posts: 1670
Joined: Jun 21, 2005 19:04

Postby angros47 » Sep 29, 2008 21:07

You're right: you have to know linear programming to understand procedural programming, and you have to know procedural programming to understand OOP: it's pointless trying to learn what a class is before knowing what types, functions or variables are.
Also, don't you think that having UDT and classes, but not strings (that are a bit more important, right?) is a nonsense? C is directly converted to ASM, so there is no runtime core; but C++ has a runtime library, so strings could be implemented (and in D are implemented, in fact)

Usually, Basic (QB and FB) is easy to learn, because a newbie first start messing with built-in commands (mainly graphic and sound), then tries adding its own (using SUBs)
To learn OOP, the best way would be starting with simple, built-in classes to build windows, buttons and so on, then trying building custom controls
anonymous1337
Posts: 5494
Joined: Sep 12, 2005 20:06
Location: California

Postby anonymous1337 » Sep 29, 2008 21:12

My Advice - Learn a few programming paradigms then use whatever the heck works best at the moment. You *know* when a project is too big to manage without using a more standard programming model. And no, OO is not going to solve the problem of you having to do actual work.

I recently wrote a converter from Windows Media Player playlists to Winamp playlists. At first, I used a bunch of types and udt procs, but I was over 200LOC and decided I had done something wrong. I rewrote it from scratch, solving the problem in its more pure, immediate format. I ended up a with 75LOC converter that simply did the god damned job.
angros47
Posts: 1670
Joined: Jun 21, 2005 19:04

Postby angros47 » Sep 29, 2008 22:07

For medium-sized project, I'm going to use FBLITE; when I have to do biggest project, I can use FB (it forces me to use a more standard paradigm, but provides access to whole features).

In FBLITE, I need a "free" environment, where I can use the coding style that i think will fit better to the task; in FB, instead, a standard coding style could be useful for projects involving more than one programmer.
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Postby Lachie Dazdarian » Sep 29, 2008 22:26

I really don't like the sound of FB forking. ;)
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Postby notthecheatr » Sep 29, 2008 23:16

I only use OO in larger programs where I need the interface to be properly formed. My little programs that I throw together in two minutes as proof of concept or to solve a simple problem, I never use OO. Which is why even though I love C++ I'll never use it for my little programs. FreeBASIC is so much faster for that stuff :D

I've written a lot of neat little programs (be it particle effects or a program to modify the saved state of Cave Story so I can see the end of the story without actually playing the game through) without any OOP at all. And none of my OOP programs have amounted to much, but that won't stop me from using it when I'm working on a larger program. It just makes more sense.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests