New OOP permissions system

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Sphen
Registered User
Posts: 36
Joined: Wed May 19, 2004 5:28 pm
Location: Land of the Beaver
Contact:

Re: New OOP permissions system

Post by Sphen »

ab9db wrote: Quick question,

Will these permissions be set up by admins within the control panel?

So will admin be able to create a group and define it's control panel powers?
That's correct.


Also, I just have to comment on this statement.
Ybarra wrote: There's also the performance to consider, as OOP programming is generally less efficient than procedural...it's an efficiency vs. organization trade-off.
If you take a look at the examples provided, the test code that the author is using is flawed. They're instantiating a new class every time that they're going through the loop. This would use up tons of memory, and explains why OOP fared so badly. The there should only be one copy of the class, but instead there's 1 000 000 copies of it.

The point: Well written OOP code is usually as fast (or faster) than procedural.

Sphen
I think, therefore I am, I think...
I refuse to have a battle of wits with someone who is unarmed.
Site - Blog

User avatar
Alfatrion
Registered User
Posts: 50
Joined: Tue Feb 22, 2005 1:03 am
Contact:

OOP vs functional programming

Post by Alfatrion »

The advantages of OOP are IMHO:
- more flexible code
- allows to code once and only once

The disadvantages are:
- need for more memory
- slightly longer execution times

Embedded system usealy use C instead of C++ because of this.

One mayor keyword is encapsulation. Not just hidding data but also other kinds of hidding like classes. Lets say we have a class RegularStudent. We can tell the student to go to the next classroom and the student will figure it out. Now we like to extend the code so we have two typs of students (GraduateStudent and RegularSudent) instead of one. This exention doesn't requere we alter the main loop, but this whould most likly be requered in functional programming.
The point: Well written OOP code is usually as fast (or faster) than procedural.
I don't beleave this is true. OOP code has more to keep track off so it would take longer and use more memory.
With Great Power Comes Great Responsibility

code reader
Registered User
Posts: 653
Joined: Wed Sep 21, 2005 3:01 pm

Re: New OOP permissions system

Post by code reader »

[go-on-soapbox]
this whole discussion is pretty far off-topic, but let me put in my 2c anyway:
in and on itself, there is nothing in oop that should cause it to be low performance.
the remark about embedded system using c rather that cpp is mostly correct, but is not really relevant here: the same embedded systems that shy away from c++ usually dont use dynamic memory allocation at all. with languages such as php, there is ONLY dynamic memory allocation, and quite a lot of it.

it is true that php 4 had a slight deficiency that could cause problems to oo code.
i will elaborate a little:
with php, by default, parameters are passed to functions by value, and not by reference.
this means that if you pass a large array to a function, and you dont explicitely specify "by reference" (in php that means use "&" in front of the parameter in the function declaration), the whole array will be copied each time you call the function.

in reality, "objects" in php are a little more than glorified ("blessed" if you talke perlese) associative arrays. if you use objects extensicvely, AND you pass them as parameters to functions, AND you dont do it "by reference", you may pay a performance penalty. no more so than if you pass similar sized associative arrays, but also no less.
php 5 changed that: object variables always hold a refernce to the object rather than the object itself, so there is no penalty for passing them to functions as parameters.

the notion that objects are expensive in terms of memory management regardless of function calls is just not true in php. creating and destroying an object doesnt cost more in cpu and memory than creating and destroying (you rarely explicitly "destroy" anything in php. things get destroyed when they go out of scope) similar sized associative arrays.

to summarize:
using oo in php 4 can cause a performance penalty IF you pass object as parameters to functions, AND IF you dont use "pass by reference" ("&") for those functions.
there is no such penalty for php 5, and the php 4 penalty can be negated by using reference parameter passing for the objects (and for other large structures).

of course, it is always possible to create a screwed up "benchmark" that will show a huge penalty, as in the example cited above. but if the example would add a
$b = array(1, 2, 3); line, you would see a very similar effect as the call to new thing();

there is a classical example that shows how inefficient recursion is by computing fibonacci numbers:

Code: Select all

function fib($number) {
  if ($number <= 1)
      return 1;
  return fib($number - 1) + fib($number - 2);
}
this function is attrociacely inefficient, but using it to show that recursion is inefficient (believe it or not but some people actually did make this argument) is wrong.
[/go-on-soapbox]

Silkrooster
Registered User
Posts: 13
Joined: Tue Apr 19, 2005 4:49 am

Re: New OOP permissions system

Post by Silkrooster »

Correct me if I am wrong, but I would believe that using OOP would eventually allow PHPBB to use plug in mods that the end user needs to do very little to get the mod to work. Also by using OOP it would be very possible for a mod to completely take place of say the permissions system. I realize this may not all happen in this release, but down the line it very well could happen. Assuming I am understanding the process that is.
Silk
Edit: typo
Last edited by Silkrooster on Sun Jan 15, 2006 4:38 am, edited 1 time in total.

code reader
Registered User
Posts: 653
Joined: Wed Sep 21, 2005 3:01 pm

Re: New OOP permissions system

Post by code reader »

though it is true that these goals can be achieved with oo technology, it is also true they could be achieved without oo. it may be slightly more tricky, but these are far from trivial even with oo.

in general, a good oo code produced by a good programmer is more elegant, usually shorter and easier to maintain than a non-oo code of the same quality that perform the same function. (the difference is seldom dramatic, though)

but it is also true that a good procedural code written by a good programmer will generally be superior to mediocre oo code written by a mediocre programmer.

as i see it, easy modding is not the top priority at this moment in phpbb development. in the future there will be future.

User avatar
Alfatrion
Registered User
Posts: 50
Joined: Tue Feb 22, 2005 1:03 am
Contact:

Re: New OOP permissions system

Post by Alfatrion »

code reader wrote: the same embedded systems that shy away from c++ usually dont use dynamic memory allocation at all.
Using dynamic memory allocation results in slower code. So this makes sence for embedded systems. Its all about looking at the plusses and minus and determen how much value they have in a certain environment. This will be different for a embedded system that has little memory and high(er) needs for speed than a computer/server.

I'm not agianst OO, in fact I'm all for it. I feel the plusses outweight the minus far out.
code reader wrote: of course, it is always possible to create a screwed up "benchmark" that will show a huge penalty, as in the example cited above. but if the example would add a
$b = array(1, 2, 3); line, you would see a very similar effect as the call to new thing();

there is a classical example that shows how inefficient recursion is by computing fibonacci numbers:

Code: Select all

function fib($number) {
  if ($number <= 1)
      return 1;
  return fib($number - 1) + fib($number - 2);
}
this function is attrociacely inefficient, but using it to show that recursion is inefficient (believe it or not but some people actually did make this argument) is wrong.
Why is it wrong? Recursion is less efficient in term of runtime because with each jump information has to be written to the stack. The code on the given webside has mayor flaws in them, so wouldn't use that as an example. I'm saying that a correct benchmark will show a penalty when using OO vs functional.
With Great Power Comes Great Responsibility

Michaelo
Registered User
Posts: 106
Joined: Thu Apr 01, 2004 7:56 am
Location: Dublin

Re: New OOP permissions system

Post by Michaelo »

I had the same discussion over twenty years ago and even then the same arguments were being used. The facts were than as they are now, well written procedural code is faster and smaller that opps code, but that where the advantages stop. The number of advantages gained with using OOPS more that balance the speed/size disadvantages.

So use procedural (C) code where speed or size is your concern and OPPS (C++) for everything else.

Strange thing is when we used nothing but assembly and along came C we had the very same discussion... Even stranger the same was true...

So use assembly code where speed or size is your concern and C for everything else.

Go figure!
Mods: Forum Icons Enhancement, Kiss Portal Engine
Links:
Kiss Portal Engine (dev site) Stargate Portal (archive site) ...
Styles: Technika

Post Reply