Tell HN: My child's first program

417 points by FactolSarin ↗ HN
Last night, I introduced my kid to programming. We'd done some stuff with Mindstorms before, but she never really caught the bug for it. But for some reason, last night when I showed her some simple Python scripting to solve math problems and write to the console, she was enthralled.

After guiding her through a few things, she took the laptop off for a while and then came back with her first program, giggling like a maniac

    you='WOW!!!'
    fart='So many poops!'
    print(you,fart)
I'm pretty proud :D

138 comments

[ 5.3 ms ] story [ 255 ms ] thread
Why not rust? /s

That is sweet. Congrats.

Because this program requires garbage collection :)
hell, get her poop-farting in 6502 assembly and in 10 years she'll be front-paging HN twice a week
Having a 7 yo and 4 yo, this completely tracks.

Nice work.

I'd like to see what instruction could let ChatGPT output such invention.
no tests, no ci, no dockerization, no deploy on the cloud

NO HIRE for me

Counterpoint: Good variable names, concise and readable. Really conveys that you fart, I don't think I could escape knowing that having read this. Shows initiative - she did this on her own.

I think we could bring her on as a junior.

"One of us! One of us!"

Congrats! What a fun and delightful thing. Props to you, and here's to many more enjoyable programs. Thanks for bringing a little humor to my day.

Here's to many more joyful moments! Congrats!
Show her how to loop through the print statement and she’ll be hooked forever!
I suspect some major portion of computer programmers discovered loops via

   10 PRINT "FARTS"
   20 GOTO 10
Hah, I think one of my first computer programs I wrote on my own looked something like this:

    while (true) {
        cout << "Fuck!";
    }
Every Commodore 64 in every department store that I went to was running that loop (but with "Hello") after I left.
I got thrown out of Currys (UK electrical store) aged 11 for doing that with

10 PRINT “Welcome to Currys the electrical ripoff store”

20 GOTO 10

The key was learning how to add a delay at the beginning and then the bell character in the message.
I did this probably too many times in Radio Shacks as a kid, using a word with one less letter (along with a space to generate a nice diagonal pattern on the screen).
Yep, pretty close to my first program on an original TRS-80.
So. I made a deal with my kids that they could have a phone if they made an app. There's enough youtube tutorials and they're old enough to follow them. I could have helped them more over the summer, but we didn't get it done.

Now ChatGPT will generate the flutter code for an app in seconds, as well as guide you with 'show me how to install flutter'. It's crazy that all the code is written for you. I tried one of their timer/todo list ideas and it generated the code, I just need to install flutter and run it today. So a summer long project of learning to code has been reduced to copy-paste instructions from an AI chat bot. Crazy times.

Is the ChatGPT sample code/tutorials much better than the tutorials that can be found on Google?
Sounds like copying from GitHub with extra steps
It's more like having an assistant who can do it for you so you need no/little knowledge of GitHub.
Less steps as the code it generates will do what you ask of it, or be modified based on your english language changes.

It also gives you a human readable section, in addition to the code, that tells you what the code is doing, and where exactly to copy/paste it to make it run.

Give me an app in flutter that does X How do I install flutter How do I run my first flutter app

That only requires typing and reading for exactly the results you want.

Github only gives you what you know already. ChatGPT only gives you what you asked for, and holds your hand for how to use it.

Create me a flutter app that has a list of todo items. Each item has a timer. The list shows one item at the top and when it's timer finishes the next one in the list moves to the top.

That prompt, or something like it, generated Futter code along with the instructions of how to modify a default flutter app for the code to work.

I haven't ran the code yet, but all the other code samples I asked for worked.

Asking for a ruby Student, Teacher application where the student takes multiple courses and the teacher can assign a grade to each course.

After you get that code, you can clarify in your next question.

I want each course to have progress steps.

More generated ruby code..

Can you add a grade for each progress step, and can the teacher have the ability to unlock the next progress steps.

Generates more code.

Then.

Generate me a react front end for this.

Generates React code.

I didn't install/run the code, but it looked accurate and had comments explaining what the lines of code did.

----

GitHub code works, ChatGPT code works, and does exactly what you want, and you can modify it just by asking.

"Change the progress array to be an object that has a grade, started date, finished date and parent acknowledgement."

That actually works as an example after the bot generated the initial app.

We're in for a world of changes.

That is what though, 2 hours of coding for an experienced dev? And the trade off is you have no context over the code running your product?
2 hours of coding for an experienced dev

Sure, building a table is a two hour job for an experienced wood-worker.

If a grade 7 student can make an app by - Describing what they want it to do - Copy/pasting some code - And running it.

That's a leap forward in my books.

The first barrier to making apps has been the time involved in to learn the syntax, if that's gone in the first days of this app, what's next? Do we teach how to write code anymore, or just to read and understand it?

IME no - but its NLP is much better than any search engine, so it's a lot easier to get a more specific answer/example.

Vs. searching for results on StackOverflow and similar, you'd probably have to combine results on 'how to basic flutter app', 'intro to programming', 'todo list example app [perhaps not in flutter]', and even then it wouldn't be exactly what you wanted if you were looking for specific requirements.

>they could have a phone if they made an app

I think this is a great way to get your kids to have a habit of self-learning. In my opinions, this is the single most important skill a kid can learn.

Every time my little cousins ask me something they want to learn, I go with "Let's search for the answer together" and guide them on how to do basic research. Sometimes I ask them follow-up questions if they find the topic interesting so it gives them a sense of accomplishment. Takes little time and effort but teaches the most valuable skill.

I think it's a great way to ensure that the only motivation your kids have is external. "What's the point of doing X is no one offered me a phone for it"

When I was a kid, I heard that some friends were getting money from parents as a reward for good grades. I always had good grades so I suggested to my mom that I should get money for good grades. She said "No, because then you'll get used to only work hard when I'm offering you money". At the time my take away was just "no money, got it." But now I think it was actually an insightful observation.

Now re-contextualize that as if it were an employer/employee relationship. That's actually a pretty messed up lesson to teach a kid about negotiation and self worth.
But it's not an employer/employee relationship.

It teaches you that you should _also_ consider your own long term goals, as opposed to only chasing the someone else's short term goals. I think it's a great lesson to teach a kid about self-worth.

This seems like someone else imposing their own long term goals onto you because they allegedly know better.

You didn't describe any explanation of why good grades are an important step towards your own long term goals.

I'm not saying that paying for grades is a good way to motivate kids. I'm saying that framing it as "I won't pay you because it'll make you lazy" is a very weird way to teach a kid about long term payoffs.

There is this book "Drive The Surprising Truth About What Motivates Us" which makes the same point, they also cite some studies about this.
Good luck teaching a small kid the concept of self-improvement as an investment into the future. You have to reward kids to create habits. They don't have the experience or the knowledge to think far ahead. The best way to reinforce a behavior is immediate reward, not a promise of "better future". The reward can be something as simple as "a sense of accomplishment" or as big as a phone as long as the perceived value of the reward is proportional to the achievement and effort.
What's the license, are you allowed to distribute? Anyway, we already started using this in production, we expect some free support. /s
shit man what if github copilot picks up on this
YES! Great things ahead.
.... to be honest, fart humour is pretty universal. This could be a 16 year old kid to be honest :D
He never mentioned how old the child is. Could be 23!
My 30 year old ex blue collar worker buddy who took up programming wrote something like this ... but it's too crude for HN.
Adorable. Interesting that mindstorms didn’t take while Python did.

I’d kind of assume the opposite, since MS is more tangible and easier to visualize.

IMO Mindstorms is a bit more of an all-in proposition; you have to build a thing that does a thing, and then build a "complete" program for it.

I never really got into Mindstorms either, I remember I would build a thing, then use the pre-loaded programs to run stuff, but then because I was starting from zero and didn't really have an understanding of what was going on, I wasn't able to really fiddle around very much.

With Python, it's easy to get something from very little- as is seen here from OP.

That was my experience with it, too. The feedback time is just too long for autodidactic play. Leetcode style stuff and hacking stuff together in Python? Fantastic.

That said, I did get really into Mindstorms when I went to summer camp that split the days between that in the morning and 3D modeling in the afternoons. Once the time was more structured, the feedback loop of "modify working code on a working robot and see what happens" was very fulfilling.

Hilarious! After a few of those, I taught my son how to open the javascript console and "hack" his favorite cookie clicker. He was so excited to show his friends but the school-provided chromebooks are really locked down.

I was disappointed, thinking that would be the end of it, but his whole class has been trying to find ways around the blocks and filters ever since. They've found some clever workarounds and a lot of things that sort of look like hacks but are not. It's adorable.

Poorly implemented device lockdowns by my school were the start of my interest in understanding and manipulating systems, long may they last!
Yuuup. My favorite instance in I think 9th grade was opening the computer case while the teacher was out so I could pop out the CMOS battery to disable the BIOS password, boot a live disk without the disk protection software (Deep Freeze), edit the Win95 boot logo screen[1] to put a little smiley face in the corner, and then put it all back together (sans BIOS password, since I never knew what it was originally!). No one ever mentioned it, but I'd see my little smiley every time that PC booted. Later, I spent 13 years working in reverse-engeering-related software :)

[1] https://www.dslreports.com/faq/3880

The default admin password for a popular educational software that locked down Windows was "changeme". My school did not change the password.
its excellent! my school only let us modify files in our user network folder, and locked down anything on the C: drive. Turns out, if you could open cmd (you weren't allowed directly, but you could ask a vba script from excel to open one) you could just rename the C: drive to the K: drive or whatever, and that wasn't blocked lol. I'd use it to hide games like https://wz2100.net/ on particular computers, and show my mates which ones were on which computers, and make little excel files that had macros to open them
Back in my day you could just rename programs (read: Quake 2) to winword.exe and they would run no problem.
I started programming as an autodidact in fourth grade, creating programs on an Amstrad with BASIC language, reading the instruction manual (I didn't speak English). I remember the joy when I had the idea that it was possible to add a variable to itself to increase a number A = A + 1 instead of having to use multiple variables and that testing it worked. I felt like a genius.
This is more sophisticated than my first line of code, but maybe reflects some universal underlying truth about how all of humanity is connected.

We kids finally got parents to buy a computer. They brought home a TI 99/4A, plugged it into the TV, kids all gathered around, got to the TI Basic prompt, everyone's full attention, but we didn't know what to do.

Someone typed something, got an error message, and a few more things.

One of us asked whether what we type "goes into the memory of the computer", wide-eyed fascinated.

Then we proceeded to type juvenile naughty things into this memory of the computer, which is the greatest thing.

I love the variable names. I definitely had the same naming conventions as a kid :)

Funny story. Sophomore year at college, I worked at a dev shop, and I was the first person to set up version control there (CVS... it was like year 2000.) The next day I reviewed changes that were merged and variables $tit and $ass were all over the place.

I assumed the guy who checked it in was just immature and met w him to "professionalize" him. But turns out these variables referred to Titles and Assignments (it was staffing software). LOL!

As a kid? When writing stupid scripts, I frequently use `fart` as a variable name to this day.

I'm a staunch supporter of naming variables intentionally in software that lives, but I'm definitely not above doing a `fart=True; while fart: ...` in temporary repl work.

Maybe I'm just eternally 10 years old, haha.

Heck, when I write throwaway scripts most of my variables are different slang terms for feces. Sure, I use foo, bar, baz, bing sometimes too. But I never grew up either. At some point I decided that was a Good Thing, and I have no further plans to mature.
I must be old-fashioned! My variable names in throwaway programs tend to be x, y, and z and my iteration variables tend to be i, j, and k.
(comment deleted)
Same (did you start learning programming with C?). i++ is pretty much hardcoded into my brain.
Everyone doesn't use i,j,k for counting variables?
Yes. At least all decent people.
Huh. I tend to use the first letter of the type, so "s" for a string, "d" for a dictionary, etc. Then "s2," "d2," etc. if there are more than one.
When I learned programming the BASIC variant I used only supported two-character variable names. And even where longer names were allowed, the text of the program consumed memory so you could optimize by keeping variable names as short as possible. So I had the habit of using single-letter variables for quite a while. I still use them as loop counters, or in small functions where the scope of the variable is maybe a few lines of code and completely unambiguous. In such cases I think long variable names are distracting.
My foo is "yo" and my bar is "ho"
Mine are just whatever happens to be under the keyboard layout I'm using at the time. If qwerty, then `asdf`, `qwer`, `uiop`, `zxcv` are likely to be temp variable names. But since I've dabbled in other layouts, I've found the names have changed to:

- Dvorak: aoeu, htns, gcrl, mwvz

- Colemak: arst, neio, qwfp

- Mtgap: inea, htsr, dlcw, fvgj

etc...

In college, usually a few minutes before an assignment was due, I'd frantically Ctrl+F the project for various curse words.
Nice. I vividly remember the days, sometimes in the 80s, in some university cellar, hacking away at our green-lit vt terminals connected to some vaxens, that one of the other regulars in the room and I used temp variables _hudli_ and _tralla_ as some kind of ritual.
heck, in MY time, variables could only have 2 (significant) letters, so we were stuck with "hi", "jk", "ah" and things like our initials....

The good thing is that since only 2 letters were significant, the variables "fa", "fart", "fan", "fall" etc. were all treated the same, which could cause some confusion to people not familiar with the intricacies of C64 BASIC ;-)

Are you serious?! That is so hilarious to me, because I do the same thing! And I am always so terrified that I will get an interview, and they will want to see a sample of my code, and I will have forgotten to take out all the bits of juvenile humor that are scattered through the code of my personal projects!
I actually try to not do that now. As they say, programming is the art of naming and I think forcing myself to think about what a variable is (and then using that name) leads to better outcomes.

Agree for throwaway work it may not matter but I try to keep myself disciplined anyway. A good example is say I am doing an advent of code and the temptation is to treat it as throw away code. But the reality is, sometimes I put it down and come back to it, and having variables like fart doesn't really help snap back into the context.

Not saying this is an absolute but I find it a general rule of thumb for myself

In a class where we were writing a parser for math expressions, this was my plausible deniability scenario when I named the functions whose job was to analyze characters. Looking back, I'm sure the teachers were not at all amused.
Surprisingly I did get pulled into a meeting with the CEO and a sales/custcare guy because of a similar issue.

I wrote functions that are available for the users to use (they can customize their own dashboard). Our function conventions are camelCase. The function I wrote was something along the lines of `cumOnMetric` or something like that.

Needless to say some square somewhere thought this was a joke and didn't like it. So there I was, just blinking away and wasn't even aware this was something sensitive. It was funny sure, but I didn't have the idea that it was "unprofessional". I still feel the idea of professionalism is quite a club thing.

But yeah we got our first snake_case function name because of that.

I don't see how the casing matters here? Would `cum_on_metric` somehow be better?
As a kid my dad told me that I could name my variables whatever I wanted. I still remember the confusion on his face when he saw “int iPod” and “string xbox” all over my code.
I lied! It wasn't CVS... It was Visual Source Safe!
I can't imagine anyone accidentally naming their variables $tit and $ass and not realizing it. I expect the guy thought it was funny, and the domain gave him some plausible deniability.
For those with even younger kids (they say ages 5-7), you might enjoy checking out Scratch Jr[1]. Building-block style programming with lots of examples for kids to get started on their own! (No affiliation, I just loved what happened when I gave it to my kid)

[1]: https://www.scratchjr.org/

The first program I ever wrote was in AppleSoft BASIC. It would pick a random location on the screen and print MILK in inverse text at that location. And then GOTO 10. Anyone else remember their first program?
Wasn’t quite my first, but one of the earliest I recall on a TI-99/4A was programming the Jeopardy! theme song with frequencies and durations in CALL SOUND statements.
An AutoIt script that opened the cd tray and popped up a message box with some taunting phrase or another.
My son took a coding class in elementary school (MIT scratch), and he came in one day and told his teacher that his Dad was a "pro programmer" and had helped him. The program was a pigeon farting on a man's head. The teacher asked what Dad had helped with, and he said "he recorded the fart sound".
All programmers have to start somewhere. My first program was an interactive piece of concrete.
Much like the parent's comment, we all need to fart somewhere too
My first was a car (seen from above) driving up the screen, disappearing from the top by printing empty lines below it, and then appearing from the bottom after 24 empty lines.

I thought it was the greatest trick ever. Meanwhile my brother was reimplementing every game he saw, including Tetris and some early Mario game.

This comment is my spirit animal.
Can we get a link to this scratch, please.
Thanks for making my day!
I've always said that most kids my age got the programming bug with something like the following:

    10 PRINT "FARTS"
    20 GOTO 10
And it's as good a start as any other. Probably better since it drives home the idea that the computer follows your orders, even to the point of breaking taboos.

There was an intro to computers book from the 80s that was written entirely this way. Its first example Pascal program concatenated the strings FAR, TIN, and G, yielding FARTING. When they wanted to introduce machine language and assembly language, they invented a pretend instruction set and an assembler for it, calling it the Simple, Excellent for You Assembler, or SEXY ASS.

Now to suck the joy out of it for her by giving her a code review and a lecture about I18N :)

I like that the code itself is almost poetic, and is in itself a statement about the problem domain. Knuth would be proud.

Hedy https://www.hedycode.com/ has worked very well with my kids. It starts as an extremely simple language, minimizing friction, provides good examples and exercises, and gradually adds more and more to the language. Finally, it tells you that with just a couple minor changes, you have now learned Python.
Better code than most engineers can muster.