DEV Community

Discussion on: How do you learn a new programming language?

Collapse
 
dwd profile image
Dave Cridland

I have to admit, I've not learned new languages recently - beyond some basic fiddling to alter an existing program. I look them over and get an idea of what I might want to learn them for eventually, and then sigh about not having the time.

But when I used to learn new ones more often, I'd first block out some time. I generally went for 24 hours - a bit arbitrary, but it worked.

Then I'd write a rough webserver. I'd make it handle HTML, images, and a CGI program - which probably dates this technique - and support HTTP/1.1 (which was a bit bleeding edge back then). In those days, there weren't, typically, library functions for HTTP, so this was written from first principles.

This got me a good feel for a few things:

1) Network handling. Often asycnhronous event-driven stuff, but sometimes I'd have to use forking or threading. Usually I'd pick whatever worked best in the language, sometimes I'd deliberately try a few approaches.

2) Text and binary data handling. Some languages I learned couldn't handle binary data very well - the Tcl webserver I wrote suffered from this badly, for example. Others handled text and binary data equivalently (C++, Python2).

3) Parsing. HTTP headers, being RFC 822, are a disaster to parse - which is why mail servers were written to avoid this. HTTP servers, however, can't avoid it. Folding is particularly fun.

4) IPC. That's Inter Process Communication. This is probably less useful now than it was, but handling external programs got me a good feel for how well the language and its environment exposed the platform functionality.

Whatever I needed to find out, I'd go hunting for on the Internet - but it meant I wasn't looking for "How to write Tcl", but "How do I XYZ in Tcl", which meant my research for more focused and goal-driven.

Looking back, while it provided pretty good coverage, it missed several aspects which are really quite interesting to me now, like data storage, for example. I don't know what project I'd pick now that would be any better, either - an XMPP server would be fun, but that's really quite a huge thing.