473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

I couldn't understand why PHP is so popular. The PHP code looks sohorrible compared with Java.

Could you put up with the horrible PHP code?
Jun 2 '08 #1
22 1762
Since you have already admitted in comp.lang.java.programmer (Is there
any web programmer who is willing to help me...)

"I'm poor at programming."
What the hell would you know.
Jun 2 '08 #2
On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi**********@gmail.comwrote:
Could you put up with the horrible PHP code?
No offcourse not, that's why we read this group.

For comparison, here's some Perl:
#!/usr/bin/perl -l
s--@{[(gE^Ge)=~/[^g^e]/g]}[g^e]x((!!+~~g^e^g^e)<<pop).!gE-ge,
s-[^ge^ge]-s,,,,s,@{[(g^';').(e^'?')]},(G^'/').(E^'|')^Ge,ge,
print,s,(?<=/[^g^e])[^g^e][^g^e],$&^(G^'/').(E^'|')^gE,ge-ge
--
Rik Wasmus
Jun 2 '08 #3
tenxian wrote:
Could you put up with the horrible PHP code?
Yes, I can. PHP is a language that's easy to learn and easy to use,
which is why so many choose to use it.

IMO, it's not much more horrible than C++ or Java; it all depends on
the programmer who makes use of it.

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Jun 2 '08 #4


"tenxian" <hi**********@gmail.comwrote in message
news:9d**********************************@n1g2000p rb.googlegroups.com...
Could you put up with the horrible PHP code?
It takes several months before one becomes productive in Java. All those
abstract classes and interfaces are quite confusing. PHP is much simpler but
very powerful.
Btw can you access a field of resultset in Java like this

resultset[var]

where var is a variable and not a literal?

Jun 2 '08 #5
Rik Wasmus schreef:
On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi**********@gmail.comwrote:
>Could you put up with the horrible PHP code?

No offcourse not, that's why we read this group.

For comparison, here's some Perl:
#!/usr/bin/perl -l
s--@{[(gE^Ge)=~/[^g^e]/g]}[g^e]x((!!+~~g^e^g^e)<<pop).!gE-ge,
s-[^ge^ge]-s,,,,s,@{[(g^';').(e^'?')]},(G^'/').(E^'|')^Ge,ge,
print,s,(?<=/[^g^e])[^g^e][^g^e],$&^(G^'/').(E^'|')^gE,ge-ge
LOL.
The old I-hate-PERL-vibes are running up my spine again.
Thanks for reminding me why I code PHP these days. ;-)

Regards,
Erwin Moller
Jun 2 '08 #6
tenxian schreef:
Could you put up with the horrible PHP code?
Dear Mr. Troll,

I expect you mastered both Java and PHP before spitting your wisdom?
Is that correct?

I coded a few years in both languages, and can only say I need LOADS of
time to get things done in Java (J2EE/tomcat).
My honest estimate is that I code around 3-4 times faster in PHP, and I
produce readable code.

In Java, you needs to have intimate knowledge of all classes interfaces
you use, even to get the most modests tasks done.
Personally, I don't see the advantage of Java above PHP when it comes to
serverside programming.
For me PHP is easier to read, easier to understand, and easier to
maintain. Above that: PHP is less errorprone since you don't need to
know hundreds of classes/interfaces to do basic stuff.

Now I wonder, what made you post this?

Regards,
Erwin Moller
Jun 2 '08 #7
In article <48***********************@news.xs4all.nl>,
Erwin Moller
<Si******************************************@spam yourself.comwrote:
Rik Wasmus schreef:
On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi**********@gmail.comwrote:
Could you put up with the horrible PHP code?
No offcourse not, that's why we read this group.

For comparison, here's some Perl:
#!/usr/bin/perl -l
s--@{[(gE^Ge)=~/[^g^e]/g]}[g^e]x((!!+~~g^e^g^e)<<pop).!gE-ge,
s-[^ge^ge]-s,,,,s,@{[(g^';').(e^'?')]},(G^'/').(E^'|')^Ge,ge,
print,s,(?<=/[^g^e])[^g^e][^g^e],$&^(G^'/').(E^'|')^gE,ge-ge

LOL.
The old I-hate-PERL-vibes are running up my spine again.
Thanks for reminding me why I code PHP these days. ;-)
Does that actually *do* anything? Or is it *really* just line-noise? I
copy pasted it into Terminal and all I got was a perl syntax error.
Jun 2 '08 #8
On Tue, 29 Apr 2008 11:55:29 +0200, Tim Streater
<ti**********@dante.org.ukwrote:
In article <48***********************@news.xs4all.nl>,
Erwin Moller
<Si******************************************@spam yourself.comwrote:
>Rik Wasmus schreef:
On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi**********@gmail.com
wrote:
>Could you put up with the horrible PHP code?

No offcourse not, that's why we read this group.

For comparison, here's some Perl:
#!/usr/bin/perl -l
s--@{[(gE^Ge)=~/[^g^e]/g]}[g^e]x((!!+~~g^e^g^e)<<pop).!gE-ge,
s-[^ge^ge]-s,,,,s,@{[(g^';').(e^'?')]},(G^'/').(E^'|')^Ge,ge,
print,s,(?<=/[^g^e])[^g^e][^g^e],$&^(G^'/').(E^'|')^gE,ge-ge

LOL.
The old I-hate-PERL-vibes are running up my spine again.
Thanks for reminding me why I code PHP these days. ;-)

Does that actually *do* anything? Or is it *really* just line-noise? I
copy pasted it into Terminal and all I got was a perl syntax error.
Well, offcourse it's deliberately obscure.
It creates triangles based on a number:
$test.pl 1
/\
/\/\

$test.pl 2
/\
/\/\
/\ /\
/\/\/\/\

$test.pl 3
/\
/\/\
/\ /\
/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\/\/\/\/\

$test.pl 4
/\
/\/\
/\ /\
/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\ /\/\/\/\
/\ /\ /\ /\
/\/\ /\/\ /\/\ /\/\
/\ /\ /\ /\ /\ /\ /\ /\
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
--
Rik Wasmus
Jun 2 '08 #9
tenxian wrote:
Could you put up with the horrible PHP code?
Hi, troll. It's obvious you know nothing about either language.

The language has nothing to do with it. It all depends on the
programmer. If you write horrible code in PHP, that's your problem.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #10
On Apr 29, 2:00 am, tenxian <hi.steven...@gmail.comwrote:
Could you put up with the horrible PHP code?
I completely agree. I mean, it's ridiculous that you need all this
code just for a simple "hello world" program:

<?php
$arrData = array(72,101,108,108,111,32,87,111,114,108,100,33) ;

for($i = 0; $i < count($arrData); $i++) {
$char = $arrData[$i];
$char = fConvertChar($char);
print $char;
}

function fConvertChar($char) {
$char = 72 + 2 * $char / 4 * 2 - (8.32 * 8.65384);
$char = chr($char);
return $char;
}
?>
Jun 2 '08 #11
On 29 Apr, 13:02, ZeldorBlat <zeldorb...@gmail.comwrote:
On Apr 29, 2:00 am, tenxian <hi.steven...@gmail.comwrote:
Could you put up with the horrible PHP code?

I completely agree. I mean, it's ridiculous that you need all this
code just for a simple "hello world" program:

<?php
$arrData = array(72,101,108,108,111,32,87,111,114,108,100,33) ;

for($i = 0; $i < count($arrData); $i++) {
$char = $arrData[$i];
$char = fConvertChar($char);
print $char;

}

function fConvertChar($char) {
$char = 72 + 2 * $char / 4 * 2 - (8.32 * 8.65384);
$char = chr($char);
return $char;}

?>
Wow, I never realised you could do Hello World without instantiating a
custom class.
Jun 2 '08 #12
tenxian wrote:
Could you put up with the horrible PHP code?
Yes, PHP has something that is called "alternative syntax". Without it,
PHP would be as incomprehensible as java!

LOL,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Jun 2 '08 #13
..oO(Rik Wasmus)
>Well, offcourse it's deliberately obscure.
It creates triangles based on a number:
$test.pl 1
/\
/\/\

$test.pl 2
/\
/\/\
/\ /\
/\/\/\/\

$test.pl 3
/\
/\/\
/\ /\
/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\/\/\/\/\

[...]
JFTR: These structures are called Sierpinski triangles and are quite
well-known fractals.

http://en.wikipedia.org/wiki/Sierpinski_triangle

Here's something similar in PHP, also quite famous:

<pre><?php $c=0;for($y=1.2;$y>-1.3;$y-=0.1){for($x=-2.08;$x<.92;$x+=.04){$r=
$n=0;for($h=127;$r*$r+$n*$n<4&&--$h>32;){$d=$r;$r=$r*$r-$n*$n+$x;$n=2*$d*$n+
$y;}($x>0.98)?print chr(10):print chr($h);if(++$c%75==0)print"\n";}}?></pre>

Micha
Jun 2 '08 #14
In our last episode, <67*************@mid.individual.net>, the lovely and
talented Kim André Akerĝ broadcast on comp.lang.php:
tenxian wrote:
>Could you put up with the horrible PHP code?
Yes, I can. PHP is a language that's easy to learn and easy to use,
which is why so many choose to use it.
Widely supported has something to do with it. Just about commercial host is
going to have PHP and MySQL.

For web applications, it is sort of like inside-out perl. Lots of
processing and little markup output: perl or C(++). Lots of markup, a
little processing: PHP. Giant dedicated serverzilla for major landmark
site: Java.
IMO, it's not much more horrible than C++ or Java; it all depends on
the programmer who makes use of it.


--
Lars Eighner <http://larseighner.com/us****@larseighner.com
Countdown: 266 days to go.
Jun 2 '08 #15
On Tue, 29 Apr 2008 08:14:33 +0000, Kim André Akerĝ wrote:
tenxian wrote:
>Could you put up with the horrible PHP code?
Horrible code comes in all languages.
Yes, I can. PHP is a language that's easy to learn and easy to use,
which is why so many choose to use it.
Actually I chose it because it's cross-platform, stable, powerful, tried
and tested and specifically designed to do what I'm doing with it. I'd
like to see where you collected your statistical data on PHP adoption.
IMO, it's not much more horrible than C++ or Java; it all depends on the
programmer who makes use of it.
My PHP code is pretty... as is my C++ code.

Blame the Indian not the arrows.

--
"Remain calm, we're here to protect you!"

Jun 2 '08 #16
On Apr 29, 9:43 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>
Wow, I never realised you could do Hello World without instantiating a
custom class.
You mean like this?

public interface MessageStrategy {
public void sendMessage();
}

public abstract class AbstractStrategyFactory {
public abstract MessageStrategy createStrategy(MessageBody mb);
}

public class MessageBody {
Object payload;

public Object getPayload() {
return payload;
}

public void configure(Object obj) {
payload = obj;
}

public void send(MessageStrategy ms) {
ms.sendMessage();
}
}

public class DefaultFactory extends AbstractStrategyFactory {
private DefaultFactory() {}

static DefaultFactory instance;

public static AbstractStrategyFactory getInstance() {
if (null==instance)
instance = new DefaultFactory();
return instance;
}

public MessageStrategy createStrategy(final MessageBody mb) {
return new MessageStrategy() {
MessageBody body = mb;

public void sendMessage() {
Object obj = body.getPayload();
System.out.println(obj.toString());
}
};
}
}

public class HelloWorld {
public static void main(String[] args) {
MessageBody mb = new MessageBody();
mb.configure("Hello World!");
AbstractStrategyFactory asf = DefaultFactory.getInstance();
MessageStrategy strategy = asf.createStrategy(mb);
mb.send(strategy);
}
}
Jun 2 '08 #17
ZeldorBlat schreef:
On Apr 29, 9:43 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>Wow, I never realised you could do Hello World without instantiating a
custom class.

You mean like this?

public interface MessageStrategy {
public void sendMessage();
}

public abstract class AbstractStrategyFactory {
public abstract MessageStrategy createStrategy(MessageBody mb);
}

public class MessageBody {
Object payload;

public Object getPayload() {
return payload;
}

public void configure(Object obj) {
payload = obj;
}

public void send(MessageStrategy ms) {
ms.sendMessage();
}
}

public class DefaultFactory extends AbstractStrategyFactory {
private DefaultFactory() {}

static DefaultFactory instance;

public static AbstractStrategyFactory getInstance() {
if (null==instance)
instance = new DefaultFactory();
return instance;
}

public MessageStrategy createStrategy(final MessageBody mb) {
return new MessageStrategy() {
MessageBody body = mb;

public void sendMessage() {
Object obj = body.getPayload();
System.out.println(obj.toString());
}
};
}
}

public class HelloWorld {
public static void main(String[] args) {
MessageBody mb = new MessageBody();
mb.configure("Hello World!");
AbstractStrategyFactory asf = DefaultFactory.getInstance();
MessageStrategy strategy = asf.createStrategy(mb);
mb.send(strategy);
}
}
LOL.
;-)

Good job. :P

Erwin Moller
Jun 2 '08 #18
On Apr 29, 1:03 pm, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
ZeldorBlat schreef:
On Apr 29, 9:43 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
Wow, I never realised you could do Hello World without instantiating a
custom class.
You mean like this?
public interface MessageStrategy {
public void sendMessage();
}
public abstract class AbstractStrategyFactory {
public abstract MessageStrategy createStrategy(MessageBody mb);
}
public class MessageBody {
Object payload;
public Object getPayload() {
return payload;
}
public void configure(Object obj) {
payload = obj;
}
public void send(MessageStrategy ms) {
ms.sendMessage();
}
}
public class DefaultFactory extends AbstractStrategyFactory {
private DefaultFactory() {}
static DefaultFactory instance;
public static AbstractStrategyFactory getInstance() {
if (null==instance)
instance = new DefaultFactory();
return instance;
}
public MessageStrategy createStrategy(final MessageBody mb) {
return new MessageStrategy() {
MessageBody body = mb;
public void sendMessage() {
Object obj = body.getPayload();
System.out.println(obj.toString());
}
};
}
}
public class HelloWorld {
public static void main(String[] args) {
MessageBody mb = new MessageBody();
mb.configure("Hello World!");
AbstractStrategyFactory asf = DefaultFactory.getInstance();
MessageStrategy strategy = asf.createStrategy(mb);
mb.send(strategy);
}
}

LOL.
;-)

Good job. :P

Erwin Moller
Sorry, I should have included my source:

<http://ask.slashdot.org/comments.pl?sid=250311&cid=19862863>

Somebody else referred to that as the "Gang of Four Job Security
Strategy" pattern.
Jun 2 '08 #19
On Tue, 29 Apr 2008 09:54:07 -0700 (PDT), ZeldorBlat wrote:
On Apr 29, 9:43 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>>
Wow, I never realised you could do Hello World without instantiating a
custom class.

You mean like this?

public interface MessageStrategy {
public void sendMessage();
}

public abstract class AbstractStrategyFactory {
public abstract MessageStrategy createStrategy(MessageBody mb);
}
Ah, now THAT looks like some of the stuff some coworkers turn out...
(;

--
19. I will not have a daughter. She would be as beautiful as she was evil, but
one look at the hero's rugged countenance and she'd betray her own father.
--Peter Anspach's list of things to do as an Evil Overlord
Jun 2 '08 #20
On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi**********@gmail.comwrote:
Could you put up with the horrible PHP code?
I think we missed something guys. He says 'the PHP code is horrible', not
'PHP code is horrible'. Now, if someone would like to point me to the
source of the JRE, maybe we can get somewhere...
--
Rik Wasmus
Jun 2 '08 #21
On Apr 30, 1:29 am, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi.steven...@gmail.comwrote:
Could you put up with the horrible PHP code?

I think we missed something guys. He says 'the PHP code is horrible', not
'PHP code is horrible'. Now, if someone would like to point me to the
source of the JRE, maybe we can get somewhere...
--
Rik Wasmus
PHP code is horrible. Don't get me wrong.
Jun 2 '08 #22
tenxian wrote:
On Apr 30, 1:29 am, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
>On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi.steven...@gmail.comwrote:
>>Could you put up with the horrible PHP code?
I think we missed something guys. He says 'the PHP code is horrible', not
'PHP code is horrible'. Now, if someone would like to point me to the
source of the JRE, maybe we can get somewhere...
--
Rik Wasmus

PHP code is horrible. Don't get me wrong.
Not at all. Horrible programmers write horrible code in any language.
Good programmers write good code in any language.

Your prejudice is showing.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
6
by: baumann | last post by:
hi all, i couldn't understand why code 1) can solve the problem of code 2) has. code 1) template<class T> T* clone(const T* tp) { return tp->clone(); } and change our make_unique member to...
4
by: codecraig | last post by:
Is there any obfuscator out there that obfuscates the python code (byte code i guess)???
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
5
by: Peri | last post by:
Dear All, In VB 6.0 declaring this function and calling this functions works smoothly. But in VB.NET or ASP.NET (Code behind), I am getting an error in the line "HResult =...
51
by: erikcw | last post by:
DiveIntoPython.org was the first book I read on python, and I really got a lot out of it. I need to start learning Java (to maintain a project I've inherited), and was wondering if anyone knew of...
21
by: blackx | last post by:
I got this error: error C2664: 'Vector::setVector' : cannot convert parameter 1 from 'const std::ifstream' to 'std::ifstream' How can it not be able to convert from std::ifstream to...
0
by: zgh1970 | last post by:
Hi, All, I have problem on updating JAVA UDF on db2 UDB V8 FP10 on aix. I just updated a JAVA code used by the JAVA UDF. I deployed this change to our three region (DB2 UDB v8 FP12 and DB2 v8...
3
by: Ramesh Jos | last post by:
Hi, While i was going through this code, I couldn't understand what these pieces of code are going to do ... Can anyone help me understand it ?? #!/usr/bin/perl package Person;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.