Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jonobin

macrumors 6502
Original poster
Sep 3, 2014
367
95
Well, I've had learned to develop websites with html-css and php using mySQL database and wrongly i thought i was a good developer.. never been wrong!

talking to some other web developer and surfing the web I have seen a lot of new stuff like node.js, mongoDB and more.

the answer is: is these new "technologies" helping developers to develop faster web sites?

what are the bests?

another questions: i've seen that a lot are using ruby on rails to develop instead of php, don't want a "this is better than the other" comparison, just want compatibility answer
 

JoelTheSuperior

macrumors 6502
Feb 10, 2014
406
443
As someone who develops web applications primarily using the Ruby on Rails framework, essentially what it comes down to is that more modern technologies are being developed and being used for web applications.

Sure, there's plenty of large sites still working with technologies like PHP, and with good reason, but many are finding that they can develop much more rapidly and much more effectively with frameworks such as Ruby on Rails (Ruby), Django (Python) and Laravel (PHP).

You can still definitely be a good developer whilst using PHP and MySQL - it depends primarily on how you use it, how efficient your code is and quite simply how well written it is. The fact that people have been switching to other languages and frameworks doesn't devalue your own experience so long as you can deliver an end result that the client is happy with.

The best is fairly subjective, but I do know that Ruby on Rails is popular with good reason - I'd say the learning curve is a little bit steep since some of the basic concepts aren't as well explained as they could be, but it is a fantastic framework for getting applications developed quickly with. Of course, other options are out there.

Regarding MongoDB, essentially it's what's called a NoSQL database, and quite simply, it's likely very different to what you are used to.

I'm not a MongoDB expert but essentially the difference is that, unlike MySQL where you have tables with rows and columns, MongoDB has 'documents'. In addition, unlike MySQL where you have to define your database schema before you can start working with it, MongoDB simply changes your database schema on the fly as and when you add data to it. If for example, you pushed a set of data for a user and started adding phone numbers to that, MongoDB would automatically create a field for that in the database.

If you're curious about MongoDB I would definitely recommend reading this:
http://www.mongodb.com/nosql-explained

Hope this helps.
 

jonobin

macrumors 6502
Original poster
Sep 3, 2014
367
95
well before programming in php i learned a lot of c++/c#, do you think ruby is better for me?

well mongodb looks like awesome, do we need specific web hosting to use it?
 

JoelTheSuperior

macrumors 6502
Feb 10, 2014
406
443
well before programming in php i learned a lot of c++/c#, do you think ruby is better for me?

well mongodb looks like awesome, do we need specific web hosting to use it?
To be honest you won't be using either with traditional web hosting. You'll mainly want to use VPS based hosting for this. I'd recommend DigitalOcean if you want something to play with.

Should you use Ruby (on Rails)? Up to you really. I use it and personally I love it but it's a matter of personal preference. The Rails Guide is a good place to start.
 

Jamesbot

macrumors member
Jun 19, 2009
51
1
Like Joel said, there's nothing about using PHP and MySQL that makes a person a good developer or a bad developer. I'm sure there are plenty of bad javascript developers building node/mongo apps.

Frameworks (of any kind) don't make a developer "good" either. The good ones provide the tools to get 80% of functionality most often needed in web apps, but you still need to do that last 20% yourself.

That said, there are some really cool frameworks out there now and no one can tell you which one is best for you.

Rails is certainly a good choice for a general purpose web framework.

There are some javascript frameworks out there for single page apps that are worth checking out. Personally, I think Meteor (https://www.meteor.com) is pretty sweet. It's built on node and mongo.

For rails hosting, you may want to check out Heroku. With a VPS you'd have to set up everything yourself, which depending on your linux skills, could be a challenge.
 

jonobin

macrumors 6502
Original poster
Sep 3, 2014
367
95
Web devoeloping is the strangest thing in the world to my eyes. Surfing the web almost every comparison between ruby-phyton-java vs php is won by competitors of the last one but the most famous cms like joomla-Wordpress and Drupal (just for saying someone) are based on php. I know some php (saying 'I know perfectly' would be too much) but doing the guided tours of others languages, like ruby one, made me more comfortable than developing with php. So, why are the most used softwares on the web written with that 'old and -some say spaghetti code- bad' language?
 

theluggage

macrumors 604
Jul 29, 2011
7,548
7,471
So, why are the most used softwares on the web written with that 'old and -some say spaghetti code- bad' language?

1. Virtually every web-hosting service offers PHP (with a decent selection of libraries) and MySQL. Your hosting service may not support Ruby or Python, and node.js pretty much needs a VPS or a dedicated node.js service provider.

2. PHP is stable and well-documented.

3. PHP has a comprehensive set of stable, fully developed "official" libraries well documented on the PHP website, with relatively little duplication and a clear choice of what to use. By comparison, when I've tried Python or Node, the first problem is to sift through a plethora of alternative libraries that often feel like work-in-progress, supported by that which passes for "documentation" on GitHub etc.

4. PHP is designed for embedding code in web pages and doesn't need a 'framework' or template engine for simple applications (its still good practice to separate your 'business logic' from your templates - but you can write your templates in PHP). In Node, in particular, you need a lot of code (or 3rd party libraries & middleware) before you can actually start serving programatically generated pages.

NB: I've played with Node and I like many things about it, but the "first implement your own webserver" approach is overkill for simple dynamic websites and the need for VPS or specialist node.js hosting is a dealbreaker for anything that has to run on someone else's server.

Oh, and re. NoSQL, the issue is that NoSQL just can't do a lot of important things that traditional RDBMs can do (e.g. maintaining referential integrity between records) whereas RDBMs can pretty much do everything that NoSQL can do, especially now PostgreSQL lets you create HSTORE or JSON fields to hold arbitrary structured data. It might make sense to store document data in an arbitrary format, but use NoSQL for username/ownership/permissions management? Ugh! :mad: If the worst comes to the worst, I'd much rather write code to de-normalize relational data (tedious but straightforward) than to sanitize inconsistent NoSQL data.
 

960design

macrumors 68040
Apr 17, 2012
3,703
1,571
Destin, FL
Web devoeloping is the strangest thing in the world to my eyes. Surfing the web almost every comparison between ruby-phyton-java vs php is won by competitors of the last one but the most famous cms like joomla-Wordpress and Drupal (just for saying someone) are based on php. I know some php (saying 'I know perfectly' would be too much) but doing the guided tours of others languages, like ruby one, made me more comfortable than developing with php. So, why are the most used softwares on the web written with that 'old and -some say spaghetti code- bad' language?
We've been practicing medicine for thousands of years, modern medicine has only come along in the last one hundred years. Software development has only been around for a very short time. We are still trying to figure out the best way. Just like medicine, there may never be a best, just a more practiced way.

The spaghetti code was developed by people trying to get the job done with their current time / knowledge level. I'm sure you look back at some of your first projects and laugh at the code.

I've been writing software for over 30 years ( started at nine ) and can look back just six months and see some silly things I've done. Most of my current web projects are OOP, I really wanted to type ALL, but I have one project that I threw together over a weekend to fill a need and guess what. Three other companies want the code. Yep, the crappiest crap I wrote is popular for the moment. Should I spend time going back and rewriting it so that another programmer can maintain it easier or should I just continue on... another lesson learned?

I'm sure that code will come back to haunt me in two years. Life as a developer.
 

rufhausen

macrumors regular
Jul 5, 2007
135
0
Littleton, CO
My two cents:

- If you are going to stick with PHP for now, you should check out Laravel (mentioned earlier) and laracasts.com (great video tutorials centered around Laravel, but also great for OOP and webdev in general). Laravel will move you toward "modern" PHP development using OOP, Composer, etc.
There are other good frameworks as well, but stay away from anything that doesn't at least require php 5.3+ and doesn't integrate with Composer. Either case means the framework has not adopted modern best practices, IMO.

- Digital Ocean is great, but you should have some experience with managing a *nix server environment (for instance., a 512MB droplet needs a swap disk enabled or it will eventually crash, and I found the hard way and had to figure out how to create it, etc.). Great for learning though.

- Re: NoSQL, Mongo, etc. I haven't run into any situation yet in my work where MySQL wasn't sufficient for data storage, but I guess that depends on what industry you work in and what types of apps you are building.
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
- Digital Ocean is great, but you should have some experience with managing a *nix server environment (for instance., a 512MB droplet needs a swap disk enabled or it will eventually crash, and I found the hard way and had to figure out how to create it, etc.). Great for learning though.

A 512MB droplet doesn't require any swap if you configure it correctly. I have 3 running now with no swap all running production websites.

The only reason you would need to add swap is if you are running out of RAM and the only reason you would be running out of RAM would be because you misconfigured something (normally either Apache or MySQL are the common culprits).

I'd revisit your configuration and try and fix the root problem. Relying on swap is a very silly idea.
 

rufhausen

macrumors regular
Jul 5, 2007
135
0
Littleton, CO
A 512MB droplet doesn't require any swap if you configure it correctly. I have 3 running now with no swap all running production websites.

The only reason you would need to add swap is if you are running out of RAM and the only reason you would be running out of RAM would be because you misconfigured something (normally either Apache or MySQL are the common culprits).

I'd revisit your configuration and try and fix the root problem. Relying on swap is a very silly idea.

Really? I don’t want to hijack this thread, but since you already kind of did that and your post comes with a hint of condescension, I’ll respond.

Actually, I think NOT having a swap partition in place is “silly” regardless of how much RAM your server has. Independent of how much optimization you’ve done with Apache, MySQL, etc., you cannot guarantee that some process on your machine will not develop (or already has) a memory leak over time and/or a significant increase in server load won’t overload the system regardless of the optimization you’ve done. It’s an insurance policy with no real downside. I have a 1GB droplet that has been up for 223 days and is only using 4672k of a 524284K swap, but it’s there if it needs it.

Here’s an article on Digital Ocean’s site regarding swap partitions:
https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps

And here’s a quote from the article:

“If you're dealing with any production server, you need to know that if virtual memory is not enabled and your system has no more free memory...then if a program or service - perhaps your web server - needs to allocate more memory, it will fail! Depending on your platform and configuration, this can result in many undesirable or unstable conditions including other applications (i.e. other processes than the one asking for memory) being forced to close to free the needed memory, to it failing and crashing the program - or whole server - entirely.
Because of this, I personally recommend anyone, on nearly any system - be it a droplet, dedicated server, your Windows PC or Mac or even your Android tablet or phone - should have at least a small amount of virtual memory enabled.”

I haven’t found an article yet suggesting you shouldn’t add a swap partition. And it makes even more sense on Digital Ocean with it’s SSD drives making r/w from the hard disk much faster than traditional hard drives.

With regard to MySQL specifically — a common issue with LAMP setups on small (memory) servers is that the MySQL process will get killed off once no more memory is available. While further MySQL optimization might be necessary, it’s a common misdiagnosis that’s due to MySQL at all. It’s often some other process like Apache spawning too many workers (which can also be addressed via optimization to a point, but I’d recommend using Nginx anyway) that will cause the system kill something off, and for whatever reason, MySQL often gets the short straw (maybe due to a relatively large memory footprint that makes it a good candidate to free up the most memory).

In conclusion, don’t be “silly”. Always have a swap partition in place just in case. (<= that has a nice ring to it).
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
Really? I don’t want to hijack this thread, but since you already kind of did that and your post comes with a hint of condescension, I’ll respond.

My post wasn't meant to be condescending. Blunt maybe but not condescending.

Actually, I think NOT having a swap partition in place is “silly” regardless of how much RAM your server has. Independent of how much optimization you’ve done with Apache, MySQL, etc., you cannot guarantee that some process on your machine will not develop (or already has) a memory leak over time and/or a significant increase in server load won’t overload the system regardless of the optimization you’ve done. It’s an insurance policy with no real downside. I have a 1GB droplet that has been up for 223 days and is only using 4672k of a 524284K swap, but it’s there if it needs it.

You can look at like an insurance policy if you like but I've run my Digital Ocean servers for some significant amount of time (not sure how long but it is over a year) and haven't felt the need to add swap to them.

I will admit that I use Nginx instead of Apache and PostgreSQL instead of MySQL so that might have something to do with it but I find RAM usage stays pretty consistent over time for me.

Here’s an article on Digital Ocean’s site regarding swap partitions:
https://www.digitalocean.com/community/tutorials/how-to-configure-virtual-memory-swap-file-on-a-vps

And here’s a quote from the article:

“If you're dealing with any production server, you need to know that if virtual memory is not enabled and your system has no more free memory...then if a program or service - perhaps your web server - needs to allocate more memory, it will fail! Depending on your platform and configuration, this can result in many undesirable or unstable conditions including other applications (i.e. other processes than the one asking for memory) being forced to close to free the needed memory, to it failing and crashing the program - or whole server - entirely.
Because of this, I personally recommend anyone, on nearly any system - be it a droplet, dedicated server, your Windows PC or Mac or even your Android tablet or phone - should have at least a small amount of virtual memory enabled.”

I can see where the author of that article is coming from, but then I have run Linux on my desktop and on servers for some considerable amount of time and have a pretty good idea of memory usage.

Rather than adding swap to fix stability issues on your server if you get into a low memory / no memory situation I always feel it is better to have redundancy instead. That way you can be safe in the knowledge that even if your entire server comes crashing down your website will still be up and running. Swap has always been a bit of a band-aid solution.

I haven’t found an article yet suggesting you shouldn’t add a swap partition. And it makes even more sense on Digital Ocean with it’s SSD drives making r/w from the hard disk much faster than traditional hard drives.

With regard to MySQL specifically — a common issue with LAMP setups on small (memory) servers is that the MySQL process will get killed off once no more memory is available. While further MySQL optimization might be necessary, it’s a common misdiagnosis that’s due to MySQL at all. It’s often some other process like Apache spawning too many workers (which can also be addressed via optimization to a point, but I’d recommend using Nginx anyway) that will cause the system kill something off, and for whatever reason, MySQL often gets the short straw (maybe due to a relatively large memory footprint that makes it a good candidate to free up the most memory).

In conclusion, don’t be “silly”. Always have a swap partition in place just in case. (<= that has a nice ring to it).

I have to respectfully disagree with your conclusion. Redundancy is always better than relying on swap to ensure stability.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.