3 ms·
No reason to down vote because I prefer PHP for web development. In python you have to learn an entire framework just to do web stuff. PHP everything is right t
by shire 12y ago
No reason to down vote because I prefer PHP for web development. In python you have to learn an entire framework just to do web stuff. PHP everything is right there is that simple.
- dmritard96 12y agoyou should check out flask. there isn't much to learn to get going...http://flask.pocoo.org/ http://flask.pocoo.org/ from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run()
- shire 12y agothat would be very confusing to understand for a beginner. PHP you can write <?php echo "Hello world" ?> right in a html file and see it just by refreshing the page.
- FraaJad 12y agoIt is confusing if you don't know the difference between a page templating language and a web framework. If ease of writing "hello world" is what matters, Python: print "hello world" beats PHP: <?php echo "hello world" ?>
- danieldk 12y agoYou can do this in Python too, if you wanted to: http://modpython.org/live/mod_python-3.3.1/doc-html/pyapi-psp.html http://modpython.org/live/mod_python-3.3.1/doc-html/pyapi-ps... But it's not a very good architecture, in the meanwhile we had better approaches, such as MVC and MVVM. Anyway, CS is not web programming, but should focus on the fundamentals of computer science, for which there are far better languages than PHP.
- frozenport 12y agoIn PHP you should learn a framework to do web development. For example, my websites were a mess until I used smarty.
- e12e 12y agoI agree, there's no reason to downvote you for that. However, php only comes with "everything" if you assume it is already installed with a web server. As far as I know, you can't use the php (dev) webserver to serve php scripts without additional configuration. Contrast[1] with python: mkdir cgi-bin cat <<'eof' > cgi-bin/hello.py #!/usr/bin/env python3 print("Content-type: text/plain") print() print("Hello, world") eof #try to run: ./cgi-bin/hello.py bash: ./cgi-bin/hello.py: Permission denied #fix error: chmod u+x ./cgi-bin/hello.py #test in console: ./cgi-bin/hello.py Content-type: text/plain Hello, world #Ok, does it work on the web? python3.4 -m http.server --cgi 8000 --bind 127.0.0.1 #open localhost:8000/cgi-bin/hello.py So, how can I claim that this convoluted mess is "simpler" than php? Because everything is right there, and everything can be explained conciesly (contrast with apache configs, getting the www-user right etc). You could build on what the students know of print() and string interpolation/concatenation to output html/use templates etc. Is this how I would start teaching web programming in python? Probably not -- but it might be useful as one approach, assuming we've started with doing some stdin/stdout stuff, and showing how we can do the same on the web. Crucially showing how if you know how to read a csv file with values, do some aggreation and format it as a text table, you can output it as html, as text over the web, or even as json paired with javascript. That again generalises to database access ... etc etc. It's python (and "invisible" c) all the way down. [1] Comparing using a fully wrapped up install of webserver+php (either mod-php or fcgi or what not) would a) not be fair, because if you really learn python, you have all the tools to examine the whole stack (well down to the OS level anyway), and b) fair comparision wouldn't be to python but rather with something like web2py, that also bundles a lot of infrastructure. YMMV and all that, my only point was that there isn't really anything "simple" about web development -- it's distributed development with not very clearly defined security, state or even messaging semantics -- it's a mess. A useful mess, but a mess. [edit: formatting, spelling. Aslo I agree flask is probably a much nice place to start, if one isn't building on an introduction involving text/console i/o]