April 8, 2008

How to learn a programming language

Filed under: programming, python — Tags: , , — Bart @ 2:15 pm

LEARN JAVA IN 24 HOURS!!! Sadly, it won’t be this fast but there are some ways you can speed up the process of learning a programming language.

Just like with anything, learning something new is best done when it’s not crammed, you interact, and you basically dwelve yourself into it. Without further ado, here are 3 ways you can promote the speed and depth of your learning. For my post, I will be using Python as an example as it was my most recent learning.

Read. Read. Read

Do you like reading books? Well that’s great, because for the next while you’re going to be reading about list comprehensions, variable casting, and data control and not about wizards and dragons. Reading online documentation is great, but sometime it just doesn’t do it. I LOVE getting a well written book on a language/system and getting into it. Reading “Python in a Nutshell” was a great experience because the book was well written and I was able to learn a lot. Plus I now have a bookmarked and tagged (old school sticky note tagging!) book for reference. It is of course important, to find the right book or it may become a mind numbing experience.

Get Involved.

Python has an IRC channel, Google news group, and much more. In these, you and others are free to ask and answer questions. One of the best ways I’ve found to learn was to sit in these channels and simply watch as the questions and answers come in. Sometimes I will have my own, and sometimes as I become more informed in the language I too can answer my own questions. It is a great feeling to go from being a totally novice to answering a question for someone, and I find it to be one of my greatest motivators to keep pushing and learning.

irc.freenode.net is a great IRC network filled with various channels for open source platforms and projects. Google Groups is also a great reference and has groups for nearly everything. You are also very likely to find Googlers and the guys who are part of the core on their posting :)

Just code already!

Reading is nice and all, but it makes me feel like a university student sitting in a lecture. Every time you have gained new knowledge of something, apply it! Write a small app, or extend your current one with your new findings. A good example of this is I learned Python list comprehensions and I was able to modify a lot of my code to make it more readable and smaller.

There is no point in learning a new language and then not updating your application(s) with your new findings, it may seem like more work, to have to re-write things now and then, but it allows you to look back at your code, make it cleaner, faster, find oddities that you didn’t notice before, and ship a better product in the end.

And that about wraps it up. Most of it this is common knowledge, but sometimes it needs to be drilled into your head. Hopefully it has helped!

February 16, 2008

Weekend Stuff: How I code, some Python resources, food.

Filed under: programming — Tags: , , , — Bart @ 3:33 pm

It’s the weekend. I’m sitting here at work about to get ready to finish a project I’ve been working on for a few hours each day this week and I figured I’d just put a few of my thoughts together in a post.

 How I code …

Everyone seems to have a different way of doing things when they code. Some like it in absolute peace and quiet, others need distraction, some can’t code without tons of planning, some just go at it.

For myself, I need music, a good cup of tea, and no other distractions. My biggest problem when it comes to coding is if I am not in the groove for it, for whatever reason it’s very hard for me to get into it, but it’s still possible.

Setting the mood is very important for me (and others!). I like to brew up a big pot of green tea, turn on some quality programming music (see here for a list of my favorites), set the music at the perfect pitch, relax for a bit, and then get going. Additionally, I turn off MSN and any other IM services. All they are is a distraction.

Having a plan is a must. It’s almost impossible to code just on a whim without a basic idea. I have a plan usually, and when I do not have any real documentation laid out I write pseudo code! Pseudo code is basically allowing me to do all the coding logic without the syntax. I then mess with the psuedo code until I am happy with the flow, and I can begin coding the real thing. Knowing the syntax is not even half the battle after all :)

Just gotta keep going! One thing I like to do is just get into a flow and do not stop. Next thing I know, 4 hours have passed. It’s perfect because I know I am in the zone and can get things done, and I have my night set up in such a way that I do not need to worry about other obligations and distractions. Even with a girlfriend, she can understand you are busy and give you your time to yourself so it’s not a huge issue.

Python Resources this week

Once again this week saw me playing with Python, albeit not as much as I wanted to. Regardless, here’s some more great blogs I found for Python resources:

  • Pythoneer is not exclusively a Python resource, but has some great posts now and then.
  • Just like the above, Artful Code is not Python exclusive but a great resource for well, Artful code!
  • codekite is a great blog on programming in general. Funny his latest post is also a link to various Python resources
  • Eric Florenzano’s blog, posts tagged as django. I am 99% sure he is a contributor to the Django framework but I can’t be sure

Food: YUM YUM

I’ve got a hankering to make some new and unique food this week. Here are some things on the menu that I hope to post recipes for (with pics perhaps!) this week or so:

  • Mussels! I have only had mussels about twice, both times at a chinese buffet so I’d like to take a shot at them on my own. With some white wine and a great onion/garlic marinate for them, they should turn out great. I will definitely document this when I make them.
  • Bourbon Chicken. This is easily one of my favourite take-out foods ever. Problem is, it’s generally very bad/greasy for you from the fast food places so I am going to attempt to make a healthy alternative at home. Already got some good recipes.
  • Pizza dough. Although I cannot eat pizza at all (yay gluten-free/dairy-free life!) I want to attempt to make a pizza dough I can eat. Once I achieve this, I can make a very simple cheesless pizza.

Well that’s about it. I’m going to probably redesign this blog a bit to fit more into what I’m posting about as my left menu doesn’t really correspond to much anymore. But for now, I really should start working!

February 8, 2008

Why Django and Python just won my heart

Filed under: programming, python — Tags: , , , — Bart @ 9:21 pm

As of yesterday, I completed my first Django app. Django is a high-level Python web framework designed for rapid development and quick deployment. Did it deliver? Oh god yes.

Coming into this project, my Python skill was hurting. I had not written a real Python application in a few months and before that, I never had a solid grasp of Python to begin with.

So why did Django make me so happy? First off, in a weeks time, a few hours here and there throughout the week, I managed to: Create a fully functional website with ability to add new posts (Along with card specials, release schedules), polls, a simple member registration, and of course a fully functional admin panel that made it easy for my client to add content to their site. I did this all, with no knowledge of Django before hand!

Some highlights of the Django framework:

  • Installing and configuring Django takes about 15 minutes for a newbie. Download the project from SVN (At this point in its development, this is a good idea), untar it, modify some settings and you’re golden
  • Setting up a project is simple with manage.py, the core of Django’s management capabilities. Setup the project, then setup your first app, and within a minute you are ready to fly.
  • For each application, Django creates a views.py, models.py and urls.py. These three files are the core of your program and it makes it super easy. Define your table and any core functions in models.py for that application (Ie: News Posts app), setup the templates you will pump out in views.py, and urls.py is if you want to get down and dirty with url structures.
  • syncdb and django admin are amazing. I cannot stress this enough. Define your models in models.py, run syncdb and all your tables (including multi-relational ones!), primary keys, etc are ALL CREATED! I love it!
  • Once all your tables are created, login to Django admin and you have full functionality to play with all your data. If you setup a DateTime variable in your model, the admin displays that field with a nice Javascript calendar popup.
  • Python is a sexy language that you will love the more you use it. When I first began playing with Python it was ok, kind of cool, but nothing amazing. The more I learn about Python, the more I love it. I’ve used PHP for years and I honestly can’t bare to look at it after working with Python in the past few months.

There’s a reason why companies like Google and NASA have adopted some of their technologies around Python, because it is code sex. Yes, I like that term.

To try out Django, check out these resources:

  • The official Django project site has a great documentation and beginners tutorial.
  • The B-List has some good code example and tutorials for Python/Django.
  • #django on irc.freenode.net has some great people. Magus- is a total dick, but very helpful ;)
Powered By WordPress