Hacker News new | past | comments | ask | show | jobs | submit login
Tell HN: My child's first program
417 points by FactolSarin on Dec 6, 2022 | hide | past | favorite | 136 comments
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



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.


Can we get a link to this scratch, please.


This comment is my spirit animal.


Thanks for making my day!


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.


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.


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...


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.


Mine are: x, xx, xxx, xxxx...


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


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!


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.


Ah, "hudli hudli" stands for "Extraordinarily fast guitar playing" https://www.urbandictionary.com/define.php?term=Hudli - it's only now that I look this up


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 ;-)


In college, usually a few minutes before an assignment was due, I'd frantically Ctrl+F the project for various curse words.


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.


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.



The linked "dog story" is an.. eye opener, too:

https://old.reddit.com/r/cscareerquestions/comments/95dgrx/i...


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?


lol nice find


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.


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.


I lied! It wasn't CVS... It was Visual Source Safe!


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.


>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.


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.


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.


Is the ChatGPT sample code/tutorials much better than the tutorials that can be found on Google?


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?


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.


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.


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


My girl's favourite saying at the moment is "command not found". That's the thing she reads the most, except on the occasion it does something. Walking around the house saying it gave way to answering back to requests with "command not found daddy". What have I unleashed?


She's a keeper. Edit: whoops, I read that as my girlfriend. I will say your daughter has a good dad as this is a sign you spend meaningful time together.


> What have I unleashed?

Command not found.


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


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


The default admin password for a popular educational software that locked down Windows was "changeme". My school did not change the password.


Back in my day you could just rename programs (read: Quake 2) to winword.exe and they would run no problem.


PR review:

- Reformat with `black`; needs space around "="

- Change constants to uppercase, so YOU and FART

- Probably best to use an f-string, e.g. f"{YOU}{FART}"

- Needs tests

Otherwise LGTM


You forgot space between } and {


It depends on whether you want the whitespace or not; if so, the ideal would be to use:

    messages = [YOU, FART]
    print(" ".join(messages)
So that you can add additional messages (manually or programmatically) in the future. Always important to consider extensibility!


"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.


My kid really took to Scratch last year when he was 6. We got a Raspberry Pi 400 and reading the manual he saw a full chapter on Python. Now when I'm working, he'll come by and say "hey! that's Python!"

Conveniently, the [turtle module](https://docs.python.org/3/library/turtle.html) comes built-in and he also got to draw some fun patterns after reading the "Secret Coders" comic book series. It's really fascinating to see him develop his mental models.


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.


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.


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.


.... to be honest, fart humour is pretty universal. This could be a 16 year old kid to be honest :D


My 30 year old ex blue collar worker buddy who took up programming wrote something like this ... but it's too crude for HN.


Rick Sanchez is a great fan of fart humor ("He may have manifested some sort of butt")

https://www.youtube.com/watch?v=dGqYfoO1eqo


He never mentioned how old the child is. Could be 23!


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.


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.


Nice.. I taught 2nd graders and up Computational thinking and python programming for 1.5 years during covid and it was fun and rewarding - this is the repo https://github.com/TheRockStarDBA/CodingForKids


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.


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.


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.


:D, my son tired of changing battery of a computer mouse, added charger circuit and battery of his old toys, ( that’s charging circuit of Bluetooth speaker and that’s old helicopter toy battery )

As 8 year old, I’m proud that he recognised a problem and solved it.

https://www.dropbox.com/s/ivuxfgyv9ehlvdu/View%20recent%20ph...


Would you mind sharing how old is your child?

My son is almost three. I also want to get him into programming.

I am utterly sad that my dad wasted his brain doing manual labor as we grew up in a small city in Poland and he never had the resources to even own a computer.

He would be a good programmer, as I got it from him. He is really good at finding solutions to repetitive tasks and hates to do the same thing twice.


My father was a brickmason. He could lay a completely level row of brick, using no line- and in the time that it would take 3 people to do the same thing. After a long conversation with him about learning and doing things- I realized that he would have been a very good programmer if he had been able to do so.


I well remember the epiphany I felt while learning Logo in elementary school, at the moment I understood what recursion is.

While I have never worked as a professional software developer, computers have been a hobby all my life. I don't think the fact that the language I have mostly written code in in recent years is Emacs Lisp is unrelated to the above moment.


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/


Why not rust? /s

That is sweet. Congrats.


Because this program requires garbage collection :)


#dadjokes #swooosh


hell, get her poop-farting in 6502 assembly and in 10 years she'll be front-paging HN twice a week


Proud you both can be.

Now, with the advent of programming languages supporting full Unicode encoding (e.g. in Swift) since a few years ago, the option of

   Emoji as variable names
should not be forgotten...

(Unfortunately the HN comment system does not support Unicode and justs deleted them from my neat example)


Show her some Scratch programming.

Kids I have taught, love that they can record and play back the sounds with programming blocks.


My daughter was really inspired to explore Scratch by finding all the distinct things she could simultaneously name "poop". I believe she got a variable, list, block, sprite, backdrop, costume, sound, and the project itself. Lots of distinct namespaces there. Very educational.


Had my proud dad moment when I gave my (then 6 year old) son a TI-85 during a covid lockdown and he started playing around with generating random waves and learning for/next after a few months of fiddling.


Editing a game written in BASIC on Amstrad CPC, swapping original author name with mine. Reaching level 9000 of happiness watching my name at the screen. Then playing with C and mode 13h to simulate a an explosion of pixels using for loops. Damn i was 10 and i’ll remember forever.


<3

Farts and poop talk all the time.

There was a post in the past where someone talked about “the function game”. You think of what the function does. The other person gives you “input”, and you give them back “output”, and they try to figure out the internals. Great to play anywhere.

There were plenty of fart and poop functions.


My oldest daughter's first real programming project in school was a Mondrian style art generator. I was so proud of her that I wrapped it up as a CGI and put it on the kids web site. Too bad her excitement for her project was exactly 0% my excitement.


That's excellent! Variable assignment, strings, function calls, and two layers of humor!

I'm interested as to what age she was when she figured this out? I'd think maybe a 10 year old ? But one steeped in tech from the start maybe younger? 8 ?


I just was showing my daughter some basic Python last night as well and she seemed very interested, but didn’t leave my laptop with her lol so crazy to see this on HN today! Let her have fun! Lol cool to read about today!


My first program was drawing an escher stairs using basic. Computer screens had just two colors these days, dark green (background) and light green (foreground). Things were simple and fun these days.


That's not reddit, I wish crap like this be removed from hacker news.


If the community as a whole didn't like lighthearted posts like this, they're be buried. Fortunately, it seems that the rest of HN aren't a bunch of miserable old bastards too. :P


I hate the idea that a community is only on topics. Humans are wholesome things. A certain percentage off-topic is cool.


I'd like to see what instruction could let ChatGPT output such invention.


The thing that got me to learn OO programming (9th grade...probably 1999) was my desire to write a program that contained the line:

> if (ned.isStupid):

and show it to my best friend, Ned, who only knew how to program TI-83 calculators.


I showed many kids in my school how to program the Commodore 64 on display in the local KMart to display obscenities to shoppers:

10 PRINT "Whatever obscene thing comes to mind"

20 GOTO 10

RUN

That's probably the only code many of them ever learned.


I got hooked into programming via Game Maker, and I've heard of similar experiences from a few of my colleagues.

Good fun taking a platformer base and messing with the physics calculations. :)


Very cute!

I've been bragging for a bit about my boy's first proof by induction:

"Hey dada, if seven ate nine, and that means seven ate ten... then there aren't any numbers bigger than eight!"


Accenture will hire her right now! Get after that! I'd be proud too! My first program was merely Hello World and frankly, this is a bit more complex than that.


Here's to many more joyful moments! Congrats!


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.


I wonder if humor plays a role in developing minds the same way play does. It just seems so universal and good-natured in children.


Haha you should print it and frame it. Your daughter has a bright future! And a good dad to boot, kudos to you both!


Having a 7 yo and 4 yo, this completely tracks.

Nice work.


I guess it is true!

All code has a smell...


I thought fart was a reserved word. Or is that coming in 3.12?


Adorable. Save that in case she ever gets married.


That's the moment to memorize for ever. I bet that's one of the scenes you will remember before you die (no offence, just thinking about American Beauty). I would.


Better code than most engineers can muster.


Now have them put it on GitHub ;-)


YES! Great things ahead.


that's fucking hilarious, well done!


this is the content i log on every day for


Aidan was here


She is the One.


wholesome




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: