대규모 프로젝트에는 PHP가 없습니까? 왜 안돼?
나는 사람들이 대규모 프로젝트에 PHP를 사용해서는 안된다고 언급 한 (제안하지 않고, 논의하지도 않고, 제안하지도 않음) 몇 개의 게시물을 읽었습니다.
주로 PHP 개발자이기 때문에 두 가지 질문을합니다.
- "대규모 프로젝트"를 정의하는 것은 무엇입니까?
- 왜 안돼? PHP 사용의 함정은 무엇입니까
저는 소규모 개발 팀을 운영하고 있으며 경험을 통해 품질 구축, 구성, 문서화, 주석 및 캡슐화가 우리의 최우선 과제임을 알고 있습니다. 우리는 자체 프레임 워크와 접근 방식을 사용하여 훌륭한 프로젝트를 개발할 수 있지만 여전히 시간을 낭비한다면 더 이상 투자하고 싶지 않습니다.
생각?
나는 사람들이 PHP가 끔찍한 언어라고 단호하게 말할 때 정말 싫어한다. 프레젠테이션과 논리를 혼합하는 코드를 작성할 수 있거나 SQL 주입을 허용 할 수 있기 때문이다. 그것은 언어와 전혀 관련이 없습니다. 그것은 개발자입니다.
PHP는 확장 성이 뛰어난 것으로 입증되었습니다. Wikipedia는 인터넷에서 가장 크고 인기있는 사이트 중 하나이며 PHP를 실행합니다. 충분했다?
작업 할 프레임 워크를 제공하는 많은 도구 / 라이브러리가 있으므로 누군가가 좋지 않고 유지 관리가 어려운 코드를 작성할 가능성이 줄어 듭니다. CakePHP, Symfony, PDO, Smarty 등을 참조하십시오.
그것은 진입 장벽이 매우 낮은 언어이기 때문에 나쁜 평가를 받았습니다. 무료이고, 매우 저렴한 PHP 호스팅을 얻을 수 있으며 , 문서가 최고이며 , 온라인 자습서가 많으며, 많은 것을 만듭니다. 매우 쉽습니다 (예 : URL을 열고 파일 내용 가져 오기 :) file('http://www.google.com');
. 이것은 많은 초보자들이 그것을 집어 들고 그것으로 매우 이상한 사이트를 많이 만들었 음을 의미합니다. 그러나 그것은 당신이 첫 번째로 선택한 언어로 일어날 것입니다.
견고한 ORM 프레임 워크로 작업하면 (어떤 것이 가장 좋은지에 대해 약 30 개의 질문이 있습니다) 좋은 대우를받을 것입니다.
사용하지 않는다고 말하는 많은 사람들은 PHP 4를 사용하지 않는다고 말합니다.
어떤 언어로든 좋은 코드를 작성할 수 있습니다.
과
어떤 언어로든 잘못된 코드를 작성할 수 있습니다.
PHP는 종종 얽힌 스파게티 코드 라이브러리가 될 수 있으며 '응용 프로그램'을 실제로 일련의 스크립트로 만들 수 있습니다 (이에 대한 좋은 예는 Moodle 참조).
나는 '대용량에 PHP를 사용하지 말라'는 PHP의 원래 목적인 템플릿 언어에서 해킹 된 것에서 많이 나온 것 같다. 이해할 수 있지만 할 수 있다는 것을 증명하는 많은 프로젝트가 있습니다 (Drupal, mediawiki, Facebook).
대규모 프로젝트에 PHP를 사용할 수없는 이유는 없습니다. 결국 Facebook은 PHP를 기반으로합니다. 그러나 문제가 있지만 대규모 프로젝트에는 문제가 있습니다.
PHP가 널리 보급되는 이유는 진입 장벽이 낮고 호스팅 비용이 저렴하기 때문입니다. Apache 확장으로 실행되며 거의 코딩을 시작할 수 있습니다. .Net 또는 Java와 같은 더 많은 엔터프라이즈 플랫폼으로 이동하는 경우 진입 장벽이 훨씬 높지만 확장 가능한 애플리케이션을 만드는 데 도움이되는 많은 인프라가 함께 제공됩니다.
예를 들어, PHP의 데이터베이스 추상화는 (imho) 끔찍합니다. 공급 업체별로 다릅니다. MySQL을 사용하면 사람들은 다음과 같은 일을하는 경향이 있습니다.
function get_users($surname) {
mysql_query("select * from users where surname = '$surname'");
...
}
여러 가지 이유로 좋지 않습니다.
- 쿼리 캐시를 제대로 사용하지 않습니다.
- 캐릭터의 이스케이프를 처리하지 않습니다 (물론 할 수
mysql_escape_string()
있지만 사람들이이 작업을 수행하지 않는 빈도에 놀랄 것입니다). 과 - SQL 주입 공격을 허용하는 방식으로 코딩하는 것은 매우 쉽습니다.
개인적으로 저는 위의 모든 이유로 mysqli를 선호하지만 자체 문제가 있습니다. 즉, LONGTEXT 필드를 사용하면 mysql이 충돌하고 적어도 2005 년 이후로 아직 수정하지 않고 수행했습니다 (예, 저와 여러 다른 사람들이 버그를 제기했습니다).
이것을 Java (더 익숙한)와 비교하면 JPA 또는 Ibatis는 시작 비용이 더 높은 훨씬 더 나은 ORM 솔루션이지만 엔터프라이즈 규모에서 도움이 될 것입니다.
따라서 PHP에서 대규모 프로젝트를 수행하는 것이 금지되지 않습니다. 다른 플랫폼이 제공하는 것을 복제하기 위해 점점 더 많은 작업을 직접 수행해야한다는 점에서 더 어렵습니다.
즉, PHP + memcached / APC + beanstalkd는 먼 길을갑니다.
아, 그게 다른 문제입니다. PHP는 실제로 백그라운드 처리 나 스레딩을 지원하지 않습니다. 이를 위해 다른 것이 필요합니다 (또는 독립 실행 형 스크립트). 만약 당신이 다른 것을 사용하고 있다면, 그것도 웹에 사용하는 것은 어떨까요 (예를 들어 Java, Ruby, .Net 등)?
연결 한 질문 이 삭제되었으므로 여기에 일부를 배치하겠습니다.
질문
나는 PHP를 끔찍한 언어라고 부르는 또 다른 질문 스레드에서 혀에 뺨을 맞대고 말했고 미친 듯이 투표를 받았습니다. 분명히 여기에는 PHP를 좋아하는 사람들이 많이 있습니다.
그래서 정말 궁금합니다. 내가 무엇을 놓치고 있습니까? PHP를 좋은 언어로 만드는 것은 무엇입니까?
그것을 싫어하는 이유는 다음과 같습니다.
PHP는 내장 및 라이브러리 함수의 이름이 일치하지 않습니다. 예측 가능한 이름 지정 패턴은 모든 디자인에서 중요합니다.
PHP는 내장 함수의 일관되지 않은 매개 변수 순서를 가지고 있습니다. 예를 들어 array_map 대 array_filter는 단순한 경우 성 가시고 모든 종류의 예상치 못한 동작을 일으키거나 더 나빠집니다.
PHP 개발자는 지속적으로 내장 기능과 하위 수준 기능을 사용하지 않습니다. 좋은 예는 함수에 대한 참조에 의한 전달이 더 이상 사용되지 않는 경우입니다. 이것은 함수 콜백을하는 모든 사람에게 악몽을 불러 일으켰습니다.
재 설계에 대한 고려 부족. 위의 지원 중단은 많은 경우 함수에 대한 기본 키워드 값을 제공하는 기능을 제거했습니다. 그들은이 문제를 PHP 5에서 수정했지만 PHP 4에서 참조에 의한 전달을 더 이상 사용하지 않습니다!
네임 스페이스 실행이 잘못되었습니다 (이전에는 네임 스페이스가 전혀 없음). 이제 네임 스페이스가 존재하므로 역 참조 문자로 무엇을 사용합니까? 백 슬래시! 이스케이프를 위해 보편적으로 사용되는 문자, 심지어 PHP에서도!
지나치게 광범위한 암시 적 유형 변환으로 인해 버그가 발생합니다. 예를 들어 float를 정수로 또는 다시 되 돌리는 암시 적 변환에 문제가 없습니다. 그러나 PHP (마지막 확인)는 마법처럼 배열을 정수로 변환하려고 시도합니다.
재귀 성능이 좋지 않습니다. 재귀는 모든 언어로 작성하는 데 근본적으로 중요한 도구입니다. 복잡한 알고리즘을 훨씬 간단하게 만들 수 있습니다. 불쌍한 지원은 용납 할 수 없습니다.
함수는 대소 문자를 구분하지 않습니다. 나는 그들이 이것에 대해 무엇을 생각하고 있는지 전혀 모른다. 프로그래밍 언어는 컴퓨터와 코드 판독기 모두에게 모호함없이 동작을 지정하는 방법입니다. 대소 문자를 구분하지 않으면 모호함이 많이 발생합니다.
PHP는 처리와 프리젠 테이션의 결합을 권장합니다 (실제로 필요). 예, 그렇게하지 않는 PHP를 작성할 수 있지만 실제로는 잘못된 방식으로 (사운드 디자인 관점에서) 코드를 작성하는 것이 더 쉽습니다.
PHP 성능은 캐싱 없이는 비참합니다. PHP 용 상용 캐싱 제품을 판매하는 사람이 있습니까? 오, PHP의 디자이너들이 그렇습니다.
무엇보다도 PHP는 웹 애플리케이션 설계가 쉽다는 것을 사람들에게 확신시킵니다. 그리고 실제로 관련된 많은 노력을 훨씬 쉽게 만듭니다. 그러나 사실, 안전하고 효율적인 웹 애플리케이션을 설계하는 것은 매우 어려운 작업입니다.
많은 사람들이 프로그래밍을 시작하도록 설득함으로써 PHP는 프로그래머의 전체 하위 그룹에게 나쁜 습관과 나쁜 디자인을 가르쳤습니다. 안전하게 사용할 수있는 이해가 부족한 기능에 액세스 할 수 있습니다. 이로 인해 PHP는 안전하지 않다는 평판을 얻었습니다.
(그러나 나는 PHP가 다른 웹 프로그래밍 언어보다 더 많거나 덜 안전하다는 것을 쉽게 인정할 것입니다.)
PHP에 대해 내가 놓친 것은 무엇입니까? 저는 유기적으로 성장하고 잘 관리되지 않는 언어의 엉망진창이 빈약 한 프로그래머를 낳는 것을보고 있습니다.
그러니 저를 설득하십시오!
최고 평점 답변
당신의 각 글 머리 기호에 응답 할 때 찔러 볼게요
PHP는 내장 및 라이브러리 함수의 이름이 일치하지 않습니다. 예측 가능한 이름 지정 패턴은 모든 디자인에서 중요합니다.
나는이 주제를 사랑하고 싫어한다. 핵심에서이 문제는 정확하기 때문입니다. 일부 이중 단어 함수가 밑줄로 분할되고 일부는 분할되지 않는 이유는 무엇입니까? needle 및 haystack 매개 변수가 때때로 인수 서명에서 위치를 바꾸는 이유는 무엇입니까? 그것은 말도 안돼. 하지만 결국 ...이게 정말 중요할까요? 브라우저를 클릭하기 만하면 intellisense 및 php.net이있는 내 IDE, 이것은 그다지 큰 거래가 아닙니다. 언어로서의 PHP에 대해 부정적입니까? 예. 효과적인 프로그래머가되는 데 방해가됩니까? 아니.
PHP 개발자는 지속적으로 내장 기능과 하위 수준 기능을 사용하지 않습니다. 좋은 예는 함수에 대한 참조에 의한 전달이 더 이상 사용되지 않는 경우입니다. 이것은 함수 콜백을하는 모든 사람에게 악몽을 불러 일으켰습니다.
개인적으로 이것은 좋은 지적이 아니라고 생각합니다. 언어의 진화, 특히 PHP만큼 크 러프 트가 많은 언어의 진화에는 사용 중단이 필요합니다. PHP는 "나쁜 프로그래머가되기 쉽게 *"라는 이유로 많은 결함을 얻지 만 동시에 PHP 그룹은 호출 시간 통과와 같은 어리석은 구조를 언어에서 제거하려고 할 때 문제가 발생합니다. -참고. 호출 시간 통과 참조를 제거하는 것은 그들이 만든 최고의 움직임 중 하나였습니다. 초보 개발자가이 "기능"을 사용하는 것보다 더 쉬운 방법은 없습니다.
재 설계에 대한 고려 부족. 위의 지원 중단은 많은 경우 함수에 대한 기본 키워드 값을 제공하는 기능을 제거했습니다. 그들은이 문제를 PHP 5에서 수정했지만 PHP 4에서 참조에 의한 전달을 더 이상 사용하지 않습니다!
나는 일반적인 배려가 전혀 없다고 생각하지 않는다. 나는 당신이이 특별한 변화에 찔려 입에 새콤한 맛을 남긴 것 같다. 언어 변경은 몇 년 전에는 아니더라도 몇 달 전에 알려져 있습니다. 4에서 5로 이동하기위한 마이그레이션 가이드가 제공되었으며 버전 차이는 매뉴얼에 문서화되어 있습니다. Call-time pass-by-reference는 끔찍한 "기능"이었으며 개발자에게 다른 방법으로는 얻을 수없는 표현력을 제공하지 않습니다. 사라져서 기뻐요 (마법 따옴표 같은 다른 쓰레기와 함께)
네임 스페이스 실행이 잘못되었습니다 (이전에는 네임 스페이스가 전혀 없음). 이제 네임 스페이스가 존재하므로 역 참조 문자로 무엇을 사용합니까? 백 슬래시! 이스케이프를 위해 보편적으로 사용되는 문자, 심지어 PHP에서도!
나는 이것에 대해 복잡한 감정을 가지고 있습니다. 저의 일부는 "누가 신경 쓰는지, 캐릭터 탈출은 어차피 문자열 밖에서는 의미가 없습니다"라고 생각하고, 일부는 "확실히 더 나은 것을 사용할 수 있습니다"라고 생각합니다. 하지만 그럴 수 있습니까? 모르겠습니다. 저는 Zend 파서의 개발자가 아닙니다. 5.3 PHP까지는 네임 스페이스가 전혀 없었던 것이 엄청난 감독입니까? 네 그럼요.
지나치게 광범위한 암시 적 유형 변환으로 인해 버그가 발생합니다. 예를 들어 float를 정수로 또는 다시 되 돌리는 암시 적 변환에 문제가 없습니다. 그러나 PHP (마지막 확인)는 마법처럼 배열을 정수로 변환하려고 시도합니다.
I think it's ok to disagree with how PHP does this, but disagree that it makes the language "bad". But ask me how much I want to sit in this topic and argue about weak vs strong typing. (P.S. I don't, at all) For the record: PHP will issue an E_WARNING level error when the type of an argument matters and cannot by solved by coercion.
Poor recursion performance. Recursion is a fundamentally important tool for writing in any language; it can make complex algorithms far simpler. Poor support is inexcusable.
PHP는 웹용 DSL입니다. 나는 8 년 동안 풀 타임으로 해왔고 아마도 재귀를 4 ~ 5 번 사용했을 것이다. 보통 어떤 종류의 성가신 디렉토리 나 XML 순회에 사용했다. 웹 개발에 자주 필요한 패턴이 아닙니다. 느린 성능을 용서하는 것은 아니지만 이것은 프로덕션 문제보다 훨씬 학문적 인 문제입니다. 정말 강력한 재귀 성능이 필요한 경우 PHP는 이미 잘못된 언어입니다.
함수는 대소 문자를 구분하지 않습니다. 나는 그들이 이것에 대해 무엇을 생각하고 있는지 전혀 모른다. 프로그래밍 언어는 컴퓨터와 코드 판독기 모두에게 모호함없이 동작을 지정하는 방법입니다. 대소 문자를 구분하지 않으면 모호함이 많이 발생합니다.
나는 이것에 전적으로 100 % 동의합니다.
PHP encourages (practically requires) a coupling of processing with presentation. Yes, you can write PHP that doesn't do so, but it's actually easier to write code in the incorrect (from a sound design perspective) manner.
*Hmmm, this topic sounds desperately familiar...
But seriously, I find it remarkable that people will complain about a language that will absolutely 100% let you implement any output system you want (the sheer volume and style of PHP templating systems alone speaks to this) - OR - skip all that overhead and just output directly. This does not make PHP bad at all. It's part of what makes PHP good.
PHP performance is abysmal without caching. Does anyone sell a commercial caching product for PHP? Oh, look, the designers of PHP do.
Do you mean bytecode caching (like an accelerator), or output caching?
If the former, then I don't really know how much I care about this topic. Accelerators are free and easy to run. We could argue about why it isn't part of the language but in the end, I don't think it matters much.
If you are talking about output caching then I don't know what to say to you. ANY web project with significant traffic needs caching (seed podcast #27, for example). This is not a PHP-specific issue at all.
In summary, I think you consider PHP a "bad" language in a very academic fashion. And in your previous post you were probably voted down by people like me who use PHP to "get things done".
Second Top Rated Answer
All your criticisms (and some more) are valid. You are allowed and even expected to hate PHP.
But, then again, it has some benefits:
- Ubiquitous
- Fast (especially using opcode caches)
- Huge community (and great documentation)
- Works
Finally, you can overcome many if not all the downsides by writing good code you'd write in any other language. You can write solid, secure and good smelling code in PHP, which many times will run faster and be easier to host and to scale than many alternatives.
Third Top Rated Answer
What is it that I'm missing about PHP? I'm seeing an organically-grown, poorly-managed mess of a language that's spawning poor programmers.
Simple. The fact that poor programmers get very defensive about their language. ;) PHP is easy to learn, much easier than the alternatives, and once you've learned it, it's not exactly obvious 1) what's wrong with PHP, 2) how the alternatives are better, and 3) how to switch to, and learn, one of the alternatives.
And perhaps the fact that, well, what alternatives do people have? ASP? That has plenty of problems on its own, from being unable to run on the majority of webservers (Apache), to some ridiculous and overengineered design choices on its own (webforms? Viewstate? AJAX where your asynchronous" requests are intercepted and run sequentially?) Ruby on Rails? Well, perhaps, except how many webservers support it again? It's not exactly easily approachable at the moment. And it's slow. So perhaps PHP's "strength" is really that no good alternative exists. At least this is why I stay away from all web programming when at all possible. PHP sucks, and I'm not too keen on any of the alternatives either.
PHP has so many fundamental problems that it's not even funny. From the lack of unicode support, to the many implicit type conversions which often lead to unexpected security holes, to the complete mixing of presentation and... everything else, or to the default database module which doesn't (last I checked) use parametrized queries. We're talking about a language made for two things, database access and generating HTML, and which is terrible at both.
It's just a nasty mess, a language designed by people who aren't qualified, or able, to design a language. ;)
For me the worst PHP sin is coupling of presentation with business logic. It's not that you can't write it in a better way, but it doesn't encourage you to, and if anything it encourages you not to.
A large number of security vulnerabilities are associated with PHP sites, too. I can't prove it is disproportionate (after all a lot of sites are written in PHP), but I suspect it is. If I'm right, then since security vulnerabilities are a class of bug, I suspect PHP sites tend to be more buggy on the whole also.
(I don't think that pointing at a few large sites and saying they managed to do it in PHP is any argument against this, by the way. It's a bit like saying that cigarettes don't cause cancer because your next door neighbour smoked and lived to be 100.)
Check out this similar question - Can PHP handle enterprise level sites as well as Java
Recapping - Facebook, Wikipedia, Yahoo.com, Digg, Flickr and many other giant sites are running on PHP. If you ever come close to making something of that caliber, you can still rest assured you can get there with PHP.
How maintainable, extendable, reliable, secure and performant your applications will be is entirely up to you and is language-agnostic. In favor of PHP though, it has very convenient tools for building web applications.
For me, and talking about large or even huge projects, it (primarily) boils down to one word: Dependencies.
The problem with a scripting language is like in every thing in the world: The greatest advantage is the greatest disadvantage at the same time.
The greatest advantage is to code free and fast. Just write a script and it will server it's purpose. No verbosity needed, simply code.
The greatest disadvantage is, in a way, to check if this script is not disturbing other scripts. Or better: Change an old script others are relying on. Are you sure that all dependencies do work out as you desired?
This is not true for "normal" web page generation, whatever normal means here. But we have a product relying on some 500k lines of source code, with customizations for clients consisting of an additional 100k lines of code, too. And I am deadly glad that a compiler checks all dependencies and warns/errors me in case I did something wrong (like, speaking lowest level here, misstyping a variable or method call).
I think this and the fact that other languages provide more simple-to-use "enterprisy" features by their nature (i.e. application servers for "bank usages") boils it down why many do not see PHP in large (or better: huge) projects.
Our company runs several large-ish web sites using PHP, and have had no problems that were related to the language.
There's something about the construction of the PHP language that is not good enough for me. For example, the name of the functions. It is a non best practice use a several ways to name a function in one language. The mixture between underscores (function_name), words stick together (functionname), etc.I mean, this is really a mess. There are too many functions that are very similar or do the same things, but their names are so confusing. This is not characteristic of a good programming language.
In large deployments, the language must be enough easy and specific to write. Something that PHP omits like the declaration of variable types, become very difficult to understand and deal with later.
Other point is the constant addition of features and canceling of some other. It supposes that the addition of OOP in PHP 5 gonna make the things easier for programmers, but what about the considerations of back compatibility?
The principal reason that this programming language is like it is, is due to its origins: Personal Home Page. It was not designed for large deployments.
I know that there are great efforts to make this language an enterprise-weight language, and personally, I'm waiting for a good enough open source server-side programming language; but until this day comes, it's gonna run a lot of water under the bridge.
These are all good answers.
I was a newbie. I've only been coding for 5 years but I directly support and manage 85 small to large websites and I'll tell you what, the potential to get sued by having a website down for a day will contribute a lot to your desire to learn how to and make better code.
It's nice to hear established developers share their thoughts on this matter. I don't think PHP is the best, but it seems my investment in "best practices" is well served.
Thanks everyone!
See: http://www.ukuug.org/events/linux2002/papers/html/php/
참고URL : https://stackoverflow.com/questions/385203/no-php-for-large-projects-why-not
'Development Tip' 카테고리의 다른 글
사용할 때 select2에서 선택한 텍스트를 얻는 방법 (0) | 2020.11.19 |
---|---|
C ++ 참조-단지 구문상의 설탕일까요? (0) | 2020.11.19 |
PNG 이미지에서 픽셀의 알파 채널 투명도 값을 찾는 방법은 무엇입니까? (0) | 2020.11.19 |
Android : Android 키 저장소를 분실했습니다. 어떻게해야합니까? (0) | 2020.11.19 |
Linux의 Bash에서 syslog를 확인하는 방법은 무엇입니까? (0) | 2020.11.19 |