Which Programming Language is Better for Web Development: PHP or Java?

Click For Summary

Discussion Overview

The discussion centers around the comparison of PHP and Java as programming languages for web development, with a focus on their applications, performance, and future prospects. Participants explore the suitability of each language for different types of projects, including web, desktop, and mobile development.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Victor seeks advice on whether to choose PHP Web Development or Java Development for his scholarship, highlighting his background in HTML, CSS, and database architecture.
  • Some participants inquire about the intended application of the programming skills, questioning whether the focus is on web, desktop, or mobile development.
  • There is a discussion about the future of programming languages, with some suggesting that both PHP and Java will evolve and adapt over time.
  • Participants note that PHP is primarily used for web programming, while Java is seen as more versatile for desktop and mobile applications.
  • One participant points out the differences in how PHP and Java are executed, mentioning that PHP is interpreted and Java is compiled into bytecode, though both have just-in-time compilation features.
  • Another participant clarifies that both languages are interpreted in practice, with Java having an additional compilation step to bytecode before execution.
  • There is a discussion about the performance of PHP versus Java, with some arguing that Java is better suited for computationally intensive tasks, while PHP is easier for quick scripting and web interactions.
  • Participants share personal experiences, noting that while PHP is easier for them, they have had to switch to other languages like C# for more complex mathematical programming.

Areas of Agreement / Disagreement

Participants express differing views on the strengths and weaknesses of PHP and Java, particularly regarding their applications and performance. There is no consensus on which language is definitively better for web development, as opinions vary based on personal experience and specific use cases.

Contextual Notes

Some participants mention the limitations of both languages in terms of performance for computationally intensive tasks, and the discussion includes various assumptions about the nature of compiled versus interpreted languages. The conversation reflects a range of perspectives on the applicability of each language in different contexts.

vprohnitchi
Messages
2
Reaction score
0
Dear Friends,

I am new here and I would like to ask you for an advise. I have the opportunity to start a scholarship with a good school with Cambridge International Certificate.

At this school I have opportunity to choose one of two modules: PHP Web Development or Java Development.

I worked a lot in Content Management System of different web pages, experience in HTML and CSS and some basic skills in DB architecture.

Please give me an advise. What is most indicated at this moment and has good perspective for the future.

Many thanks,
Victor
 
Technology news on Phys.org
Do you want to program for the web mainly or have the ability to program for desktop and mobile devices?
 
As I understand, PHP is for web programming and Java is for desktop and mobile devices? The second one has more future. No?
 
Don't worry about the future of the languages, both languages will evolve, adapt, and be replaced sometime in your future. You are correct about what each is used for, but both are very flexible languages. If you are a first year student, understanding the concepts of the languages is far more important than the language itself. I can read and write maybe a dozen computer languages, but because I know the basics, I can learn a new one in a day or so if I wanted to.
 
Well one is compiled and the other is interpreted . so its a little bit hard to compare them (if you were saying PHP vs ASP then we could)
Depends on which one you like more . take a look at examples .
 
Which do you think is compiled? Neither of these are traditionally compiled languages, but both have compilers. Java runs on something called bytecode, which gets compiled just in time. PHP uses something called opcode, which is also compiled just in time. Both also have true compilers also, (GCJ for Java and HipHop for PHP) but the main draw of both languages is that it works on any machine.
 
newjerseyrunner said:
Which do you think is compiled? Neither of these are traditionally compiled languages, but both have compilers. Java runs on something called bytecode, which gets compiled just in time. PHP uses something called opcode, which is also compiled just in time. Both also have true compilers also, (GCJ for Java and HipHop for PHP) but the main draw of both languages is that it works on any machine.
From what i read something like PHP that does its work on other system and shows results to you is interpreted
And something like java which runs completely on your system is compiled
Maybe i didn't understand well
 
You are not understanding correctly, both are interpreted languages, java just has an extra step.

When you run PHP, the PHP engine loads in the php script and starts to parse it. Once it's done parsing it, it creates something called "opcode" this is highly condensed code that provides instructions for the PHP engine. This engine then takes that opcode and converts it to machine code as needed in order to actually run it on the machine. That machine code is also stored for later, so if you run the same piece of code twice in PHP, it only has to interpret it once.

Java is slightly different in the fact that it does the parsing in a separate step. You can't just write java code and say "ok, go run my code" like you can in PHP. It's still parsed and creates something called "bytecode" which is exactly the same as what opcode is. This gets compiled out into a .class file. Then when you run the .class code, the java engine interprets the bytecode and turns it into machine code as needed. Exactly the same as php does.

The reason they do this is portability: machine code only works on one machine, but this special in between "opcode" or "bytecode" can run on any machine that has the php or java engine.All languages get first changed into something more universal: some sort of bytecode. The difference between the interpreted languages and the compiled ones is that the compilers change everything to machine code. There is no on the fly compilation. This has the advantage of not requiring the Java Runtime Engine or the PHP engine. Once you compile a C program in C, you don't need C anymore. But if you write your code in Java or PHP, you can't remove the engines. The disadvantage to compiled code is that it only works on one architecture (64bit intel machine code will only work on that CPU or something compatible.)

You can download true compilers for both PHP and Java thought to make pure machine code.
True compilers have bytecode too, they do that so that they only need to write one compiler. Look at the GNU compilers: C, C++, Fortran, Java... lots and lots of languages. So what they write is parsers for each language. They write a converter from C to GNU bytecode, and another for Fortran to GNU bytecode, then another for Java to GNU bytecode. Then a converter from bytecode to AMD, bytecode to Intel 32, bytecode to Intel 64. See how they've dramatically reduced complexity? Could you imagine if they had to maintain a C -> AMD, C -> Intel 32, C -> Intel 64, Fortran -> AMD, Fortran -> Intel 32... Bytecode is not new, using it for portability and requiring the end machine to have an engine for it is.
 
  • Like
Likes   Reactions: AliGh
Thanks .. a little confusing , but got what does it mean
So i meant the application of two languages is different
I have worked with both PHP and C#(which is simillar to java)
PHP was much easier to me , but if i needed to write mathematical programs and things like that , i had to switch to C#
 
  • #10
Yeah, PHP is not meant for math or anything computationally expensive. Compiled programming languages have the advantage of deeply analyzing code and optimizing the hell out of it. Just in time compilers don't have time to do that. Sometimes huge C++ projects using all of the optimization options can take hours and hours to compile. I use PHP for quickly writing scripts or interacting with the hard drive, database, networks... things that are slow anyway. For images, sound, mathematically intensive code, C/C++ and ASM is what I mostly use. I suggest watching a TED talk or o presentation by a compiler developer, the types of optimizations that they do are insane.

That said, Java is a little better at intensive stuff like that. Most programming languages actually link to other code, that can be written in other languages. For example, you can use OpenGL in Java, OpenGL is written in C. That's why it's so fast, all you need to know how to do is to wrap a header around the library. Java and PHP will never be as fast as natively compiled code that's been fully profiled and optimized, but it can use libraries that were written that way to do intensive stuff.
 
  • Like
Likes   Reactions: AliGh

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
27
Views
13K
  • · Replies 18 ·
Replies
18
Views
5K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 15 ·
Replies
15
Views
4K