There are three types of languages (in this sense):
- One type does not support OO at all, for example c. (However I will later tell you why actually c supports OO at least to a certain level, I will talk about this as a side note);
- One type supports OO, but still allows you to code in a non-OO way, for example c++ and Perl. (Although the OO in c++ and Perl are actually quite different, we disregard this in the current context);
- One type supports OO, and leave no way for you to code in a non-OO way (at least from a syntax point of view), for example Java.
Now I think it is interesting to know others’ thought as which way is better between the last two. Do you like a language that allows you more freedom (like c++ and Perl), or a language enforce more discipline (like Java). Why?
Side note:
Now why I said c actually supports OO in some sense. In our company, we have lots of c code left from a while ago, and now when we add new functions to the existing system, we still code in c (partly because we have to deal with Oracle pro*c). But I proposed a way to code c program in a OO-style, and people like it.
What we do is:
- First we analyze the situation as if we are doing OO design, so we get all the classes, properties, and methods
- we create a struct to contain all the properties for each class;
- This structure, let’s call it self structure is passed to each function (method) as the first parameter, so now all the function (method) knows about all properties;
- In the self structure we also keep pointers to all methods, in this way overload methods becomes as simple as modifying a pointer.
It is just that simple, and all our new c programs are now in this way.
Now this is actually very close to how OO is supported in Perl.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.