TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Is PHP/MySQL Still Practical for Building Web Applications?

82 点作者 jakerocheleau超过 14 年前
I ask because there are so many open source projects based on PHP code, but from what I've read RoR is faster and easier to work with. I'd like to get opinions on the matter to reference for future decisions in startup development

39 条评论

dangrossman超过 14 年前
You can just as easily say RoR is slower (than, say, Symfony 2.0 on PHP with an opcode cache) and harder to work with (from a system administration perspective).<p>Take a look down the top 100 website list, and of those sites that are web applications, more of them will be built on PHP than not. I don't think there's even a Ruby application among the top 100 sites except parts of Twitter, but I could be forgetting something.<p>- Facebook<p>- Yahoo! (Answers, Bookmarks, Delicious, etc)<p>- Wikipedia<p>- WordPress (.com application is #19, another 14 million active installs of the free software)<p>- Flickr<p>It may not be <i>cool</i> right now, but it's certainly <i>practical</i>.
评论 #1868111 未加载
评论 #1868330 未加载
评论 #1868446 未加载
评论 #1868160 未加载
评论 #1869110 未加载
评论 #1868260 未加载
TamDenholm超过 14 年前
My personal opinion is that a project can be language agnostic. You can build in whatever you want. It doesn't matter if you build your app in php, ruby, python, asp or whatever, if you're a good coder you will produce good secure code, if you suck, so will your code.<p>So build in whatever you're most comfortable with and don't pick a language because of a superficial reason.
评论 #1868102 未加载
评论 #1869016 未加载
评论 #1868432 未加载
评论 #1879698 未加载
评论 #1868429 未加载
评论 #1868203 未加载
apinstein超过 14 年前
I am a 15-year veteran of PHP and am still using it to build apps. Why? Because I have 15 years' of experience, and nothing surprises me anymore. I can fix nearly any bug in a very short time. Also, it's fast, mature, proven, and rock-solid, and I don't spend much time worrying about the surrounding infrastructure.<p>I haven't switched to Ruby personally yet because I am too busy to worry about having to spend hours/days dealing with issues that are new to me. OTOH I am allowing developers on my team to found new projects in Ruby since they already know the stack and I certainly have no aversion to learning new things.<p>PHP isn't a great language for applying the latest metaprogramming techniques and other modern patterns that make life easier. Although PHP 5.3 makes that much better with the addition of lambda, it's still tough to do certain types of patterns or write easily testable code in some circumstances. Mixins are also still a bit tricky since there's no language built-in for doing them.<p>However, some of the RFC's on grafts and traits are very promising in this regard, and frankly I think these patterns are better than doing the same in metaprogramming b/c the compiler can help you instead of delaying all errors to runtime.<p>In any case, if you don't already have lots of PHP experience I would recommend choosing a different language to build your knowledge base on. Ruby, python, clojure, javascript any of the other "hot" languages of today that attract lots of attention and offer a clear path in the future built on a solid foundation.
chriseidhof超过 14 年前
I've built a large application in CakePHP (and had plenty of PHP experience before that). For most things, it worked well. Last week, I started doing RoR again (after a couple of years), and it beats the hell out of any other ecosystem for webdevelopment. Ruby is (for me) a much better language than PHP. I've done a lot of Haskell, too, and Haskell is even a better language than Ruby, but doesn't have the same amount of web developers.<p>What's nice about Ruby is that there is a huge ecosystem. Ruby on Rails is already very complete (especially compared to PHP). There are a lot of plugins for Rails that add the functionality you want. For example: adding image uploads (including thumbnail generation) was about 15 minutes of work, adding comments to my models too, and voting on models/comments was also done by installing a plugin. In PHP, there's a lot of code available, but most of it doesn't integrate automatically with other code.<p>I think that the amount of smart people that are working on a language/framework is very important. In Haskell, for example, there are not too many people working on web frameworks, and there's still a lot missing or broken. In PHP, there are a lot of people working on the language/frameworks, but a lot of the smart developers have moved to other tools, such as Rails/Django/etc. Therefore, I would just follow them and use a framework like Rails.<p>(A slight warning: this is all very subjective, this post is not based on any objective facts)
评论 #1868661 未加载
评论 #1868086 未加载
michaelhart超过 14 年前
While RoR is getting better in this respect, PHP is vastly better documented (both officially and all throughout the web) and the community is (at least, for now) superior to RoR. This is something that simply requires more time for RoR, as PHP has had quite a few years head start to get to where it is.<p>In practice, it honestly boils down to what you're doing and what's easier for you (and your team). If you want to test the waters, follow a few tutorials for each that you're unfamiliar with, and see what suits you better.<p>If you're using a shared server, you also have to make sure that your host supports RoR (most hosts don't). So that could be an extra expense to consider.<p>Me personally: I'm a php person. I prefer PHP + CodeIgniter, and I'm all happy :) RoR is fine and dandy, imo, but wasn't worth 9 years of PHP experience when PHP works amazingly well for everything I've ever asked of it.
评论 #1868013 未加载
评论 #1867748 未加载
评论 #1867767 未加载
sp4rki超过 14 年前
A big part of the reason that many of the biggest sites websites on the net now are made in Php, is because it was the most viable and popular option 5 years ago. In that time both Ruby and Python have made leaps of advances in using their technology for web development. Now both languages are faster than Php, and in general the popular frameworks in this languages also preach better practices.<p>I worked with Php for a couple of years and I can tell you that I absolutely thought the language was a melting pot of some great ideas with a huge bunch of WTF form the very beginning. In my opinion Php as a language is archaic and the only reason to use it now is because it makes sense for your team (because that's what your team has experience with). That being said, a good developer gets great stuff out the door regardless of what language they use to do so. Hell one of best developers I know is a Php junkie - with whom I always ended up having a slight language war with. The funny thing is that even tough he was the strongest Php advocate I know, he is now using Python for everything and agrees that it's a <i>much</i> better language.<p>Now I work almost exclusively with Ruby for webdevelopment (and also for a big part of my server scripts now that I mention it) because it just makes sense. The code is a lot more maintainable and scalable, though this is because it's generally the case that out of a batch of Ruby developers you will probably get more 'good' developers than out of a batch of Php developers with the same amount of people. It's my experience that its easy to get 50 Php developers, out of which only a couple are actually good ones, while if you get 10 Ruby devs, at least half are competent.<p>This rant is getting long so I'll just leave you with a thought. If the only developers you can get right now are Php devs, it makes sense to do your project in Php; however, if it's possible for you to get your hands on some Ruby or Python developers, you really can't go wrong by choosing either over Php, specially since doing so will generally have the benefits of a faster, better, and more maintainable codebase.
qixxiq超过 14 年前
I find the hardest problem to overcome with PHP is finding developers, as it isn't a particularly nice language to work with.<p>If you're not doing a computationally expensive startup, speed won't matter much. If you ever get to the size where it does (i.e. Facebook) - there are always solutions.<p>I've been seriously considering trying to start up an alternative language that takes the best parts out of PHP, but drops all the backwards compatible nonsense. It really has some great features but the annoyances will scare off most top developers - and you're left with a crowd of 85% script kiddies and only 15% developers that actually learnt to use the language properly... and trying to find one of those 15% isnt easy.
评论 #1868676 未加载
ryanto超过 14 年前
It all comes down to the code. Good code in a bad language is better than bad code in a great language. The nice thing about RoR is it kinda forces you to do a few 'best practices things' so even newbie developers tend to end up with 'ok' code. Of course, there are many PHP frameworks that also apply this sort of way of coding.<p>Also, note that there will be a learning curve (probably small, but you will notice it) when you first start learning rails. Like all new languages, you'll overcome this eventually.<p>There is really no reason to choose one or the other. You basically already know the answer. Whenever people ask me this question I say 'What do you think the pros/cons are for each language?' and then right after they list them I say 'ok, pick one'. This is really not a subject worth dwelling on with established languages/frameworks.<p>PS: If it were me, I'd choose RoR :)
评论 #1867898 未加载
morganpyne超过 14 年前
Absolutely. The point has been made here already, but PHP + (Framework of your choice) + MySQL can still be used to produce great web applications quickly and easily. My framework of choice happens to be Symfony, but there are many good options. I also really like Compass for CSS and Capistrano for deployment (both borrowed from the Ruby folks) and that's fine too; they don't require any server-side Ruby support to be useful.<p>I would argue that a lot of the frameworks seem to be converging in ideas and functionality and borrowing heavily from each other, so whether you use PHP/Symfony, Ruby/Rails, Python/Django or whatever you probably will have more shared core concepts across them than differences. I think that a more interesting question would be "Is PHP/MySQL still practical for building web applications <i>if I don't use a framework?</i>" And the answer there is "that depends..." :-)
davidedicillo超过 14 年前
It's about the developer, not the language. Just write good code and the language at the beginning won't really make a difference. If you like rails but you are more comfortable with PHP, maybe you could try CakePHP or Codeigniter. Even Python/Django could be an option you should consider.<p>Also for RoR you could use Heroku that makes deployment a breeze, but definitely when it comes to resources Ruby is way more expensive than PHP.
LeBlanc超过 14 年前
PHP is not equivalent to Rails. It would be more accurate to compare PHP to Ruby and compare Rails to a PHP framework like Kohana.<p>I've worked with both Kohana and Rails. Rails is more popular so it is easier to find solutions and add-ons. However, it does a lot of things by 'magic' and a beginner will have a hard time modifying rails source or creating a gem (if they want to do something non-default). Kohana on the other hand is easier to understand, extend, and modify, because the entire source is in your project folder as PHP code.<p>Good luck!
mojuba超过 14 年前
One nice thing about PHP is that despite its archaism it keeps growing as a language. The 5.3 release alone added anonymous functions, namespaces, consts and many internal improvements. I recently rewrote one of my projects from the 4.x era for version 5.3 and found myself thinking that I don't hate PHP so much anymore. I still don't like it either, but at least I know the language is in good hands anyway.
评论 #1870366 未加载
oemera超过 14 年前
Lately these questions and discussions are everywhere and most times I think people are missing the point: it's all about code you want to write.<p>We created all those high level languages to make code easy to read, to make them people understand. I mean you could probably write your website in Assembla but the language won't help you to write down what you really want.<p>As a developer you are trying to develop something you do not want to mess around with a language. The language you use should help you focus on what you want to develop not distracting you with "ugly" code.<p>If you understand what the code is doing (even if you coded it on your own you sometimes have to think about what is going on there) it lets you help to focus on your goals.<p>If you brain works better with PHP code you should probably use PHP as your coding language but if not you should try something else like Python, Ruby or maybe Haskel until you find a language which is boosting you while developing. Don't get me wrong I don't say a programming language should do everything for you while you are drinking coffee. No, it should help you to think better what to implement next and how to implement it. It should support you while reading and understanding.<p>Again, we only created all those high level languages to make it easier to understand.<p>And now my standpoint to PHP: I don't like PHP cause it is a noisy language IMO. PHP is not OOP. You can use OOP in PHP 5 but the PHP core is not OOP so this seems weird. Even in PHP 5 you can't get a string length like: $str-&#62;length No you have to use strlen($str) and this is ugly.<p>Also I don't like those "symbols" PHP is using (maybe symbols are not the correct word here but I can't find a better fitting word at the moment). In PHP you have variable names with a $ symbol. Why? I don't know but this doesn't work for human beings cause human brains are assuming the dollar symbol has something to do with money or numbers but in PHP it's not. So you have to getting used to it.<p>It's really the same with the "dot" symbol in PHP. You wouldn't expect that it's concatenating strings.<p>Ruby as language is for me like reading a book. For example you can write code like this: if user.has_comments? ... end<p>That's why I love Ruby and I would prefer working with RoR for my project cause it helps you on rapid development.<p>One last thing: Ruby lets your focus on what you want to build without noise that's why (IMO) there are so much gems and a really huge community!<p>(Sorry for my bad english, it's not my primary language. I'm working on it :)<p>EDIT: corrected some typos.
评论 #1868387 未加载
评论 #1868612 未加载
评论 #1887854 未加载
评论 #1868833 未加载
makuro超过 14 年前
These answers are all pretty long. The answer is yes, definitely, without a doubt. Practical means "for use in practice" and PHP powers a lot of your daily web applications, especially the simpler ones. Judging from your question text, at your skill level, PHP is sufficient if not ideal for development, deployment, and performance.<p>MySQL is also fast and easy.
joelhaasnoot超过 14 年前
Launching a new site on the PHP/MySQL combo (with CakePHP as the framework) on monday so there better not be.<p>I do have to say, being a single coder/sysadmin/tech-cofounder, it has been an uphill battle and really it's a full-time job, but I make do with a couple of hours on the side as a student.
prateekdayal超过 14 年前
I have been doing RoR for over three years now and absolutely love it. A few things make it great<p>* The best practices are well documented and if you follow them, you are gonna end up with good code. Good code helps you iterate faster (and with more confidence) and thats crucial when building a startup.<p>* There is pretty good documentation available and tons of great books that you can read. Also with every release, it gets easier to do things in Rails. Ofcourse you should have test coverage to make sure that you can upgrade rails easily. This basically boils down to the first advice about following best practices.<p>Basically to get most out of rails, you have to buy their philosophy and follow the best practices. If you do, you can be assured of great productivity and programmer joy :)
jeffreymcmanus超过 14 年前
If you are a software entrepreneur as opposed to an individual coder, one of the things you have to consider is how easy it is to hire someone who knows the platform or language you've selected. It's a fact that in the US and around the world, PHP developers outnumber Ruby developers by a significant margin, probably at least an order of magnitude.<p>In some ways, this may seem like an unfair comparison (by way of analogy, pedestrians outnumber drivers around the world as well). This doesn't address whether Ruby is "better" or not than PHP (or Smalltalk, etc.), it only has to do with what a startup engineering manager will have to contend with if an when your startup gets traction and you need to start hiring people at a particular moment in time.
评论 #1868618 未加载
macco超过 14 年前
PHP is totally fine. The question is more: Do you like, do you want to work with PHP, or do you want to work with Python, Ruby, Smalltalk, Lisp, etc.
评论 #1873130 未加载
volkadav超过 14 年前
I do have some future-direction worries about php (the 6 dev process has had some ... quirks; like "let's just bin this and start over") and mysql (re: acquisition by oracle and ensuing staff departures, forked projects, etc.). But they're still fine for a proof of concept implementation. Not many architectures survive contact with real use unchanged, so having to buttress (e.g. op code or data caching) or swap out components entirely is not unheard of. Sometimes the best way to understand a system is to build it, so even if you do end up rebuilding it in whole or in part, at least you've learned the hard lessons about how everything hangs together to make it work right.<p>PHP and mysql are dead stupid easy to get started with. An mvc framework like symfony/kohana/zend/etc. can help speed dev time for your PoC, but most of them are performance hogs so you'll probably have to buttress that (APC, memcache, etc.) if you do end up having to scale. All this stuff's widely supported and retarded easy to deploy usually.<p>RoR is a bit more of a moving target at the moment. Which means docs can/do lag the bleeding edge quite a bit, standard OS distribution packages are frequently out of date (or just out right retarded e.g. debian's disabling of rubygem self update), and the best practices for deploying and scaling are in a state of flux. (I think currently the recommended way is phusion's passenger/mod_rails or whatever it is, for apache/nginx anyway. Or has the state of the art moved on again?)
nessence超过 14 年前
As for the title of your question, sure, PHP/MySQL are stil practical. If the answer to your question were no, then that would mean companies like Facebook and Yahoo aren't practical.<p>With regard to your future decisions, you might strongly consider another language and framework, not because one is more practical than another, but because the developers behind that framework may have more of a propensity towards the context of your startup. So, for example, Ruby has a large web application community, Python has a large scientific community, and Java enterprise.<p>The primary contention behind PHP has largely been it's limited OO and speed, as compared to it's brethren interpreted languages. You <i>can</i>, creatively, do advanced things in PHP which are done in other languages, but it's not as straight forward and often clumsy or not supported. That said, PHP is simple enough that large implementations can easily modify PHP for their own use; considering how slow PHP's codebase moves, forward compatibility is far less of an issue.<p>All together I wouldn't base your decision on speed. Computing power is cheap now and all of them are feasible as far as speed is concerned. If you need to build something NOW, strongly considering going with what you know. If you have more time, consider writing something cliche like a multi-user blog or twitter platform with each framework -- you'll be exposed to patterns you haven't seen before and can also figure out what you like and don't like.
rbanffy超过 14 年前
Servers are cheap, programmers are expensive and bugs can kill you.<p>I suggest going with whatever gives you clean and correct code faster. I wouldn't suggest PHP for a new project. If you already have a big codebase written in PHP, you should keep it, but by "keep" I mean maintaining and cleaning up, not only adding to.<p>As for MySQL, it's good enough unless you get too successful - then it becomes painful to keep it going. Mostly any RDBMS has this problem. Again, for a new project, I'd go with PostgreSQL, but that's more a matter of taste.
jentulman超过 14 年前
Yes it's very practical.<p>Finding a hosting solution for PHP is not going to be to difficult.<p>It's not going to 'go away' anytime soon, certainly not before it becomes time to re-write your codebase.<p>The docs are good.<p>Whether or not there is something which does any of those points better does not change the answer to the actual question. Yes, PHP/MySQL is still practical for building web apps.
scrame超过 14 年前
I hate php, and don't really like mysql.<p>Yes. It is quite practical.
simonpreed超过 14 年前
Use what makes you happy, building a startup will be have many more pressing questions than the choice of language. Trying to make sure you use a 'cool' technology is probably not going to worth the time.<p>Good luck.
iampims超过 14 年前
Build your webapp in a way where migrating parts of it to better suited technologies isn't impossible, and if/when you feel the need to migrate from PHP/MySQL, you'll be able to do so.
troels超过 14 年前
Any advise you can get by asking such a broad question, is anecdotal. From a technical point of view, it usually doesn't matter - You can build applications on both platforms. If your application is atypical, there might be a point in picking one over the other, but what really matters is the people that should work with it. If you have php programmers at hand, using php is probably a better idea.
n-ion超过 14 年前
there is another comment that speaks to this ("it comes down to code"), but i'd just like to say - use what ever you can to get the job done, then think about porting/optimizing/frameworks...<p>TO the question at hand - Yes - php and sql can get the job done... i mean are you building it for 1,000 users? or 100,000? php and sql can handle both...<p>Code tight and code well, tell everyone else to go to hell
noodle超过 14 年前
yes. languages are tools. use what you need to get the job done.<p>if you know PHP and C, it'll be much easier and faster for you to build your startup with PHP and C, instead of toughing it out learning RoR enough to get things done. perhaps RoR is "faster" and "easier", but it won't be faster and easier for you until you're competent with it, and that takes time.
paraschopra超过 14 年前
Visual Website Optimizer is built on PHP/MySQL stack (but we do use Redis for queue). And the application is serving 15+ million requests _daily_. So, it is certainly possible to build a good enough application on PHP/MySQL.
abraham超过 14 年前
Yes.
评论 #1868039 未加载
ntulip超过 14 年前
Oracle just put a price on InnoDB. So unless you got $2000 a year - NO. <a href="http://www.mysql.com/products/" rel="nofollow">http://www.mysql.com/products/</a><p>Postgresql is your next choice.
评论 #1884252 未加载
评论 #1868797 未加载
评论 #1868843 未加载
jarin超过 14 年前
Practical? Yes. Ideal? Maybe.<p>There are a lot of really good PHP developers around. But for ease of development and community support on a brand new project I'd probably go with Ruby or Python.
hedgehog超过 14 年前
Your biggest risk is not shipping, use the tools that make you happy and productive to help get past that as quickly as possible. Solve the rest when you get there.
quattrofan超过 14 年前
Having seen first hand the problems of transitioning a busy site built on pure PHP to ROR and the (ongoing) performance and scaling issues I would be very careful,
phpnode超过 14 年前
Yes, just use a good framework like Yii (<a href="http://www.yiiframework.com" rel="nofollow">http://www.yiiframework.com</a>) to smooth out the warts.
usajag21超过 14 年前
Does anyone use WebObjects for developing web applications? Can someone compare it Python/Ruby for development?
pornel超过 14 年前
Yes, it's practical. I'd use Postgres rather than MySQL if possible.
thinkingeric超过 14 年前
Practical? Yes. Desirable? Depends on who is going to maintain it.
eberfreitas超过 14 年前
Yes