learning how to code is not always easy

“I wrote this letter to myself as a part of an assignment in the Udacity Front-End Web Developer Nanodegree course I’m previewing today…”

Source: Learning how to code is NOT easy

 

cool…”front-end web developer nanodegree.” i have no idea what that is. (ok, i can sort of guess.)

i used to make websites, they were easy. now every site has to have a database (not true, but theyre nice) and they need a javascript library/content engine (not true, but they definitely do wonders for big websites) and you have to use html5, css and a python, php or node.js backend (all optional.)

they can make all of this complex, and industry always will. i think its unfortunate, because the bells and whistles one person will say are necessary is just a bloated pain to someone else. if you teach computer science, you might still have a webpage done in html 3 without css.

but the worst part is, modern education insists that people start in the middle. its not completely crazy; if you can start in the middle, there are certainly rewards. you get to see the “big picture” before you even understand the details. you get started right away on results, before you even know how to achieve them. i mean thats how it is with software these days– people use it, but they still dont know how.

all the same, thats not the only way to learn about computers, and its not how i learned, either. when i started with computers, i only used two programs– a paint program (great for building skills with the mouse, also good for art) and basic. so you would get a little spiral-bound book out:

3baa6eaa515090f55bbee15a97482e4c3

 

and simply follow the instructions. type this:

10 PRINT "hello world!"
20 COLOR 5
30 GOTO 10

 

then you would type “run” and hit enter. it would say hello, world! on the screen, then change the color to purple and say it again, and again, and again, until you hit ctrl-c.

if youre 5 years old and can read, you can do this. it starts out slow, but in a way that can grab your interest for the next 20 years.

ive had lots of hobbies. this one stuck– i kept teaching myself from that point onward until i wrote my own programming language. its not the best or the fastest programming language in the world (thats partly because i chose to implement it in python, and partly because speed or “being best” or fast, wasnt a design goal) but its designed to bring this sort of learning back for everyone.

if youre doing web design, youre already learning 2 or more languages at once. when it was just html, coding for the web was easy! just put little things in less-than/more-than signs < > and add the things you want to say, or links to pictures. a 5-year-old could do it.

more importantly, to someone that doesnt have a long background in coding, they may not realize that all code bears incredible similarities to all other code. on the surface, they can be very different. but the surface is abstract; its different because it was made differently, not because it has to be (or even really is, by the time it gets to the computer.)

im not attacking abstraction– my entire programming language is an abstraction over python, which is an abstraction over c, which is an abstraction over the code that the computer likes. but when you find that “coding is hard,” its hard mostly due to the abstraction making things complicated.

some of these complications make plenty of sense– others are only well-intended. some are even complicated for deliberate and dubious (market-grabbing) reasons.

if you want to become a professional coder, you can start with the easy stuff or you can start in the middle. but the “middle” these days is pretty complex stuff. im not sure why they dont take a little more time with the beginnings, because its not just that the basics are so much easier to learn (and teach.) they also give you a fundamental understanding of all the other stuff youre going to learn in the “middle.”

because all that complex stuff is based directly on the basics. thats a lesson that most of these kids arent getting, which is too bad. theyre learning for an industry first, and education second. theres really nothing wrong with doing it the other way around. it might take a little more time, and it can reach a lot more people without the feeling of “i cant do this, i cant do this.”

even if people knew there was more than one way to learn this stuff– that would help a lot.

why should it matter if coding is accessible to kids or not? #1 reason: by age 10 (on average,) they already identify as “computer people” or “non-computer people.” so many people fall into the latter category, and have a solid belief that they either cant learn, or that it will be painfully difficult. learning can be made difficult, but one of the things that contributes heavily to that is the belief that it will be– if you think learning is going to hurt, its going to be hard to get your attention long enough to prove you wrong.

i wrote fig specifically to get at the people who insist it is difficult. ive shown a handful already that programming can be fun and easy (without being cartoon-based, but based on typing actual code) but while im trying to become a better teacher, im also trying to learn how to “sell” the idea. the program is free, but time is valuable– so you still have to sell to people for the time they will spend.

to every person struggling– dont give up! but you do always have the option of trying more than one thing. coding can be easier, and you can help make it easier. either way someone has to share their passion for it, and that passion has to catch on. a lot of teaching is shared learning, and inspiration– good luck with it.

 

 

find and zip all .py files with bash

Create a Zip folder including all .py files on your computer.

via Find and Zip All .py Files — Data Science for Engineers

 

not to be obtuse, its a good demo of pythons capabilities; but it didnt take very long to figure out this one-liner to do more or less the same:

echo found $(find . -name '*.py' -print0 | 
xargs -0 zip all-python-source-files.zip -@ | wc -l) 'file(s)'

 

 

98-100 followers, and a shared comment on teaching

ive been online since the mid 90s, when the internet was infused with the portion of it called the “web.” before the web and since november 1969, the internet has included technologies like email, ftp, and eventually usenet and gopher (the text-only precursor of the once-text-only hypertext worldwideweb.) and i have met some of the loveliest people online on wordpress– i am not exaggerating– it is one of the better examples of what the web can achieve without facebook. 🙂 and what i was trying to say of course is, thank you!

i wrote a comment to a fellow poster today, in which we talked about quitting smoking, drinking less soda, and eventually having kids. if i write a comment i like that much, i may turn it into a blog post, so here it is:

 

youre going to have awesome kids. i can only offer one bit of advice as a former kid myself–

kids are definitely made in the image of their parents. its always there, people can see it, youll know it better than everyone. and parents raise their kids in the image of themselves, too. its what they know, so its what they do.

kids are trouble, and theyre people that are learning how to be people. learning is a lifelong process, which is frequently forgotten in the moment by students and teachers (all parents are teachers, as well as students) alike.

teachers too, shape minds in their own image. its what they know, and what they do. the advice is: never forget that the image will differ. cherish that– their difference will add new powers and also balance to the things in your image that you instill in them. they will never/can never/should never be exactly you, but they will carry part of you around forever– it will go much farther with their differences, than you could ever go on your own two feet or even just being cloned. remember that as you work to shape them. ❤

 

(regarding 98-100: after almost a year of blogging its fun to reach 100 followers, but i think 2 of those 100 are probably me. i set up another page which im not making much use of right now, and i had it follow this one for convenience.)

 

 

output commands in fig

this is part 3 of an introductory series on fig programming. for part 2, go here.

 

part 3: output commands in fig

 

while input commands get information from a device (or file, or connection, or from some part of the computer,) output commands send information to a device, or file, connection, or to some part of the computer.

obvious output devices are the screen and speakers. sending files to the printer counts as output, although the printer itself also sends information back to the computer, making it an input/output device.

a touchscreen is a separate device than the screen itself and an input device, although the display directly behind it is for output. these are technical distinctions and not always important, but are sometimes relevant to programming.

x  "hello there"  print

 

sets x to a string and sends x to stdout, which generally means the screen (or window.)

x  "hello there"  prints

 

same as the previous line using print, except prints stays on the same line instead of advancing.

x   "text.txt"  open "w"
y   "ok"        fprint x
now x           close

 

you would normally find these used separately.

the first line sets x to a string containing the path and filename of the file to save information to; then it opens the file for writing (the “w”.)

the fprint command writes the value of the main variable to x, which is still holding the filename. in this case, the string “ok” is saved.

the close command will update / save / stop writing to a file that was opened before. it closes whatever file is specified by the main variable. dont close the file until youre done fprinting (each and every line you want to save) to it.

each time you open a file for writing, it starts writing at the beginning. python lets you “append” or add to a file, which could even be added as a feature to fig.

(it doesnt have that feature yet. if it did, you would open “a” for append, instead of “r” for read or “w” for write.)

if you need to, you can already add to a file this way:

  • open to an array using arropen
  • open again using open “w”
  • write the array with the existing information using fprint, before adding to it.

 

writing an array using fprint is possible by using a loop, or by turning the array into a string, using join. both loops and the join command are covered in later chapters.

most languages use a filenumber or handle to track an open file; which is a different thing than a string or a numeric variable. ive always thought that is weird or unfriendly for beginners.

for python coders and the extra curious: fig keeps the handles in a special type of array called a dictionary, with strings as the key to each handle. fig coders dont need to worry about any of that, so long as they make certain to use the same string (contents) to close or fprint that they used to open it.

in other words, if you use the string “../text.htm” with the open command, you will need exactly the string “../text.htm” to read or write or close that
file. it doesnt matter if it’s a constant (written out) or two variables holding the same value, as long as theres a perfect match.

for what its worth, ending the program with end or system (or just letting the program stop normally) is supposed to close all the files that are still open.

x  cls

 

clears (and goes to the top left of) the screen.

x  display

 

the first time this is called, it turns off graphics auto-updating (the default is to update every time you use a graphics command.)

if already called once, display updates the screen with any graphics that were drawn to it. this only affects the graphics windows, not “text-mode” graphics.

textmode

 

forces text-mode graphics– or dont try to display graphics commands in a graphics window; display them using ansi and unicode text codes.

graphics

 

the default mode; open a graphics window when any graphics commands are used. if the graphics window fails (perhaps pygame is not installed) then fig falls back to text-mode graphics.

if textmode was used explicitly, the graphics command turns real graphics back on.

x  line 5 7  10 20  14

 

draws a line from point (5, 7) to point (10, 20) in yellow– where (5, 7) is the 5th dot horizontally and the 7th pixel vertically.

x  pset 5 7 10

 

draws a point at (5, 7) in light green.

x  locate row column

 

move to (row, column) on text screen.

x  colortext 5

 

changes text color to magenta:

0 black         8 grey
1 blue          9 l. blue
2 green         10 l. green
3 cyan          11 l. cyan
4 red           12 l. red
5 magenta       13 pink
6 brown         14 yellow
7 white         15 b. white

 

x highlight 0

 

changes text background to black:

0 black         4 red
1 blue          5 magenta
2 green         6 brown
3 cyan          7 white

 

 

another touchy-feely post for lonely hearts and hopeless romantics

kissing is gross! previous entry was about programming: here.

tr

ive been a romantic all my life– from age 5 to 15 i was simply wild about this girl (also shes half a year older, which is pretty impressive when youre 5.) we never dated or “went out,” but we did hang out together sometimes as kids. her mother was a teacher.

 

we are almost 40 now, but i dont know how old the picture is– maybe shes 30 in it; i know she would get carded if she walked into a bar looking like this.

i wasnt always hopeless, either– depending on your definition of course. my marriage didnt work out, but its only a 50% success rate for everyone else; and i met a woman who was soulmate material until she dumped me a little over a year ago, but we had the better part of 3 years together. fair enough if you say “3 years, and ‘soulmate’?” but we were exceptionally close. i wrote fig while i was with her, and she helped inspire many of the things i now do.

throughout 2016, i was very depressed… i missed my girlfriend, i was (am) in a town where practically everyone was married and doing everything as a couple– an absolute nightmare for a lonely fellow– and i had to make new friends. ive made great ones, which is partly why i havent moved.

i even had a girlfriend briefly– word of advice for passionate romantic types: the people who are quickest to date you are sometimes the quickest to dump you for whatever reason tickles their fancy. we got back together once and broke up again, and that was that.

before i move to the point of this post, a note: the vast majority of my friends (until about 30 or so) were female, and my best man was an older guy i met at a peace vigil. we started hanging out there and when he played guitar at open mic events. these days a good portion of my friends are male, which is great for me– you appreciate men a lot more when you have them as friends.

considering that i lost who i thought was the love of my life– more like a second marriage– only a year or two ago, i really had to find a way for my hope to survive. the following is the system i came up with; i didnt intend it as a system you know, it just sort of came into being as i scrambled to put my life and happiness together again. it will sound convoluted (im sorry for that i guess) and at its most cynical and superficial it will appear to be a rating system for people–

that isnt the point at all, but it may be tempting to look at as one. also i dont encourage developing such a thing; it would make you a more cynical and probably unhappier person, and this has had the opposite effect.

ive spent my life looking for inspiring, intelligent and uplifting people– either to date or befriend, and this is how i do that in a town low on real prospects. i dont like “hooking up” (never did) and i refuse to start using 21st century dating apps like tinder (google dating, seriously? id rather be alone) even though i tried online dating a few times, over a decade ago.

apart from being romantic im also pretty eccentric, as are many of the people im most attracted to. and here is how i did things in survival-mode, in 2016:

it is a list— it wasnt intended to be, but im practical enough to not simply pine away for one person that isnt available or entirely interested. on the one hand, its similar to a list of prospects, but most of the people on it are unrealistic in that regard. a lot of the people on it are, or become friends. some people would find the whole thing creepy– it really shouldnt be, but people that think it is probably wouldnt end up on it in the first place. these are very special people to me.

the list has 3 people on it– unofficially there could be more, and unofficially it isnt only 3 people. its simply too nutty to keep track of more than 3, and keeping track of fewer would somewhat defeat the purpose. note again this isnt a system i devised; its something i noticed i was doing and became conscious of until i realized how it worked. and im totally fine with it. i explain it because perhaps it will help someone (some peculiar person like myself) in some way.

the list looks like a ranking system– its not; i dont have a table or a scorecard, being in the #1 spot isnt “the point” for anyone else, and most people wouldnt want to be in it anyway– its kind of intimate.

who is on this list? the people in my life who are the most inspiring, sweet, intelligent, and in most cases adorable people i know. everyone on the list is human after all, and no one on it is perfect. the “ranking”– its only a ranking system in the most technical and superficial way– has nothing to do with looks, although everyone on it happens to be beautiful; at least i think so.

the person who spent the longest at the top is a friend of mine that quite honestly looks like a latin supermodel, but thats not why shes there. (the person in the second spot reminds me of audrey hepburn, although that is too extraordinary to have much of anything to do with it.)

now to explain what theyre doing there:

these are the people in my life that i most adore– some are crushes, and/or friends, and some began as unlikely (but welcome) prospects for dating– you never know, and shouldnt sell yourself short. all my best relationships began as a long shot, in my opinion. what relationship really begins as a “sure thing” anyway?

for obvious and practical reasons, i try to keep married women off the list. its dangerous and mostly futile to adore a married woman, though most of my friends are both adorable and married. i kept #2 off the list as long as i could, by trying to ignore how much i liked her. except we always have wonderful conversations, it almost always improves my day when we talk to each other, and i found out last year that i was simply in love with her– dont worry, she will move off the list when i meet enough single people that are truly wonderful.

theres nothing wrong with moving off the list– people have gone from crushes to actual friends, once their status was no longer at the top. i find at any given time, i have actually fallen in love with the people who are in the top 2 (this is a discovery, not an intention or purpose of the thing) and the only way to be at the top is to be totally alright with that–

the person who has spent the longest at the top is a dear friend; she knows i truly love her and i know she loves me, because she says so (plus, it shows.) she gives the best hugs in the world, buys me drinks and even got me dinner a couple times, but we never dated and she will absolutely never be my girlfriend. well, thats life.

call me a liar if you like, but the fact that she looks like a supermodel– and thats no exaggeration– is more of an amusing coincidence. i would say which one, but i want to give her a little more anonymity than that. and i really would love her just as much if she were ugly, because she has– truly– the most beautiful soul of any human ive ever met in my life. thats why i love her, and i know i always will.

does that mean i couldnt date someone if i met them tomorrow? absolutely i could! because if i already love you nearly as much as my favorite person, and then on top of that you love me and kiss me and hold me and spend more time with me, youre going to be much more important than this list of friends! someday i will find someone who is my sun, and my moon, and my stars. for the time being, they are 3 separate people who happen to bring the most light into my life.

#2 snuck onto the list while i was trying to keep her off it (by trying to ignore that i liked her so much) as shes married. i dont know her husband and i have no ill intentions, yet she moved up as high as she could go– you cant be at the top unless you know and are ok with the fact that i adore you– and i dont want any married person at the top. in late 2016 she was my second-favorite person on earth– i saw her today, and every time i see her i fall in love again– im only human.

#3 can just be a person with the third-nicest personality i know. if i go somewhere and theyre there, it usually makes my day nicer. i might have a crush on them and they might know it– im pretty obvious anyway.

if they know or i want them to, i simply tell them “you know, youre one of my three favorite people in the entire world.” no one has taken insult to this yet!

all of this is largely a 2016 thing– i had no resolutions but im determined to distance myself from #2 because i still dont want her on the list at all. if youre married, im trying to meet someone that moves up to replace you as soon as possible– of course i will always think youre great, i just dont want you to be one of my 2 favorite people on the whole planet.

the list changed throughout the year– it included people that i might have ended up dating and included people i actually went places with, as friends.

until a real prospect comes along, dont knock the list– today, i was talking to one of my best friends, who ive known for more than a year. i never was in love with her, and thats only because i dedicated myself to getting distracted from any feelings i might develop. i said the other day, “you know if i hadnt tried really hard all year, i wouldve fallen in love with you.” she already knew this, but id never said it and she took the compliment just fine. shes married and her husband and i get along fine, and i keep her up to speed with whomever i admire.

“i dunno,” she says with regards to my latest interest, in another conversation entirely: “you were in love with b._____ and then you were in love with r.______ and now you tell me youre in love with this person you met this week.”

“im still in love with b._____!” i said. “i will always love b._____ but shes been with the same guy for 8 years, and thats practically married!” like i said before, i dont bother pining for someone that will never be available. as a coincidence, b._____ and my friend im talking to about her were/are friends for many years now.

the second time b._____ and i met, she was leaving town and asked if i wanted to come along. we went to a museum and various shops, searched for an unmarked grave of an ancestor of hers, and had fish and chips in a restaurant near the coast. “this would be a nice date, if it were one.” “yeah, it would!” she replied. we always have a nice time together.

so after my friend and i finish talking about b._____ i walk outside, and (none of what ive told you is either fiction, or exaggerated– but you dont have to believe it) b.______ pulls up. she always does that, when i havent seen her in weeks or even months– she doesnt live in town. i laugh. she smiles. she asks me if i want to get in the car, and we go to run errands; she says shes hungry– do i want to go to ______?”

“oh, anywhere but _____ or _____” i reply. “how about [a local bar that doesnt have much for food anyway]?” she offers instead– “sure!” weve been before and i love the place even twice as much with her for company.

we catch up on the beginning of 2017, and i tell her everything ive been up to. “are you still working on [fig]?” she asks me. “sometimes– that woman/friend i told you about [the one at the top of the list] even helped me come up with another version of it.”

why talk about all this now, anyway? well b._____ says, “you have to write a book about these encounters you have with women!” i dunno about that, but the thing about my favorite person in the entire world is, shes going to move again– shes not from the usa, and she isnt staying here forever. her last visa will expire, and (anything is possible) we will probably never meet again.

well ive loved her since the day we met, and she knows that. we didnt get together for christmas, we didnt get together for new years, and i met her the other day and we hung out for hours. the last time we did this, was one of the best days of my life.

“im going back to ______” she tells me as we stand outside in the snow (she smokes, but i never have.) “why dont you kiss me then?” i tell her. she never has, and i never presumed she would.

“i can only do a little one, like this” and she gives the air a little smooch. “i’ll take it.” she gives me a little kiss on the lips.

we talk about a few other things i wont repeat here. none of it is super-private or anything to worry about– its not some dramatic news about an illness or how shes entering a convent when she gets home– still i tell her “in that case, you should give me a real kiss.” …she did.

anyway, i kissed the woman of my dreams– it was everything i ever hoped it would be. by this time next year, she will be long gone and one of my lifes happiest memories. i promise you, im fine with that; i couldnt ask her for more.

someday i will find someone who is my sun, and my moon, and my stars; but the other night, i kissed the sun.

to heck with 2016, naturally. 2017 (finally) started with a handful of small miracles, and all that really matters in life… is pretty amazing stuff.

❤️

 

  • photo is under copyright, all rights reserved (id change that if i could.)

input commands in fig

this is part 2 of an introductory series on fig programming. for part 1, go here. for the next part, go here.

 

part 2: input commands in fig

 

some functionality is  a matter of both input and output; in fig, functions can usually be separated into or at least categorized as one or the other.

the previous chapter mentioned arrshell, which can almost be categorized as an input command because it takes all the output of a command line shell and puts it into a variable. even if the shell session does other things, the purpose of arrshell is to collect and store information in the program itself and get it back into your fig program.

usually, the word “input” is used to describe commands that take information from a device connected to the computer– such as a drive, keyboard, or even another computer. there are some gray areas, because the computer treats some of the things it does with software as if those things were physical devices.

open is categorized simply as a function, because whether it opens a file on a drive for input or output depends on the value of a parameter. it acts as an input command when a file is opened for reading, and an output command when it opens for writing. you could refer to open as an “input/output” command, but in fig any command that isnt related to specifically to variables, input, output, math, loops or conditionals is simply lumped under “functions.”

now that weve distinguished between what really is and sort of is an input command, lets talk about the ones that are quite clearly related to input:

x  timer

 

sets x to the number of seconds past midnight. it gets the value using the computers internal clock.

x  arrstdin

 

sets x to an array of all the information streamed into the program from whatever shell called it. this can be used to “chain programs together” including programs written in other languages or by other people. in unix-like operating systems and even dos and windows, this is called “piping” information from one program to another.

to pipe information from another program to a fig program, use arrstdin to get the information into an array.

to pipe information from a fig program into another program, simply use print on the fig side– the other program will use whatever accesses stdin on that end.

x  lineinput

 

sets x to the string typed in on the keyboard. the program waits for the user to press “enter” after typing text in.

x  "text.txt"  open "r"
y  flineinput  x

 

opens “text.txt” for input and reads a line using flineinput, which stores the line in variable y. if you had an incredibly large file and didnt want to open it all at once, this would be one way to avoid that. otherwise, arropen is easier to use instead:

x  arropen "text.txt"

 

opens “text.txt” into array x. really, thats all you do. if you used open “r”, run “text.txt” close to close the file after youre done reading from it.

x  time
x  date

 

while timer gets the seconds past midnight, time gets the hh:mm:ss time and date gets the mm/dd/yyyy date. unlike timer which is numeric, both time and date return strings.

x  arrcurl "https://duckduckgo.com"

 

downloads the source of the page for https://duckduckgo.com and loads it into an array just like arropen would do for a local file.

x  sleep 2

 

waits until 2 seconds have gone by to continue running the program. does not affect the main variable, and is only categorized as “input” because it gets information from the clock.

x  command

 

sets x to an array including each parameter the fig program was called with. didnt open the program you wrote with any parameters? then this command isnt going to do much for you.

if you are on the command line, this is how you call your program with parameters:

name-of-your-program.fig.py par1 par2 par3

 

the array will contain “par1”, “par2” and “par3”.

 

the concept of fig os

fig os was originally an experiment to update puppy linux, by mixing in modern components from refracta.

on a more fundamental level, fig os is based on:

  • an automated script
  • which downloads and opens iso images for gnu/linux distros
  • then mixes (copies) certain components together
  • and compresses everything back into squashfs and an iso image

 

in order to do this, fig os borrows the isolinux configuration of one of its source distros.

fig is chosen for this task for the following reasons:

  • theres less fiddly syntax / whitespace than bash or python requires
  • theres less fancy footwork required than in bash
  • fig handles arrays pretty well, and can get them from shell output easily

 

in other words, i didnt prefer to use python or bash for this. mkfigos actually contains about 50% bash, but that is inside strings run by fig, and could be refactored to use less code (and less redundant bash code.)

one of the nice things about fig vs bash is that fig has real scoped functions– in bash, all variables are global. ive done very large bash scripts, and find those tedious.

here is a stack outlining what fig 2.4 consists of:

  • the bulk of the distro, copied from refracta
  • files and folders created from contents in script, and copied from librepup
  • a few tools created in fig and python, added from online repos
  • packages and updates from debian/security repos
  • deb packages added to filesystem using dpkg-deb -x (no chroot)
  • some configs changed using sed -i or similar fig routines
  • many files deleted from source distros for space
  • filesystem compressed using mksquashfs
  • iso written using genisoimage
  • made dd-able using isohybrid from syslinux

 

all this from a single fig program designed to run more or less unattended, making it relatively clear (vs. python or pure bash) whats being done to create the distro.

thats the idea, anyway. you can try the latest version (2.4) for yourself: https://archive.org/download/Puppy_Linux_Refractapup/figos2.4.iso …support forums and fig source at: http://unofficialdistros.freeforums.org