Will_Newsome comments on (Virtual) Employment Open Thread - Less Wrong

35 Post author: Will_Newsome 23 September 2010 04:25AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (276)

You are viewing a single comment's thread. Show more comments above.

Comment author: Will_Newsome 25 September 2010 08:20:27AM 4 points [-]

Thanks, I'm significantly less confused now, and back end programming now sounds like fun.

Comment author: wedrifid 25 September 2010 08:24:35AM 1 point [-]

It's a lot of fun. Now you're making me whimsical! ;)

Comment author: Will_Newsome 25 September 2010 08:35:48AM *  1 point [-]

Hmuh, this is intimidating. I was gonna pick up some PHP but to actually use it for a project I'll need MySQL and for that I'll need to set up an Apache web server of some kind... which is intimidating, and I'm probably approaching this the wrong way, especially as I'm not sure yet what I'd even be scripting for. Also I feel alienated as a Windows user; I have Ubuntu but it's frickin' annoying sometimes. How do most people get started with this whole hacker thing?

EDIT: Eff it, I'll switch to Linux and play with Django, it seems easiest. Stupid Linux.

Comment author: wedrifid 25 September 2010 09:26:29AM 7 points [-]

There is essentially no reason to bother with PHP these days. It's a relic and you'd end up having to learn all sorts of arbitrary distracting things.

I can empathise with the intimidation. There was a whole heap of linux administration stuff that I had to pick up to get started. Fortunately, you don't need to do anything like that any more and it can be even easier on windows! You can install the whole stack (ie. Ruby, Rails, apache and mysql) all at once. From there you can just find a tutorial to follow then start copy and pasting stuff from similar applications till you have one that does what you want. (You didn't hear 'develop by cut and paste and google' from me! ;))

RubyStack is one option. The one I have used is InstantRails. I think that one is getting out of date (about a year old) but it probably doesn't make any difference for your purposes.

I don't know what the options are for other web development frameworks. I'm sure there is something simple out there for Python somewhere but I just haven't had reason to look into it.

So if you wanted to get started it is easy enough. Depends on your interest.

How do most people get started with this whole hacker thing?

When I have something I want to do I go do it. Sometimes that means learning stuff like programming. Sometimes it means learning pharmacology. That's probably the underlying spirit behind the 'hacker' mindset.

Comment author: Nic_Smith 26 September 2010 05:08:35PM 0 points [-]

There is essentially no reason to bother with PHP these days. It's a relic and you'd end up having to learn all sorts of arbitrary distracting things.

I rather like PHP. Examples of "arbitrary distracting things"?

Comment author: Will_Newsome 25 September 2010 09:32:38AM 0 points [-]

Thanks! Ruby looks good, but I know more Python/Django folk, so it's tempting to leave Windows for a bit. I guess I'll start with the RubyStack and see what I can build. I'm guessing a lot of the basic skills I need are transferable to Django development anyway.

Comment author: wedrifid 25 September 2010 09:38:27AM 0 points [-]

I wonder if there is a "DjangoStack" for windows about someplace. Maybe your friends would know? Not that I'm saying linux is bad, just that you've already got enough stuff to be absorbing without cramming in two languages and frameworks at once. (But you are right, the fundamental concepts are the same.)

Comment author: Will_Newsome 25 September 2010 10:03:56AM *  0 points [-]

I downloaded RubyStack and the install process doesn't do anything; not sure why. It flashes a BitNami logo and then goes blank, but the process is still sitting there in my task manager... maybe it doesn't play nice with 64 bit Windows 7. At any rate BitNami also has a DjangoStack! So I'll try that instead. :/

...and that also didn't work, so it looks like Ubuntu for me, where my problems will be even greater. I hate computers.

Comment author: Morendil 25 September 2010 01:17:54PM *  3 points [-]

So the good news is, you need none of these "stacks". Really. What you're trying to do here is run before you've learned to walk.

Web programming is as simple as writing a program that does

puts "<html>Hello World</html>"

and redirecting the output to "index.html" when you run this from shell. This gets you a dynamic Web site generated from a program that you wrote.

If that's too simple for you, congratulations: you've mastered enough of the fundamentals to get on to the next step. Something like parametrize the Web page to greet you by your name.

You may be protesting at this point that running the program whenever you want to update the Web site wasn't your idea of "Web programming" - you want a Web site that updates on the fly.

Now we're talking about Web frameworks. But still you don't need a "stack", you need to build up an understanding of how Web servers work, and maybe study a few architectures of historical interest:

  • CGI (the way Web programming was done for years, basically a hack to get the "invoke program from command line and redirect output to a Web connection" idea to work on-the-fly)
  • PHP as an Apache module, or what happened when the Web server coders realized the hacks weren't going away anytime soon
  • frameworks like Sinatra, a gentle introduction to Web frameworks in a modern language without excessive baggage

With something like PHP or (if you lean toward Ruby) Sinatra, you're reaching the point of building up arbitrarily complex Web pages in response to HTTP requests, on the fly. At this point you'd better have a solid understanding of how the dance unfolds between Web clients (typically browsers, but not just) and Web servers. What are requests and responses, headers, parameters.

Rewrite your Hello World example in Sinatra. The next exercise is to orchestrate a simple interaction where your Web app displays a form with a text box asking for your name, and a Submit button which takes you to a page greeting you by name. Just this little loop requires you to stay on top of a surprisingly large number of abstractions spanning several layers.

Note that at this point you still don't need a database, knowledge of CSS is superfluous, and client-side scripting very much not even on the agenda. Discussion of design patterns like MVC should be deferred until you have experienced for yourself the issues that these patterns are supposed to solve. (That way, you can judge for yourself to what extent the big frameworks like Rails actually solve the issues. Affective Death Spirals are just as deadly in programming as in the rest of your intellectual development.)

When you feel comfortable with this kind of program (check that by writing a more complex one like a calculator or a tic-tac-toe game), you can move on to one that handles arbitrarily large sets of data. By now if you feel like tackling MySQL, go ahead and do that, but you could also focus on your learning programming (as opposed to learning technology). Get your data from a text file, maybe YAML which is like XML, only much more friendly.

Anyway, that's the kind of learning that works for me: instead of getting in way over my head, I try to cut it down into chunks that I can master one at a time.

Comment author: gwern 26 September 2010 10:10:21PM 0 points [-]

puts "<html>Hello World</html"

This comment inadvertently recalls to my mind Perlis's epigram: 'most people find the concept of programming obvious, and the doing impossible'.

Comment author: Morendil 27 September 2010 05:55:52AM *  0 points [-]

:)

ETA: I remained torn for a while, but I've edited the grandparent to fix the mistake.

Comment author: Will_Newsome 26 September 2010 09:30:39PM 0 points [-]

Get your data from a text file, maybe YAML which is like XML, only much more friendly.

I'm confused, you're talking about data for a tic-tac-toe game, which should be stored in YAML? I got a tad confused because YAML sounds like HAML and I'd just been reading about HAML, then I realized I'd never used XML and didn't even realize what it was for, so I tried to see if it was related to HTML which I've used a lot of, but it looks like it's not, it's just a way to format text files so that programs/scripts can import data from them. HAML on the other hand is a prettier version of ERB which is a way/template to use Ruby to make HTML use variables. So HAML is this thing I shouldn't be using yet because it's complicated and I should be focusing on Sinatra/Ruby whereas YAML I should start using eventually because it's a way to format data for easy interpretation by ruby scripts and the like. Or did you mean YAML should be used for other things? Am I totally off?

Comment author: Morendil 27 September 2010 06:14:41AM 0 points [-]

No, something like tic-tac-toe has a bounded set of data to keep track of, no database or other long-term storage required.

Once you've mastered tic-tac-toe or the like the next kind of Web app you're likely to tackle is one with an unbounded data set: for instance, a list of user accounts, or a list of posts and comments. Data like this should survive shutting down and restarting your server.

The traditional approach is to use MySQL to store this kind of data, but I would advise against getting a premature interest in MySQL, as there's a risk that doing so will warp your thinking. YAML is an alternative for storing such data that would keep you more in the Ruby world.

All four of HTML, XML, YAML and HAML share the two initials ML - they're all "markup languages". It's easy to get confused because the differences between them are minute, in the grand scheme of things, and only relevant to people who care so deeply about what tools they work with that it magnifies the differences.

The one you can't do without is HTML, so it makes sense to use only that for a little while. (Actually in the past few years HTML has been redefined as a dialect of XML, so using it means you'll also be using XML.)

Using HAML makes a lot of sense, but there's also a bias it (and ERB, and every similar templating language) induces that you want to be aware of. When you start using these things you start thinking of your generated Web pages as "documents with Ruby variables".

This is fine for some class of features but it will wreck your design skill if you generalize the approach too eagerly. Some (indeed many) portions of a significant Web app should be thought of as Ruby objects with the ability to output a HTML representation of them. Things like row/column tables; menus; data entry forms; recursively nested structures like LW comment threads; and so on.

Comment author: gwern 27 September 2010 12:24:09AM 0 points [-]

YAML, and pretty much every data serialization method is overkill for Tic-Tac-Toe - you can store a game just as a few integers if you represent the board as a magic square: http://www.reddit.com/r/programming/comments/9904e/interesting_alternative_to_captcha_pic/c0bw41g

Comment author: Will_Newsome 26 September 2010 05:01:30PM *  0 points [-]

I think I'm limited to just playing around with Ruby on Windows for now; my wireless card doesn't work in Linux. And the thing that might work to fix that is in a package that I need the internet to download. I hate Linux so much, it's seriously a horrible operating system. GRUB actually knocked out access to all of my partitions once, meaning I couldn't even get to GRUB and therefore Windows 7; there's no way I would've been able to fix that without SIAI folk. I'm also running it in VMWare and the internet works there but Gems doesn't: the paths are messed up somehow so that gems don't run, and the internet isn't helpful in fixing that. Stupid stupid operating system. No wonder everyone owns a Mac.

Comment author: Morendil 26 September 2010 05:07:30PM 0 points [-]

It helps that Ruby is installed on Macs out of the box :)

Being able to get gems is kind of a big deal in Ruby, but I as I said above you don't need the big guns like Rails yet.

Comment author: arundelo 25 September 2010 12:24:28PM 0 points [-]

Welcome down the rabbit hole!

Comment author: rhollerith_dot_com 25 September 2010 11:40:48AM *  2 points [-]

I am not a web developer, but as a Linux user of 15 years let me explain why it might not be as bad as you think.

Get any old computer and put Linux, Apache, MySQL on it. (Those softwares require very little in the way of hardware resources unless you are serving 100s or simultaneous users.) Network the Linux machine with your Windows machine. Even better if your Windows machine has enough memory, run Linux on a virtual machine on Windows. I do not know what the cool kids are using these days in the way of virtualization software, but VMWare would work.

Use a web browser on Windows to test your web app of course.

Editing of text files (mostly config file for Apache, etc) on the Linux box or Linux virtual machine can probably be done using whatever text editor you already use on Windows though I do not know the details of how to set that up in any editor other than Emacs. (For Emacs I would probably use the FTP protocol. The SMB and NFS protocols are alternatives.)

True, you will probably need to interact with a shell on the Linux box or the Linux virtual machine occasionally (using something like PuTTY on Windows), but this way saves you the trouble of having to learn anything about Linux's graphical user interfaces. The good thing about the shell is that it lends itself very well to textual tutorials, with the result that there are 10s of 1000s of blog posts and web pages describing in exact detail how to do stuff in the shell. I would be happy to answer questions by email about the shell, but I do not know about Apache or MySQL.

This way of working with Linux -- by establishing connections to it with browsers, text editors, FTP clients and ssh clients like PuTTY on Windows is very common.

Everything I have described is the worst-case scenario. You can probably either install Apache, MySQL, etc on Windows like wedrifid says or avail yourself of some online service that will host the software for you and allow you to configure and administer it using a web interface.