3 ms·
I would argue that whitespace provides a visual cue to code organization that could prove critical to children learning to program. To provide an (adult) examp
by jnbiche 15y ago
I would argue that whitespace provides a visual cue to code organization that could prove critical to children learning to program. To provide an (adult) example of what a little whitespace and DRY can bring about, I'll describe my struggles to learn to program fluently. From 1998 until 2010, I did web design on and off, even working as a professional web designer for a few years. Although I was good at HTML, CSS, and design, I came from a non-CS background and struggled to learn Javascript beyond simple cutting and pasting of scripts and a little jquery. I eventually learned enough PHP to begin considering myself a programmer (yes, cue the laughter), but it wasn't until I started to learn Python a few years ago that I experienced a breakthrough.
Now I'm fluent in Python. After I was comfortable with Python, I went back to Javascript, via Coffeescript initially, and with the background Python provided, was able to grasp the fundamentals of Javascript to the point where I can now actually create full programs in JS. Since then, I've been able to pick up some C and am making excellent progress with Haskell. I attribute this programming epiphany to Python, and particularly to the visual cues that whitespace provides (along with "explicit is better than implicit"). Whitespace not only provides key visual cues to code structure, it also forces you to organize your code coherently before you can run it.
I've not learned Ruby, but I like what I've seen of it a lot. I'd love to have the opportunity to use it one day. However, I firmly believe that for some people at least -- including children learning to program -- semantic whitespace provides critical visual and organizational pedagogical support. For that reason, I think that Python, or even Coffeescript, would be a better first language for child (and adult) learners.
- ddagradi 15y agoI've definitely gone back and forth with that, and felt the exact same way when I learned Python. And I agree - semantic whitespace is a really great feature that makes Python simpler in a lot of ways. Where I start to like it less is when I think about how much structure it imposes on the code before you can even write a line - it has the potential to remove some degree of experimentation. And how easy, for a new user, it could be to get it just wrong enough to be problematic. Don't count me as a hater though. I would love to write Ruby with semantic whitespace - HAML already gets me halfway there!