
|
View Full Version : What's your language?
insanelymacintosh 06-23-2008, 05:47 PM Which programming language do you prefer when it comes to creating web pages?
1. Java
2. Ruby On Rails
3. ASP.NET
4. PHP
5. PERL
6. PYTHON
7. C++
8. No Programming - HTML Only
9. Other
toasty2 06-23-2008, 08:40 PM PHP and Python here. Starting to lean toward Python, but I know PHP so well.
OminousZounds 06-23-2008, 10:41 PM What language do I prefer to create web pages?
PHP.
What language do I prefer for most everything else?
Python.
I've yet to wrap my mind around the process that most of the python Web Application Frameworks use to serve up a website. Much to used to file-based! ;-(
Dustin56 06-23-2008, 11:39 PM I've become quite familiar with PHP, but I would like to learn more Perl as well. Perl is just so versatile, but without mod_perl its still slower than PHP, so, I'll have to look into whether or not mod_perl support is any better than when I last checked.
dollar 06-24-2008, 02:17 AM php here as with most others, I was surprised to see 0 for ASP.net though.
insanelymacintosh 06-24-2008, 02:21 AM I was surprised to see 0 for ASP.net.
Me too. I figured to see about the same number for PHP and ASP.NET.
Codebird 06-24-2008, 04:05 AM Me too. I figured to see about the same number for PHP and ASP.NET.
I never saw so much ASP.NET questions on wht. I think it is just that there are not much asp developers here.
as for the programming language I like PHP for web applications and just started learning python.
BurakUeda 06-24-2008, 04:06 AM PHP here too.
AFAIK RoR is not a language, but a framework of Ruby?
insanelymacintosh 06-24-2008, 04:57 AM PHP here too.
AFAIK RoR is not a language, but a framework of Ruby?
Perhaps you're right (probably are :)) Never programmed in any form of Ruby so I didn't know weather to put Ruby, or Ruby On Rails.
I watched the RoR videos a while back, but it just looked foreign to me, coming from a PHP background.
Bjørn-Erik Hansen 06-25-2008, 02:02 PM Java here.
About to learn HTML, XML, SQL, PHP and a couple of others >.<
etogre 06-25-2008, 09:09 PM HTML and XML are relatively simple. SQL can get complex, depending on what you're trying to do. Make sure you read up on views and indexes when learning SQL, it surprises me how many people don't utilize them. Also coming from Java, PHP should be a breeze for you.
jt2377 06-25-2008, 09:39 PM ASP.net should be consider as framework like RoR.
You can write ASP.net website/web app in any lanague supported by .Net for example i can create ASP.net site in C# or VB.net
For me, it's C# since that's what my employer use and what i do everyday but i'm leaning toward F# recently. I'm trying out the Functional programming paradaim.
MichaelMcC 06-26-2008, 12:11 AM For dynamic sites I use SSI calls to access Perl. I just have it spit out pure html so all browsers can handle it.
Chasseur d'étoiles 06-26-2008, 03:10 AM mostly using PHP but slowly learning .Net/C# and rails :)
mark0168 06-26-2008, 04:13 AM I only use PHP&MySQL now. Because AJAX is getting popular, I'm paying more attention to javascript.
RoyalDesigns 06-26-2008, 04:14 AM Definitely PHP, starting to learn Perl and ASP. :)
CoderJosh 06-26-2008, 04:57 AM PHP. But I was pretty surprised to see NO vote for Ruby so far, after reading so many great things about Ruby and RoR. Is it overrated?
Bjørn-Erik Hansen 06-26-2008, 02:01 PM HTML and XML are relatively simple. SQL can get complex, depending on what you're trying to do. Make sure you read up on views and indexes when learning SQL, it surprises me how many people don't utilize them. Also coming from Java, PHP should be a breeze for you.
Yea, I've already noticed the similarity between java and PHP.
SQL is not so hard, just a lot of reading, Google is your friend there :P
stanosf 06-26-2008, 03:33 PM php with some perl (migrating all the php)
phpghost 06-26-2008, 07:26 PM I personally prefer php, it's powerful and flexible enough for just about anything i need to do.
ASP.NET is not a language, it's a framework.
I vote for C#
mainly PHP, some Java and plan to learn C++
Shannara 06-27-2008, 05:23 PM Lol, this must be a trick question? There's only one programming language on that list to vote on (besides 'Other'), the rest are scripting languages.
insanelymacintosh 06-27-2008, 07:28 PM Lol, this must be a trick question? There's only one programming language on that list to vote on (besides 'Other'), the rest are scripting languages.
What else should I have put on the list?
Courtix 06-29-2008, 10:45 AM I prefer PHP, ASP Next..
BetaOrange 06-29-2008, 12:55 PM Likewise, PHP and MySql takes the lead, it's just how flexible it is really.
greg2007 06-29-2008, 02:12 PM PHP
I probably stay in PHP much more than I should echoing everything, where it would be easier and perhaps better to end PHP and go back into HTML.
I find often though I break out of PHP and code a load of plain HTML and with the bits of HTML that needs to echo a variable value, it gets a pain opening and closing PHP tags all over.
Especially where I need an IF/Else clause.
Having an IF then some plain HTML, then opening PHP again just to have }else{ is a bit of a pain.
SO defo PHP for me
Xeentech 06-29-2008, 02:38 PM For quick RAD stuff I've been doing the PHP/Smarty/ADOdb thing recently.
For anything really serious it's still Perl. Often the PHP front end will dump the hard work to Perl via XML-RPC.
Xeentech 06-29-2008, 02:40 PM PHP
I probably stay in PHP much more than I should echoing everything, where it would be easier and perhaps better to end PHP and go back into HTML.
I find often though I break out of PHP and code a load of plain HTML and with the bits of HTML that needs to echo a variable value, it gets a pain opening and closing PHP tags all over.
Especially where I need an IF/Else clause.
Having an IF then some plain HTML, then opening PHP again just to have }else{ is a bit of a pain.
SO defo PHP for me
You should look into some templating systems. It sounds like you're mixing a lot of logic with HTML and layout, not good for maintainability.
darkiceman 06-30-2008, 07:33 AM You should look into some templating systems. It sounds like you're mixing a lot of logic with HTML and layout, not good for maintainability.
It can be necessary depending on what you are doing, his content might be dynamic with what a user selects on a menu etc. I find myself doing the same thing, and when properly organized it can still be simple to maintain.
I prefer php for the wide range of tasks I can put it to. I mostly deal with flat file php, no sql, however it has tremendous benefits when used with php; so often times I find myself using both.
greg2007 06-30-2008, 09:21 AM It can be necessary depending on what you are doing, his content might be dynamic with what a user selects on a menu etc. I find myself doing the same thing, and when properly organized it can still be simple to maintain.
Exactly it, most of the HTML served has different text/images/colours etc depending on is user logged in, is user xx account type or yy account type, what page are they viewing etc
Although I always look into any advice people have to offer. Everyone always has something new to learn.
Adam-AEC 06-30-2008, 01:39 PM PHP. But I was pretty surprised to see NO vote for Ruby so far, after reading so many great things about Ruby and RoR. Is it overrated?
At least one vote from me there now for Ruby (and Rails).
I use/write more Ruby than anything. Capistrano for server automation, Sake for repeated tasks, etc.
awatson 06-30-2008, 02:56 PM Was perl for a long time, do a lot of php now, which is similar enough to make things confusing now and then ;)
Xeentech 07-01-2008, 07:57 AM It can be necessary depending on what you are doing, his content might be dynamic with what a user selects on a menu etc. I find myself doing the same thing, and when properly organized it can still be simple to maintain.
I prefer php for the wide range of tasks I can put it to. I mostly deal with flat file php, no sql, however it has tremendous benefits when used with php; so often times I find myself using both.
I don't think it is ever necessary to output HTML or other markup from your logic. Sure, sometimes it's faster to do it that way.. but never necessary.
Was perl for a long time, do a lot of php now, which is similar enough to make things confusing now and then ;)
How are Perl and PHP similar? I'm not saying you're wrong I'm just interested in why you think that.
awatson 07-01-2008, 05:50 PM The syntax is very similar in many ways - use of variable names, how control structures are used, etc.
Snargleflap 07-03-2008, 05:37 PM VB & C# in the .Net framework, and classic Asp!
insanelymacintosh 07-03-2008, 08:10 PM VB & C# in the .Net framework, and classic Asp!
Wow, classic ASP. I started on Classic ASP. You're rollin old school :)
Snargleflap 07-04-2008, 01:23 AM Wow, classic ASP. I started on Classic ASP. You're rollin old school :)
Yep... still bangin' out a lot of code in it. It's tough to find the time to migrate everything to .Net. I have a full-time job, a full load of consulting development work, launching my own hosting site, and a wife and 3 kids :)
Sometimes it's just easier to make an enhancements in classic rather than migrating an app, but I'll get it all converted one day.
I'm rollin way more old school than you know. I'm still doing Cobol coding on old HP3000 midrange systems!
gplhost 07-04-2008, 02:38 AM Writing a web site: pure html + css
Writing an app (like our web hosting control panel): PHP/MySQL/sh
People have tendencies to abuse using PHP, when the content is static. Nothing is served faster than a clean, static web page, that can be cached in Squid, using the reverse proxy mode (which is a WAY faster than any other caching system that I know).
Thomas
Xeentech 07-04-2008, 06:20 PM Writing a web site: pure html + css
Writing an app (like our web hosting control panel): PHP/MySQL/sh
People have tendencies to abuse using PHP, when the content is static. Nothing is served faster than a clean, static web page, that can be cached in Squid, using the reverse proxy mode (which is a WAY faster than any other caching system that I know).
Thomas
There's no reason PHP/CGI output can't be cached on a reverse-proxy.
Even with sites that are almost entirely static I'll setup a basic CMS class with a site wide template for the client to more easily edit the content.
gplhost 07-05-2008, 03:45 AM Even with sites that are almost entirely static I'll setup a basic CMS class with a site wide template for the client to more easily edit the content.
For clients that don't understand the basic of HTML/CSS, ok, that makes sense. But for myself, I think CMS are (almost) always very heavy for no reasons. Most of them store all the content in database, which is a nonsense if the content is static. The only good way would be that the CMS generates the HTML pages in advance, but I have found this type of feature very rare, unfortunately. So I stick with pure HTML for my own site, and as few as possible content is in PHP.
Thomas
Snargleflap 07-05-2008, 03:53 AM For clients that don't understand the basic of HTML/CSS, ok, that makes sense. But for myself, I think CMS are (almost) always very heavy for no reasons. Most of them store all the content in database, which is a nonsense if the content is static.
I agree. I would say probably half my clients have static websites, because that's what they required. It's basically an online brochure for their business. CMS for the sake of CMS adds a lot of overhead and potential points of failure to a website that doesn't require any changes. I've built some sites that are almost completely data-driven, but generally I end up building CMS utilities only for portions of the site that the client specifically wants to be able to manage, the rest is always static.
dcahrakos 07-05-2008, 01:54 PM PHP, I may start to learn something else as well, but I know PHP, and love using it.
tinkertim 07-06-2008, 03:58 AM I use PHP because its easy but I feel like its made me a little lazy. What I need to do is sit down and force myself to use Python on a couple of projects to get competent and up to speed. I'm also known to roll my own stuff in C around simple non blocking HTTP 1.1 compliant mini servers.
The problem is since everything needs to be done yesterday I keep saying "I'll use Python 'next time'" and it never happens.
For now, I've been playing with Roadsend PHP which I really like. Being able to compile PHP code to native, optimized ELF is really cool. Its all the advantages of using C as far as eliminating byte code with the convenience of PHP. Unfortunately, your a little limited compared to Zend PHP which is why I keep coming back to Python as a compromise.
insanelymacintosh 07-06-2008, 04:09 AM I've been playing with Roadsend PHP which I really like.
Wow, I had no idea that was around... I just checked out their website. I'm sure this makes PHP files run faster.... even if just a little, looks like it would be worth it (given all the functionality of PHP is still included).
Reading their website it states:
"It includes a compiler that produces native binaries (no interpreter required). Roadsend Compiler can build online web applications with Fast/CGI, offline web applications with an embedded web server (MicroServer), desktop GUI applications with PHP-GTK, and console applications."
Being a PHP nut, I'm totally going to check this out more.
tinkertim 07-06-2008, 05:07 AM If you just want to 'kick the tires' go with the binary packages. I installed my copy from source, it took a while to get bigloo configured and installed properly on my system.
What's also really neat is it allows you to statically link the compiled code .. this means your app will be much larger in size but not depend on certain shared objects .. ideal for embedded systems and such.
Check out the GTK support too, if your in to that .. easy to make desktop apps with PHP :)
acidhoss 07-08-2008, 03:37 PM Perl.
I was bottle fed it, went through a few languages, but I always always always come back. I've dabbled in ruby on rails but it just doesn't work for me like Catalyst does.
Edevere 07-10-2008, 01:05 AM Where is the 'anything but PHP' option? PHP is a dog from hell, almost all the tutorials on the net are crap, and it lends itself to amateurs trying to be programmers, which means 90% of the time when you are given PHP code to clean up it will be a horrible insecure spaghetti mess of mixed logic and very_long_function_names, er, sorry, real_very_long_function_names.
It got one thing right, and that was ease of deployment. For people who have to use shared hosts, it's ideal. Using it myself on a platform I control is inconceivable (and with WebFaction and Amazon's platform, even on platforms I don't control now. yay!) Everything else is better. Perl, Ruby and Python are better languages, Java has insanely better tools...okay, not C++, but that shouldn't even be in the discussion.
dollar 07-10-2008, 01:12 AM Where is the 'anything but PHP' option? PHP is a dog from hell, almost all the tutorials on the net are crap, and it lends itself to amateurs trying to be programmers, which means 90% of the time when you are given PHP code to clean up it will be a horrible insecure spaghetti mess of mixed logic and very_long_function_names, er, sorry, real_very_long_function_names.
It got one thing right, and that was ease of deployment. For people who have to use shared hosts, it's ideal. Using it myself on a platform I control is inconceivable (and with WebFaction and Amazon's platform, even on platforms I don't control now. yay!) Everything else is better. Perl, Ruby and Python are better languages, Java has insanely better tools...okay, not C++, but that shouldn't even be in the discussion.
What makes you say the languages you listed are better then PHP? A poorly written application is going to be poorly written no matter the language it is in so I can't see that making one language better or worse then another language.
spacehosting 07-10-2008, 01:29 AM I pick 8. No Programming - HTML Only
My team do the rest.
Edevere 07-10-2008, 01:33 AM What makes you say the languages you listed are better then PHP? A poorly written application is going to be poorly written no matter the language it is in so I can't see that making one language better or worse then another language.
PHP does a lot of things that are well known and inexcusable in a modern language. The most glaring one, that I alluded to, is the lack of namespaces until like, RIGHT NOW. This is why PHP doesn't have nice packages and you have to name everything like my_module_blah_blah so you don't have collisions. I mean, this is stuff I'll take from C, which was created in the '70's...but PHP? Speaking of functions, there are approximately eleventy billion built in, many of which duplicate features(why do I need join and implode again?), have inconsistent naming, parameter order, etc..
Furthermore, it's weak, weak, weak. There are no first class functions, there are no closures...at least it finally got a decent OO implementation stuck in there. Compared to the things that those languages offer PHP is, to use JWZ's phrase, about as expressive as 2 cups and a piece of string. Java is a pretty sucky language too, especially since the generics mess they made, but it has tool support that is second to none as far as I can tell, which helps make up for it.
The PHP community's ideas about security are also not exactly highly regarded. The php.ini idea was a horrible error, both in spirit, because the language working differently at runtime based on a configuration file is a horrible idea, and in practice, because it makes it harder to move from host to host, unless you can set you own custom php.ini, in which case you've just outsourced the complexity tax to your host, but it still sucks.
It's not really fair to compare PHP to a real language, since it's a niche language after all -- its only use is in web scripting and templating.
A bad app is a bad app I agree. But some languages help you more than others. PHP makes it very, very easy to write bad apps, and based on my experience, a hell of a lot of people take it up on that offer.
charman 07-10-2008, 05:38 AM i like php as it works great with many types of databases. easy to use and works on most if not all hosting plans clients or your self have :D
i also plan to learn JAVA soon as it the best one for a new site i am going to be making
gplhost 07-10-2008, 07:14 AM Face it, the only language that interfaces well with the web server is PHP. Look at Java, and the way you have to configure tomcat. NO WAY you can run that in a shared hosting server. True, there are some efforts for other languages (like python), but it's not as successful as PHP. No other language was MADE for the web servers, all were ADAPTED, which is the wrong way of doing things.
And ok, there are some issues with PHP itself, but really, I don't agree saying that the problem is OOP, or namespaces. YOU think it's a problem, because you like them. But that's not the case for everyone. I personally think that using namespaces is not a good idea, and I see no problem in using long function names. I also think that most of the people that use objects don't know how, and that the resulting code is most of the time totally stupid. See something like this:
class page{
var $content;
function addContent($txt){
$content .= $txt;
}
function printContent(){
echo $content;
}
}
$myPage = new page();
$myPage->addContent("Bla!<br>");
$myPage->addContent("Bli!");
$myPage->printContent();
when all this can be written so fast without classes:
$page = "Bla!<br>";
$page .= "Bli!";
echo $page;
I see this type of object programming so often... Jeez, so stupid, WHY? What's the advantage of it? Saying that you are a god in programming because you instance classes? The ONLY reason why to use OO is when ... you really need the concept of an object (like when you need abstractions, refinements, etc.). And that doesn't FOR SURE need the word "class" in the language itself. I remember I wrote some object oriented code in ... ASSEMBLY language (68000, back in the Atari days...). And I'm using objects in the form of arrays with php so many times, and NEVER use the class stuff, that I feel useless. So I highly disagree with you ! :)
Thomas
Edevere 07-10-2008, 02:55 PM As I said, the one thing PHP got very right is deployment.
The trivial problem with long function names over namespaces is that they are longer to type and ugly. The worse problem is that it means you are constantly having to be on the lookout for naming collisions. If you are just hacking away by your lonesome whatever, keep it all in your head. When you work in teams scattered all over the place or want people to contribute, it's a pain in the *** to not have a good way to do modular organization. Why would I want to have to have a bunch of subtly differently named functions just because the language 'designers' (the idea expressed by someone else, that PHP was 'designed' is laughable) didn't see the need for namespaces that basically every other modern language designer has?
Classes are not about 'showing off' they are about combining data with methods that act on data in a natural way, about encapsulating that data, about code reuse, etc.. I mean, this isn't even a discussion. OO has, at this point in time, won, and if you don't know why and when to use it you are just a ****** programmer. That's not to say it's the best or a perfect paradigm...but until we start moving toward functional programming(which is happening in the better mainstream languages) it's here to stay.
gplhost 07-10-2008, 11:25 PM OO has, at this point in time
Won what? The competition for the most misused concept? For sure!
Why a class is more reusable than a function? I never understood it, I think it's fake, only praised by people that don't understand what OO is really about. Apart from that, I really agree with you when you say:
combining data with methods that act on data in a natural way
but that kind of case is rarely the case with people doing ONLY classes and methods, and never functions.
So yes, use OO WHEN it's needed, but not ALWAYS as I see it too often. Use the CONCEPTS of OO when you need them, don't use them when the result is not a cleaner code (see my example). That was what I wanted to write, nothing more, really!
Thomas
Edevere 07-11-2008, 12:04 AM Won what? The competition for the most misused concept? For sure!
Why a class is more reusable than a function? I never understood it, I think it's fake, only praised by people that don't understand what OO is really about. Apart from that, I really agree with you when you say:
but that kind of case is rarely the case with people doing ONLY classes and methods, and never functions.
So yes, use OO WHEN it's needed, but not ALWAYS as I see it too often. Use the CONCEPTS of OO when you need them, don't use them when the result is not a cleaner code (see my example). That was what I wanted to write, nothing more, really!
Thomas
A class isn't inherently more reusable, except that often you need to keep state, and a function provides you no facilities to do so unless you pass around some global data everywhere, which is pretty ugly.
Also, classes provide inheritance.
vpsfusion 07-11-2008, 01:01 AM asp.net c# all the way! wuhuuu. lol.
tinkertim 07-11-2008, 01:06 AM A class isn't inherently more reusable, except that often you need to keep state, and a function provides you no facilities to do so unless you pass around some global data everywhere, which is pretty ugly.
Also, classes provide inheritance.
Well, global meaning something in a storage structure that can be passed to a function, or global variables?
For instance, I could :
volatile unsigned int some_var = 0;
char *some_var = "some string"or I could :
typedef struct {
volatile unsigned int some_var;
char *some_other_var;
} mystorage_t;
And then just pass it around:
int main(void)
{
mystorage_t *store;
store_init(&store, someint, somestring);
/* inherits what store_init did and can pass it to others */
my_function(&store);
/* de-allocate anything store_init() allocated */
store_finit(&store);
return 0;
}Or you could really break it up and write constructors, destructors, etc.
I never really saw the need for classes.
You could take that a step beyond and store pointers to other functions within the structure, sort of like:
typedef int * (* class_entry_t)(char **, somestruct_t *);
Then add that to your structure:
typedef struct {
volatile unsigned int some_var;
char *some_other_var;
class_entry_t entry;
} mystorage_t;
Hence, back in main we just:
store.entry(argv, &somestruct);Where somestruct is a populated structure we picked up from an entirely different group of functions.
That's just an off the hip example that should be more clear and neater, my only point is that globals are not needed for functions to inherit the results of other functions.
Although, in PHP or other 'high high' level languages, this is rather difficult. What is alarming is that OOP is becoming some kind of defacto standard where 'no code is good unless object oriented' .. and that opinion is juxtaposed on languages that offer better facilities to the programmer.
In the case of (but not picking on) PHP try a little test. Write 2 scripts that basically produce 'hello world' in various ways. One being a function or two, one being a class.
Head them with #!/usr/bin/php and run them via shell through valgrind, i.e.
valgrind ./helloworld.php
Look at the actual heap allocation (and leaks) in both instances. You'll see what I mean :) Some of the errors you'll see are trivial, some aren't.
But, most OOP fanatics really don't care what their code actually _does_ to a computer, they just care that it works and is easy to read.
RexLayer | Prashanth 07-11-2008, 01:24 AM For a free-to-use, easy-to-learn and easy-to-develop robust experience, PHP stands out great and no doubt its the choice of the most people.
As for JAVA, it's also really good.
Edevere 07-11-2008, 01:47 AM "But, most OOP fanatics really don't care what their code actually _does_ to a computer, they just care that it works and is easy to read."
I'm not an OOP fanatic by any means, I'm just saying there's a reason that the most popular languages all support that paradigm(some excessively so...looking at you Java). Optimizing "hello world" at the level of the heap is premature by any measure. As The Deity has stated, "premature optimization is the root of all evil" and as The Bible states "programs must be written for people to read, and only incidentally for machines to execute." I mean, unless you're programming an embedded system or doing some kind of real-time work, worrying about the overhead of creating objects is almost always pointless.
You can add function pointers to some struct and fake OOP, sure, but how much more work do you have to do to get encapsulation? And then when I want to let someone else extend mystorage_t with two other structs like that to combine them into one? Polymorphism? Etc. etc.
I completely agree that you can abuse it, and you shouldn't need to declare any classes to print 'Hello, World' (hi again, Java). If potential for abuse is the standard I could argue for the removal of the C preprocessor, which has led to some of the greatest abuses ever conceived by man, woman or child.
tinkertim 07-11-2008, 01:47 AM Actually guys I just did it , below are two scripts that effectively do the same thing by saying hello to the world:
This is script 1:
tpost@tower:~ $ cat hello.php
#!/usr/bin/php
<?php
print("Hello, world.\n");
?>
This is script 2:
tpost@tower:~ $ cat hello1.php
#!/usr/bin/php
<?php
class Hello {
var $hello;
var $world;
function PrintHello() {
print($this->hello);
print($this->world);
}
function HelloWorld() {
$this->PrintHello();
}
}
$test = new Hello;
$test->hello="Hello, ";
$test->world="World.\n";
$test->HelloWorld();
?>
Valgrind results for script 1:
==12062== ERROR SUMMARY: 78 errors from 15 contexts (suppressed: 155 from 1)
==12062== malloc/free: in use at exit: 2,082 bytes in 18 blocks.
==12062== malloc/free: 17,925 allocs, 17,907 frees, 1,137,889 bytes allocated.
==12062== For counts of detected errors, rerun with: -v
==12062== searching for pointers to 18 not-freed blocks.
==12062== checked 1,032,664 bytes.Valgrind results for script 2:
==12067== ERROR SUMMARY: 78 errors from 15 contexts (suppressed: 155 from 1)
==12067== malloc/free: in use at exit: 2,082 bytes in 18 blocks.
==12067== malloc/free: 17,988 allocs, 17,970 frees, 1,152,675 bytes allocated.
==12067== For counts of detected errors, rerun with: -v
==12067== searching for pointers to 18 not-freed blocks.
==12067== checked 1,032,680 bytes.As you can see, an additional 14k was allocated just to parse that simple class. While nobody really cares about 14k, the example is at best trivial and basic. In things such as database abstraction / etc the difference is really noticeable.
Such things you probably _want_ in a class, otherwise how would using them be practical .. however the idea of 'pure OOP being better' is nonsensical.
Edevere 07-11-2008, 01:56 AM Fortunately nobody every claimed that 'pure OO was better.' What's nonsensical is measuring 'better' by trivial differences in the amount of memory that is allocated by the most trivial of scripts that has no cause to have a class. If you're optimizing for 14k of allocated memory instead of programmer efficiency and conceptual clarity, you're doing it wrong.
tinkertim 07-11-2008, 02:17 AM I completely agree that you can abuse it, and you shouldn't need to declare any classes to print 'Hello, World' (hi again, Java).
I think much of the problem is that there are no peer reviewed standards for high high level languages. Many who spark these trends have never (or rarely) used lower level, or low level languages.
It was just an example to illustrate that classes are indeed more expensive. While premature optimization is the root of all evil, realizing how people are going to actually use the stuff that you write is also important.
If you are writing a blog in PHP, you should understand that someone will hope for it to serve 400 clients at once while competing with other over allocating processes hungry for memory. That's not really optimization, its just polite :)
I reviewed a patch for something a week ago which was just ugly, using a bloated class where 2 simple functions would have done it. When I asked the guy "err, why so much code?" he replied that he was worried about people complaining that he didn't use a class.
Thats just scary.
tinkertim 07-11-2008, 02:20 AM Fortunately nobody every claimed that 'pure OO was better.' What's nonsensical is measuring 'better' by trivial differences in the amount of memory that is allocated by the most trivial of scripts that has no cause to have a class. If you're optimizing for 14k of allocated memory instead of programmer efficiency and conceptual clarity, you're doing it wrong.
I wasn't implying that anyone here claimed that :) However, many people do.
I also wasn't suggesting that someone optimize for 14k of memory. The examples were trivial just to show that there is a difference.
Take a much larger class in the same type of scenario and you would see a much larger difference.
gplhost 07-11-2008, 03:12 AM As I wrote earlier, you don't need the language to know about objects and classes, to work out with them. I wrote some polymorphism in assembly 68000, with some very fast jump table (tables containing the number of bytes to jump to get to the right function). Same goes for most concepts of OOP.
The most important thing is to UNDERSTAND the CONCEPTS and use them WISELY. Abusing them and saying that only methods are the only to be good (and functions stupid) is a non sense, IMHO.
Thomas
tinkertim 07-11-2008, 03:59 AM <?php
class Wht {
var $who;
var $what_they_did;
var $how_much_they_suck;
var $how_much_i_lost;
var $filing_chargeback;
var $suing_them;
var $i_want_my_mommy;
var $i_paid_less_than_five_bucks;
var $losing_per_hour;
.....
$gripe = new Wht;
$gripe->suing_them = true;
$gripe->filing_chargeback = true;
$gripe->i_want_my_mommy = true;
if ($losses < 10) {
$gripe->losing_per_hour = 10000;
$gripe->i_paid_less_than_five_bucks = true;
}
$gripe->Post();
So yes, classes can be useful I guess.
Sorry, could not resist :D Please don't hurt me ....
xenex 07-11-2008, 04:35 PM PHP all the way I say, lol
|