A Serious Article Debating the Pros and Cons of FreeBASIC

For other topics related to the FreeBASIC project or its community.
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Sep 24, 2009 14:46

marcov wrote:(oh, and don't OOP what aren't already objects)

I'm not sure what you mean here.

(maybe also the method kind, which adds an instance reference)

No, not at this time. There was idle talk of trying some form of Delegate construct, but nothing came of it. C++'s member function pointers are a bit ugly-- IMHO--and Delegates may make more BASIC sense anyway.. (C++ had to integrate similar functionality in the stdlib, done better by Boost)

To my best knowledge, [neither C++/Java/xxx] have support for [Vistor]. Some of their libraries do, but it is not a language feature.

IOW if you really want this, start designing FB template support (you'll need it anyway for when you come back from C++) ( :-) :-))

But anyway, I wouldn't use features that won't be easy to add to the initial in basic compiler. It will only make that already horrible hard decision harder.

I wasn't talking about having 1st class support for Visitor, but those familiar with those languages can generally see the pattern well. I know that C programmers are very familiar with "void *", unions and functions pointers, but the point is that other languages support the design in a more "friendly" and extensible/flexible way, without the use of dangerous casting or excessive boilerplate.

But yes, the idea would be to create a design that's easily portable, which for Visitor would only need some method of double-dispatch--either run-time or compile-time polymorphism, but I imagine templates/generics would come later..

I don't even think you'll make it till then. It will have forked into oblivion, by the people that want to stick/port to C++/Java/C# and maybe a bit more over compiler versions, OSes etc.

C++ ian sich will be pretty similar, but build systems, approaches, library use, use of newer C++ standards (Boost etc), way to interface assembler etc won't.

If the project was entered into without any forethought whatsoever, then I agree. Forking into a different language implies that the old language wasn't suitable for the task (for instance, the interest in a C++ effort in the first place). I'm not interested in a rewrite in C++ for the sake of having something to do in C++.

Unfortunately make systems and other project files are not [portable]. And keep in mind that this is all work for a temporary measure that only indirectly contributes to the FB codebase.

I think the benefits of an OOD aren't to be understated like that, but then again, compilers are new to me.
marcov
Posts: 3011
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Sep 24, 2009 19:25

stylin wrote:
marcov wrote:(oh, and don't OOP what aren't already objects)

I'm not sure what you mean here.

Trying to OOPize anything, even if it is only a basic struct.

(maybe also the method kind, which adds an instance reference)

No, not at this time. There was idle talk of trying some form of Delegate construct, but nothing came of it. C++'s member function pointers are a bit ugly-- IMHO--and Delegates may make more BASIC sense anyway.. (C++ had to integrate similar functionality in the stdlib, done better by Boost)


IIRC C++ has a problem that they really tried to map to a single function pointer for a long time, messing with trampolines etc. I'm not sure if they cleaned that out in more recent standards.

I don't think this really is a problem for a new language/compiler, where you can simply have the method function variable as a structure with two pointers in it.

I wasn't talking about having 1st class support for Visitor, but those familiar with those languages can generally see the pattern well.


Yes, and they have generics. Not the easiests feature to start with. Moreover, for a limited set of classes a bit of typecasting and code duplication isn't that bad.

I know that C programmers are very familiar with "void *", unions and functions pointers, but the point is that other languages support the design in a more "friendly" and extensible/flexible way, without the use of dangerous casting or excessive boilerplate.


I think that is a bit exaggerated, both the pains as the gains IOW while all you say is true, I don't agree with the tradeoff.

Partially also because compiler trees are so polymorphic with lot of special cases depending on type, and not business code with a simple visitor pass. For the few applications, the code duplication is acceptable.

But yes, the idea would be to create a design that's easily portable, which for Visitor would only need some method of double-dispatch--either run-time or compile-time polymorphism, but I imagine templates/generics would come later.


Generics are only needed if you want to recycle the visitor code for multiple base types. They are nice, but IMHO typesafe containers are more desirable from generics than trying to recycle patterns.

If the project was entered into without any forethought whatsoever, then I agree. Forking into a different language implies that the old language wasn't suitable for the task (for instance, the interest in a C++ effort in the first place). I'm not interested in a rewrite in C++ for the sake of having something to do in C++.


It implies that people think that the old language wasn't suitable. There is a difference :-)


I think the benefits of an OOD aren't to be understated like that, but then again, compilers are new to me.


The strange part is that your route seems to postpone that same useful OOD coming to FB :-)
Eponasoft
Posts: 264
Joined: Jul 26, 2007 2:40

Postby Eponasoft » Sep 24, 2009 21:58

This thread is again reminding me of why I stopped upgrading FB at 0.16. Too many things change and point towards OOP, which is never what I wanted to see. Not all of us like OOP or even see its so-called usefulness. So yeah...y'all enjoy this fruitless debate; I'm going back to procedural land where things make sense.
Hard
Posts: 135
Joined: Aug 29, 2008 21:13

Postby Hard » Sep 24, 2009 23:52

i'd love to see fb as a c wrapper, but thats only my opinion.

for me fb is kind of like a hobby language, even though i write professional programs with it. anyway if i really wanna sell my programms (which are huge and relly need to be stable) i kind of need to port them to c/cpp. why? stability and bugs! oh gush its so annoying to work with the double<>ulongint conversion ...

even more fb would then be a bridge for those who wanna learn c/cpp and come from basic (cause they can compare the basic and the wrapped c code).

maybe that is not what you wanna have for this project what is coherent, too. but this is just sth that really makes sense to me.

Eponasoft wrote:Not all of us like OOP or even see its so-called usefulness.


i am one of those, too.

but i use 20.0b and have no problems, not using all the oop stuff :P
John Spikowski
Posts: 453
Joined: Dec 24, 2005 2:32
Location: WA - USA
Contact:

Postby John Spikowski » Sep 25, 2009 0:10

I don't want to be accused of meddling in the business of the Basic but it would seem to me the most important first step is to document what you already have. Unless a new project is just that, a new Basic compiler and the sins of the past are best left forgotten.

The longer you guys wait on this, the more that is forgotten and asking founding fathers for another round may be asking too much.
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Sep 25, 2009 2:19

marcov wrote:Trying to OOPize anything, even if it is only a basic struct.

Oh, OK. I agree.

Yes, and they have generics. Not the easiests feature to start with. Moreover, for a limited set of classes a bit of typecasting and code duplication isn't that bad.

Good point. I don't know how deep or wide the hiearchies may eventually get. But, we'll leave that to UML. :)

I think that is a bit exaggerated, both the pains as the gains IOW while all you say is true, I don't agree with the tradeoff.

Perhaps I was being a little morbid there; just saying what's easier for me.

The strange part is that your route seems to postpone that same useful OOD coming to FB :-)

Like I said, I'm guilty as well. I've helped with the manual more than the compiler, and not that for a while. Still, I don't know that it would postpone those features necessarily.. Race to the finish ? :)
jcfuller
Posts: 324
Joined: Sep 03, 2007 18:40

Postby jcfuller » Sep 25, 2009 16:39

As this posting is drifting about I hope this is still somewhere near on topic.

First: was V1ctor the only gas programmer of the developers or are there others?

If a better oop object format is desired, while staying with the current asm emitter, would a translation of ObjAsm32 ( http://objasm32.winasm.net/ ) from masm format to gas be feasible?

James
marcov
Posts: 3011
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Sep 26, 2009 11:23


The strange part is that your route seems to postpone that same useful OOD coming to FB :-)

Like I said, I'm guilty as well. I've helped with the manual more than the compiler, and not that for a while. Still, I don't know that it would postpone those features necessarily.. Race to the finish ? :)


If FB was your implementation language, the motivation to quickly add (and stabilize) them would be way larger.
John Spikowski
Posts: 453
Joined: Dec 24, 2005 2:32
Location: WA - USA
Contact:

Postby John Spikowski » Oct 09, 2009 0:53

jcfuller wrote:As this posting is drifting about I hope this is still somewhere near on topic.

First: was V1ctor the only gas programmer of the developers or are there others?

If a better oop object format is desired, while staying with the current asm emitter, would a translation of ObjAsm32 ( http://objasm32.winasm.net/ ) from masm format to gas be feasible?

James


Is the idea of a new FreeBASIC compiler still being considered by the developers? Has any decissions been made on direction or what tools would be used?
aurelVZAB
Posts: 342
Joined: Jul 02, 2008 14:55
Location: Croatia
Contact:

Postby aurelVZAB » Oct 09, 2009 17:58

Not all of us like OOP or even see its so-called usefulness.


I'm also one of you.
If someone like OOP - it's nothing wrong.
I prefer good old procedural and like current way of programming in
Free Basic..[/quote]
John Spikowski
Posts: 453
Joined: Dec 24, 2005 2:32
Location: WA - USA
Contact:

Postby John Spikowski » Oct 09, 2009 18:34

Since this thread is all over the place, an OOP discussion seems in order.

Here is a recent example of ScriptBasic OOP I'm playing around with. Modules are namespaces in SB and work well as class definitions.
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Oct 09, 2009 19:45

John, while the thread has drifted a bit, I fail to see how your ScriptBasic code has anything to do with it. The fact that FreeBASIC currently supports the mechanisms your code (and the similar, in some cases identical, FB code on these very forums) laboriously implements -- namely object allocation/initialization/methods/destruction within namespaces -- makes me scratch my head as to why you would post such an ugly example (the FB code that does the same thing is ugly too). Let's not devolve the language now as well as the discussion.
John Spikowski
Posts: 453
Joined: Dec 24, 2005 2:32
Location: WA - USA
Contact:

Postby John Spikowski » Oct 09, 2009 20:09

Sorry. I didn't mean to affend anyone showing off my ugly child. ;-)

The example reference was to show how a top/down interpreter can be used in a OO programming style. It's not for everyone but it's nice to know the option is there if you want to use it. I really don't think it's that ugly IMHO.
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Oct 09, 2009 22:13

John, sorry, I didn't mean to be rude. It's just that the same code could be written in C (or QB, for that matter) and would be equally relevant to the thread.

Just to make myself clear, I think it's ugly as a demonstration of OOP because there is no automation going on whatsoever; "destructors" must still be called manually regardless of scope and the "next new instance" index must be kept track of (think about what you have to do to support multiple constructors, for instance). IMO, productive discussion should be about what kinds of things FreeBASIC needs in order to eliminate this kind of repetitive and error-prone code.
John Spikowski
Posts: 453
Joined: Dec 24, 2005 2:32
Location: WA - USA
Contact:

Postby John Spikowski » Oct 09, 2009 23:39

John, sorry, I didn't mean to be rude.


Just in time, I had one foot off the bridge. ;-)

I'm not sure what this thread is about anymore. I'll go back into lurk mode till you guys figure it out.

Return to “Community Discussion”

Who is online

Users browsing this forum: Landeel and 3 guests