I learned by modifying existing modifications. I would want a mod to do X, but found a mod that did Y and learned how to do the little changes to get it to do what I wanted. I also learned by looking at the simple mods that just did one little thing and looked to see what plugins were needed. I still never code anything complicated, but by learning how to tweak existing mods and seeing how simple mods worked, I am now able to write some of my own modifications.
I did know some of the basics of programming before though. However, the programming I knew were basic, fortran, and pascal.