Live data from Hacker News

Rambling On [PHP] Internals

blog.ircmaxell.com

141–150 of 169 posts

Re: Rambling On [PHP] Internals

#141
post #115

Earlier quoted context omitted.

What bad things are culturally accepted in PHP?

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

Is the last time you even looked at PHP about 6 years ago?

You and yours really need to read up on what you hate so much so you don't look like a bunch of fools arguing about things that don't exist.

That said: There are many projects still using crap like that, but that is because of bad programmers. This stuff is deprecated in core and its use is heavily discouraged.

Re: Rambling On [PHP] Internals

#142
post #14

PHP is addictive. You can create whole web app in one PHP file from scratch and it will have everything including API and DB management layer and be secure and fully functioning. And it will work on all servers and on all operating systems. Millions are made by average developers developing themes and plugins for wordpress. Hard to beat all that. #drama is for queens :)

>You can create whole web app in one PHP file from scratch and it will have everything including API and DB management layer and be secure and fully functioning. And it's very, very difficult to do that properly, because PHP seems to go out of its way to make all of those things (APIs, DB management, security, functioning) difficult. >And it will work on all servers and on all operating systems. Except for UNIX, wher…

PHP's PDO is extremely easy to work with. Seriously, it's like 5 lines of code to connect to a database and retrieve information. Is that really all that difficult?

Security? DB-wise, use PDO and named parameters. It's passing in an array. Sessions? For private servers, using file-based is fine. For shared or for scaling, use DB/memcache.

APIs? It's dead easy to implement a RESTful interface. Interacting with remote APIs is nothing more than some curl commands, or your tool of choice.

Explain to me what's so difficult here?

Having a language behave slightly differently between different operating systems is ... expected? Maybe? I'm not sure, I never use PHP on Windows. Why would I?

Re: Rambling On [PHP] Internals

#143
post #85

Earlier quoted context omitted.

That's why i'm impressed with Symfony and Doctrine. Taking one of the worst language out there , and creating these well crafter libraries , that's insane. I think type hinting and basic POO saved PHP.

Symfony..maybe..but Doctrine? Do we really need a sudo-sql language for creating object->db table relational mappings? I used Doctrine extensively at my last job..and I will not be using it for any personal projects. It's bloated and when I need to optimize a sql query, I have to essentially create a hack outside of the main ORM..which kinda defeats the purpose in the first place. I much prefer Zend or Codeigniter.

Doctrine1 was a mess. It was riddled with magic functions that were horrible to work with. It was slow, too.

Doctrine2, mixed with entities, is awesome. Its relationship manager is fun and easy to work with and it works very well.

You can even create hand-written custom queries if you want, using its own DSL that's fairly similar to what you would expect.

Re: Rambling On [PHP] Internals

#144

Earlier quoted context omitted.

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

Is the last time you even looked at PHP about 6 years ago? You and yours really need to read up on what you hate so much so you don't look like a bunch of fools arguing about things that don't exist. That said: There are many projects still using crap like that, but that is because of bad programmers . This stuff is deprecated in core and its use is heavily discouraged.

PHP has always had the option to write good code. It's Turing-complete, you could just write a Haskell interpreter for it if you wanted. The problem has always been that PHP's bad programmers, by and large, are the ones evangelizing the language and writing the tutorials, so anyone trying to "learn programming" via PHP gets heavily exposed to things-only-bad-programmers-do, and never really sees much good code to know that there's another way.

Re: Rambling On [PHP] Internals

#145
post #144

Earlier quoted context omitted.

Is the last time you even looked at PHP about 6 years ago? You and yours really need to read up on what you hate so much so you don't look like a bunch of fools arguing about things that don't exist. That said: There are many projects still using crap like that, but that is because of bad programmers . This stuff is deprecated in core and its use is heavily discouraged.

PHP has always had the option to write good code. It's Turing-complete, you could just write a Haskell interpreter for it if you wanted. The problem has always been that PHP's bad programmers , by and large, are the ones evangelizing the language and writing the tutorials, so anyone trying to "learn programming" via PHP gets heavily exposed to things-only-bad-programmers-do, and never really sees much good code to kn…

I'm trying to do my part. I'm a mod of /r/php and trim out the crap and promote the good stuff.

Anytime someone new to PHP or not at a higher level asks a question, I point them to proper resources.

I'm in ##php and #phpmentoring on Freenode helping out with questions.

I write articles that are, in my humble opinion, not bad and have received many compliments from people who learned from my writings.

I'm doing my part, and so are many other PHP-centric developers, and it's annoying as hell to have us lumped in with code that's several years old, or sweatshop programmers that know nothing more than the very basics.

Re: Rambling On [PHP] Internals

#146
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…

> [Javascript] is just as simple as PHP to learn. (I'd say simpler, because it doesn't have all the weird stuff in PHP)

Oh, don't worry; JavaScript has plenty of weird stuff of its own.

With that said, I agree it's probably more worthwhile to learn than PHP.

Re: Rambling On [PHP] Internals

#147
post #140
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…

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.

PHP internals are actually very different from Javascript internals, but the same could be said for a lot of languages. Point stands though, no language is the same as another and habits die hard.

Re: Rambling On [PHP] Internals

#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%)

Re: Rambling On [PHP] Internals

#149

The author is complaining about lack of vision, leadership and regulations. And most of us can perfectly understand that, except: those are exactly the things that set PHP apart from most other major open source projects. It is by far the most anarchic and disorganized major OSS project and yet it still thrives . It still moves forward, it still gets better. Yes, it's design foundations as a language are not particul…

Beached whales take a long time to die. I think these are signs that PHP is dying, not thriving.

Re: Rambling On [PHP] Internals

#150
post #140
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…

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.

Post reply on HN