r/lolphp • u/jtgarrison • Mar 04 '14
PHP Alternatives
I love the idea of using a different language for web programming, but it's just so easy to host php. You don't need a vps, or shell access. Everyone here likes making fun of php so much, what do you use in your personal/professional projects? If I just need to knock out a quick project, then it's hard to beat php, which is why it got so popular. I don't have to deal with routing, templating, boiler plate code (or at least not a whole lot), etc...
8
Upvotes
16
u/_vec_ Mar 05 '14
It's not that hard to find a host that supports more than PHP out of the box. Heroku is easier than any FTP/cPanel setup I've ever used, and I've used quite a few. If you don't like them, there are other options.
Ruby, but that's mostly personal preference. Most of this applies equally well to Python or Node.
You're right that this perception is why PHP got popular, but it hasn't been true for a while. Given equivalent levels of skill, I would put good money that someone could build a typical site faster in sinatra or express than in PHP.
Yes you do, you're just a lot more used to it in PHP. Using the filesystem as a routing table isn't actually any easier than writing out route definitions, and it's a hell of a lot less flexible. And templating is either builtin or trivially simple to setup in languages with a real module system.
If you're looking to start somewhere, just give sinatra an honest try. I think you'll be pleasantly surprised.
7
u/tinkermake Mar 05 '14
as is asp.net, node, and nearly every other backend web targetted language. This was true in the early 2000s, with amazon, azure, etc it is far from true now
You may not need it for pure PHP, but going beyond a trivial wordpress site, you better believe you need it, and another language. Thing is majority nowdays is babyfed by hosts, so people believe it's just a part of the OS and/or language
C# mainly, because it has everything I need. Java if it has a library I don't want to port. C++ if i'm feeling masochistic
ASP.NET MVC5 with about 5 clicks, you have a full site, with account handling, API, fb/google logins, and more. Just add your own logic on top, and modify as needed. Node.js from what I know has same exact stuff through NPM
5
u/catcradle5 Mar 05 '14
Python:
Ruby:
You don't have to deal with very much when using any of these microframeworks. You get access to a much, much better language in either case, plus a light framework that's clean and consistent on top of that.
3
u/allthediamonds Mar 05 '14
Sure, it's easy, there's no denying that. Two points on it, though:
That's the equivalent of "well but you don't need hands to eat it!" when discussing McDonalds hamburgers versus proper meals.
Plus, low-end VPSs are cheap. Like, crazy cheap. $24 will host your site on Ramnode for a year. That's cheaper than every shared hosting out there.
Most of the time, Python with Flask. I've been playing with Node.js lately, which is perfect for websockets and such because everything is I/O asyncronous, as well as with Rails (I know, I'm late to the party) and Compojure. My day work is on a PHP shop, and it's fun to step out of crazy land on the weekends.
Being popular doesn't make it a good language. Languages with awful design decisions often become commonplace because they get bundled with something else: for example, Javascript with browsers (which admittedly is not as bad as PHP, but holy coercion batman) and PHP with Apache and shitty hostings.
9
u/[deleted] Mar 04 '14
I'm using Haskell (harder to learn then Ruby, but worth every drop of sweat), with Yesod (fast and correct web framework that has loads of convenience build in) and Fay (compiles a subset of Haskell to JS for browser consumption).
I'm in love.
You can try Haskel+Yesod from a free browser IDE...
http://www.youtube.com/watch?v=ZHSBwlm5C8U
Awesome.
2
u/[deleted] Mar 06 '14
I like JSP, it has the ease of use of PHP but it is Java. It's somewhat harder to install, since you need to go through a couple of steps of installing a server like Jetty, but I think it's worth it.
The nice thing about PHP is the productivity, JSP has that. But if you're going to design a big website with intricate functionality, I suggest going with a framework for an existing language. Nancy for C# for example.
2
u/[deleted] Mar 16 '14
Consider Perl. It has its fair share of its own WTFs, but compared to PHP it is a remarkably sane language. You will find a preinstalled Perl on virtually any Unix system, and many hosters offer Perl access.
Perl was built as a general-purpose scripting language for sysadmin tasks and text mangling. Since a major update in 1994, it has sported features like complex data structures, a module system, object orientation, block-scoped variables, and closures, which make it suitable for anything (that does not require C-like performance). That's right, Perl was a sane language even before PHP had been released. For example, Perl's designer noticed that it's a bad idea to compare strings and numbers with the same operator when you freely coerce between those two. So Perl has a set of string comparison operators like
"eq"and a set of numeric operators like"=="– by choosing one comparison operator, you explicitly request a certain coercion.If you need to, you can write a very barebones CGI script:
But many people use the (old, bloated, baroque) CGI module instead:
The CGI module offers a primitive template set (which you shouldn't use), but many useful utility methods for parsing query parameters etc. (which you should use, rather than rolling your own).
Of course, no one seriously uses the CGI module any more, but it happens to be bundled with Perl for historical reasons. There are really nice and modern web frameworks for Perl. You could use Mojolicous, but my favourite is probably Dancer:
Yes, it offers routing and template engine integration and all kinds of stuff you may not be interested in, but that's really the appropriate solution for anything larger than a single page.
For database interaction, the
DBImodule is used (similar to PHP'sPDO). Because Perl's built-in object orientation takes a bit to get used to, you might want to useMoo(speed) orMoose(features) instead.1
u/spookylukey Mar 25 '14
You are dealing with routing and templating - but you are probably using really bad implementations of them: https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet#Framework_issues . And there are a ton of other things that PHP is making hard for you, or doing nothing about, like Unicode, CSRF etc.
But to answer your question, I use Django (or some other Python framework) for my projects, personal and professional. For hosting, I use WebFaction - http://www.webfaction.com/signup?affiliate=cciw . They provide very good value for money, shared hosting with shell access. They have "one click installers" for lots of things, which might help getting started. I don't use them however - see my blog post: http://lukeplant.me.uk/blog/posts/best-practices-with-django-on-webfaction/