Live data from Hacker News

Rambling On [PHP] Internals

blog.ircmaxell.com

151–160 of 169 posts

Re: Rambling On [PHP] Internals

#151
post #132
post #94

I recently started learning PHP as my first programming language and I love it so far. But the amount of negativity and hatred I see towards PHP on the internet (even among so-called PHP lovers) makes me question my decision of learning PHP. My main purpose for learning PHP is for web-development. I have looked into java code and I felt like I am going to shit pants if I have to learn that. 2 questions. - Am I wastin…

YES, you are wasting your time with PHP! (If by "wasting time" you mean that there are other better ways to use your time and learn much more in the same amount of time. ) PHP is mostly ok as tool to get shit done with but it is one of the worst possible options for something to learn as a first programming language for many reasons, including: - you will not learn how most real programming languages are, as PHP was…

> it has two namespaces for functions and variables (not other common language has this - yeah, there's Perl and Common Lisp, but...)

Separate namespaces for variables and functions in Perl? Huh?

Re: Rambling On [PHP] Internals

#152
post #106

Earlier quoted context omitted.

No, you are not wasting your time. You will read people complain about PHP but in the end, it provides me with a great job that pays the bills and then some! When used properly, it doesn't have to be a bad language and can be fun. That, and if you are just starting to get into web development, it is a great place to start. You can always branch out into other web technologies down the road. Have fun and keep learning…

> When used properly, it doesn't have to be a bad language > That, and if you are just starting to get into web development These two things don't square well, and is a major reason why I discourage PHP. It's pedagogically suboptimal to be encouraging the sorts of behavior that culturally accepted PHP often does. You can write good PHP. After many years I got to the point where I could say confidently that I can. But…

So what you are saying is that unless you can write good code from day one you shouldn't attempt to use a language, regardless of language?

The code I'd write in say, Clojure day one would be terrible when compared to the code I'd write a year or two later. Does that mean I shouldn't learn and use it?

Re: Rambling On [PHP] Internals

#153

Earlier quoted context omitted.

> The remaining thing keeping PHP so popular is how amazingly ubiquitous it is. A fork wouldn't have that advantage, especially in comparison to languages and environments that are objectively better anyway. Initially, I believe you are correct, but I am not sure long term. PHP is easy for a system admin to install. Other than perl, I am not sure if there is anything out there that is as easy. I would imagine a fork,…

A lot of things are becoming extremely easy to install though. With the growth of AWS and cloud-services I'd guess there will be movement away over the next 5 years.

I have not seen anything that comes close (other than CGI scripts) from either the system admin side or the client code side. I would love to know if other folks are addressing this. The closest (well, other than Perl) is some of the tooling surrounding Java deployment.

Re: Rambling On [PHP] Internals

#154
post #140

Earlier quoted context omitted.

Some people pour way too much emotions into the choice of programming languages. PHP is fine and no matter which language you start out with, switching to a new one later isn't a big deal - They are pretty much the same underneath the syntactic layer anyway.

Wow, I strongly disagree with that. Different languages have different libraries, different communities, different philosophies, different purposes. Sure, a person who started in C can go and write C-ish code in many other languages. But that's bad code. Good code is idiomatic and takes advantage of the strengths of the language and platform it's written for.

Depends on your perspective, I guess. The difference between not knowing how to program and learning, say, ruby is a fair bit larger than the difference between knowing how to program in php and learning ruby.

Take php and ruby (two languages I happen to have used a fair bit both). If you're writing your typical web app, you'd probably use mysql for a database. That's the same. You talk http to the client - same. You want to parse xml? Probably going to use libxml underneath the covers. And so on. So yes, there's different libraries for the two, but there's also a lot that is shared.

As for different philosophies, they are both pretty much imperative languages. Php has a simpler object model than ruby and ruby has some fp features, such as co-routines, but by and large you write programs in the same style.

And different purposes? I'll dispute that. You pretty much use both languages for more or less the same things.

Mind you - I'm not saying they are exactly the same. Clearly they're not. But I'm saying the difference is in the nuances.

And while I do agree that ruby is a nicer language than php, I think the trend of treating it as if it was toxic is completely out of proportions.

Re: Rambling On [PHP] Internals

#155
post #132

Earlier quoted context omitted.

YES, you are wasting your time with PHP! (If by "wasting time" you mean that there are other better ways to use your time and learn much more in the same amount of time. ) PHP is mostly ok as tool to get shit done with but it is one of the worst possible options for something to learn as a first programming language for many reasons, including: - you will not learn how most real programming languages are, as PHP was…

> it has two namespaces for functions and variables (not other common language has this - yeah, there's Perl and Common Lisp, but...) Separate namespaces for variables and functions in Perl? Huh?

Sigils.

Re: Rambling On [PHP] Internals

#156

Earlier quoted context omitted.

Most common thing that seems to come out is using string concat for sql queries.

Yes, 8 years ago ... PDO and prepared statements is the quasi-standard since the release of PHP 5.1

...if you're lucky to be working in a PHP dev shop that utilises current and proper tech. Most PHP shops that I've had experience with, either directly or through other PHP coders, are mostly stuck with mysql_query esque setups all over the place. If they're lucky, someone wrote an OO wrapper for it.

That being said, it's a small sample size of maybe just over 100 over the last few years. Weigh accordingly.

Re: Rambling On [PHP] Internals

#157
post #148
post #94

I recently started learning PHP as my first programming language and I love it so far. But the amount of negativity and hatred I see towards PHP on the internet (even among so-called PHP lovers) makes me question my decision of learning PHP. My main purpose for learning PHP is for web-development. I have looked into java code and I felt like I am going to shit pants if I have to learn that. 2 questions. - Am I wastin…

There's always lots of PHP hating going on from language snobs, mostly from people with toy projects in the latest language du jour (was Ruby, then Node, Scala, now Clojure and Go). Fact is PHP, for all its faults, still runs far more websites than all of those others combined and then some ( http://w3techs.com/technologies/overview/programming_languag... - eg PHP 80%, Ruby 0.5%, Python 0.2%)

The "it's popular, hence it's great" argument isn't a good one to use to evangelize though, at least not by itself. Case in point, what operating system is still the most popular by far? Popular doesn't always equate to best.

Re: Rambling On [PHP] Internals

#158
post #148

Earlier quoted context omitted.

There's always lots of PHP hating going on from language snobs, mostly from people with toy projects in the latest language du jour (was Ruby, then Node, Scala, now Clojure and Go). Fact is PHP, for all its faults, still runs far more websites than all of those others combined and then some ( http://w3techs.com/technologies/overview/programming_languag... - eg PHP 80%, Ruby 0.5%, Python 0.2%)

The "it's popular, hence it's great" argument isn't a good one to use to evangelize though, at least not by itself. Case in point, what operating system is still the most popular by far? Popular doesn't always equate to best.

You're right, but it's a strawman argument as I never said that. "it's incredibly well used, but it has faults" is nearer the mark.

Re: Rambling On [PHP] Internals

#159

Earlier quoted context omitted.

> it has two namespaces for functions and variables (not other common language has this - yeah, there's Perl and Common Lisp, but...) Separate namespaces for variables and functions in Perl? Huh?

Sigils.

I figured that may have been the reasoning, but I long ago stopped thinking of the variable names in Perl as just the alphanumeric portion. To me, the native data types, which are denoted by the sigils, are intrinsic to the name.

Re: Rambling On [PHP] Internals

#160
post #154

Earlier quoted context omitted.

Wow, I strongly disagree with that. Different languages have different libraries, different communities, different philosophies, different purposes. Sure, a person who started in C can go and write C-ish code in many other languages. But that's bad code. Good code is idiomatic and takes advantage of the strengths of the language and platform it's written for.

Depends on your perspective, I guess. The difference between not knowing how to program and learning, say, ruby is a fair bit larger than the difference between knowing how to program in php and learning ruby. Take php and ruby (two languages I happen to have used a fair bit both). If you're writing your typical web app, you'd probably use mysql for a database. That's the same. You talk http to the client - same. You…

I agree that different languages don't all have perfectly different purposes or philosophies, but I'm not sure why you'd think I'm claiming that.

I think you could pick better examples. PHP and Ruby are both interpreted, Perl-inspired languages started by hobbyist first-time language designers who released 1.0 versions about months apart. So yes, if you apply them to similar problems and use similar techniques in the same languages, you'll have similar experiences.

But even so, I think PHP's purpose, which is rooted in letting amateurs simply render web pages, is very different than Ruby's purpose, which is a flexible, general purpose, objects-first scripting language. I also think their design philosophies are pretty different. PHP has never worried much about elegance or consistency; Ruby inherited Perl's DWIM approach, but tried to do it in a way that was not just functional, but beautiful.

Post reply on HN