Monday, March 08, 2021
I’ve been thinking lately about a lesson I saw taught in a martial arts class over a decade ago.
A young student was misbehaving. I knew this kid from field trips and other school activities, and he was doing typical things for him – not paying attention, calling out funny responses from the back row, making faces and showing off, that sort of thing. He was always a little difficult to manage but this particular day he was worse than usual. One of the instructors stopped the class and took the boy aside from the group. He picked up a lightweight rattan sword. They use these for practice – they’re very light, and they are made of several light sticks bundled together. They make a loud clattery noise when they hit, and use up most of the energy doing that, so they don’t hurt. They weigh very little.
The instructor got the student to sit or kneel, and hold his hands out straight in front of him at shoulder height. Then he held out the sword and asked the student to take it with both hands, holding the sword and his arms all parallel to the floor. Simple. You could do the same thing yourself right now with a ruler or a pencil or anything else rigid and lightweight. It’s trivial to hold your arms extended, elbows locked, hands a fixed distance apart (because they’re holding something that doesn’t bend or stretch.) Easy, right? By now everyone was watching to see what the actual punishment was going to be. Would the instructor now hit the student, or demand they do something difficult? (It was common in that class to assign pushups for misbehaviour, and I adopted the habit myself, giving my kids pushups in the grocery store if they were driving me crazy.) But no, the instructor just stepped back and said “just hold that as long as you can.” The kid grinned. Everyone else looked puzzled. It was trivially easy to do.
But if you try this yourself, you’ll soon discover that very quickly it gets harder. It starts to really hurt after just a few minutes. If you’re stubborn and you grit your teeth, you can keep going. This student was very stubborn. After a while though, his arms would occasionally droop down. “Either put it down or keep it up! Shoulder height! Arms straight!” the instructor would call and the student would try again and manage to get back into position. Eventually he was clearly in distress. The instructor told him “you can put it down whenever you want” but it was quite a while before he did. His muscles were clearly very sore.
On that day, the instructor didn’t explicitly close the loop. He seemed content to have found a way to get through to this student that classes were not his to disrupt and there were things the instructors could do that the student didn’t like. But years later, I saw a larger lesson in the choice of that particular exercise. Lifting that light sword (or the pencil or ruler you tried this with) is nothing. It’s really nothing at all. No effort. Anyone can do it. And at first, holding it is nothing also. If you had never lifted a pencil before, and you met someone who was struggling after holding one for many minutes, and you tried lifting a pencil yourself, you would be really puzzled. “Why are you complaining? This is super easy. There’s nothing to it! Anyone can do it!” The student’s misbehaviour was like this. Each little thing – the funny comment, the silly face, doing the move backwards – was in itself nothing. Easy to deal with or ignore. Not a problem. But enough of them add up. Just like the time holding the light weight. It becomes hard. It becomes painful. It becomes unbearable.
I really urge you to try this. How long can you hold the pencil or ruler out before you start to feel an effort? Before it hurts? Before you physically cannot do it any longer? Try predicting these times and then doing it.
The world is full of things that are trivial and nothing if you only experience them once, or once a decade, for a few minutes. It can be nearly impossible to imagine that these trivial things could ever add up to something painful. In 1970 (yes! 50 years ago!) a university professor coined the term microaggression for tiny moments of “you don’t belong” aimed at racial minorities, disabled people, women in male-dominated industries, gay people, and so on. People who haven’t experienced a steady diet of “you don’t belong”, however mild, often literally cannot imagine how it could add up to something painful. Sure, maybe you wince for a moment when someone assumes a group of developers are all male, or all straight, but it’s no big deal, right, and I’m sure the women know that when we say “men” we mean everyone, and the gay people know that when we say “wife” we mean wife, husband, partner, whatever. On its own, one tiny moment of “the only people I have to consider are X” is a little needle for people who aren’t X, but it’s such a tiny needle, who would complain, who would object, there was no nasty intent. Think about holding your arms out for 10 or 15 minutes and then think again about exclusionary language, policies that assume only married people have children, asking people “where are you from”, telling someone “you don’t look like a software developer”, making jokes about people’s weight or appearance, and all those tiny tiny little things that are nothing once, but that truly genuinely add up over time to real pain.
And then ask yourself: if it really doesn’t matter whether you say “men” or “people”, then why is it so important you keep saying “men”? That sounds like it actually does matter after all. If it’s no big deal and of course we all know that there are people who differ from you in some way, why are you not prepared to do the work of talking as though such people exist, instead asking them to do all the work of translating your literal words into what you probably meant, or would have meant if you had thought about it? How can you lessen some of the pain and effort other people have to put in all day, every day, day after day? It will be no big deal to you, right?
Saturday, February 20, 2021
A lot of people say often "if you're comfortable, you're not learning", "the only way to grow is to get out of your comfort zone", "don't expect to enjoy changing yourself" and the like.
And you know what? This is wrong. Sure, sometimes when you're doing a new thing you don't know how to do, it feels weird and scary and you're a little embarrassed and a little lost. But not all learning is like that. Sometimes learning a new thing is joyful and exhilarating and marvelous. Sometimes you have a teacher who is reassuring and supportive, sometimes you're just discovering connections and trying things that work and it's just fantastic. Don't tell those people they're not learning! Learning can be one of the most pleasant and wonderful things we do. I try to live my life that way both while I'm learning and while I'm teaching.
I think it's some sort of leftover Calvinist thing: we're not supposed to like work, we're not supposed to find joy in good things, we're supposed to push ourselves and do them even though they're horrible. Think of sayings like "No pain, no gain", "Feel the burn", or "They call it work for a reason." Sure, some stuff is difficult and you don't really want to do it but you do it anyway because it's important, or you said you would, or someone's paying you, or you know you want the end result of it. But some stuff is fun and joyful and delightful and you do it with happiness and it's still important, still something you said you'd do, you still get paid, and you still get the end result. I remember teaching someone some stretching exercises and they said with complete surprise "I like doing these! I thought exercise was supposed to be horrible!"
How would it change your learning if you let yourself enjoy it? If you let go of the idea that learning only happens in discomfort? If you could feel yourself improving at whatever you're learning and enjoy that?
But that's not the worst of it. Yes, people are missing out on a ton of joy that they could tap by just sitting up and thinking "hey, I really like my work. learning this stuff is super fun. Wow, what a great time I'm having." But on top of that, there are a pile of "teachers" who basically make you feel bad, and if you object they say you're resisting learning. Fitness instructors who literally make the fat people cry while exercising, because "that's the only way they will change what they've been doing." Activists and influencers and everyone who wants to change your opinion starting with upsetting you and keeping you upset. "hey, don't blame me. If you're comfortable, you're not learning." "If you're happy, you're not growing." First, that's not true. And second, it doesn't then follow that if you make me uncomfortable or unhappy I magically grow and learn. You need to focus on teaching, leading, inspiring, educating, showing, demonstrating, and modelling.
Yes, I may feel clumsy as I learn a new technical skill, lost as I try to understand new facts, embarrassed as I realize things I did wrong in the past. When those come as a side effect of learning, I need to embrace them because discomfort can be part of learning and growing. But there isn't some short cut where you tell me I'm horrible, say things to upset me, and claim that upsetting me is proof you're a great teacher. It's not. There is no need for you to actively try to put me in a bad place. Sure, I may need to be ok with feeling bad as part of learning. But yelling at me, telling me I am not good enough, speaking roughly to me -- these aren't teaching skills. They're psychological tricks and I am not ok with them. Perhaps you truly believe it's important to cry in order to learn. Well, you're wrong.
I'm not saying everyone has to centre my happiness to teach me. What I am saying is that some teachers (and I have names) claim they don't care if they upset others, but that's a lie: they do care. Step 1 is to upset the learners. It's their trick to get people to listen, or to let themselves feel important, or to say they have changed a person by making them feel bad. If you meet a teacher like this, whether it's a fitness trainer, a culture improver at your workplace, a twitter influencer, a tech trainer, or a conference speaker, walk away. You can find someone to learn from who won't emotionally manipulate you as part of the process. You can learn in comfort, or in the discomfort that comes from realizing you have a lot to learn; you're not obliged to learn in artificial discomfort imposed by someone who thinks it makes them a better teacher to do that to you.
Wednesday, September 02, 2020
A little while ago, I recorded a chat with Adam Bell for the CoRecursive podcast. My episode is now published, and it's good. There's a transcript, which needs some help (C++ apparently sounds like syphilis to machine transcription), but will give you an idea of the topics we covered so you can decide to listen. It's definitely a conversation to listen to, with tone of voice and laughter and such being more important than in say, how to write generic lambdas or some other technical topic.
We basically elaborated on the 5 tips I covered in a lightning talk at Meeting C++ 2017, while I was still receiving treatment but knew that it was working and I wasn't dying after all. So the focus is on how to do your work and manage your time more than on anything specifically C++-related. We also talked a little about #include <C++> and the culture of this industry, and what I (with some friends) am trying to do about that.
Take a listen, and I hope you enjoy it.
Thursday, August 06, 2020
At the start of the lockdown, Pluralsight made its huge curriculum free to help those who were suddenly needing new skills to find a new job during the pandemic. I saw a huge number of views of my C++ course for those who don't already know how to program. It was ironic, because I was busy updating that course, a process that is finally complete.
Please check it out on Pluralsight. The new course is called Learn to Program with C++. (The similar-but-not-the-same Learn How to Program with C++ is the old one.) Here's what I did to the 6+ year old course:
- redid all the demos in the latest compilers (Visual Studio Community Edition on Windows; Clang on Ubuntu and Mac)
- added more Ubuntu and Mac versions of demos and tested EVERYTHING on all the compilers
- moved content to slides and then just demonstrated it in the demo, instead of trying to explain concepts during long demos where there's no typing or other "demo" action
- took a more "modern C++" approach wherever I could
- improved the names in my sample code, trying not to have a,b,c and the like if I could
- added some explanation of "make" and removed rather a lot of "how to get Visual Studio to be nicer" because it does that itself now
Plus I just generally tweaked samples, slides, and demos throughout the whole course based on comments I've had from new learners since the original publication. It's a better course.
People often say that C++ cannot possibly be taught as a first language, but that's wrong. Modern C++ is not that hard. This course is a little over 5 hours long and covers most of the syntax and punctuation you need, functions, classes, type safety, using templates from the STL like vector and string, and even touches on const and RAII. If you want to learn C++ for whatever reason, don't let someone else tell you that you must go and learn some "scratch" or starter language first before coming back to what you really want to learn.
If you already know one programming language, and concepts like "if" or "loop" then you don't need this course. C++ Fundamentals Including C++ 17 is for you. It covers even more syntax, punctuation, library, and design aspects of the library.
As always, if you don't have a Pluralsight subscription, you can get a ten day trial by clicking the big white square on the blue sidebar of this blog. Enjoy!
Tuesday, June 09, 2020
This year is very strange, but conferences are still happening. And they aren't all free, either. Perhaps there's a conference you'd like to go to, and being online makes it almost feasible for you, but you can't afford the conference fee? If you're a member of an under-represented group in C++, you might win a scholarship to C++ on Sea
in July or CppEurope
in just two weeks. (I'm speaking at C++ on Sea, so if you win, you'll hear my talk.) The scholarships are arranged by #include <C++>
and the application process
is pretty easy. Please let us know a little about your background: perhaps you're part of a gender minority, a racial minority, or in some way you feel that there are less people like you in C++ than there are in the world. If you work somewhere that pays to send you to conferences, this isn't the program for you: this is for people who maybe aren't working, or who are working somewhere that sends other team members to conferences, but not you. Your application should show us that, so we can decide to send you.
More details, including a list of conferences we've sent applicants to in the past, and testimonials from recipients, are on the scholarship page
Want to contribute? We're ok for these two conferences. But when face to face conferences start again, we'll be raising money for admissions, plane tickets, hotel rooms, and all the other costs that keep people away from the life changing and career changing benefits of conferences. Remember our site for when that is necessary.
Thursday, May 28, 2020
Lately a lot of people have been asking me for help as they write C++ code. I’m usually happy and able to help. There are times, though, when I either cannot help, or choose not to help. I thought it might be helpful to explain some of these a little. It’s quite likely that other members of the community have a similar set of guidelines in their heads for when they do and don’t help people with code.
Warning: this is long. I think it's worth reading it all. You want a TL;DR? It’s this: if you want free mentoring and consulting from successful people, you can have it! All you need to do is ask. But if you expect your helpers to do most of the work in helping you, and to take instruction and direction from you, you’re going to get a lot less help than if you know how to be helped effectively.
The first choice is where and how you ask. People often email me, message me on LinkedIn, DM me on Twitter, DM me on the #include <C++> Discord, and so on hoping to get personalized, instant, one-on-one help from me. That’s not a good use of my time. I prefer to help in places where others will see the question and the answer. That helps more people. It also enables more people to help – so it produces better advice as well as helping those people learn and grow. Often, I learn from the times when other people chime in. So I encourage you to post on StackOverflow (if you have the sort of just-one-question, just-one-right-answer problem that fits there), or on the #include <C++> Discord, or some other public place where a number of people can see the question and the answer over time.
The rest of the issues have to do with how much work the person expects me to do, or how much they save me. Think about how you ask the very first thing you ask. Compare “here is a zip of all the files in my project can you tell me what’s wrong with it?” to “here is a link to an online compiler (Godbolt, wandbox, etc) showing a compiler error on line 43 that I don’t understand. Can you tell me how to fix that error?” Expecting someone to install things, trawl through multiple files, guess your question, and then solve your problem and explain it all to you is really too much. At least tell people what your problem is! Often people ask for help saying something like “it’s not working” or “what’s wrong with this?” and I don’t even know if it’s a compiler error or a runtime error or running fine but calculating the wrong answer. So before you post on the discord, for example, try to have a single crisp question, not just “help, it’s not working.”
- Show us your code, and your errors. And not as screenshots! You can copy the code into an online compiler like Godbolt or Wandbox, or if it’s less than 20 lines or so, paste it into the chat window – but please learn how to format it as code when you do that. Copy and paste the errors as text. That makes them much easier to read, and lets us copy and paste parts of them while explaining things to you. If you can’t show your real code because of how big it is or because it’s work-related, create a tiny example that shows the same problem and show us that. Stack Overflow has some tips on how to do that. Whatever you do, do not free-type some code into the chat window that you think is the same as your problem, and then whenever people point out missing semi colons or undeclared variables, reply “oh yeah, that’s not really my code it’s just something I typed to give you the general idea.” Compilers (and runtimes) are picky and asking for help with something that’s vaguely like your real code (but not really) is pointless.
Now let’s assume you manage to get a conversation going with someone who is trying to help you. They solved that compiler error, for example, but now you have another one. As part of this process, I often make suggestions to people that they reject. I think they believe the suggestions are to make things easier for themselves in the long run, because they say things like “I can do that once it’s working.” I then have to spend a lot of effort explaining that I want them to do these things so that I can help them get it working. These suggestions include:
- Write good variable (and function) names. If your variables are all called i, n, c, r, s, and so on – I don’t know what they represent. If I ask you to change those to words like next, rate, total, and so on, or to words you think of yourself, that’s because I can’t understand your code (I don’t know the problem you’re trying to solve) without some help. Good names aren’t a someday thing that you paint over working code once it’s all good. They are how you make code other people can read. And you’re asking me to read this code. Make it readable.
- Use a debugger. When I ask “have you looked in the debugger to see the value of a before the loop?” an answer of “I don’t know how to use the debugger and I don’t have time to learn that today” is a great way to end our conversation. Real programmers use the debugger. We don’t have some magical compiler-simulator in our heads that can read code and tell you if it compiles or not, and we don’t have a magical runtime-simulator either. Sure, maybe I can tell at a glance that a is 0 before the loop and that’s why it’s not working, but in that case I would tell you so. It’s more likely that I want you to quickly check and see if it’s 0 or not. When you refuse to debug, you’re making it so much harder to help you. You need to learn to use whatever debugger is available to you, and you will probably save enough time today to make up for the time it takes to learn it.
- Add some tests. You don’t have to go learn a whole unit testing framework. But if you’re writing a function to do whatever, work out by hand what it does for simple values, and write a test harness that passes it those simple values. Then you can debug the test harness and see what the function returns and confirm whether or not it works for simple values. Whether you’re reversing a string in place, calculating the Fibonacci sequence, calculating sums of things, whatever, you should be able to think up simple test cases and test your code with them. And eventually, you should be writing tests as you write your code. It’s a good habit you can build now.
- Break up big things. You don’t have to embrace full OO or write functional programs, but don’t give me 1000 lines of code and ask me to load it into my head. Write some functions. Heck, throw in some comments and some blank lines. Show the structure of your code so it’s not a wall of text.
Some other good behaviours that will take you a long way:
- Try the substitutions people tell you to try. A lot of times, people who are having a hard time don’t want to learn a new thing. I run into that situation all the time myself. I’m already frustrated and I’ve spent longer than I meant to and I can’t understand any of it, I don’t want you to tell me to go learn yet another thing right now. I have gained some wisdom over the years though, and it includes this: sometimes jettisoning all that half-understood not-really-working mess and doing something simpler is the best way forward. If someone tells you that vector would be better here, and offers you a few lines of code to use, just digging in your heels and refusing to try it isn’t going to lead you into learning. If you’ve got a problem because you’re trying to manage memory yourself by hand but you forgot about copying and so on, then using a smart pointer, or dropping the pointers altogether and using an object on the stack, is going to make a whole pile of work just fall away. The person advising you to try this knows how much effort it will save. You don’t, that’s why you came for help. It’s really frustrating to see a beginner insist on doing something the hard way (for no benefit), do it wrong, and refuse to accept any help other than “here is the precise and exact code to do that thing the hard way.” I don’t want to do things the hard way any more: why would I type out all the code for you?
- Try things that don’t matter to you, if the person who is helping you tells you that your code is harder to read the way you have it. Things like initializing member variables in a constructor with the : syntax, not between the braces, or adding some using statements – these may not matter to you, but making things too hard for a busy helper may mean that helper is too busy to help today. Or ever. I don’t want to teach you bad habits, I don’t want to teach you to “pretty things up” only once it’s working, and I don’t want to exhaust myself reading difficult code to spare you the trouble of doing the right thing. Also, when a person asks for advice but never takes any of it because they’re sure it’s not actually relevant to their problem, eventually the advice-giver will stop giving it. It’s pointless.
- Write your own code. If I tell you “the problem is that you’re not initializing x” don’t ask me to edit your code for you or paste in the new version of the function or whatever. You need to understand what you’re doing and that comes from writing the code yourself. If you don’t understand how to fix a problem that someone has told you about, ask them “how do I fix that?” If you can’t understand their answer, say “I don’t know what [whatever] is, can you explain it or show me?” Don’t just ask “what would that line of code look like?” That feels like you’re asking me to even do the typing for you.
- Work with whoever is talking to you. Maybe when you first ask, one person has a couple of thoughts, and those are good, but while you’re changing your code to see if that works, someone else chimes in. That’s great. It’s a group chat. Don’t tell them that you’re working with the first person or anything like that to reject their help. Consider all the suggestions you get. If you’re talking to someone and then they stop, that’s cool too. Many people pop into chat for 5 or 10 minutes waiting for a conference call to start, or while they’re eating lunch, and don’t stay long. People get called away from their keyboards. Don’t start pinging the person trying to bring them back or ask if they have any more thoughts or saying you’re still stuck. You can tell the room or channel as a whole that you’re still stuck. Maybe someone else will have some ideas. Your problem may end up solved over an hour or so with three different people. That’s a win!
I know, that’s a lot of advice. Thing is, you can get a lot of help from strangers on the internet, if you ask the right way. If you ask the wrong way, most people will just shrug and say “looks like you have a problem” and move along. They won’t even tell you why they’re not helping you! To get the marvelous free help, and to truly join the community, you have to put in a little effort. Trust me, it’s worth it!
Wednesday, May 06, 2020
Since late February, when I returned from a personal trip to Singapore, my travel and conference world has been shrinking in around me. Conference after conference has been cancelled (or postponed to next year which is the same thing), moved online, or put off to perhaps later this year. Of course, the rest of my world has also been shrinking: for the last 8 weeks I've left the house only a handful of times, and seen almost no-one. I'm sure it's the same for you. So it was quite a surprise to remember that my last conference wasn't actually that long ago: the video of it has just gone live.
This is a shortened version of Emotional Code for students, who don't all know C++ and don't all have a lot of experience with other people's code. I hope you like it. I've also updated my playlist, which has all the talk recordings I know about. If you're looking for conference substitutes around now, perhaps there's a talk of mine you haven't yet seen? Take a look at it now.
Looking forward to in-person conferences and live audio feedback once again,
Sunday, January 19, 2020
This week I travelled to Montreal to deliver a keynote at CUSEC 2020, the Canadian University Software Engineering Conference. Everything was nicely arranged and I happily took the train from Oshawa to Montreal, then a short all-inside walk to the hotel where I checked in, told the organizers I was there, and settled in for an early night. I got a light dinner from room service but oddly could only eat half of it. Ah well, I thought, they fed us really well on the train, I'm probably just full. No big deal. I went to sleep.
About 10:30 I woke up and realized I needed to throw up. So I did. And did. And did. All night. For an extended part of the night it was every 45 minutes. It was bad. And then it got worse. Now I am not telling you this to gross you out or to overshare, but to get you, as a possible speaker or conference organizer, to consider this possibility if you have not done so before (I had not.) I felt perfectly normal when I left home, and even when I first arrived in town. Whatever food poisoning or virus got me, it hit fast and hard. When the sun finally dragged itself up over the Montreal horizon and into my eyes, I was exhausted, having not slept all night, and pretty sure I was not done throwing up (which it turns out I was not.) I got on Slack with my organizers and told them I could handle being tired but actually vomiting while on stage was a bridge too far for me. Could we switch with someone scheduled for Day 2?
Of course we could. They did that lovely duck trick, where above the water it all looks smooth and simple and you have no idea what amount of paddling and ruddering is happening underwater. Someone else did an opening keynote; my keynote moved to 11 am Day 2. A much needed bottle of ginger ale appeared at my door. I spent the day in bed and slowly returned to normal. I slept that night and did the keynote the next day, and very much enjoyed the rest of the conference. I didn't shake hands with anyone in case I was contagious. When the AV people started touching my laptop I gave them hand sanitizer.
So, if this happened to you, would you be able to come up with a plan B? Do you travel with anti-nausea meds? (I do, for airsickness, and took some to help me sleep during the day since they sedate me. They had no hope of working during the worst of it, but they still had value.) Do you have a little bottle of hand sanitizer with you all the time? (I do, and always will.) Do you know how to reach your organizers with some urgency when you can't leave your room? Organizers, I hope you would all react as smoothly and quickly as my CUSEC hosts did. Ellen and Afreen were ultra professional, as was everyone else I dealt with.
You don't want to think about it, I know. But -- you should, anyway. It doesn't take long to have a disaster recovery plan. Swapping two keynotes was the obvious choice, and it worked because the keynoters were staying for the whole conference not just popping in for their morning. A little prior preparation can predict proper performance, or something like that.
© Copyright 2021 Kate Gregory
Theme design by Bryan Bell
newtelligence dasBlog 2.3.9074.18820
| Page rendered at Thursday, October 21, 2021 5:06:27 PM (Eastern Daylight Time, UTC-04:00)
On this page....
Pluralsight Free Trial