PDA

View Full Version : Server Programming




drewyboy
Apr 30, 2010, 10:48 AM
Hey everyone. I'm wanting to start learning some server framework programming and I'm not sure where to start. I've become familiar with XHTML & CSS and was thinking about moving to Javascript, but I've been told to learn PHP first. Soon I'll be getting snow leopard server and was wondering which language would be best suited for the mac server world. I've seen Ruby on Rails, PHP, etc. and wanted to see what you guys/gals thought. The purpose would simply be for my home website which I want to eventually use SproutCore and do some web app development for my family so they could upload pictures, videos, audio, playback of all of it, update their own blogs on the website, etc. Any advice would be helpful.



nickmathis
Apr 30, 2010, 11:05 AM
I would recommend Ruby (and Ruby on Rails) over php. I think it is a much better language, and has the benefit of being useful for more than just websites, such as OS X programming (MacRuby, RubyCocoa). I also use it frequently for scripting tasks in both OS X and Linux.

If you're just getting started in programming, you will probably have less headache with Ruby over php. If nothing else learn one, then learn the other, and pick which one you prefer and meets your needs.

splitpea
Apr 30, 2010, 11:06 AM
PHP is probably the easiest to get started with (you can enable a PHP server on your Mac with the click of a button), but also the easiest to learn bad habits with. Be very wary about learning PHP from web tutorials since many of them omit very important steps such as escaping user input or parameterizing DB queries, and concepts such as object-oriented programming or separating logic from presentation.

Javascript of course you can start learning with just a browser and text editor, but some of the concepts (e.g. closures, prototypes) are a bit more confusing, and you'll need server side programming if you want to learn the advanced stuff (AJAX).

I like Python as a first language. It's easy to understand the basics of and will teach you good habits and fundamental concepts. However, it's a little more difficult to get a web server set up.

GorillaPaws
Apr 30, 2010, 11:34 AM
I like Python as a first language.

I also think Python is a great first language. The syntax is very clean/simple and Python is a great general-purpose language can be used for lots of different tasks from server code to writing programs on the Mac to database access to quick little scripts. This free course from MIT (http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-00Fall-2008/CourseHome/index.htm) is a great place to get started with learning how to program using Python by watching the videos of the lectures and working through the posted assignments. Also there is a tutorial on Python's main site. (http://docs.python.org/tutorial/)

Cromulent
Apr 30, 2010, 01:26 PM
I also think Python is a great first language.

Python and Django is a dream combination. Unfortunately you still need to use Python 2.x to get anything useful done at the moment. It'll take a few years yet before you can use Python 3.x for general development.

jpyc7
Apr 30, 2010, 01:28 PM
I also think Python is a great first language. The syntax is very clean/simple and Python is a great general-purpose language can be used for lots of different tasks from server code to writing programs on the Mac to database access to quick little scripts. This free course from MIT (http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-00Fall-2008/CourseHome/index.htm) is a great place to get started with learning how to program using Python by watching the videos of the lectures and working through the posted assignments. Also there is a tutorial on Python's main site. (http://docs.python.org/tutorial/)

If you go with python, you might not want to use mod_python with Apache. Mod_python works fine, but it is not actively supported anymore.

You can still use python on your web server if you're willing to use one of the python-based web frameworks, e.g. Django. Mod_wsgi is an Apache module that interfaces with python web frameworks, but it has a specific interaction model that is more structured than mod_python.

AlmostThere
Apr 30, 2010, 02:29 PM
I like Python as a first language. It's easy to understand the basics of and will teach you good habits and fundamental concepts. However, it's a little more difficult to get a web server set up.

1. From Terminal.app: sudo easy_install cherrypy

2. Put this in a text file called helloworld.py:

import cherrypy

class HelloWorld(object):
@cherrypy.expose
def index(self):
return "Hello World!"

cherrypy.quickstart(HelloWorld())


3. Back in Terminal: python helloworld.py

4. Go to http://localhost:8080

Easy as py :)

Cromulent
Apr 30, 2010, 04:04 PM
I like Python as a first language. It's easy to understand the basics of and will teach you good habits and fundamental concepts. However, it's a little more difficult to get a web server set up.

I'm going to have to disagree with you there. Of course you might need to spend a little while reading the mod_wsgi documentation to get it working correctly but then as a programmer reading documentation should be second nature :).

Seriously though, it's no harder than getting PHP setup correctly and securely (in fact it is easier - there are lots of security issues associated with PHP).

splitpea
Apr 30, 2010, 04:26 PM
I'm going to have to disagree with you there. Of course you might need to spend a little while reading the mod_wsgi documentation to get it working correctly but then as a programmer reading documentation should be second nature :).

The OP is a complete newbie. Enabling Apache + PHP on a Mac is as simple as clicking a button.

Seriously though, it's no harder than getting PHP setup correctly and securely (in fact it is easier - there are lots of security issues associated with PHP).

Set up correctly and securely maybe. But OS X's default PHP config is perfectly fine for developing within a home network or on 127.0.0.1, not serving to the outside world. It's also a lot easier and less expensive to find third-party PHP hosting than Python hosting.

Besides, not every programmer is a sysadmin -- especially those coming into the game from the HTML end of things. Even if one can grok the mod_wsgi documentation well enough to get it installed and functional, there's no guarantee that one will understand it (or the underlying networking / OS concepts) well enough to get it configured securely and performing well -- any more than with PHP.

Just saying.

jpyc7
May 1, 2010, 02:39 AM
The OP is a complete newbie. Enabling Apache + PHP on a Mac is as simple as clicking a button.

Besides, not every programmer is a sysadmin -- especially those coming into the game from the HTML end of things. Even if one can grok the mod_wsgi documentation well enough to get it installed and functional, there's no guarantee that one will understand it (or the underlying networking / OS concepts) well enough to get it configured securely and performing well -- any more than with PHP.

Just saying.

I have also been considering doing server programming on my Mac. I made my comment endorsing Python without really investigating the installation process. I see now that neither mod_python nor mod_wsgi come with the default Snow Leopard installation. If one is willing to use MacPorts and install software that way, it is probably doable for a newbie. I don't think that compiling from module source code to work with the installed Apache is straightforward, particularly getting the right library header versions.

On Snow Leopard, I could not find the "push button" for turning on PHP but enabling Apache was easy; it seems that one must still edit the apache httpd.conf file manually. Maybe it is easier on Snow Leopard Server.

Now I think I might learn PHP. I'll stick with Python for non-web server programming.