Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a rather odd problem. I love the practicality of PHP - specifically that I can fairly safely assume that on any random server I'll have access to the MySQL libraries, and that I can go between PHP/HTML with <? and ?>. That said, I find the language atrocious - Ruby and Python are considerably more expressive, yet since they're not web-specific, they lack both of those features - at least last I used them both.

So my question is, is there some way to get the practicality of PHP from Ruby or Python (specifically the two issues I mentioned)? If not, is there some other language that doesn't feel like a C/C++ parser gone wrong?

share|improve this question
6  
I hear people throw the 'expressive' word around a ton when talking about Python or Ruby, but I've never been able to find more 'expessiveness' in those languages in comparison to Perl, or PHP, or JavaScript. Can someone give me an example of 'expressiveness' where Python or Ruby is, but PHP isn't? –  Jonathan Rich May 6 '13 at 15:16
    
Rails would give you all this and a bit more for Ruby and I think the same holds for Python with Django. –  thorsten müller May 6 '13 at 15:17
1  
Look at embedded ruby, though realize you don't want to write the entire application in .rhtml –  MichaelT May 6 '13 at 15:21
    
I've done Rails before; I don't like its forced approach to architecture. –  Melllvar May 6 '13 at 15:34
1  
While I'll agree that that looks nice, I think arguments about its readability are completely subjective. –  Jonathan Rich May 6 '13 at 16:13

2 Answers 2

up vote 2 down vote accepted

Are you looking for something like Python Server Pages?

<html>
<%
  import time
%>
Hello world, the time is: <%=time.strftime("%Y-%m-%d, %H:%M:%S")%>
</html>
share|improve this answer
    
Looks like psp and eruby are the best alternatives; thanks –  Melllvar May 6 '13 at 17:41

Unless you're dealing with a large legacy codebase, it's relatively easy to avoid PHP's warts. Most hosts will have PHP 5.3 and, except for a few of the gems from 5.4, you're going to get a lot of functionality.

What specifically about PHP is it that you are trying to avoid?

share|improve this answer
    
As a scripting language, I find PHP not as expressive as either Ruby or Python. I realize this is rather subjective, and my goal here isn't to start an ideology war, but that's basically it. PHP got features like OO and lambdas way too late to make the language more elegant, and what it is today is something that looks like C (mind you, I have no problems with C itself), with random features that look out of place. –  Melllvar May 6 '13 at 17:35
4  
If you're looking for an elegant language, then PHP is not it. There is no other language that is ubiquitous as PHP, though. –  Jonathan Rich May 6 '13 at 17:38
    
That's exactly what I was trying to find out :) –  Melllvar May 6 '13 at 17:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.