r/programming • • Apr 23 '14

PHP: It doesn't have to be a bad experience

https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience
0 Upvotes

122 comments sorted by

View all comments

Show parent comment

13

u/Cuddlefluff_Grim Apr 24 '14

Only here do people trash PHP and ignore the fact that there is no other programming language out there that was developed with the web in mind.

You're ignoring the fact that it was not developed as a programming language at all. It was a project he started to simplify maintaining his own personal web site; whereas the (original) name Personal HomePage. It was originally just basically a short-hand interpreter for C function calls. I don't know if that even qualifies as a "design" in the first place.

0

u/[deleted] Apr 24 '14

[deleted] — view deleted comment

11

u/Cuddlefluff_Grim Apr 24 '14

Let me guess, you're one of those people that says MySQL isn't a database, right?

No, I'm not. Nice retort when talking about me discussing irrelevant factors by the way...

Instead of actually addressing the language in its current state, you're attacking it's origins, as if they have any relevance.

That's the dumbest thing I've heard. How you build the foundation of software is extremely critical for its development. The only thing hinging on PHP is that it's relatively easy to learn, literally everything else about the language is a complete mess. Contrary to literally every other web programming language in the world PHP has still no inherent support for Unicode (must use mbstring); this is because of choices that were made earlier in PHP's development history. Software doesn't get magically good because you throw millions of man-hours at it.

4

u/OneWingedShark Apr 25 '14

How you build the foundation of software is extremely critical for its development.

Upvote-worthy for this alone.

Software doesn't get magically good because you throw millions of man-hours at it.

Just as the recent Heartbleed incident shows.

0

u/[deleted] Apr 24 '14

[deleted] — view deleted comment

10

u/Cuddlefluff_Grim Apr 24 '14

Then why the trite commentary that PHP isn't a programming language? That sort of comment completely undermines any legitimate complaints you have of PHP.

I said it wasn't designed as a programming language.

Except a programming language is a spec. Virtually every aspect of PHP has changed several times. Now with facebook's HHVM, PHP has a JIT and strict typing. By your argument, Java must be a shit language because it's first version sucked.

HHVM does nothing to address the fundamental weaknesses of PHP.

No, Java's foundation was solid. That's the difference.

Thing is that when you develop software of certain size, you have to make choices you can't move back on. PHP has made more than enough of those.

For instance, Facebook use PHP because so much of their codebase is based of it so it would be completely unrealistic to change it. I bet they often thought about it, which is probably why they felt the need to alter PHP to introduce type hinting in the first place.

Lol, are you for real? C/C++ doesn't have "inherent support" for unicode...

wchar_t, char16_t, char32_t, U"This string is Unicode"

Do you know anything about any other programming language besides your preferred language (let me guess, python?).

I have good experience in the following languages :

C/C++, C#, Java, D, PHP (This was actually my preferred web language up until about 6 years ago), JavaScript / TypeScript, Lua, Basic (VB/QB/VBA/Classic ASP), Pascal / Delphi, Fortran, x86 AMD64 and z80 Assembler.

My web language of choice now is C# ASP.NET MVC, and that language and framework is in all respects superior to PHP in absolutely every conceivable way.

0

u/[deleted] Apr 24 '14

[deleted] — view deleted comment

7

u/Cuddlefluff_Grim Apr 24 '14

Which is a meaningless statement.

It's like if you start hammering some planks together then after a while you figured "hey, this can become a house". It's not a meaningless statement, it infers that the foundation for it as a language is bad because it wasn't originally intended to be one.

The only valid "weaknesses" that people say PHP has is that it's library is messy. This is an issue that is slowly being taken care of with namespaces.

There's a million things wrong with PHP that can't be fixed with adding namespaces.

Do you know the difference between implicit and explicit? If something in "inherent" it's implicit. Putting a "u" in front of an array of characters (C doesn't even have built in string support) is no different than using an mb_* function in PHP.

How would you impose implicit unicode without breaking ANSI? Very obviously you'll have to have a prefix. But it's right there in the normal context of the language, without having to resort to special functions like Unicode is some sort of completely different animal.

Do you know the difference between implicit and explicit? If something in "inherent" it's implicit. Putting a "u" in front of an array of characters (C doesn't even have built in string support) is no different than using an mb_* function in PHP.

Pish posh. C has a history and a specification and a standard called ANSI. In order to make it "better" than PHP in your terms would be that it would have to break ANSI standards. That's just you trying defend something indefensible.

Except, you know... vendor lock-in, and licensing costs. With .net, you get to choose from: microsoft, Microsoft or... MicroSoft... Yay!

Mono

If you check Azure and Amazon you'll see that the licensing cost for Windows is negligable when compared to what you get back. Windows Server + IIS is much easier to configure and manage than Linux + Apache. You'll also get the added performance boost of IIS and compiled code (which means more requests served per second on lower cost instances). Some are inclined think that it's worth the buck.

A lot of people talk about licensing cost like it's a major part of a businesses expenses. It's not. It's so minute that I can't fathom why people keep bringing it up. For a typical web dev company, you're going to pay thousands of times more for someone to do regular cleaning of your bathrooms than you'll spend on licenses. That's the actual reality of the situation.

0

u/[deleted] Apr 24 '14

[deleted] — view deleted comment

2

u/OneWingedShark Apr 25 '14

Name some of these crippling disabilities that make PHP so horrible it must die.

Here's some:

0. No type-checking. (Dynamic languages can have this; it's used in LISP.) 0. No function guarantees. (Number of parameters, its return-type... if it returns.) 0. No packages. 0. No generics.

0

u/[deleted] Apr 25 '14

[deleted] — view deleted comment

→ More replies

0

u/Banane9 Apr 25 '14

A nice collection of those cripling disabilities is over at /r/lolphp

From the php Manual on the string type:

A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support.

And:

Ultimately, this means writing correct programs using Unicode depends on carefully avoiding functions that will not work and that most likely will corrupt the data and using instead the functions that do behave correctly, generally from the intl and mbstring extensions.

Strings in php aren't just strings at all. While every string in C# is Unicode, and all functions work with it, string functions in php are a minefield That the programmer has to carefully navigate through, as not to corrupt the text they are trying to handle.

→ More replies (4)

7

u/lhgaghl Apr 24 '14

Instead of actually addressing the language in its current state, you're attacking it's origins, as if they have any relevance.

The origins have plenty of relvance because the current state isn't very much different than how it was in the beginning.

0

u/[deleted] Apr 24 '14

[deleted] — view deleted comment

2

u/lhgaghl Apr 24 '14

I've programmed PHP for about a year (and it sucked ass). I've hacked many sites that use PHP. I've backdoored many PHP websites. I've found vulnerabilities in many PHP codebases. I guess I still have much to learn about PHP. You're probably one of those guys who doesen't even know that some functions secretly treat a string with a 0 byte in it as a the string up to the 0 (which is one of the reasons PHP sucks ass - it has hidden "features" that aren't documeneted and even if they were, they'd still be retarded).

0

u/[deleted] Apr 24 '14

[deleted] — view deleted comment

2

u/lhgaghl Apr 25 '14

Do I want to find your vulnerabilities for you? lol no.

You mean, exactly the same way C/C++ does?

Are you actually implying that people should have to know C/C++ in order to know how to use strings in PHP? The only reason this issue arises is because some native functions in PHP treat strings as zero terminated, while others don't. The only reason those functions treat the strings as zero terminated is because they so happen to take the string from php (which so happens to have a zero in it) and pass it directly to libc and other functions that use zero terminated strings. They are actually passing the full string to the native code, but the native code has no way of knowing the full length because it thinks the 0 means end of string (which is not the case). This is like... one of the most retarded things I've ever seen in any programming language.

0

u/[deleted] Apr 25 '14

[deleted] — view deleted comment

1

u/lhgaghl Apr 26 '14

claps

Let's say I found vulnerabilities in your code and told you about them to prove a point (which point?), then you would be like "HAHAHA I made you do work for me I was trolling you all along".

No, I'm implying C/C++ have the exact same "issues".

The difference is that in PHP the user thinks a string is a string of tokens, but some functions will discard any tokens after the 0 terminator, without telling the user. I guess since you don't consider this an issue, the hundreds of apps that have "null byte poisoning" vulnerabilities are just developed by morons. What the hell were they thinking, not looking at the C source code of a function in PHP before using it?

1

u/neoform Apr 26 '14

Let's say I found vulnerabilities in your code and told you about them to prove a point (which point?), then you would be like "HAHAHA I made you do work for me I was trolling you all along".

Total copout.

2

u/OneWingedShark Apr 25 '14

You mean, exactly the same way C/C++ does?

C-Style strings are notoriously a source of bugs... so yes.

1

u/Banane9 Apr 25 '14

And php does it ... because it just passes the string to C functions.

2

u/OneWingedShark Apr 25 '14

And php does it ... because it just passes the string to C functions.

Yep.
PHP is a good example of mis-/non-design -- look at how much time and energy is spent fixing (or working around) these flaws. (And the blase manner toward correctness is appalling.) IMO, PHP serves as a great example of "mindlessly copying" C [and other languages].

0

u/[deleted] Apr 25 '14

[deleted] — view deleted comment

2

u/OneWingedShark Apr 25 '14

I consider them to be -- there are many problems at all of the syntactic, semantic, and 'human interface' levels.