HighDots Forums  

site design technologies required heads up please

Website Design comp.infosystems.www.authoring.site-design


Discuss site design technologies required heads up please in the Website Design forum.



Reply
 
Thread Tools Display Modes
  #31  
Old   
Bruce Lewis
 
Posts: n/a

Default Re: rant about PHP - 05-20-2005 , 09:45 AM






Lauri Raittila <lauri (AT) raittila (DOT) cjb.net> writes:

Quote:
in comp.infosystems.www.authoring.site-design, Bruce Lewis wrote:
Lauri Raittila <lauri (AT) raittila (DOT) cjb.net> writes:

in comp.infosystems.www.authoring.site-design, Bruce Lewis wrote:
Please post some example code illustrating how easy it is to learn PHP
for some specific trivial case. I will respond with my own example
code.

Only PHP thing that is more or less ready I have is this
http://lauri.cambridgelaan.nl/index.phps
(and result is http://lauri.cambridgelaan.nl/)
Thanks for stepping in when kaeli didn't respond, but a 300+ line
example is a little too big to keep the discussion focused. Hopefully
kaeli will post a smaller example.

Quote:
Does:
- finds images in folder
- makes gallery out of them, first time it produces thumbs.

It was very easy to do as I wound most of the code ready. I was able to
read and understand what it does whitout any learning, to change
functionality a bit I needed to learn some stuff.
You could understand what it does by reading the comments. A comment is
code that tells the computer to ignore text, because it's only there for
humans to read, e.g.
# Just drop this script into the directory that contains your#
# images. Your image file names becom the inage captions. #

Don't look at comments for evaluating the readability of a language.
Look at code, e.g.
$title = ereg_replace("[^/]*\$", "", $title);
$output .= "<div class='size'>\n" . sprintf("%.02f",
(float)(filesize($jpegs[$i]) / 1024)) . 'KB
</div>';

Code like the lines above is not what you want to put forth when trying
to prove PHP much easier than the alternatives. I'm still waiting for a
good example.


Reply With Quote
  #32  
Old   
Chris Morris
 
Posts: n/a

Default Re: rant about PHP - 05-20-2005 , 10:15 AM






Bruce Lewis <brlspam (AT) yahoo (DOT) com> writes:
Quote:
Don't look at comments for evaluating the readability of a language.
Look at code, e.g.
$title = ereg_replace("[^/]*\$", "", $title);
I think the lack of readability of that line says more about regular
expression syntax than it does about PHP. A slight improvement would be

$title = ereg_replace('[^/]*$', '', $title);

Can you give an example of code from a language in which "Remove
everything after the last '/' in a string" is written in a more
readable way?

Oh, depending on the contents of $title, the following might be more
readable in PHP:
$title = dirname($title).'/';

Quote:
$output .= "<div class='size'>\n" . sprintf("%.02f",
(float)(filesize($jpegs[$i]) / 1024)) . 'KB
/div>';
$filesize = filesize($jpegs[$i]);
$output .= "<div class='size'>";
$output .= sprintf("%.02f",($filesize/1024))."KB";
$output .= "</div>\n";

Not *quite* equivalent code (couple of line breaks in different
places) but it is more readable.

Okay, the "%.02f" is a little odd-looking, but on the other hand it's
standard string formatting syntax as seen in sprintf() functions in
many languages. Like regex, it's not really the fault of PHP if the
convention it follows is incomprehensible to the beginner [1].

If you don't mind 3.20 being displayed as 3.2 - which in this case
would be fine, I think - then you can do

$output .= round($filesize/1024 , 2)."KB";

instead.

[1] PHP's date() function did implement its own date format syntax,
rather than sticking to the standard date format syntax, and this has
not been popular.

Quote:
Code like the lines above is not what you want to put forth when trying
to prove PHP much easier than the alternatives. I'm still waiting for a
good example.
Easier to read or easier to write?

There is a lot of difficult-to-read (and otherwise badly-written) PHP
code out there. I think that reflects how *easy* it is to write PHP
code that appears to work if you don't look too hard.

I've not found well-written PHP code any easier to read than
well-written code in other imperative languages.

I've not found poorly-written PHP code any harder to read than
poorly-written code in other imperative languages.

--
Chris


Reply With Quote
  #33  
Old   
Bruce Lewis
 
Posts: n/a

Default Re: rant about PHP - 05-20-2005 , 12:54 PM



Chris Morris <c.i.morris (AT) durham (DOT) ac.uk> writes:

Quote:
Bruce Lewis <brlspam (AT) yahoo (DOT) com> writes:
Don't look at comments for evaluating the readability of a language.
Look at code, e.g.
$title = ereg_replace("[^/]*\$", "", $title);

I think the lack of readability of that line says more about regular
expression syntax than it does about PHP.
You may be right. Right or wrong, that line does not showcase PHP's
alleged design for simple web applications; it's a more general
string-handling operation. I'll reiterate that I want to stay focused
on a specific application area rather than programming in general, as
generalized discussion about programming languages goes nowhere.

Quote:
Okay, the "%.02f" is a little odd-looking, but on the other hand it's
standard string formatting syntax as seen in sprintf() functions in
many languages. Like regex, it's not really the fault of PHP if the
convention it follows is incomprehensible to the beginner [1].
I don't think Java was the first language to use "#,###.00"-style
formatters, much more readable. I did C programming for 12 years, but
didn't often have to format numbers. I always had to go back to the man
page to know which side of the decimal point did what. The implementors
of PHP did not make a design decision based on what would be good for
web developers; they simply went with what they were already familiar
with in the C world.

Quote:
[1] PHP's date() function did implement its own date format syntax,
rather than sticking to the standard date format syntax, and this has
not been popular.
Maybe they thought strftime() formats were just too full of % signs for
people to read them. However, they could have copied Java's
SimpleDateFormat, where the difference between "yyyy-mm-dd" and
"yyyy-m-d" is more apparent than PHP's "Y-m-d" and "Y-n-j".

Quote:
Code like the lines above is not what you want to put forth when trying
to prove PHP much easier than the alternatives. I'm still waiting for a
good example.

Easier to read or easier to write?
The statement I'm contesting is the following from Lauri Raittila. (I
got mixed up earlier and attributed it to kaeli; apologies.)

"The fact is that it is much easier to learn PHP than program for web on
almost any other language, especially on trivial cases."

I think both reading and writing are important, but Lauri could choose
either reading or writing and I'd be happy to restrict the discussion
accordingly.

Quote:
I've not found well-written PHP code any easier to read than
well-written code in other imperative languages.

I've not found poorly-written PHP code any harder to read than
poorly-written code in other imperative languages.
I'd prefer not to restrict the discussion to just imperative languages,
my references to Java objects in this post notwithstanding.


Reply With Quote
  #34  
Old   
Lauri Raittila
 
Posts: n/a

Default Re: rant about PHP - 05-20-2005 , 06:13 PM



in comp.infosystems.www.authoring.site-design, Bruce Lewis wrote:
Quote:
Lauri Raittila <lauri (AT) raittila (DOT) cjb.net> writes:

in comp.infosystems.www.authoring.site-design, Bruce Lewis wrote:
Lauri Raittila <lauri (AT) raittila (DOT) cjb.net> writes:

in comp.infosystems.www.authoring.site-design, Bruce Lewis wrote:
Please post some example code illustrating how easy it is to learn PHP
for some specific trivial case. I will respond with my own example
code.

Only PHP thing that is more or less ready I have is this
http://lauri.cambridgelaan.nl/index.phps
(and result is http://lauri.cambridgelaan.nl/)

Thanks for stepping in when kaeli didn't respond, but a 300+ line
example is a little too big to keep the discussion focused. Hopefully
kaeli will post a smaller example.
Actually, you answered my post, so I assumed you asked me...

Anyway, if doing something more trivial, then the difference of
environment is more important - if you have access to server with PHP it
is easier and cheaper than if you need to find new server or get current
updated.

Quote:
Does:
- finds images in folder
- makes gallery out of them, first time it produces thumbs.

It was very easy to do as I wound most of the code ready. I was able to
read and understand what it does whitout any learning, to change
functionality a bit I needed to learn some stuff.

You could understand what it does by reading the comments.
But that wouldn't have been enough to change the functionality.

Quote:
Don't look at comments for evaluating the readability of a language.
If you looked carefully, those comments are just explaining the functionality
and settings - actual code is not much commented...

Quote:
Look at code, e.g.
$title = ereg_replace("[^/]*\$", "", $title);
$output .= "<div class='size'>\n" . sprintf("%.02f",
(float)(filesize($jpegs[$i]) / 1024)) . 'KB
/div>';
It looks easy enough for me. Difficult is regexp and rounding syntax -
but you can always look them up from spec, if you need to make a change.

Quote:
Code like the lines above is not what you want to put forth when trying
to prove PHP much easier than the alternatives. I'm still waiting for a
good example.
I have to say that I don't find this confusing - I get what it means,
without comments..

What I have wanted to say is that PHP is easy different way than others -
it is not very elegant as language, but it well supported and you can
easily copy paste stuff from different sources.

Also, it most likely is not the best PHP coding, as someone already
pointed out. And it could look worse
(1st line would be
$title =~ s§[^/]*$§§;
in perl - easier, when you know what it means, impossible otherwise)

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
Support me, buy Opera:
https://secure.bmtmicro.com/opera/buy-opera.html?AID=882173


Reply With Quote
  #35  
Old   
Chris Morris
 
Posts: n/a

Default Re: rant about PHP - 05-21-2005 , 11:28 AM



Bruce Lewis <brlspam (AT) yahoo (DOT) com> writes:
Quote:
Chris Morris <c.i.morris (AT) durham (DOT) ac.uk> writes:
I've not found well-written PHP code any easier to read than
well-written code in other imperative languages.

I've not found poorly-written PHP code any harder to read than
poorly-written code in other imperative languages.

I'd prefer not to restrict the discussion to just imperative languages,
my references to Java objects in this post notwithstanding.
Feel free to add OO languages to my statements. They're similar enough
that many languages - PHP, for example - can be programmed either OO
or imperative.

I'm not so sure about adding functional or logic languages, though,
since they're so different to imperative languages that how
(relatively) easy to read/write someone finds depends to a fair extent
on how familiar they are with the languages' paradigms.

Also, insert 'sensible' before 'imperative' since I forgot about
Intercal and other languages designed to be unreadable.

--
Chris


Reply With Quote
  #36  
Old   
James A. Donald
 
Posts: n/a

Default Re: rant about PHP - 09-25-2005 , 11:50 PM



--
Bruce Lewis
Quote:
Nobody's saying PHP isn't widely installed. I'll just
say that having it already installed is where the ease
of use ends.
If you want to get started, PHP is easy to install, easy
to whip up a web page. It is installed everywhere
because it is free, easy to install, easy to use.

Eventually, if you are doing something advanced, PHP
will start to be an obstacle - then you can whip up your
own C++ extension to PHP. That should keep even the
most advanced programmers happy, and a lot of people
have done exactly that. If you want to be really cool,
do a template based C++ extension to PHP.

Use the right tool for the job. For a simple job, PHP
MySQL is the right tool.

--digsig
James A. Donald
6YeGpsZR+nOTh/cGwvITnSR3TdzclVpR0+pr3YYQdkG
ZhXfsAPEBruusqbSL/+YRuTwm2UJIZJ4L/1E6Nti
4Sl3dIMgVX08MkO3jCULs97gOkOTLfdgFiudN/bBm



--
http://www.jim.com


Reply With Quote
  #37  
Old   
James A. Donald
 
Posts: n/a

Default Re: rant about PHP (was: site design technologies required heads up - 09-26-2005 , 12:06 AM



--
Stefan Nobis:
Quote:
I'm still curious: I developed in many different
languages and only very few (like VB) felt as bad as
PHP. So what are people seeing in PHP?
You can get a program up and running and superficially
looking good mighty quickly in VB, and mighty quickly in
PHP/MySQL

Of course, eventually a program in VB tends to turn into
an out of control pile of crap, and PHP is only
marginally better, but you can a lot of good stuff
looking good, mighty quick.

If you have a project that requires six programmers
working for two years, yes VB or PHP is going to turn
into a catastrophe, and the startup will go down the
tubes, but if you have one less-than-experienced
programmer, and the job needs to go live before the end
of the month, PHP/MySQL is the way to go.

--digsig
James A. Donald
6YeGpsZR+nOTh/cGwvITnSR3TdzclVpR0+pr3YYQdkG
z2fbhf4q5kjNcZOzf03ucx2JK71lkLGNJfqauf9t
43IPpF3JP71kgn4DYRm8QT3BwNgruKydDQsO1srgL


--
http://www.jim.com


Reply With Quote
  #38  
Old   
mbstevens
 
Posts: n/a

Default Re: rant about PHP - 09-26-2005 , 01:32 AM



James A. Donald wrote:

Quote:
Eventually, if you are doing something advanced, PHP
will start to be an obstacle - then you can whip up your
own C++ extension to PHP.
For doing advanced things on the web most people use
Perl (e.g. the w3c validator) or Python (e.g. Google's search
engine).

Quote:
That should keep even the
most advanced programmers happy, and a lot of people
have done exactly that. If you want to be really cool,
do a template based C++ extension to PHP.
Seems like massive overkill to grind out a C++ extension for
something as easy as that. See:
http://www.mbstevens.com/cgi/mkatt.pl?name=cgi_perl/html_through_cgi
....which shows a templating system in 14 lines of Perl, if you
ignore the comments.
--
mbstevens





Reply With Quote
  #39  
Old   
Bruce Lewis
 
Posts: n/a

Default Re: rant about PHP (was: site design technologies required heads up - 09-26-2005 , 10:00 AM



James A. Donald <jamesd (AT) echeque (DOT) com> writes:

Quote:
If you have a project that requires six programmers
working for two years, yes VB or PHP is going to turn
into a catastrophe, and the startup will go down the
tubes, but if you have one less-than-experienced
programmer, and the job needs to go live before the end
of the month, PHP/MySQL is the way to go.
I said this in May in the thread you're replying to now, and I'll say it
again: ease of installation is the only thing that makes what you're
saying true. PHP and MySQL are full of pitfalls for the inexperienced
or the unwary, and some of these pitfalls show up even in the simplest
web/database examples.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.