View Full Version : c++ and OOP
I started to go through my c++ video course and am understanding it better this time around.
Object Oriented Programming is really nice. I was put off with it a long time, althought I knew of its benefits from using Visual Basic and of course reading about it and seeing its benefits in demos and online videos.
I am still confused by dll's. Althought I wrote one or two in Turbo Delphi for thinBasic, I still don't quite understand it.
For example, since thinBasic is in modules, which are dll's themselves.
1 - Could those thinBasic dll's be used in a c++ program?
2 - Could a c++ written module to bring OOP to thinBasic be made?
My guess to all of these is No.
Is it No because thinBasic is interpreted and C++ is compiled? But dll's are compiled, so that is confusing.
Well back to studies, just wanted to post as kind of slow on the forums lately.
Michael Hartlef
24-05-2007, 06:47
Without knowing the ins and out o fTB I guess I can answer no 2.
NO, as the parser cannot handle objects and TB is no compiler. The objectcode behind some OO programming is nothing different then procedual programming. OK, there are pointers to a structure and/or a structure has a virtual function table, but at the end, the parser of an OO language turns the object code into something that you could have created with an non-oo language. Remember, there is no OO in assembler, and that is what compiler do, they translate into assembler or even lower then that.
About using TB modules in other languages. Well, it might work. But they use the extended data type very much so that could become a problem with exchanging values. Plus string handling can be different. And I'm not sure if the license of TB would allow you to do this. Better Eros will answer this.
Thanks Mike for the information. I guess over time I will understand this stuff. It is nice having more questions than answers, then you never get bored :)
One thing about c and c++, you can make it look rather nice. I think hard core programmers like making their code look scary and tough on the eyes. It is a shame, but since the rules are quite free, I am going to try to make my code as pleasing to the eye as I can.
The windows api with their zillion datatypes and syntax, makes it look tougher than it is. At least the core concepts are really nice I am finding out.
Michael Hartlef
24-05-2007, 10:51
Thanks Mike for the information. I guess over time I will understand this stuff. It is nice having more questions than answers, then you never get bored :)
One thing about c and c++, you can make it look rather nice. I think hard core programmers like making their code look scary and tough on the eyes. It is a shame, but since the rules are quite free, I am going to try to make my code as pleasing to the eye as I can.
The windows api with their zillion datatypes and syntax, makes it look tougher than it is. At least the core concepts are really nice I am finding out.
Have fun. I hate C++, allways find it much more difficult to read code from 3rd parties then like DELPHI code for an example. I also hate the fact that most of your time you have to deal with compilation errors regarding type conversion, then with errors in your code.
ErosOlmi
24-05-2007, 11:20
Ken,
sometimes it easy to forget that thinBasic is an interpreter and, for many aspects, an interpreter is much complex than a compiler mainly because it has to keep all the structures and the states (read scopes) active at the same time and "on the fly".
In any case, like Mike said, is just a matter of parsing design and choices. In our case is more a choice. I do not like OOP. I like the idea and the philosophy but I do not like the way it is developed in many languages. One of the OOP main idea was to make things simple but looking at the code and the many innovations (most of them not stardard) introduced by OOP I do not see this big simplicity. Maybe elegant, yes, but at the end of the day for us what is important is to have the work done!
Also, some of thinBasic main targets are to keep things simple and dedicated to automation, programming learning, easy to be used, easy to be mastered, easy to be executed and fast. Introduction of OOP will complicate the whole idea, create confusion without getting so much advantages (from thinBasic point of view).
Regarding OOP languages for developing thinBasic modules, I do not see big problems as far as the OOP language you use is able to create standard dll (no COM dlls). It doesn't matter how dll was programmed inside, important is that interfaces (functions exposed and type casting) are respected.
Still open the possibility to talk about any language here :D
We like comparisons and if we can keep something from other languages to create a better thinBasic we will be happy!
Ciao
Eros
Mike mentioned the typecasting problems, and that happens a lot, but it happened to me in Delphi, but Delphi is so much easier to grasp than c++ that is for sure. It is shame it is not the dominate language like c++ or java. It should be in my opinion.
I had a really hard time getting into studying c++ after having so much fun with thinBasic, it does spoil you for sure. I think once we get User Types within UserTypes, we could do everything we can in OOP, like Eros said without all the work. It does take lots of planning and setup work to get classes going, but once they are there, wow really neat stuff.
I am enjoying the studies and finally got out of the basics and into making an old DOS type game, simple ascii characters for now. But eventually will have real graphic sprites. It is very interesting. Once I have a decent version finished I will put a link to play. It is not my own game, but what I will do from the lessons, but before I release it, I am sure I will personalize it enough to make it unique in its own way.