Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Rick, your opinion on Obeject Oriented Programming

Author
Message
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 23rd Nov 2002 07:27
Hey Rick, I was kinda curious. I had mentioned in the what would you like to see in Dark Basic Pro post that I would like OO implemented into Dark Basic Pro. I was kinda curious your take on this? I would think that OO would be good for those who wanted to flex their programming skills and implement it into their programs.
Thanks.
SoulMan
I am my own and own my am I
striker25
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location:
Posted: 23rd Nov 2002 08:20
I agree soulman

MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 23rd Nov 2002 12:13
I would have thought making BASIC object oriented - firstly because BASIC is supposed to be, well, basic - simple to use and understand. Adding OO would contradict everything BASIC stands for.

Good news everybody! I really am THAT good...
haggisman
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 23rd Nov 2002 12:31
As it has already been said earlier, OO doesn't have to be compulsary, a bit like all those complicated 3d Math commands. I'd surely hope DBS wouldn't restrict themselves from expanding the language due to some ancient definition of what BASIC should be.

Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 23rd Nov 2002 13:58
MrTAToad, what you said doesn't make sense.

Visual Basic is still BASIC, but it supports Object Orientated programming. It can make life a hell of a lot easier at times. OO is much easier to do than BASIC.

what is a signature?
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 23rd Nov 2002 16:08
Visual Basic is a pain to use.

It would put a lot of new people off if OO was used.

Do you find usin friends, inheritence and overloading easier to use than straight-forward BASIC?

Good news everybody! I really am THAT good...
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 23rd Nov 2002 16:38
There are things way more important to do then change a working syntax. I have tried VB for ASP but I really don't like VB at all. I much rather use PHP.

Example - printing out text
VB: document.write "Hello World"
PHP: echo "Hello World"

Setting up an SQL connection in VB takes 2-4 lines of code that my ASP teacher didn't even understand. PHP uses one single command that everybody understands.

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 23rd Nov 2002 18:40
MrTAToad and Dead Glory, did it occur to you that

A.) It wouldn't change the syntax of Dark Basic Pro
B.) You could continue to program to how you like without having to use OO(You don't even have to use it in C++ but of course you won't get far with that)
C.) That by putting in OO into Dark Basic Pro those who have advanced programming skills can flex them
D.)That those who know it and those who will learn will find that it makes development go faster
E.) It would solve not being able to pass UDT's to functions, you would have member functions that would work just fine.

Of course you would want to be able to pass UDT to functions later on. Maybe now would be a good time to start working on OO and fixing the UDT passing to functions.
OO is a good teaching tool about objects, much so than UDT's. I don't think it would be that hard to implement OO into Dark Basic Pro. If you didn't want to use it, you wouldn't have to.
SoulMan

I am my own and own my am I
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Nov 2002 18:45
We don't need full OO support.

If we had the ability to pass variables into functions by reference instead of by value, and we could do this with UDTs, we would get a good part of the benefits of OO programming without requiring a full re-write of the compiler.

We do need:
to be able to pass UDT's into functions.
to be able to pass variables by reference.
to force variable declaration.
overloaded functions (functions with identical names but different parameters)

We do not need:
inheritance (especially not multiple inheritance).

This would allow you to create a type:


and call it like so:


See - we don't even need the address of the type - it's all hidden from us keeping things BASIC
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 23rd Nov 2002 19:20
UDT's aren't even true OO.
If it was true OO, then you could only manipulate the variables inside the structure by member functions.
Example code of what a class in DBP might look like

What's so hard about this?
To explain to the common man, a class is like a UDT only it has member functions and you specify inside the class if variables or functions are private, public or protected.

Private - you can only access through a public function
Public - you can call the function but must be used with a defined object in your code
Protected - It's like private but used to give access to
other classes derived of that one class.
Then to make an object all you need to do is

employee programmerInfo
That is all you would need to do. Just like a UDT, but with full class implementation.
OO is the way to go.
SoulMan

I am my own and own my am I
DrakeX
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 23rd Nov 2002 19:30
...except member functions are pointless if you're not going to be making inherited classes. you can just as easily call a function on a class as you can call a class's member function.

and since all member functions really do is modify the class's data, they're somewhat useless in DBP. wel can do that with external functions, really.

i'm looking at yooooou!
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Nov 2002 19:42
Right.

No-one NEEDS OO - it's just another way of doing the job. But DBPro is supposed to be BASIC not C++ - it took me years to learn how to properly use objects/inheritance/polymorphism and its still not easy.

With 'byref' you get as much as is needed, but no more (I'm paraphrasing Einstein here - quite a clever chap by all accounts).
Megaman X
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location: Sweden
Posted: 23rd Nov 2002 21:58
I just love Visual Basic Seems so clear and u can make so many useful things with that. I actually am not a Microsoft fan, but since DirectX 7.0 which could be used with Visual Basic, makes me look at this toy diferently. But I don't have time to read another long book... and expensive they are too about OO and DirectX for VB

I don't suffer from insanity, I enjoy every minute of it.
-- Rogue
crawlin
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 23rd Nov 2002 22:38
everyone has a different style of coding. I like too use OO so that I can make my code as modular as possible i.e. writing some code like DB access (in PHP) ina class in a seperate file and then just using that in all my projects. Of course others will want to do it there own way and thats fine. DBPro should cater for as many styles as possible and, as I have said, OO is one. Its not that complicated anyway.

Please Visit [Dark-BASIC UK] :: 100% Unofficial Home Of The DarkBASIC Professional Programming
Language - db-pro.co.uk
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Nov 2002 23:42
I beg to differ ... an OO compiler *IS* that complicated.

But the real point is that OO is not easy and as I said before, DBPro is BASIC.
crawlin
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 23rd Nov 2002 23:54
i'm not talking about the code behind the DBPro Compiler thats Mike's and Lee's job. I mean the code we use for example it could be:

class cTestClass
name as public string
age as public integer
dob as private string

function dob()
return dob
endfunction
endclass

class cTestTwo derive cTestClass
house as private integer
road as public string
endclass

test as cTestTwo
test->name = "john"
test->age = "25"
test->dob = "33/13/9999" (compiler would flag as error - private)
dob = test->dob()
test->house = 22 (error - private)

this isn't that complicated and this involves functions, private and public member variables and inheretence. I can see many uses for this such as a base enemy class with x,y,x and movement function and then specific classes like dog that has its own functions like bark() etc

Please Visit [Dark-BASIC UK] :: 100% Unofficial Home Of The DarkBASIC Professional Programming
Language - db-pro.co.uk
Viktor
21
Years of Service
User Offline
Joined: 7th Oct 2002
Location: Austria
Posted: 24th Nov 2002 00:04
No one needs OO!!! The first thing I did in Visual Basic was the start of deinstallation routine after reading the manual. It was a real waste of money. DBP was a waste, but if after the bugs are fixed, please do not mess it up with OO coz no one really needs this. If someone needs it, use VB or similar languages.
Dark Basic with OO is not a Dark Basic anymore, baka baka! (Not a personal attack on anyone). And I preffer really the DB style of coding a lot more than the VB´s style, or even XBasic.
And Btw: I Allready coded some progs in RapidQ, and this is OO too, so I know how stupid the idea of OO is.
DO NOT mess up DBP with OO... Please...

-----------------------------------------------------
PC: Amd Athlon 1200/512 Mb SDRam/GeForce2MX Dual Display Video/Win2000, 19" Monitor
ZX: ZX Spectrum 128+ Customized version.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Nov 2002 00:11
type TestType
name as string
age as integer
dob as string
endtype

function dob(byref this as TestType)
endfunction this.dob

type TestType2
tt as TestType
road as string
endtype

x as TestType2
x.tt.name="john"
x.tt.age=25
mydob=dob(x.tt)

VB got away without having inheritance for a long time using just this technique. I understand all of the pro's of OO programming - I'm a C++ programmer myself. I just don't see the need to complicate a (currently) easy to use language and scare off beginners.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 24th Nov 2002 00:13
Why
test->name = "John"
and not
test.name = "John"
(the same syntax is used with types).

Well, it would be nice to have objects with events (eg: collisions). I would really appreciate OO Basic (or preferably Object Pascal ) but IMHO that would only make sense if it is consequently implemented; and that would mean a drastic change to the current syntax.

Ogres have layers.
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 24th Nov 2002 01:35
People, some of you don't even realize that you DON'T HAVE TO USE IT IF YOU DON'T WANT TO!!!
READ BETWEEN THE LINES!!!!!!
GOSH DARN IT!!!!
NO ONE READS THE ENTIRE POST!!!!!!!!!!!!!!!!!!
THEY NEVER DO!!!
YOU MISS PART OF WHAT I AM SAYING.
Dark Basic Pro is not just Basic. It includes much more than Basic. Anyone remember how Basic or QBasic was in the first place?
Plus it's not just Dark Basic anymore, it's Dark Basic Professional, you see professionals use OO to do any programming. In fact, even Rick can tell you that Dark Basic and Dark Basic Pro was programmed in C++ which uses OO. If you don't know how to program OO like I do, don't knock on what you don't understand. OO is good and if you are going to become a professional programmer you will need to learn this stuff. Otherwise you are going to stagnate on programming if you don't learn OO.
Yes I know some of you are C++, but try to understand from my perspective. I want to program in OO. By expanding to OO you are keeping the future of Dark Basic Pro alive.
SoulMan

I am my own and own my am I
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 24th Nov 2002 02:11
"if you are going to become a professional programmer you will need to learn this stuff."
Well, how many of the DB(pro) users do want to become professionals?

I would suggest (if possible) to release something like an SDK that let's you sort of implement DBpro in other languages like C++/# or Delphi, so that DB handles the low-level DirectX stuff. 3DGS did something like that.

Ogres have layers.
The One Ring
21
Years of Service
User Offline
Joined: 15th Sep 2002
Location: United States
Posted: 24th Nov 2002 02:55
This is an interesting thread... Having a background in C/C++, I really don't care if DBP goes OO or not. Truly, the ability to creates classes would be an added benifit.

DBP Team, do whatever makes the product better, keeps the customer happy, and make you guys money!

AMD Athlon 900 768MB DDR
ATI Radeon 64MB DDR All-In-Wonder 7500, ATI XPert 128 16MB
Sound Blaster Audigy Gamer w/FireWire Support
Viktor
21
Years of Service
User Offline
Joined: 7th Oct 2002
Location: Austria
Posted: 24th Nov 2002 03:26
Keep Dark Basic Professional OO-Free. If someone wants to make professional games, he/she uses C++, and no Basic. Basic has to be Basic and not OOBasic-thingie.

-----------------------------------------------------
PC: Amd Athlon 1200/512 Mb SDRam/GeForce2MX Dual Display Video/Win2000, 19" Monitor
ZX: ZX Spectrum 128+ Customized version.
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Nov 2002 03:44
TYPED Arrays are the closest component to adressing OO type objects in DBP at the momo.

I dont see the harm in adding a few commands for OOP.

As said above u dont have to use them if u think there (gay what has the internet come to with everything thats bad is gay ugg)

I wouldnt mind a clone object command to save multiple loading.

You could also prolly make your own pusedo method with memblocks or some fancy DLL work perhaps.


Whats your solution for managing hundreds of multiple objects then Viktor?

Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 24th Nov 2002 04:25
Basic just isn't an OO language, it never has been and never will be. I agree with MrTAToad, you want OOP, learn Python or C++

BTW OOP isn't everything, granted it can be very helpful modeling real world stuff using objects but you can still do this the 'old fashioned way' using normal programming methods in Basic. My opinion is DB shouldn't try to incorporate OOP, it just wouldn't be basic then!

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Nov 2002 04:29
what are types then?

are they not a basis to the start of an OOP style, like classes.

there in there and since many games use multiples it would help.

Steverino
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United States
Posted: 24th Nov 2002 07:19
If DBP goes down the Alley OOP, it'll lose the readable, understandable linear quality that makes it fun to program in. If I wanted Visual Basic or C++, that's what I'd use. My limited exposure to those, though, they just seem creepy.

Surrealist writing toy -- http://www.iconpoet.com
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Nov 2002 08:39
some of us wouldlike access to more OOP, u dont have to use those commands

heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 24th Nov 2002 09:06
OOP?
OOPS is more like it.
CODE IS BINARY.
However you want to look at it, you can only flip the switches on or off, tru or false, in or out, up or down, 1 or 0.
Everything else is smoke and mirrors.
If you look at some OO code it really is "structured programming" gone insane.
Give me procedural methodology any day any time.
(That's FORTRAN, C, PASCAL, PL-1, COBOL and BASIC.
I feel sorry for Lee Bamber having to code using M$ Visual Studio. What a bunch of hoops to jump through!
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Nov 2002 09:53
granted we all like our own flavours.
and all could be used in harmony

and if theres enough reason for it to be used effectively in games, Im thinking RPGS and RTS etc.. then why not have it as an option?? why deprive yourself of a tool because your other experiences with it were flawed, take this opportunity now to solve some things u did or didnt like and rationlise it out so it could be for DB.


think more its free

SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 24th Nov 2002 10:03
Dude, you don't even understand the power that OO even gives to you.
Do you even program in C++ at all? If you don't I wouldn't understand in the world why someone with no experiance with OO would even bad mouth it. Do you not understand that over 85% of the programming today now uses C++ with OO. In C++ you couldn't even program something without OO because you are using OO to begin with.
Why you might ask.
Hmmm, well for starters cin>> and cout << are part of OO.
Yes without OO, you would be stuck to using printf and scanf. cin >> and cout << made things EASIER TO UNDERSTAND
For instance I show you C code which doesn't use OO
and I will show you C++ which has OO

C print statement
printf("%d%d%d%d Now tell me this looks clean",a,b,c,d);

C++ Print Statement

cout << a << b << c << d<< "Now tell me this looks better";

C Input Statement

scanf("%d%d%d",&a,&b,&c);

C++ Input Statement

cin >>a>>b>>c;

WIthout OO programming, you wouldn't have been able to get cin or cout without throwing in assembler into the mix which brings up, would you even want to?
Don't knock anything unless you know what you are talking about aka EXPERIANCE
Soulman

I am my own and own my am I
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Nov 2002 11:38
Its amazing how little sense my sentences make when they're read again... Oh well...

I would have thought in order to add OO features the whole system have to be re-written, unless you dont want OO to interact with normal functions.

Good news everybody! I really am THAT good...
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 24th Nov 2002 11:53
i had in mind maybe more cloning features for media
as types suit me so far.

crawlin
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 24th Nov 2002 12:46
i really don't see what everyone has against OO! If they added it you coiuld just think of it like the 3D Maths commands - they are there but you DON'T have too use them. I like coding OO and it is another option. No one is saying that the language has become completly OO. It is another style - some people will find it easy (i know it makes more sense to me) and some people won't - and I think DBPro should cater for as many people as possible.

Please Visit [Dark-BASIC UK] :: 100% Unofficial Home Of The DarkBASIC Professional Programming
Language - db-pro.co.uk
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Nov 2002 13:04
Soulman:
I do read the posts all of the way through. Your c/c++ example is flawed. It is not OO, it is an example of function overloading of the functions operator<< and operator>>. I do understand the power of c++ - I use it professionally.

OO promises 2 things - The first is reuse of code, however I don't believe that any games house today reuses code to any great extent, except for expansion of existing games, or when buying in an engine - too much changes between games. The second is information hiding, and you can get the same effect by using modular programming.

MrTAToad: I agree. Thats what I was trying to say when I said it is difficult to do. If it wasn't, then c++ would not have taken 18 years from kickoff to get to standardisation - and there is still not one fully compliant compiler available (yes I know that some come close).

OO is not a magic wand that you can wave to make things right. It is *MANY* times harder to design and code an OO system then a modular system when doing it properly.

If you really want OO, then why not write your own front-end ... just like the inventor of C++ did If we ever get pass-by-reference it might just be possible. (Err ... that last was not a dig at DBS ... but it would be nice).
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 24th Nov 2002 14:29
[quote]
C print statement
printf("%d%d%d%d Now tell me this looks clean",a,b,c,d);

C++ Print Statement

cout << a << b << c << d<< "Now tell me this looks better";

C Input Statement

scanf("%d%d%d",&a,&b,&c);

C++ Input Statement

cin >>a>>b>>c;
[quote]

These examples have nothing whatsoever to do with OOP. There just enhancements. I have coded extensively using python (next gen of OOP IMHO) and agree it can be extremely useful in the right project, but OOP in a Basic? no thanks! Basic being basic is what makes basic fun.

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Nov 2002 15:00
To me, the printf statement has always been clearer than cin, mainly because cin << "test" makes it look like your trying to perform a left-shift on test...

Good news everybody! I really am THAT good...
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Nov 2002 15:09
It should be cout actually..

Good news everybody! I really am THAT good...
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 24th Nov 2002 16:47
MrTAToad,

Visual Basic is stupidly easy to use, even easier than DBPro.

It is possible to make OO completely optional.

what is a signature?
Megaman X
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location: Sweden
Posted: 24th Nov 2002 19:54
Gay? Did anyone say gay?... I dunno about gay, but Tatu ROCKS.... it's on those times I wish to be lesbian?

I don't suffer from insanity, I enjoy every minute of it.
-- Rogue
Bitmap
21
Years of Service
User Offline
Joined: 20th Oct 2002
Location: Latvia
Posted: 24th Nov 2002 19:58
>> My opinion is DB shouldn't try to incorporate OOP, it just wouldn't be basic then!

yeah, your right Kale... it would be better, more flexible, advanced.....

thy boss
mamaji4
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location:
Posted: 24th Nov 2002 20:47
Game programming is about speed. That's why 3DGS still runs on DOS and Quake was written to run on DOS. Also the game loop is basically procedural, and a procedural language is therefor good enough. Also procedural loops are better at handling real time events. Also, C++ compilers are known to produce far less efficient code than C compilers. If you use the OO commands of DBPro your going to get 1)an FPS hit 2)The executable will be larger , than if you were to do the same in a procedural manner.
My arguement of course doesn't really hold true for any other type of programming task, because OO programs do provide for maintainable, scalable design. I am specifically talkin about game programming.
Finally if you really need to use OO you could always use C++ and some other game engine that supports it (There are quite a few of them.)
A final note. DarkBasic is an abstraction built upon DirectX using C++, to simplify the programming paradigm. Now you want to introduce another level of abstraction to revert back to OO in DBPro. You are going to get extremely inefficient, slow compiled code for your games.

Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Nov 2002 22:58
hmm... i wonder what object orientate language actually means, because from what i understand of it - it is just allowing for quicker manipulation access by allowing variables to be used as an object on a function class...
giving the variable an ownership and value within the class!

now erm don't the types do this?
to me it is no different to code something in C++ really as it is to do it within DarkBasic, just a few minor alterations with the Types instead of Classes.

and pointers have been around in C and have absolutly NOTHING to do with Object Orientation because from what I understand only C++ uses it, if this is the case then how can C use this OOL stuff when only C++ really is? Hmm?

Personally yes i'd like to see pointers added, as well as variable Function usage - so you don't need complete function variables just the minimum.

eg... my rendermode function for DB,


now it would be good if there was a way to set it up that if i didn't use window mode i didn't set it up
so just type ->rendermode( 640,480,16 )
instead of rendermode( 640,480,16,0,0,0,0,"" )
(^_^)

just my tuppance worth here

Anata aru kowagaru no watashi!
Kale
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 25th Nov 2002 01:57
Quote: "yeah, your right Kale... it would be better, more flexible, advanced.....
"

but not as quick! you want an oop'd 3d language see jamagic, then check its speed

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
SoulMan
21
Years of Service
User Offline
Joined: 22nd Nov 2002
Location: In a house somewhere on the planet earth
Posted: 25th Nov 2002 07:03
Why would it matter now that a language supports OO and it's speed. If you are talking about Jamagic, I want to see an example program written with an OO approach using Classes and inheitance. Then I want to see the same program written in Dark Basic Pro using only procedual approach. Then I want to see a C++ version of the same code written in both OO and procedual. Now you tell me on a 3Ghz Machine, which one is faster than the last.


Plus the fact, Jamagic is not compiled. It's interpreted. It's just like Java. It's a VM like Dark Basic was.
Dark Basic Pro is 100% compiled. Java though fast can still run slow. For instance, Java Applets, you get too many going at the same time, it's going to bog any system down because the VM just can't keep up. It acts like a computer but is slower than the actual hardware. Until they come out with Hardwired Java chips that execute code, you will never see it run very fast. Now to start answering some of your other questions.
I am both a C++ and C programmer. Having said that, I went a head tonight and programmed up two similar programs in both C++ and C.
In C++ I used classes
In C I used Structs and passed the struct by reference to the functions I made for it.
When I looked at the size of the EXE's that were produced, I was shocked! It was true that the C++ program was bigger. Yes, the C program was 204K and the C++ program was 224K. Yup a 9% size increase. Yup, a lot of people are going to be disappointed that a program fills their 20 gig hard drive up by 20Kilobytes more.
Now to put down anyone saying that OO is slow and
inefficient, let's put it this way. A guy buys your game. Installs it on his 2Ghz machine. Do you really think a few milliseconds are going to matter to the guy running the game? No really. Since the code is compiled, it's going to run as fast as the processor will allow it to. The only areas that you can get in trouble with speed is sorts and searches. I am not even sure why you are saying that OO is inefficient at speed. It isn't.
Heck, my friend programmed a Java program that runs faster on my machine than on his. Can you believe that? Even if the VM is suppose to run the same no matter how fast your computer is?
Why oh why would after having C++ this long we would be producing OO code that was inefficient coding to the procedual style of C. Why would the industry choose C++ over C. Hmmmm. Maybe the reason is that OO code is NOT inefficient? If it was inefficient they wouldn't be teaching C as an afterthought course in college. They wouldn't want C++ programmers, they would want more C programmers this day and age. iD Software wouldn't be programming Doom3 in C++. No, they would be doing it in C.

Ok, another point I would like to make. Operating Overloading and C++ way of intializing data.
You point out that cin and cout have nothing to do with OO. I beg to differ. If you have MSVC++ or Borland C++ open up a copy of your istream.h and ostream.h. Why, look at that, sitting inside a class are the overloaded operators. Hmmmm/ Plus as far as I know, Overloading Operators is apart of Object Oriented design. Without the ability to overload operators you wouldn't be able to copy one object to another without getting into shallow copying which won't work. Unless you use temp variables. So you would have to overload the = operator, but it would make more sense to overload the = operator.
Also, another point I would like to make. Any time you declare a variable in C++, you are treating it like an object.
Example code

#include <iostream.h>

int main()
{
int x = 5;
int y = 6;
int c = x + y;
cout << c;
return 0;
}
[\code]
Ok now that I have shown you that, look at this. It does THE SAME THING.

#include <iostream.h>

int main()
{
int x(5);
int y(6);
int c(x + y);
cout << c;
return 0;
}
[\code]
What does this mean? It means that C++ treats it's variables as Objects. In C++ we have what's called a constructor. In a class these are called to intialize the variables inside the class. Now with a class you can tell it how you want it to initialize or you can let the compiler do it for you.
Anyway, in C++, each time you declare a variable as type int also known as integer, you are creating an object of the class integer. When you do an int x = 5; you are passing the 5 to the constructor of class int. Although you can't directly access class int since it's a built in class, it's there. This is the same for any data type in C++ that's built in.

Next Point
"unless you dont want OO to interact with normal functions."
That's why we have friends. But why would you need to do that if you are coding private functions within the class?

Next
If you use the OO commands of DBPro your going to get 1)an FPS hit
What proves this? Nothing. The only things that matter are CPU, Amount of Ram and Video Card. Oh yeah, take already optimized C++ code, rewrite to C and see if you can get that 1 to 3 extra FPS. Yup, that makes sense.

Next
"how can C use this OOL stuff when only C++ really is? Hmm?"
Structs are an idea of OO, but they leave out two basic needs. Encapsulation and memeber functions to access member data. In C++ you can actually stick functions inside structs, but if you are already programming in C++, why would you want to use a struct? Structs are ok for some things, but I prefer classes. Usually I see structs used for making lists and I like that approach, but I would rather stick to using class to do linked list. Plus the STL provides one we can use if we so choose. Templating is good for linked lists.

Next
"A final note. DarkBasic is an abstraction built upon DirectX using C++, to simplify the programming paradigm."

DarkBasic/DarkBasic Pro makes it easy to use the Direct X API. It's not simplifying the programming paradigm any further than it already has been. You can make very complex DarkBasic Pro programs if you wanted to. Adding OO is not going to take away from how simplifyed it already is. It's giving those who have advanced skills the ability to use those skills.
This is what I want. If DBS added OO programming to Dark Basic Pro, it's not going to even bother you. You don't have to use it if you want to. It's for those who want it.
Repeat after me.
You don't have to use OO if you don't want to.
You don't have to use OO if you don't want to.
You don't have to use OO if you don't want to.
You don't have to use OO if you don't want to.
SoulMan

I am my own and own my am I
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Nov 2002 14:30
Sorry.
Yes, cin and cout are objects.
Yes, OO is very useful.

But I was pointing out the fact that you were using overloaded operators in your example, which are standard function calls, and have nothing to do with OO. What these calls do demonstrate though is the difficulty of parsing, identifying and transforming the following code :

cout << "Hello";

to this

operator<<( cout, "Hello" );

or even worse, this:

cout << "Hello" << endl << "How are you" << endl;

to

endl( operator<<( endl( operator<<( cout , "Hello" ) ), "How are you" ) );

or
cout* Temp=operator<<(cout, "Hello");
Temp=cout(Temp);
Temp=operator<<(Temp, "How are you");
Temp=cout(Temp);

I think you are underestimating the difficulty of adding OO to an existing language. Check out how long it took for C to properly become C++, and for VB5 to become VB.NET (VB6 was NOT properly OO).

I would rather Lee and Mike spent their time adding extra facilities to DBPro, instead of recoding the parser (which many people are saying is already too slow ... not me tho )
Viktor
21
Years of Service
User Offline
Joined: 7th Oct 2002
Location: Austria
Posted: 25th Nov 2002 16:08
@Soulman: If you are a C++ ace, so why do you use DBP? Beacuse it is easier? Because it is not OO?

-----------------------------------------------------
PC: Amd Athlon 1200/512 Mb SDRam/GeForce2MX Dual Display Video/Win2000, 19" Monitor
ZX: ZX Spectrum 128+ Customized version.
coyote
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location:
Posted: 25th Nov 2002 16:20
without smartxxx talking, spend more time for making fun game with dbp, dudes.
Shadow Robert
21
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Nov 2002 17:07
Erm... did i miss something?
When did Doom3 start being programming in C++??
Oh well nm - I'm still not sure about this whole OOL stuff ya know, quite franly Types work and act just like Classes and if classes are basically what puts the ++ in C++ then explain to me how that isn't Object Orientation.

Functions and such can be assigned objects within which they work on!

I think the main point forgotten here is, so a simple program you made is 9% bigger in C++ and ran a few milliseconds slower ... well complex games have THOUSANDS of these little programs running at once.
When everything compounds up those few milliseconds turn into seconds, which turn into minutes.

Best example I can give are the BSP compilers around, I have a Quake3 BSP/RAD/VIS compiler which is from id software which are C based, it'll build a simple box with a light and start point in around 23seconds.
I also have GTK's Quake3 Compilers which are C++ based, and it'll take 31seconds for the same task.

you thinkin' so what 8seconds!
But thats 8 seconds PER box... when you get into levels of say 60box's and such the difference is EXTREMELY noticeable.

Yes the ease and benifits outweight the minor speed problems, but at the end of the day the language isn't faster - and for more complex operations this is very plain to see!

Anata aru kowagaru no watashi!
Ratty Rat
21
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 25th Nov 2002 18:19
Typically sitting on the fence I would add these points:-

The Object Orientated approach is a methodology for approaching any complex design (programming or otherwise). The emphasis here being on Complex.

The usefulness of the Object oriented approach in DB-Pro will be dependant on the size of the project. Remember you can still use OO for the design of a large project in DB-Pro even if you don`t have specific OO language elements available to you in the language.

Designing an old school game, like breakout, space invaders or whatever using an OO approach could well end up with excessive time spent on design.

Larger games (MMORPG`s for instance) will undoubtably benefit from an OO approach, but is DB the best language to try to write an MMORPG in? A proper OO approach to the design would actually help you make this decision, before you`ve written a line of code.

I agree with Soul Mans point that adding OO functionality to DB-Pro would not stop you being able to code in the current manner.

Although I would add that if you`ve already used OO to design your object classes you would get better speed from writing them in C++ and plugging them into DB in a DLL.

So to try to sum up the main points:

1) does DB need OO functionality - NO, there is nothing you can write with an OO language that you cannot write with a non-OO language (although it may be more difficult to do so)
2) Will OO in DB make coding easier - Only if you want to do a really complex project.
3) Will OO functionality be useful in DB - Yes, particularly 2 or 3 projects down the line where you find yourself re-using the same classes over and over, without ever having to re-write them, or to expand an existing project.
4) Can DB-Pro be easily retro fitted with OO functionality - I would suspect this may be very difficult, but only Lee and the rest would really know the answer to this.
5) Do I want OO functionality in DB-Pro - Don`t care, if Lee wants to add it then great, I would definately make use of it, if not then fine, I love coding in this 'traditional' way (takes me back to my school days, BBC micros etc.... oops, am I showing my age?) + its great for doing quick and easy code with superb looking results.

Well thats my 2 cents worth (2 and a bit maybe?)

:0

Login to post a reply

Server time is: 2024-05-04 05:12:18
Your offset time is: 2024-05-04 05:12:18