4 ms·
One of the reasons I like PHP is that it still lets you get to a lower level of coding. Many of the newer languages and frameworks that have become popular in
by rick888 15y ago
One of the reasons I like PHP is that it still lets you get to a lower level of coding. Many of the newer languages and frameworks that have become popular in the past couple of years abstract things such as database connectivity away (Django is a good example of this) and it makes it difficult to optimize queries effectively without hacking onto the framework.
- dshah 15y agoMost ORMs (including Django) let you easily drop-down into writing your own custom SQL queries when the need arises.
- rick888 15y agoI've used Django and many others and while you can do this, you end up with code that isn't very clean.
- ch0wn 15y agoDepends on your definition of 'clean'. I think Django found a very solid way to handle raw SQL statements[0]. [0] https://docs.djangoproject.com/en/dev/topics/db/sql/ https://docs.djangoproject.com/en/dev/topics/db/sql/
- epochwolf 15y agoRails has two ways to do this. You can do any select query returning active record objects with Model.find_by_sql("raw select query") And any query with a driver dependent result using ActiveRecord::Base.connection.execute("raw sql") You can shorten the second one to simply "execute" by creating a method to wrap the functionality.
- astrodust 15y agoDon't confuse abstraction and formalization with convention with restricting low-level access. Most ORM frameworks allow you to drop down to direct SQL if you need to.
- rick888 15y agoWow, It's pretty apparent that there are a lot of young programmers here on HN. I was just stating my opinion and I got downvoted because I talked bad about your precious frameworks.
- adambard 15y agoThe comparison between PHP and frameworks isn't valid. Writing PHP on a framework probably abstracts away SQL too, just like writing CGI in Python gives you lower-level control.
- rick888 15y agoWhen frameworks are the popular alternative to PHP (RoR,Django,etc), it is valid. Are we also not allowed to talk about RoR when it comes to a discussion about PHP alternatives?
- randomdata 15y agoThat is like saying Cocoa is a popular alternative to C++, but you prefer C++ because it allows you to write your own UI event loop. I guess it is true if you really stretch your imagination, but does it mean anything?
- rick888 15y agoYes, when I write a web app, I don't want to be stuck with extra code that abstracts away the database into a less-efficient object/class and forces me to break the convention of the framework to write the code that I need. I suppose it's fine when many of then newer programmers don't even know or understand what's going on underneath anyway...
- docgnome 15y agoIt's a bit comparing apples to oranges. If you were comparing say Cake or Zend to RoR and Django then it would be a reasonable comparison.