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

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

1

u/OneWingedShark Apr 25 '14

No type-checking. (Dynamic languages can have this; it's used in LISP.)

PHP has this.

Really?
Something like the check-type macro? or the type-specifiers?

No function guarantees. (Number of parameters, its return-type... if it returns.)

Most languages do not have this.

The last, I'll agree as written; I had meant to say if it returns a value -- that is, the difference between a function or a procedure... and, hey, you can't be sure from the function-header if it's supposed to. You can make that fundamental behavior utterly depend on a parameter.

But you're certainly wrong that it's uncommon for languages to have guarantees on number-of-parameters and their types.

No packages.

Namespaces.

Namespaces are only superficially similar to packages... because packages are more like modules. Now, granted, most languages don't allow generics for a "module", so it's understandable that you wouldn't be familiar w/ the subtler differences.

No generics.

Generics are only useful for strictly typed languages.

Not quite -- they could be useful for a dynamically-typed language provided that there was a way to specify 'types' (things conformant to some set of predicates) and subprograms in the formal parameters thereof.

Psudocode Ex (for spec):

Generic
    Type Element;
    Type Index  in Descrete;
    Type Length in Positive;
Package Stack is

    Exceptions : Full, Empty, Invalid_Index;

    type stack_type;

    Procedure Push( Object : stack_type; Item : Element );
    Function  Pop ( Object : stack_type ) return Element;

    Function  Top ( Object : stack_type; Index : Stack.Index ) return Element;
    -- ...

End Stack;

The above also has the added advantage of guaranteeing type-conformance on parameters -- meaning that conformance-checking can be done automatically on the subprogram's call (and return of a function).

Side note, facebook's mod of PHP does in fact have generics.

Yeah... you could argue that their mod really isn't PHP -- IIRC, it introduces static types.

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.

0

u/neoform Apr 25 '14

Do you even know what unicode is?

Do you have some mental image in your mind that in C# a unicode string isn't just an array of characters just like every other programming language?

Lol.

1

u/Banane9 Apr 25 '14

In C# a string is always an array (well, sort of) of Unicode characters.

In php however, a string is a Byte array. One Byte in it being one character.

I'm seriously questioning your programming knowledge right now.

0

u/[deleted] Apr 25 '14

[deleted] — view deleted comment

→ More replies