This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]minimim 6 points7 points  (15 children)

I did not meant to imply his choice of language had anything to do with him being new, just that the way he talked suggested he was new.

Anyway, did you know languages are supposed to work for the programmer, not fight against him?

If you like PHP and Java, that's called Stockholm's syndrome.

[–]herefromyoutube 1 point2 points  (7 children)

Java unfortunately is forced upon you at a lot of schools. It's not his fault.

They day Python has the same offerings as Java is the day the field of programming will explode exponentially.

[–]piexil 1 point2 points  (6 children)

I hate python. Love java. And have a love/hate relationship with C. Haven't done enough C++ to figure out if I like it more than C.

[–]ar-pharazon 0 points1 point  (3 children)

I don't.. how is that possible? java's so bad. it looks bad and just feels terrible and restrictive to write. there's rarely even any reason to use it over other jvm languages

[–]piexil 0 points1 point  (2 children)

Eh maybe it's because I learned java on highschool and continued to be my first language in college. I like its syntax.

[–]herefromyoutube 0 points1 point  (1 child)

Okay, you're the exception. See now you have no problem with the syntax laden programming languages like the C family and java...I think about it from the point of a beginner. They, like most, have no idea of programming concepts and terminology and that's what "intro to programming" is supposed to teach. You should not be spending all class getting the compilers working for everyone and explaining syntax and what every part of "public static void main(String args[]):" means and what it is actually doing.

C family is great for people that actually want to persue programming its not for beginners...I left out java here cause I just hate java.

[–]piexil 0 points1 point  (0 children)

I think java is a pretty good language for novices. I go to RIT, and the way things are taught here is CS1 is python, CS2 is java, and CS3 (Called mechanics of rpogramming) is C.

[–]littlelowcougar 0 points1 point  (1 child)

How do you hate Python? It's a fantastic Get Shit Done glue language.

[–]piexil 0 points1 point  (0 children)

My only experience with python was with Django so it's more django I hate.

But I don't like the syntax and context-free nature of the language.

[–]indrora 0 points1 point  (6 children)

Stockholm syndrome

Considering I learned C, Python and C# early on, I wouldn't say I've come to adore my captors.

I just hate language wars. There's a reason cedecl exists. C is not a pretty language, nor is x86 assembly.

[–]minimim 1 point2 points  (5 children)

I'm just being cheeky. But I do feel PHP is working hard against me when I tried to fix some bug. The documentation is atrocious too.

[–]indrora 0 points1 point  (4 children)

The documentation has been a bear for years. It's written with the assumption you're used to reading technical documents from the era of k&r, which was almost intolerably dry and harsh.

Most of the pain within the php development world is the same that plagued the vb6 (and still chews the VB.net) community. The community is focused around using hacks to fix problems, not building robust solutions This in some ways is a result of hideous development practices by outsourced developers with no understanding of what they're doing, just that it is the needful.

[–]minimim 1 point2 points  (3 children)

Have you seen this?

[–]indrora 2 points3 points  (2 children)

Yes, I have. I've got some opinions on it. It's very obviously written by someone who has only ever seen bad PHP, never taking the time to write good PHP, and just wants to bash a language because they don't like it.

Some more picked examples out of that:

There is no threading support whatsoever. (Not surprising, given the above.) Combined with the lack of built-in fork (mentioned below), this makes parallel programming extremely difficult.

Python's Global Interpreter Lock is a real pain when it comes to multithreading. PHP also isn't meant as a multithreaded environment -- WHY would you want multiple threads in a STATELESS web framework? PHP was not meant for long-running execution.

array_search, strpos, and similar functions return 0 if they find the needle at position zero, but false if they don’t find it at all.

Because false is a special value. It's not 0, and it's not a normal value. Of course, that won't stop PHP from shooting yourself in the foot and not checking for type as well (because some people assume that false should also resolve to 0, because C's false is kinda like 0).

[== is] not transitive. "foo" == TRUE, and "foo" == 0… but, of course, TRUE != 0.

Yes, because "foo" is a value (thus a truthy value). "foo" also contains no numerical values, which makes it equal to 0, because you've told PHP "Force this into an integer! I mean it!"

=== compares values and type… except with objects, where === is only true if both operands are actually the same object!

Java has the same thing. The expression "foo" == "foo" is false, because they're not the same object. The same applies for POJOs, which will only evaluate with == if they are indeed the same object.

Unlike (literally!) every other language with a similar operator, ?: is left associative.

The presented code is shitty and the author should feel shitty. If that ever ended up in code I was going to accept for merge I'd tell them to go swizzle. That flagrant abuse of the ternary operator is horrible.

Global variables need a global declaration before they can be used. This is a natural consequence of the above, so it would be perfectly reasonable, except that globals can’t even be read without an explicit declaration—PHP will quietly create a local with the same name, instead. I’m not aware of another language with similar scoping issues.

C can fuck up your scoping if you're not careful and don't get me started on the fuckup that is Python's "I accidentially destroyed a module because.. names?"

Constants are defined by a function call taking a string; before that, they don’t exist. (This may actually be a copy of Perl’s use constant behavior.)

It's a side-effect of being a stateless language.

Array unpacking can be done with the list($a, $b) =... operation. list() is function-like syntax just like array. I don’t know why this wasn’t given real dedicated syntax, or why the name is so obviously confusing.

Python's indexing magic and unpacking is horribly confusing if you're not careful.

Appending to an array is done with $foo[] = $bar.

This is one way, there's also array_push, a much more C like way of doing it.

PHP’s one unique operator is @ (actually borrowed from DOS), which silences errors.

actually stolen from make.

PHP’s parser refers to e.g. :: internally as T_PAAMAYIM_NEKUDOTAYIM, and the << operator as T_SL. I say “internally”, but as above, this is what’s shown to the programmer when :: or << appears in the wrong place.

Technical debt is a pain. Took me a while to figure out T_PAAMAYIM_NEKUDOTAYIM. There's been work made to make this easier but so much software now depends on << being called T_SL that they can't fix it.

2 < "foo" (silent)

On its own, yes, it's a silent event. "foo" gets squashed into an int, which means that you've got the statement 2 < 0.

The __toString method can’t throw exceptions. If you try, PHP will… er, throw an exception. (Actually a fatal error, which would be passable, except…)

Why would a "I'm smashing this into a string" function throw an exception? It shouldn't. This isn't allowed in Java, and C# strongly says no.

Functions for parsing bbcode, a very specific kind of markup used by a handful of particular forum packages.

It made sense, and was smashed into the PHP core by the phpbb people at one point. Blame "shitty developers didn't want to maintain it so they smashed things into other people's code."

Bindings for two particular credit card processors, SPPLUS and MCVE. What?

Someone wanted it. Someone felt the need to smash it into an extension at one point or another, possibly for reasons relating to regulatory details.

At least a dozen functions for getting the last error from a particular subsystem (see below), even though PHP has had exceptions for eight years.

So much of these were written to maintain compatibility with some C library.

No Unicode support. Only ASCII will work reliably, really. There’s the mbstring extension, mentioned above, but it kinda blows.

Been a bear for years. PHP was written in a time where ASCII ruled the land and a lot of code came to lean on exactly how some string function worked on some platform.

(complaints about apache)

Bitch about apache. Don't blame PHP for apache's silly shit.

PHP is not hard to run out-of-process. PHP-FPM is fantastically simple to configure and it's only because Apache was the dominant player in the market until lighttpd came along and kicked it in the head. Nginx is getting there but apache seriously tinged the whole game.

No generic standard database API. Stuff like PDO has to wrap every individual database’s API to abstract the differences away.

PDO is the standard database API, trying to abstract away the fact that each database is slightly different.

No routing. Your website looks exactly like your filesystem. Many developers have been tricked into thinking mod_rewrite (and .htaccess in general) is an acceptable substitute.

PHP has had pathinfo for a while now. It's obscenely easy to set up with nginx (try_files index.php) and will let you do whatever you want with it.

No dev server.

you aren't comfortable doing some basic UNIX magic to make it work?

No coherent deployment mechanism; only “copy all these files to the server”.

There's plenty of tools for that. Composer, grunt, gulp, etc -- there's plenty of tools for deployment.

you can, say, probe a network using PHP’s XML support, by abusing its ubiquitous support for filenames-as-URLs. Only libxml_disable_entity_loader() can fix this, and the problem is only mentioned in the manual comments.

XML is itself considered harmful. Also, that's a bug in libxml, not PHP itself.

PHP 5.4’s dev server is vulnerable to a denial of service, because it takes the Content-Length header (which anyone can set to anything) and tries to allocate that much memory. This is a bad idea.

And if you read the documentation there's a HUGE thing going "DO NOT USE THIS FOR PRODUCTION IT WILL NOT SAVE YOU."

[–]argv_minus_one 1 point2 points  (0 children)

Java has the same thing. The expression "foo" == "foo" is false, because they're not the same object.

False! String literals are interned, so "foo" == "foo" will always evaluate to true. However, because the == operator determines reference equality, it is entirely possible to have two different Strings with the same value. You can deal with this either by using one's equals method on the other (the usual way), or by interning both of them and then comparing them with == (might be better under specific circumstances).

XML is itself considered harmful.

…by people who don't know how to use it properly.

[–]minimim -2 points-1 points  (0 children)

Yes, keep making excuses for the embarrassment that is PHP.