Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,410 members, 7,808,461 topics. Date: Thursday, 25 April 2024 at 12:16 PM

Which Is Faster? Php Or Java - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Which Is Faster? Php Or Java (1359 Views)

How To Make Money From Developing Software Using Vb Or Java / C++ Or Java: Which Way To Go? / PHP Or Coldfusion: Which Is Better? (2) (3) (4)

(1) (Reply)

Which Is Faster? Php Or Java by naijaguru(m): 3:47pm On May 26, 2007
(Note: I am not comparing JAVA and PHP in terms of what each can do or not, I’m just checking out development time)

Hey! Before you guys eat me up and call me dumb dummy, let me rephrase my topic. Which is faster in terms of development? PHP or Java. This question popped into my mind after feeling Java for quite some weeks. I used to believe PHP was faster in terms of development, but I am having some doubts. Thanks to my TechnoPsychic friend who wouldn’t stop rambling about Java this, Java that, Java frameworks, Struts, Spring, JFC. Don’t be surprised that I don’t know much about those names, but I am sure they are there to help Developers cut development time.

Now, these frameworks are there in PHP too. CodeIgniter, which I use rocks, but with some very little headache in terms of limitation, but you could actually alter the BASE easily and suit your pranks! The Active Record class is so cool, not to talk about the much important libraries like validation class, url helper. Also has a plugin for plugins that is shared by a community. CI supports both PHP4 and PHP5. Hey! CI is carrying me away. PHP also has Symfony, this turned me off out rightly, though, from the little I read and from the feel of the Symfony community, Symfony looks great. But I can’t afford the luxury of a dedicated server! My shared hosting account wouldn’t upgrade to PHP5. So one wonders why one can’t get a stable Symfony version for PHP4. Or is one out there? I wouldn’t say much about ZEND or CakePHP because I haven’t touched them for now, may not touch the Zend Framework for some time, because of the PHP5 wahala.

Apart from the frameworks, and more about it, what makes me thinks PHP could be faster in terms of development time is because, you wont have to compile, you just write and upload / update, you don’t need to create packages, or doze in a command-line hitting the javac keyword whenever you want to see your application run. I don’t know if JAVA too works that way. Maybe the JSP part does. Thanks to the MVC design pattern, I can just sit on my computer for four hours and write all model parts, provided there is a clear design on ground. With CI in PHP, I’ll do.

Class Mymodel extends Model
{
function Mymodel()
{
parent::Model();
$this->load->database();
}

function get_last_post($post_id = ‘’)
{
//The procedural code
//Or some function reuse in this class
//like $this->get_last_login()
}

function upload_post($post_details)
{
//The procedural code
//Or some function reuse in this class
//like $this->get_last_login()
}

//And so on and so forth
}


Then in my controller, I simply call the MyModel guy like $this->load->model(‘MyModel’) and give Mr View the data from the methods or functions:

Class MyController extends Controller {

function MyController()
{
parent::Controller();
$this->load->model(‘MyModel’)
}

function index() //works the way your index.php or index.htm works on your server
{
$data[‘last_post’] = $this->MyModel->get_last_post();

//Then load the Mr View
$this->load->view(‘MyPage’, $data);

/*for the sake of simplicity, I omitted some logic you might want to apply on the stuffs you get from the model, like if $data[‘last_post’] turns out not to have any post at all.*/

}

}


Then Mr View (MyPage.php or .htm or .tpl or whatever you want), which is the face of your application will be an HTML predominant file like this (Your view file doesn’t have to be PHP file to work, but advisable )

<html>
<head>
<titile>My Php View</tile>
</head>
<body>
<p>
<?=$last_post?>
<!-- Yes you can use the php_short_tags to call in the values in the $data array form the controller -->
</p>
</body>
</html>


So simple and saves development time substantially. You can even share it amongst your crew. Someone writes the controller, someone designs the view and you write the model classes. As simple as things can be, the infuriating part is muddling HTML with your PHP codes. Though to an extent, things can be simple with the help of some Templating system like smarty, there can still be a problem when u add great looking views to your application. For example, in CI, you can do something likt $this->table->generate(); Which will generate a table based on an array or your result from the DB, but if you have to edit the data in the table, like add in image in a <td> or add an hyperlink to a user_name, you would have to use the foreach statement, thus mixing <a href=’’> or <img> in <?php ?> doing the ugly looking concatenation operator “.”.

In my opinion, and if this isn’t misleading, this aspect is where PHP fall short of the glory of Java! In Java, everything is code; cool (How about JSP? My mind tells me same problem applies). Probably, some Java people in the house would shed some light. As a sweet graphic / web designer come addicted coder, I like switch-casing my mind between designing and coding, so when any interferes with any, I get pissed off, and it slows me down. Or maybe, I should start thinking of writing HTML like I write codes. Huh?

If Java is a write-code-only language, even in JSP, that will be an edge over PHP, as you would just sit and code out your designed application while enjoying debugging the glitches. This point has launched me into looking at how JSP works, anyway, I am not planning to switch to Java for writing Web Applications, (When I start writing my Games and Mobile Apps, I wouldn’t need HTML) just ranting…

This piece isn’t meant to be about CI, or Frameworks, but about which, due to language structure and design, is faster to write; PHP or Java. PHP is pretty fast to write, but due to HTML’s interference, especially when it comes to styling, writing HTML ridden PHP at times pisses me of. Would love to here from some Java pros…

(1) (Reply)

Simplex Media Converter download link available ! / App Developer Thread. / Warning: No Voting Policy - Evoting Trolls Bugging Me, Beware

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.