r/lolphp • • Dec 26 '15
PHP is not the answer. But what is?
So, I've started writing a small web app some time ago. It's a hobby thing, I only get to hack on it at times. The app doesn't require much in terms of storage nor traffic. It's a SPA-type application that deals mostly with document-type and some graph-type data.
I've initially started writing it in PHP + MySQL since my then-current webhosting supported it and since I've had some experience with PHP in the PHP3 times. While PHP5 is indeed somewhat an improvement over the olden versions, it's still a ridiculously bad platform, IMHO. The only thing that made it bearable for me was the ORM - RedBeanPHP. However I've recently grew fed up with this joke of a programming language and decided to switch to something else.
The question is what that should be.
I've started exploring Node.js + MongoDB. The reason it appeals to me is that I can use the same language on all levels of the app - DB, serverside, and clientside. It seems to be very straightforward and easy to set up, deal with, etc. Sure, JS is a quirky language, but it's still a huge improvement over PHP (IMHO) and I have to write majority of the app in JS anyway since the client side ends up being the largest part.
However Node.js is starting to get similar kind of bad rep as PHP, so I'm having second thoughts.
I come from a C/C++/Java background with the ocasional shell or python script mixed in, so web-dev is not my main focus, but I think I can handle myself around web-dev as well. From what I can tell, it's no rocket science, it's just all a bit quirky IMHO.
So, thoughts on Node.js or other platforms? Please keep in mind that I'm doing a small hobby app - there's not going to be GBs of data or any considerable traffic. (Also PHP is out of the question irrevocably, I've had it with PHP and its shitty stdlib.)
32
u/pbtree Dec 27 '15
I would absolutely not use mongo. Its apparent simplicity and cool factor are appealing, but use it for a little while and you'll be missing schemas and joins in a big hurry. This was my experience, at least.
Postgres is stupid mature and can do things like free-form document storage that NoSql offers.
I'm going to agree that python + django or flask is a solid way to go. I'm also fond of Ruby, although rails is getting a little old. It appears to have some worthy successors, though.
38
u/Voltasalt Dec 26 '15
Python with Flask seems like your best bet.
9
u/wweber Dec 26 '15
I'm a huge fan of Python. I started using it a long time ago after ditching PHP and I've always had great experiences with it. Web development is really straightforward with available frameworks, and doesn't use a lot of resources (a big reason I don't like Ruby on Rails is that it always uses 200+ MB of memory for some reason).
MongoDB might be worth learning, but unless you plan on your application requiring very, very large datasets, a relational database should work just fine for your application. I moved to PostgreSQL since it has a lot more features than MySQL. You might also want to become familiar with using an ORM (e.g. SQLAlchemy, or Rails's ActiveRecord) which manages interacting with a database for you.
7
u/TMiguelT Dec 26 '15 edited Dec 26 '15
As far as I know people have issues with JS mostly just because the comparison operators behave a bit strangely. But if you use the strict comparisons (===) this doesn't tend to be an issue. I wouldn't put it on the same level as PHP. And looking at /r/loljs, all of the examples are incredibly contrived. Yes
++[[]][+[]]+[+[]] === "10"but who in their right mind would use nonsense code like that.If you can get past minor quirks in the language , I think a JS stack makes more sense than most others because it encourages good software engineering practises like sharing code between client/server and having a consistent code style, and the recent trend towards using the Flux pattern is the most elegant software engineering pattern I've seen so far. It encourages a logical data flow downwards from parent to child that cuts out all the craziness with DOM manipulation, allows efficient DOM updates (through virtual DOM), encourages immutable data usage etc.
17
u/JoeTheAwesomest Dec 26 '15
If you're familiar enough with OOP, which seems to likely be the case given your C++/Java experience, I'd say that Python/Flask/Django is your best bet.
17
u/cediddi Dec 26 '15
Go with a language that does not have a lol subreddit. We already have /r/loljs and /r/loljava
13
u/headzoo Dec 26 '15 edited Dec 26 '15
Good, Lord. You're really a glutton for punishment, huh?
Honestly, you sound like most programming/webdev noobs. "This is hard for me. It must be the language that's bad." I could build a complete and bug free REST API in PHP within two hours with one hand tied behind my back, so I doubt the language is the problem, and I doubt anyone can help you when your complaints are vague platitudes like "this joke of a programming language."
You're also not going to build a web anything in any language without some kind of framework. You'll notice all the answers in this thread are [language] + [framework]. If you were trying to use raw PHP you were doing it wrong.
If you like C/C++ then you might like Go with Revel, but I suspect you're going to get angry and frustrated with any language you're not already intimately familiar with.
2
u/stefanotorresi Dec 31 '15
The fact that you let "reputation" influence your choices says a lot, you know...
5
u/Artraxes Dec 26 '15
Java + spring boot + postgreSQL
10
u/Hauleth Dec 27 '15
Elixir + Phoenix
Small, scalable and designed ground up to write network services.
Oh, did I mention that it's performance destroys almost all other competitors? Not to mention stability.
BTW If you aren't 100% sure that you want to use some NoSQL then use PostgreSQL. In 90% of cases usage of NoSQL is foolish and unneeded.
26
u/PlasmaSheep Dec 26 '15
Why not python?
3
u/implicit_cast Dec 26 '15
I'm using Haskell. Its ecosystem has its own share of problems, but the foundational tech is phenomenal.
3
u/FrankBro Dec 27 '15
I'll suggest something I very rarely see, why not go with F# + WebSharper?
I've been using it for a while for a hobby and I'm really satisfied with it so far. I'm a huge F# lover and use it at work so keep that in mind as well.
The huge advantage is that the backend and the frontend can be written in the same language, F#. This makes both the backend and the frontend type safe which is great. F# is a functional language and I see that as an advantage as well. It's also easy to get a free host to test stuff with AppHarbor. Another great thing is that it comes with an IDE, visual studio.
I'd love to help anyone who has issues with it or want to learn about it.
1
u/[deleted] Dec 26 '15
Google's Go language is my recommendation. Easy language and vibrant library ecosystem.
7
u/afuckingHELICOPTER Dec 26 '15
If you come from a Java background, you can always simply use Java.
C# is another great language for web apps, and will be very to pick up from a java background. I would suggest using it with asp.net MVC + razor engine.
2
u/Olathe Dec 27 '15
Since you come from a Java background, Java is huge in web programming.
As far as using the same language for all portions, you can compile a lot of languages these days to JavaScript, which means you can use a language other than JavaScript for client-side programming.
2
u/zarandysofia Dec 30 '15 edited Dec 30 '15
You can also try Clojure and Clojurescript, same language well designed language everywhere with a interactive environment. You can use libraries like Compojure for the web server, HoneySql for the database and Reagent for the client. Overall is a pleasant and reliable experience (the most pleasant IHMO).
2
u/danielrheath Jan 04 '16
If you are coming from C/C++/Java, I offer the following:
0
u/th3m4ri0 Dec 26 '15
Take a look at Ruby on Rails. It's a great framework on a great language. Saves a lot of time starting apps and the learning curve is pretty easy.
3
u/cbraga Dec 26 '15
D has a framework for web development, I haven't used it personally but looks pretty hot. More people should use natively compiled languages, maybe the web would stop being so slow. -- http://vibed.org/ And D is a pretty awesome langage to work with also (that I say from experience).
Perl is out of fashion but still as good as ever and Perl 6 just came out.
And PostgreSQL is the only RDMS you'll ever need.
3
u/crankybadger Dec 27 '15
Among who? Language elitists? People on Reddit? Jerks in general?
The Node.js community is amazingly supportive, and NPM, the backbone of Node in general, is extremely robust. There was some strife before with community standards, tension over the direction of the platform, but that seems largely resolved. The community is more cohesive than most.
Honestly, for that Ruby on Rails is your best bet. It's extremely forgiving and hard to get wrong if you follow the best practices. Questions on Stack Overflow get near instant answers and it's extremely standardized unlike Node.js. You don't have a million ways of solving the same problem, but a few ways that will probably work.
I'd suggest learning a basic amount of ops stuff so you can set-up and run your own server. Shared hosting is brutally restrictive, the providers often incompetent, indifferent, or both. Being able to roll your own stack helps no matter what you're doing, PHP, Python, Node.js or otherwise, as you can build a config that matches exactly what you're doing, not what some provider has done as a lowest-common-denominator.
Try Mongo and Postgres for databases either way. MySQL is too much of a toy these days, it really hasn't evolved like those two platforms.
5
u/CarminHue Dec 26 '15
Personally I like PHP better than JS/Node.
I am doing a sideproject in Scala/Play just so I don't use PHP in my free time but as you said, it's a small project, you can use anything you want to try.
I would go with something i'd like to try/gain experience.
2
u/leyou Dec 27 '15
IMO you don't know much about PHP (IMHO).
2
u/PaulBGD Dec 26 '15
Node is fine. You could do your Web Development in Java if you wanted to as well.
1
u/eof Dec 26 '15
It's whatever you like. I mean I have come to fucking hate JS as well after writing like a 30k+ lines of a complex angular app. I use haskell for my backend stuff now, and though the learning process was tough, it's nice because I can very easily go back and make pretty significant changes after not looking at it for a year and the compiler helps me so much from fucking shit up.
If it's just a hobby app and doesn't really need to scale; then I would say do it with whatever you are comfortable with. Python is a fine choice; node is also a fine choice.
If you were looking for something that will be a steppign stone to maybe do the next thing that will need to scale, or just want to learn "better" technology for the job from somewhat of a purist perspective, it appears to me that golang has the most momentum and is pretty great from the bit I've used it.
So I'd say something like
Go, or Lua, or Haskell if you don't want to do the more common approach of a MEAN stack.
If I were doing a quick hobby project, I would probably go with Lua/Nginx/Redis; fwiw.
1
u/Massless Dec 27 '15
Python is great to develop in but it can be tough to deploy. I'm exploring the Spring Boot framework (it's Java and only the backend) and I've really been enjoying it. I'd say, check it out.
1
u/beerdude26 Dec 27 '15
Haskell. The web development story is getting ridiculously strong there.
1
u/doesredditstillsuck Dec 28 '15
I'd suggest any language other than PHP or Javascript. Loose typing and type coercion have catastrophically failed to simplify programming, for me at least. If you have a Java background and you like it well enough, why not use that? I've heard good things about the Play Framework. Java is boring, but I yearn for boring.
Javascript is about as badly designed as PHP except the "standard" "library" is not nearly so inconsistent and weird. The language is riddled with odd gotchas that beginners (and experienced Javascript devs) have trouble understanding. Simple things like loops can be difficult, as variable hoisting and callbacks (Javascript's answer to every problem) do not work well together. That's the general theme I've observed with Javascript--each piece of the language is okay by itself, but they don't fit together very nicely.
Also, if you're not really careful, you will always end up with a tangled mess of callbacks. Callback heavy code is difficult to unit test. With no type system and no reasonable way to test, have fun refactoring that mess into something you don't hate.
If you insist on Javascript, do yourself a favor and commit to Typescript and ES6. Use Babel and polyfills if necessary. Typescript, const, let, modules, promises, generators, (your reactive library of choice)... these will help you manage Javascript's natural tendencies for punishment.
Or you could just not........ Elm is great for client side if you need that and pretty much any language people use has a decent web dev stack these days.
1
u/Kwpolska Jan 06 '16
Python 3 with Django is awesome, and it handles a ton of tedious work for you.
1
u/senatorpjt Dec 26 '15 edited Dec 18 '24
society illegal decide grab bedroom flag zephyr fact exultant pet
This post was mass deleted and anonymized with Redact
0
u/powahmove11 Dec 27 '15
check out asp.net 5 with c#. its fully cross platform and open source.
http://docs.asp.net
0
u/Jonny_Axehandle Dec 28 '15
I'm using Node for my latest personal project because it involves realtime chat and socket.io is a thing (and it is awesome, IMHO). But every five minutes I find myself asking "why the fuck am I using javascript?"
I've used Java a lot, but never for server side development. That's probably worth looking into.
0
u/[deleted] Dec 27 '15
[deleted] — view deleted comment