Learning programming via web apps
February 15, 2005 8:58 AM   Subscribe

Learning programming via web apps. [+]

I understand the mechanics of programming, like the various control structures and have a decent aptitude for algorithmic thinking. In the programming classes I've had since secondary school in (BASIC/C/Matlab), I've done very well. Now I wish to learn some real-world skills. The projects and assignments in those classes were mostly computational and didn't involve much I/O work, or working with APIs or libraries, data structures, or security..etc. In short, I didn't think I could do anything useful besides the elementary accounting style apps.

Well, I got some webspace for real cheap via a promotional code. So that's given me the motivation to take it to the next step and learn some web apps programming.

I've two projects in mind.

1)Writing my own groupblog engine. Just for the heck of it.
2)Writing my own web-based notes/bookmarks/calender app.

I can run the usual PHP4, Perl5, Python2 apps with access to MySQL, as well as C/C++ binaries.

Which language should I pick? What's the best way for learning with respect to practical skills? From which resources?

Note: I haven't learnt much about OO programming.
posted by daksya to Computers & Internet (19 answers total)
Best answer: If I were in your situation I would start off with PHP. It is a very simple language that allows you to do nice things on web-pages. It is also used by many people on the web (duh) and there is a multitude of information available. The two projects you have in mind are really good for it.

For a starter I would get an O'Reilly book on PHP programming and start with the basics: Show a page on the web, show a page with variables that you get for the database, then build it out from there.

However, what you have to keep in mind is that if you start off with the basics and are trying to write a group-blog there is a very big chance you start off with writing an app now that you will have to rebuild from scratch later on if you want to extend it. The structure of the application is quite important and it can be very frustrating to notice that if you want to have an extra function in your tool you have to change 30-odd pages of PHP.

What I would not do is use an open source app and try to change it with you own code. Most of this code is really well written and you can learn from it, but it just doesn't give the same satisfaction as writing it yourself.

The other thing you might want to read up on is SQL. It may not be the most difficult language to learn in the world, but it will save you a lot of time and effort if you learn some SQL and know that you can order by, group by, make links and everything in SQL already without having to write some silly php subroutine.

As for all the practical problems you will encounter during programming an app (how do I use sessions, how do i set a cookie, do I send the plain password or use an md5 hash) use google a lot, as well as php.net. It's amazing, but I am refreshing my Java skills at the moment and I realised every question I have has already been asked and answered on some forum somewhere. I love the internet.

On review: I realize I am not really answering your question specifically. Sorry.
posted by sebas at 9:30 AM on February 15, 2005

I'd go with sebas's route. I wouldn't go with odinsdream's route because they often won't be accepting of newer coders, but boy howdy will they let you work on their documentation... *insert the rolling of eyes here*

And quite honestly, most of the open-source PHP apps have spaghetti for code. You're likely to learn more about the basics noodling around on your own than you will from someone else. Just try to keep a separation of style, code, and content...

I learned PHP4 about three years ago while working for a big company. I was put in a pressure cooker where I needed to crank out some apps quickly, and I learned a lot doing it.
posted by SpecialK at 9:35 AM on February 15, 2005

I'd back sebas' advice here. I started in much the same way, learning PHP by copying MetaFilter's functionality. That was a long time ago, but it gave me a good basis in C-style languages. Definitely learn some SQL too. PHP and MySQL Web Development is a terrific resource for beginners. Once you get comfortable, start learning OOP. PHP4 isn't perfect, but you can gte close.

The me of today would say, "Go with Python," but PHP is probably easier to pick up and provides a lot more noob-friendly resources. Not that Python doesn't have good resources for people new to Python, but PHP has a lot for people new to programming in general.

On preview: SpecialK said it a lot cleaner than I.
posted by yerfatma at 9:36 AM on February 15, 2005

It's tough to get objective advice on programming languages, as learning them takes quite a bit of effort, and programmers like to defend their investment. So take my advice with a grain of salt.

I second the PHP recommendation. It is fairly easy to learn, oo design is not required, and it has a bounty of libraries for making web sites. I'd also recommend Python. It's also fairly easy to learn, and ultimately more powerful than PHP, though it doesn't have the same level of web-libraries.

I would NOT recommend Java, Perl or C++ (at least not off right away). These languages are definitely not designed with the new-user in mind, as there is quite a lot of syntax to digest before you can even begin.
posted by Popular Ethics at 9:51 AM on February 15, 2005

I agree with the other recommendations: start with PHP. It's a nice little language, fun, forgiving, convenient, and practical. You can start small and work your way up as you gain confidence. It has OOP features which you can use when you are comfortable with them, but you can also just bang out simple procedural code that gets the job done if that's all you know how to do. There are lots of useful utility functions built in that take a lot of the drudge work out of building a practical web site, so you can focus on the parts you're interested in. It's a very rewarding sort of language to play with.
posted by Mars Saxman at 10:01 AM on February 15, 2005

PHP and MySql are indeed an excellent way to start.

most of the open-source PHP apps have spaghetti for code

For sure. The quantity/quality ratio of PHP code in the wild is depressing. But you should feel free to learn to use the semi-official PEAR libraries. They can save you from reinventing a lot of wheels.

A counter argument could be made that you should learn Python first, but its easier to become productive quickly in PHP. Just be aware that the very nature of PHP encourages people to mix logic with presentation, which is a Bad Thing. For this reason, many people start with PHP then move on to some other platform.
posted by gsteff at 10:06 AM on February 15, 2005

Best answer: The most important thing is to have a project. So you already have that going for you.

Language-wise, PHP, Perl, and Python all have their partisans. I'd go as far as saying that the language you prefer is basically a taste issue. Professionally, you're likely to find the most demand for Perl, then PHP, then Python. I've used all three on the job, and here's my take.

PHP has good online documentation and its API is very well suited to web development. You'll find tons of online resources for working with PHP, especially if you're planning on using MySQL in conjunction. This makes it a very good language for people to just pick up and start using. On the downside, PHP has poor OO support, isn't a very good general purpose language, and its design makes it easy to write bad code.

Perl is powerful, chaotic, and better suited to quick, small projects than large ones. Because of how the language is quote unquote structured, it is hard to write maintainable Perl. OO support feels fragile and the way Perl makes you reference and dereference variables is hateful. This makes working with complex data structures more complicated than it should be. On the plus side, Perl has CPAN, which is a very extensive archive of Perl code you can use to solve whatever problem ails you. I would recommend learning a touch of Perl, if nothing else because it's a useful language for systems administration.

Python is different from Perl and PHP in that it has good OO support. It is also strongly typed. This means, for example, that a variable that is an int stays an int, and if you try to treat it as a string you will get an error. Personally, I find that this makes programs easier to debug and enforces better programming habits. Syntactically Python is very clean, and it strict use of whitespace makes it very easy to read. Python has a large standard library and an excellent free online book, but its API isn't as good for web programming as PHP and it doesn't have the vast archive of modules that Perl does.

If I were you I'd start with PHP/MySQL and build the projects you have in mind. See how much you like it. If you want to build really practical skills, I would then work a bit with Python to pick up some OO concepts. Python is an excellent language for pedagogy. After that, I'd start working with Java, which is the current language of choice for most enterprise-level web work. You'll find that Java is in much more demand than any of the other languages you named.

As far as C/C++, I'd hold off. C and C++ are harder languages to master, and though it's useful if you need to get close to the metal, it isn't something I'd recommend diving into straightaway.
posted by amery at 10:08 AM on February 15, 2005

daksya, for me it's all about what motivates YOU. Sounds trite, but I mean - you may need to try out various languages and see what works with you.

Some programming languages leave me cold whereas others I find to be intuitive and friendly. I think it does come down to an individual-personality-thing because you'll often find two programmers with completely different views on programming (both of them 'right' of course!).

I think the key thing here is that programming is supposed to be an enjoyable challenge that you can make a living from. If you find the language you're using boring or tedious or just plain abstract/counter-intuitive or a chore, it's probably not for you - you should enjoy the language from the get-go, from building simple "hello world" pages with it to full web apps.

Just my two cents of course!
posted by FieldingGoodney at 10:18 AM on February 15, 2005

Response by poster: Thanks for all the replies so far...

What I've heard is, that among the Ps, Python is the easiest to pick up. It also instills some good coding practices.

Now, I'm in no hurry to get my projects ready; of course, I don't want to be a slouch either. So the quick use-me of PHP is not so tempting or important. A solid foundation is more important.

What won't I be able to do, or will be pretty hard, using Python as far as my projects go?
posted by daksya at 10:36 AM on February 15, 2005

What won't I be able to do, or will be pretty hard, using Python as far as my projects go?

There is nothing in either of your projects that will even begin to challenge the capabilties of Python (or for that matter Perl or PHP).
posted by kindall at 10:41 AM on February 15, 2005

Best answer: Check out Ruby on Rails, a toolkit based on the Ruby programming language. It's gathering a lot of momentum as a completely new, pragmatic web programming framework that makes sense; you can get productive in -- literally -- a few minutes. Open source, of course. O'Reilly's ONLamp.com has a good article about it.

43 Things is written with Rails. ("Learn Ruby" is actually the 9th most popular thing at the moment.) Instiki is another cool Rails app.

Consider Ruby. It's an amazing language. If Python is concise and readable, then Ruby is even more concise and readable. It's also very popular, and growing fast in popularity, and is very much wired for Internet/web programming. More than anything, it's fun to work with, and in my opinion gets the job done faster than most other contemporary languages. Why's (poignant) Guide to Ruby is a brilliant, funny and, yes, poignant guide to the language. Programming Ruby: The Pragmatic Programmer's Guide is another good manual.

And as for hosting, TextDrive is a cheap hosting provider run by developers (the leads of Rails, Wordpress and others) with proceeds going back to the open-source projects they represent. You will get Ruby, Rails, MySQL, PostgreSQL, PHP and tons of other stuff.

As others point out, PHP is easy to get started with, and it's supported more or less everywhere these days. But it doesn't scale. I don't mean performance -- I mean that at some point in your personal skill development, the language will become a bottleneck. The language is a cesspool, and unless you're already a star programmer, you will be writing crappy code, and you will be picking up bad habits.
posted by gentle at 3:08 PM on February 15, 2005 [1 favorite]

Response by poster: gentle, Ruby sounds inviting. Unfortunately, my host, Dreamhost has Ruby 1.6.7 installed, and it seems that Rails requires 1.8.1. It looks like they will upgrade when there's a stable release for Debian. I probably don't want to switch hosts since I got my year-long package for $9 total. I'll inquire about a possible upgrade, else it looks like Python for now. But thanks for the info.
posted by daksya at 3:45 PM on February 15, 2005

daksya, sounds like you're on Debian Woody (aka stable). Debian, as you probably know, is laughably late with supporting newer packages, even if new means <= 3 years old.

Ruby 1.8.x, of course, is stable. The reason it's not in Woody is not because it's not stable, but because Debian has a policy about not pushing "major" version upgrades on users within a single iteration of their distro. That's why Woody has Python 2.1.3 and Ruby 1.6.7, both of which are pretty exactly 3 years old. Ruby 1.8 came out in 2003! That's, what, a millenium in Internet years?

I'm a Debian user myself, and I use Sarge (the upcoming iteration, which contains Ruby 1.8) with no instability issues. Even Sarge is very late with upgrades -- which is why I have now, after three years of Debian love/hate, switched to Gentoo. With Gentoo, there's no versioning/dependency problem to speak of; you can choose between no less than 13 versions of PostgreSQL, for example, and mix and match to your heart's content.

Anyway, I understand your predicament, of course. But for your own sake I would find somebody who didn't run such a conservative distribution. You're very likely to be encountering software that doesn't exist in Debian, or is too old; and I know from experience that butting into package problems every step of the way is extremely discouraging when you're learning and just want to make something that works.

Incidentally, I am a Python programmer who switched to Ruby fairly recently. Python is good, but somewhat lacking when it comes to web toolkits. Python doesn't have anything close to Rails, or Webrick (the excellent little web server module that comes with Ruby), or any of the cool, well-designed packages you will find in the Ruby world -- the closest is probably Zope, and I would not recommend it for what you're talking about.

I wish you good luck. :) Feel free to message me privately for any questions.
posted by gentle at 4:26 PM on February 15, 2005

You should be able to install a version of Ruby in your home directory on Dreamhost - might want to check to see if you can do that with your plan.

As far as language suggestions go, I started with Perl and eventually moved to PHP for web apps. Sometimes I use both in a project if the functionality requires something specific (like a quick-and-easy pre-made Perl module from CPAN). If you do start with PHP, I suggest you jump into PEAR as soon as you can.

If it was me starting over, I would go with Python or Ruby.
posted by melt away at 4:59 PM on February 15, 2005

I forgot to mention above that I'm a DH customer as well and most plans, especially those well-suited for development, allow you to compile your own version of software. That includes PHP, Perl, Ruby, Python or whatever.
posted by melt away at 5:10 PM on February 15, 2005

Best answer: Language bigotry warning: once you know C++, everything is easy.

I passed the Sun Java Certification test based just on knowing C++ and studying Java, but without ever having compiled a line of Java code.

Downside is, learning C++ is hard.

Learning at least a perfunctory amount of assembly language is also good, as it gives you insight into what operations in high-level languages are efficient, and what are not. And if you then take up C, you'll be able to "see" in your mind's eye, what assembly instructions will generated from the C code.

For the things you want to do (blog, PIM-type apps), you'll almost certainly want to use a database. Learn the SQL-92 standard, and then write standard code regardless of what database you use. SQL is mostly easy, and it's all just sets -- if you've ever used a Venn diagram or solved a logic puzzle on the combinatorial sort ("there are five house and five owners and five cars. Jones doesn't live in the blue house...."), SQL is actually pretty relaxing. But make sure you understand the Normal Form hierarchy, and what null means. (Null means "I don't know that value", not "that attribute/datum makes no sense for this entity". Misunderstanding null as the latter leads to ugly databases that are mostly unusable.)

Whether you're programming in a high-level language (C, C++, Java, PHP) or a "4GL" (SQL), whether it's object oriented or not, remember functional separation. (OO is mostly an extension of functional separation, along with the idea that objects know for themselves how to do what they do.) Write functions that do one thing and do it well. Tinier is better. Functional decomposition can be achieved in databases too -- layered views are a great way to do this, and any reasonable database will optimize away any redundancies in layered views. If not, showplan is your friend. (Note that MS databases and mySQL should not be considered "reasonable" databases.)

Avoid perl: it's a powerful language for ad hocery but too ad hoc for maintainable projects. And perl gurus can write code that is unreadable. But do use perl if your main task is pattern matching and text processing.

If you use Java, make sure you understand pointer aliasing and relatedly, why Java wrapper classes are immutable. Understand that use of Java's instanceof operator signals that the code's author doesn't really understand object-oriented programming, and avoid using istanceof in your own code. Testing for null object references is also a good sign that the coder doesn't know OO as well as he should. Make sure that you have a policy for object ownership: garbage collection won't save you from circular references nor will it release resources other than memory.

If you use C, make sure you understand the relations among strings and arrays and pointers and why an arrayname "decays to" a pointer when passed. You can still learn almost all of C by reading K&R, and you should read K&R.

If you use C++ understand that the point of objects is abstraction, and why, as Andrew Koenig put it, "abstraction is selective ignorance". And figure out what RAII means, and more importantly why it's such a popular C++ idiom (hint: good C++ coders like objects to act like automatic (local, stack-based) variables.
posted by orthogonality at 12:03 AM on February 16, 2005

C++ was a mistake.

C started as a small language; pretty much a portable assembler. You'll see this quite clearly if you get hold of a copy of Lions' Commentary on Unix.

ANSI C is a bigger, mostly disambiguated portable assembler with bells and whistles. C++ appears to be composed entirely of bells and whistles. There isn't a single idea in C++ that isn't a more comfortable fit in some other language.

ANSI C is worthwhile to learn and not nearly as hard as people would have you believe. K&R is of course the classic reference work which will need to be on your bookshelf if you seek any kind of credibility, but for my money Harbison & Steele is a better book.

You can learn assembler by studying what your C compiler spits out; just don't make the mistake of thinking C compilers emit nice code. I don't know of a single one that does. It's worth studying both optimized and non-optimized compiler output - this gives you a feel for what the machine underneath actually needs to do.

Personally I think it's very valuable to have a reasonable grasp of the assembly code of every machine you can get your hands on, even if you don't actually need to debug device drivers; but I'm the kind of person who thinks Latin is interesting, so YMMV.

I reckon you can start calling yourself a programmer when you understand why it is objectively justifiable, and not merely a matter of religion, to take the position that the Power PC archtecture craps all over that of the 86 family. Hint: i686 is to processors as C++ is to languages.

Above all: enjoy the journey!
posted by flabdablet at 5:44 AM on February 17, 2005

Response by poster: flabdablet, I already 'know' C. In my OP, the mention is sandwiched between BASIC and Matlab, so I guess people tend to miss it. A few years back, I did manage to work through K&R. Like I say in the OP, I already know the mechanics and syntax of the classical languages (C, BASIC, LISP/Scheme). I just don't know how to code real-world projects. I'm in the process of correcting that.
posted by daksya at 2:44 PM on February 18, 2005

Which language to pick, while somewhat important, is not that big of a choice to make. You'll find that concepts learned from studying one object-oriented language will be easily applied to others.

Language choice matters. PHP is an nice templating language that has expanded to include some aspects of OOP, but at root is is a crufty procedural language.

With PHP, you will find it easy to get certain things done, while acquiring poor programming habits along the way.

You will not get the full power of a more deeply OO language, which is not a big deal on small projects, but a major loss on large projects.

You would be far better off going with Ruby. It is arguably easier to learn than PHP, has a far cleaner conceptual model and syntax, and offers all the tools and libs you need to do enterprise-level Web application development.

Your choice of language will, over time, influence how you think and how you solve problems. Ruby makes life easier.
posted by Ayn Marx at 9:57 AM on February 21, 2005

« Older Any suggestions on contacting video game companies...   |   I'm looking for stories on the web. Newer »
This thread is closed to new comments.