The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Regarding the compilation question, ASP.NET code is compiled into native binary. It's first compiled into IL (Intermediate Language), not machine code. The output from the compilers (csc.exe, vbc.exe etc.) is in IL. However, this IL is JIT compiled into machine code before execution. That is, the IL isn't interpreted; it isn't converted to byte code (like Java) or p-code (like VB6); it's compiled into native machine code then executed. Probably the critical difference between the JVM and .NET's CLR is that the CLR compiles into native code.

PHP is an interpreted language; every time a page is requested the script must be interpreted (effectively the page is opened, parsed, and compiled on every access). The PHP Accelerator works by caching the compiled version on disk (and in memory I believe?) and using that for future requests.

The two work in significantly different ways, with strikingly similar outcomes (basically, a compiled version of the page can be used straight off for future requests, eliminating the most time-consuming parts of the process).

The comment ".NET or Zend Accelerator simply optimise the process of interpreting scripts" is incorrect, because .NET is not a scripting language and does not use a scripting engine; hence it cannot be interpreted. It is always natively compiled.

Regarding speed, I'd love to see the benchmarks which prove that ZendAccelerator is faster than .NET. I don't doubt the two will be close, and I wouldn't even be surprised if ZendAccelerator was faster; I just haven't seen any conclusive (or even inconclusive) comparisons. As it's apparently established fact I'd be interested in seeing it myself.

-----

As far as the original post goes, anyone who claims .NET is better than PHP (or vice versa) without giving good reason isn't making much of a point. Unfortunately, from what I've read these last few weeks on the forums, there seem to be more people slamming .NET without knowing what they're talking about than the other way round. I can respect people who back up their objections with reasonable arguments of course, but the number of false statements or blind objection without any first-hand experience ("it's MS ergo it sucks") I've seen is staggering. I know that MS pump out PR like there's no tomorrow, and some people follow it blindly and sing MS's prasies without really knowing why, but (on these forums at least) it seems the anti-.NET crowd are, with a few notable exceptions, the ones unable to open their minds.

.NET is a great technology. So is PHP. They have advantages and disadvantages compared to one another, many of which depend on your personal circumstances and preferences. The advice I'd offer is not to get too hung up on one thing to the exclusion of everything else. There's room in the world for more than one good technology, and there's room in most developers' heads for knowledge of more than one language / platform / technology. Personally, if I had to choose between learning PHP and learning .NET I'd choose the latter... but the great thing is, I don't have to choose. I simply learn both, and get the best of both worlds; use PHP when it's the best choice, and .NET when that's more suitable. It's a win-win situation, as long as you don't mind keeping an open mind .

I honestly have not followed .NET recently because when I first read about it I thought of it as a solution to a problem that didn't exist. I do not think that it is a big innovation.... Just something new to learn

So if you could explain what problems .NET addresses and solves that would help. 'Cause I do not know of any.

I have also read that the .NET Community or whatever it was called has been dropped by MS.

Regarding the compilation question, ASP.NET code is compiled into native binary. It's first compiled into IL (Intermediate Language), not machine code. The output from the compilers (csc.exe, vbc.exe etc.) is in IL. However, this IL is JIT compiled into machine code before execution. That is, the IL isn't interpreted; it isn't converted to byte code (like Java) or p-code (like VB6); it's compiled into native machine code then executed. Probably the critical difference between the JVM and .NET's CLR is that the CLR compiles into native code.

Along with my use of the word "byte code" earlier, I put "I believe". That's my ignorance of terminology in lower level languages. For byte code, please replace with the correct term for your respective langauge.

PHP is an interpreted language; every time a page is requested the script must be interpreted (effectively the page is opened, parsed, and compiled on every access).

Just like ASP v3.0. Also ASP.NET, C#, J# and the rest are also interpreted languages.

The PHP Accelerator works by caching the compiled version on disk (and in memory I believe?) and using that for future requests.

Zend built in the "Optimizer" into the C++ code behind PHP 4, to which the Accelerator hooks. In terms of what is does, the steps are still exactly the same as .NET - the Accelerator caches an "interpreted" version of the script in it's own "intermediate langauge" and JIT compliles as well, before execution.

In the strictest sense, neither is storing (caching) "real" binaries, because a "real" binary has already had all compiling performed it and can be simple "run" without any intermediate steps.

Both are using a layer which sits between them and the operating system, and when you really think about it, you'll see there's only one solution to this problem, which they've both adopted. The nature of the solution is what makes the end result, this "5x peformanace boost" the same for both - that's no coincidence.

As far as the original post goes, anyone who claims .NET is better than PHP (or vice versa) without giving good reason isn't making much of a point. Unfortunately, from what I've read these last few weeks on the forums, there seem to be more people slamming .NET without knowing what they're talking about than the other way round.

They are in many ways equal technologies. The difference is the fine print. And as to people slamming .NET, I've seen just as many claims to the effect "PHP is dead. Long live .NET".

Sorry Harry, but I'm afraid you're mistaken - ASP.NET code is not interpreted. Languages like Visual Basic (versions 6 and lower) were interpreted - even C++ compilers used to produce byte code which was interpreted (this is some years ago). The advantage of interpreted code was hardware independence; the disadvantage was slower execution.

Interpreted code is code which is "compiled" into byte code (or an equivalent, whatever name you wish to give it - VB called it p-code for example - but basically it's all byte code, so let's just call it that). These bytecode executables and libraries had to have each instruction interpreted at execution time, with the inevitable slowdown in execution. This is what the ASP 3.0 scripting engine does, and what PHP does (ignoring Zend Accelerator for now).

For .NET, code first gets "compiled" into IL which is basically byte code. If that was all there was to it, then .NET would be interpreted. However, there's an additional compilation step. Instead of interpreting this IL bytecode at run time, large blocks of it get compiled into native code. This native code isn't byte code, it doesn't need to be interpreted at all, it runs directly on the system's CPU. Just as modern-day C++ compilers produce code which runs directly on the CPU.

I can't explain it any clearer I'm afraid. The end result of a .NET page being compiled is lumps of machine code which run straight on the CPU. This isn't exactly the same as, say, a standard C++ compiler's output (which converts the code straight into a huge lump of native machine code), but it's not byte code which needs to be interpreted either.

In short - interpreted code is code which has to have each byte evaluated at runtime. That's what interpretation is. Compiled .NET code doesn't have to be evaluated byte by byte - it runs straight on the CPU. Therefore, by definition, it's not interpreted code.

-------

My post wasn't an attempt to denigrate the Zend Accelerator or PHP or anything, just to clear up a point. I'm not brilliant at explaining these terms, so I'm afraid that if what I've posted above isn't clear then I'll have to stop trying. And as I said, the two (.NET and ZendAccelerator) do arrive at pretty much the same point. They take a different route to get there though. And I imagine that they are very similar performance wise too (still haven't seen any benchmarks to show it conclusively though, could you link to the source which shows it please?)

My final paragraphs there [edit: in my last post] were only my personal view on these forums. I too have seen a lot of people (stupidly) claim that PHP is now pointless, that .NET is far superior etc. It just so happens that, on these forums, I've seen more posts going the other way. Personally I wish both would stop . I like both technologies and can see real advantages to both; I just dislike it when people shout something down without really knowing anything about it (that works both ways too, and people slam PHP without trying it or learning enough about it).

Probably true . I'm not exactly arguing that the .NET process is better than ZendAccelerator or vice versa you understand - I understand the .NET process reasonably well (not very well!), the Zend process less so. I was only really trying to clear up the "interpreted code" bit, and explain that .NET produces code which executes straight on the CPU without having to be evaluated (interpreted). Maybe Zend does the same thing too? I don't honestly know, which is why I confined my explanation to .NET .

Perhaps as you say it's merely a difference in meaning - what I think of as interpreted code may not be what you think of as interpreted code.

Well for what it's worth.
I see a lot of big sites running PHP and they seem to be doing fine. As time progresses hardware is only going to get better, more powerful. ASP.NET may be a great technology but for a small business or a cost conscious big businesses, PHP does its job well for a price that can't be beat. In addition I really like how quickly these open source technologies release security patches and develop new features. Even if ASP.NET is the Ferrari of web applications, PHP would probably be the Porsche of web applications for the price of public transportation.

Oh, one question:
Wouldn't ASP.NET be slower on Apache then mod_php with Apache?

I was thinking that if the PHP CGI is slower than the PHP Apache module (mod_php), that any type of system which had to adapt .NET to work under Apache would bring some kind of performance hit. Since it has to pass through an extra conversion layer.(???)
But maybe that logic is still messed up?