PHP4 Or ASP.NET - that is better

In the letter to us Alexey Filatov has noted, that counts the review subjective. At a sight of edition, at all incompleteness of clause{article}, objectivity in her it is much more, than in detailed researches which authors aspire to prove to themselves and anothers, that once the technology chosen them is better than the others. So, what it is better - PHP4 or ASP.NET - from the point of view of the independent web - programmer? - Vladimir Guriev.


It is a little about itself. I have made a pair of small projects on PHP4 (unfortunately, about one today any of them has not lived). But I can brag of the completed sites made on technology ASP.NET: Melodyland <http://www.melodyland.ru> which has been copied by me with ASP on ASP.NET, and the "domestic" site, <http://www.melodyland.ru/goodman>, which has been created as a test platform for programming on ASP.NET. All works on sheaf Celeron 500 + 128 Mb RAM + Windows 2000 + IIS 5 + SQL Server 2000, and contrary to ordinary opinion about tormoznutosti Windows, and ASP, and ASP.NET fine function at loading 30-50 sessions. That at this time occurs to the window interface - other question, but services fly.


ASP.NET is not continuation ASP. It is conceptually new technology Microsoft created within the framework of ideology .NET. The key parties{sides} .NET are scalability, krossplatformnost`, mezh``jazykovoe interaction and shaky concept " safe programming " (safe-programming).


PHP - on the contrary, open and free-of-charge technology. Certainly, to decipher today PHP as Personal Home Page it would be wrong, but echoes of the past have an effect and to this day. PHP - skriptovyj the language created only for dynamic conclusion HTML. It does not mean, that on him it is impossible to create the large project. It means what to create the large project on PHP dearly and difficultly.


The expensive{dear} environment of programming is not necessary for programming on PHP. To learn to write more or less efficient scripts, enough the unique tutorial. About ASP.NET such focus will not pass. Without Visual Studio, MSDN and sometimes - access in the Internet there there is nothing. The beginning{starting} developer spends the most part of time on shtudirovanie MSDN. And by then, when he will teach{learn} navorochennuju model of classes and all functions necessary for him, Microsoft for certain will think up something new. It is remembered, someone spoke, that the more variants it is offered, the more time leaves on a choice of the best. ASP.NET - bright to a volume acknowledgement{confirmation}.


But if to teach{learn}... The Counter of visitings? - please, ten lines. To add here the same table? - two - three clicks by a mousy, fifteen lines of the text. Other conclusion of the information? - there are no problems: we do{make} an affiliated class, we block function, we remove{assign} on debugging a quarter of hour, we adhere to a conclusion of the second table - it is ready! In general, job in ASP.NET with application Visual Studio strongly reminds job in Delphi, with that only a difference, that all occurs much fastly, easy and more logically. The basic languages on which ASP.NET-applications are written, - Visual Basic.NET and C *, - are successors accordingly Visual Basic and Java/C ++. And if transition with Visual Basic on Visual Basic.NET demands some revision of philosophy of programming (as from an old BASIC there was only a part of syntax and the name), transition with With ++, and it is especial with Java on C *, is organic so, that should not borrow{occupy} more than two-three weeks.


Theoretically under ASP.NET it is possible to write programs in any language for which there is a corresponding compiler. However in practice for creation of ASP.NET-applications are used mainly Visual Basic.NET and C * (somewhere behind trudge managed C ++ and J *). Some program environments - for example, Delphi 8 - provide nominal support ASP.NET, but to sense from it{her}, we shall directly say, a little.


The "Native" environment ASP.NET - IIS, working under management Windows. Yes, IIS the most stable web - server, and Windows - as not the most stable operational system is known as not. But a small history from a life.


At one my job there was a server under management Windows 2000 and IIS on which the system administrator held during that moment of more two hundreds sites. Their big part has consisted of dynamically generated ASP-pages (ASP.NET then only has appeared, and unique who risked with it  to work, - the truth, by the separate machine, - the servant was your obedient). And so, the server for two years was reloaded all few times, short of obligatory perezagruzok after installation critical obnovlenij. At other job in which I was engaged in parallel, there was a server with FreeBSD 4.x, ispolnjavshij a role of a proxy / khb®Uu«½½b for a local area network. He fell time, and even two times a month. I some time was the system administrator and not by hearsay I know, how it is necessary to try to reach{achieve} such impressing results in stability of job both Windows, and FreeBSD. Since then I am confident, that 90-95 % of stability of job of the server are provided at all with a choice of "correct" system, and a choice of the "correct" system administrator.


I do not try to convince someone that Windows works more stably and predictedly, than Unix/Linux. Besides, I so do not think. But ASP.NET is not only Windows. There is, for example, project Mono, allowing to start any .NET-applications under Linux (and, accordingly, under FreeBSD in a mode of binary compatibility), exists mod (our way - a plug-in) Apache for processing ASP.NET-applications. But all the same ASP.NET and *nix - meanwhile more heterogeneous environment, with all following.


ASP.NET it is not adapted to small projects and the more so - for not numerous worked well together groups to which do not need precise management. The reasons for that set - starting{beginning} from high cost of a platform and finishing{stopping} complexity of model of classes .NET. For the first time having undertaken for programming under .NET, I could not understand, who can teach{learn} all this, all this is designed for what intellectual monster? Has then understood - anybody. Credo of .NET-programming: climb in the business. Write the module, teach{learn} the functions, know the place - this principle in collective works wonderfully.


On ideology Microsoft, the programmer - small vintik well organized mechanism. Singles - kamikadze like me, piously believing in the light future of this corporation, were not considered and not considered. We exclude us - and remain big, it is fast and constantly extending Internet - projects where one programmer is responsible for one module. And, as a matter of fact, still it is required to projects what krossplatformnost` and mul`tijazychnost` by default? Only such where can employ such pro, that language on which he writes, differs from the basic design. Only such by which subsequently it can be demanded painless portirovanie on Pocket PC, MAC, Internet - services, etc. can be demanded. In such projects ASP.NET it is developed{unwrapped} on glory. Problems with productivity, shortage of resources? Nonsense! We shall buy still computers, we shall buy still programmers, we shall buy stars from the sky if only rates of development did not fall.


In similar projects it nothing RNR-PROGRAMMERS. Why? Yes because they will need a heap of coordinators in which money to pay it is necessary. Coordinators which most part of job is incured with .NET environment. And, by the way, with klasternymi Unix-systems to address too it is uneasy. Whatever one may do, Unix is perfect stand-alone-sistema but for this reason to make a cluster on her much more difficultly, and accordingly, money will leave more. I do not speak about supercomputers, I speak about park at 20-50 machines. For that time that will leave on automation and connection of the additional Unix-machine to a Unix-cluster, programmers on Windows already will write for a long time the following module. Not speaking that klasternaja SUBD MySQL as the cluster exists only in the alpha - version. Automation of interaction between machines on Windows Server 2003 and SQL Server - one of the strongest parties{sides} of these systems (Edition washes hands. All reasonings on complexity of creation of clusters on Unix entirely on conscience of the author. Personally it seems to me, skillfully is not too for a long time, that on Windows, that on Unix, but the expert in the given question I am not and to judge I am not taken. - the Comment red).


Technology RNR differs radically from ASP.NET. Most of all she is similar to classical ASP-applications, only skriptovyj language in her one. Language RNR reminds a motley crew from C and Perl with small addition of spices as Basic and even Pascal. All this is tense on a skeleton from primitive model of classes which represents habitual structures C with the inheritance somehow attached sideways. To tell the truth, the fifth version PHP giving quite good opportunities for object-oriented programming recently has appeared, however she yet has not received the big distribution.


PHP4 Too trusts the programmer. In him there are no types, to declare variables unessentially, there are dangerous designs. Syntax PHP is sharpened under the fast and simple decision of typical problems. Thus the responsibility for dangerous tricks lays on the programmer. That, in particular, results in such widespread phenomenon, as detection of serious mistakes in a code through month - other after delivery of the project.


Scope PHP - small projects which are done{made} or closely worked well together group, or in general by one person. Thanking besplatnosti PHP (and also besplatnosti MySQL and the platform), this language becomes an ideal choice for small author's sites or sites for small and average business. Besides PHP works faster.


Theoretically ASP.NET should work faster (all the same here we deal with once compiled binary codes whereas PHP-scripts each time are processed anew). However PHP flies both on IIS, and on Apache and at big (the truth, it is artificial called) to loading always gives out results better, than ASP.NET. And especially it is better, than classical ASP. Discouraged, I have gone on site Microsoft to find even one clause{article} in which speed PHP and ASP.NET would be compared. Unsuccessfully. But on other resources very many clauses which authors came besides to a conclusion, as I were found. "Native" sheaf PHP + MySQL + Apache works faster ASP.NET + IIS + Microsoft SQL Server 2000.


Whether it means, what ASP.NET it is worse? By no means. On same site Microsoft there is a weight of the data from which follows, that decisions on base Linux/Unix as a whole manage to average and big business is much more dear{expensive}, than similar decisions on basis Windows (it would Be strange to find other information on site Microsoft. But the share of the truth in it is - besplatnost` technologies at all does not mean besplatnosti their use). Such, apparently, paradoxes actually are quite logical. Speed of job is provided with that, that all RNR-APPLICATIONS work in uniform address space whereas ASP.NET for the bill navorochennoj models of classes repeatedly checks and rechecks the data, keeping each application in separate address space. The first approach is faster, but less reliabl, the second - is more reliable, but it is necessary to pay for it. Miracles it does not happen. Speed of sheaf RNR + MySQL is provided with that, that developing these two technologies of group very closely cooperate. The same and with a sheaf ASP.NET + MS SQL.


However speed of job RNR with others SUBD (through ODBC) has disappointed. With the majority known SUBD, switching MS SQL Server, SAP and MaxDB (the same SAP, since version 7.5), he at me worked more slowly ASP.NET. As far as I have understood, that ASP.NET tries to do{make} of a DB as small as possible vyborok, placing all actual tables and even communications{connections} between them in a cache (technology ADO.NET in a case with MS SQL) while RNR is declined to generate set of searches to SUBD.


Paradox with the prices when to pay some licenses Microsoft is cheaper, than to take free-of-charge Unix/Linux, PHP and MySQL, too it is quite logical. It is necessary to take into account, that, first, these products are free-of-charge, while you are not going to to do{make} on them commercial projects (Linux and PHP, certainly, are free-of-charge without any conditions. The commercial license in full sense of this word is only at MySQL. Some expenses on PHP, perhaps, threaten only to the programmers doing{making} scripts on sale. To not open a code of scripts, they should use products of company Zend, and they, alas, paid. - the Comment red), and second, that development and support of projects under these platforms as a whole manages more dearly{expensively}. Besides Linux in some cases works more slowly Windows. Probably, I am mistaken, but for any SUBD I and close did not see such quantity{amount} of critical corrections and messages, as for MySQL. And all this is risk (Edition washes hands. All reasonings on complexity of creation of clusters on Unix entirely on conscience of the author. Personally it seems to me, skillfully is not too for a long time, that on Windows, that on Unix, but the expert in the given question I am not and to judge I am not taken. - the Comment red.).


Now PHP. If briefly to characterize sensations from job with it  is a constant debugging, debag. Also put at all that high-grade debaggera while no (at least, the best, that I have found, Zend Studio, cannot be compared with debaggerom Visual Studio), and that the device of language promotes serious logic mistakes.


Example which was sent recently to me by the classmate, having asked to help:

<p>

<?

$bukvi = "abcdefg";

$stroka = "abcdefg";

echo $stroka [0]; echo "<br>";

echo $bukvi [0]; echo "<br>";


if ($srtoka [0] == $bukvi [0])

echo “ lines coincide “;

else

echo “ lines do not coincide “;

?>

</p>



The script works, but works incorrectly.


Even the primitive typing error (it is selected red) results in a logic mistake which in C * would not be basically. In general, in RNR the announcement of variables is absent as a class, that, from my point of view, the big minus. And any person expert in programming understands, in what results absence of types in the large project.


Certainly, programmers on RNR can say, that I understand nothing: in fact it is enough to climb in php.ini and to adjust a conclusion of preventions . But also here not all so is simple. My familiar PHP-programmer was called recently by the employer, at which zavis a site. In result it was found out, that khoster has updated PHP from version 4.3.6 up to 4.3.8 in which preventions  of use of undeclared variables appeared by default are switched on. In a result the site began to represent the collection of every possible preventions  from cursor PHP as the friend, having got used to indifference PHP, never complicated itself the announcement of variables.


As a rule, updating of version RNR on the server - a headache both for customers, and for programmers. At times to find a mistake very difficultly, especially if she appears only under the certain circumstances so she  can be not revealed at all before delivery of the project. In it both force, and weakness RNR. While in With * you will be engaged in planning, to write different classes, interfaces for collections both other and other that then at one stroke for ten minutes to make page, - in RNR you will have time to write the same page some times. Only each following page on ASP.NET is done{made} only for ten minutes, and in RNR again and again it is necessary to spend same time. Something is necessary visually in a conclusion on page to change - in ASP.NET it is required five minutes, and in RNR - it is necessary to search and correct conclusion HTML. the PHP-programmer will prefer to copy more likely all anew, and in ASP.NET programmer will be compelled to use ready operating time. Otherwise it  simply will not take on job. On such collectivism when individuality of the programmer is levelled up to a limit, and all philosophy .NET is constructed, and this philosophy, I shall be repeated, fine operates in the big collective. And individuality and simplicity of RNR-PROGRAMMING - in small.


This fact is reflected well with a situation in a labour market: parity{ratio} RNR-and now makes ASP.NET-programmers 3:2, that speaks both about availability of free-of-charge products, and about a plenty small, but arrogant projects for which PHP approaches ideally. Other situation, for example, in Israel (there a parity{ratio} approximately 1:10), America and Europe.


Earnings of the ASP.NET-programmer too is higher, and if the good PHP-programmer receives at us at the best 800, well a maximum of 1000 dollars (the information with www.job.ru) the salary of the ASP.NET-programmer, as a rule, begins with 800 dollars. It and is understandable - the responsibility more, it is more than job, it is more than hemorrhoids, it is less than freedom.


So, small and average projects - destiny of small groups of programmers and PHP; average and big - destiny of the big groups using products Microsoft (It is any false dikhotomija. It is possible to think, that in the world is only PHP and ASP.NET. The weight of large projects is made on Perl which is deprived listed lacks PHP and fine works. - the Comment red), and also very not numerous well organized groups of programmers on RNR; huge projects divide among themselves products HP, IBM, Sun, Oracle, and quotations there in some times higher. But it is already perfect other history.


What to choose to the beginning{starting} programmer? I am at a loss to answer unequivocally. RNR, certainly, it is easier … but I all the same would advise to study ASP.NET, he  absolutely precisely has future in the average and large companies that you will not say about RNR. I shall note also, that the situation on a labour market only a year - one and a half ago was approximately 1:9 for the benefit of RNR, and radical change of this parity{ratio} should guard.


If will carry and if you really good programmer - are possible to get in " completely other history ", where also the salary completely another. This can be promoted by participation in the various competitions spent by the companies (to get there in other way, without serious operating time on the party , it is very difficult).


I offer you two variants (on ASP.NET and on PHP) same unpretentious programmki. Both are written to a forehead (specially) and solve the same problem : count up, how much time this or that letter meets in the entered line.


ASP.NET:

private void Button0_Click (object sender, System. EventArgs e)

{

string alphabyte = "ABCDEFGHIJKLMNOPQRSTUVWXYZJJCUKENGSHHHZKH``FYVAPROLDZHEHJACHSMIT`BJUJO";

int [] counter =new int [alphabyte. Length]; // the File - counter

string Text=TextBox1. Text; // It is taken away the data

Text=Text. ToUpper (); // the Entered text to the top register

foreach (char t in Text) // we Go on a line as on a file

{

for (int i=0; i <alphabyte. Length; i ++) // we Go on the file - counter

{

if (t == ((char) alphabyte [i])) counter [i] ++; // If the current letter in line is equal to the letter the alphabet we increase the file - counter by unit for the current position

}

}

// A conclusion

for (int i=0; i <counter. Length; i ++)

{

if (count [i]! =0)

{

Response. Write ("Letter" +alphabyte [i] + "meets" +Convert. ToString (count [i]) + “ time <BR> “);

}

}

}



I have specially cleaned{removed} a file with patterns and the text which is automatically generated Visual Studio. Here only that is written by "hands"; the real text of the program of times in five is more. I have made it to show, as job with actually HTML in ASP.NET is intentionally reduced to a necessary minimum (in this case - to obrabotchikam events, as in the usual visual programming language). Thus, there is possible{probable} completely a separate job of programmers and designers when the programmer, as a rule, is not necessary for radical change of design. In RNR too it is possible to realize it by application of patterns, but it is appreciable the greater blood.


And now the same code on RNR:

<form action = "test.php" method = "POST">

Enter a word

<input type = "text" name = "str">

<input type = "submit" name = "submit" value = "To consider">

<? php

$quiz_string = $ _ POST [' str '];

if (strlen ($quiz_string)! =0)

{

$alphabyte ='QWERTYUIOPASDFGHJKLZXCVBNMJJCUKENGSHHHZKH``FYVAPROLDZHEHJACHSMIT`BJUJO ';

$quiz_string = $quiz_string.strtoupper ($quiz_string);

for ($i=0; $i <strlen (quiz_string); $i ++)

{

for ($j=0; $j <strlen ($alphabyte); $j ++)

{

if ($alphabyte [$j] == $quiz_string [$i]) {$result [$j] + =1;}

}

}

echo ' <br> ';

for ($j=0; $j <strlen ($alphabyte); $j ++)

{

if (strlen ($result [$j])! =0) {echo “ the Letter $alphabyte [$j] meets $result [$j] time <BR> “;}

// echo $quiz_string;

}

}

?>

</form>



It is obvious, that in RNR correct a dancing party dynamic conclusion HTML, whereas in ASP.NET delano everything that the programmer whenever possible did not think at all about HTML.


So, the general{common} conclusion.


ASP.NET: firstly rates of development should fall sharply, then stably grow and eventually stop at the certain level.


PHP: at enough great volume of a code rates of development should fall with nachal`no very high level, and I shall not be surprised, if speed of falling will be proportional to a square of volume of a code.