Creative Compassionate Code

๐Ÿ๐Ÿ‡ฎ๐Ÿ‡น

Nicholas H.Tollervey

๐Ÿ  ntoll@ntoll.org / ๐Ÿ‘” ntollervey@anaconda.com

And you..?

Stand up!

Now sit down if your coding experience is...

  • Total beginner / zero experience ๐Ÿ˜ฑ
  • 2 years or less ๐Ÿ‘ฉโ€๐Ÿผ
  • 5 years or less ๐Ÿ‘ถ
  • 10 years or less ๐Ÿง’
  • 20 years or less ๐Ÿ‘ฉโ€๐ŸŽ“
  • 40 years or less ๐Ÿ‘ฉโ€๐Ÿ’ผ
  • Go talk and learn from those left standing!

Today:

  • Three personal coding stories: ๐Ÿ—ฃ๏ธ
    1. My 8 bit origin ๐Ÿ‘พ
    2. Mu, coding for beginners โ‰๏ธ
    3. Future Python via PyScript ๐Ÿš€
  • What do these stories tell us about coding? ๐Ÿค”
  • Paying attention as engineers. ๐Ÿ”

Three coding stories ๐Ÿ—ฃ๏ธ

My 8 bit origin ๐Ÿ‘พ

Life lessons

  • Coding is fun: we feel empowered and creative ๐Ÿ˜€
  • Code has unforeseen consequences ๐Ÿ˜”
  • Stop, think and consider what you're doing ๐Ÿค”

Asking what sort of education we want is the same as asking what sort of community we want to become.

For education is the process through which we interact with our future colleagues, collaborators and friends.

Mu, coding for beginners โ‰๏ธ

๐Ÿ’ฌ ๐Ÿง„ ๐Ÿ‡ซ๐Ÿ‡ท ๐Ÿฅ ๐ŸŽ‰

๐Ÿ˜ฌ

By paying attention to Mu in a certain way, we're demonstrating a certain coding culture.

Mu is also the means of passing on such a culture.

That culture is open, collaborative and supportive,

...and so is Mu.

Life lessons

  • Compassionate engagement is humbling ๐Ÿคฏ
  • KISS (Keep It Simple, Stupid) ๐Ÿ˜˜
  • The community is amazing โค๏ธ and terrible ๐Ÿ’”

Future Python via PyScript ๐Ÿš€

PyScript is an open source platform for Python in the browser, and sponsored by Anaconda .

If Python and the web had a baby, it'd be PyScript.

"For the 99%..." ๐Ÿ’— Peter Anaconda

Core Concepts

An Invent application is made of this:

  • Pages contain components used in the app ๐Ÿ“ฑ ๐ŸŽš๏ธ โ–ถ๏ธ
  • Media are assets used by the app. ๐Ÿ–ผ๏ธ ๐ŸŽถ ๐ŸŽฅ
  • Functions define custom behaviour. โš™๏ธ๐Ÿ’ช
  • Channels carry messages to coordinate behaviour. ๐Ÿ’ฌ๐Ÿ“ก
  • The Datastore keeps state: it stores key/value data. โœ๏ธ ๐Ÿ“–
  • Tools do async work then store results in the datastore. ๐Ÿšš ๐Ÿ“ฆ

An Italian traffic app. ๐Ÿ‡ฎ๐Ÿ‡น๐Ÿ›ต๐Ÿ”Š๐ŸคŒ

import invent
from invent.ui import *
from invent.tools import sound

# Initialise datastore with default values.
await invent.setup(number_of_honks=0)

def make_honk(message):
    """
    A message handler. Increment the datastore and use
    a task to play sound media.
    """
    invent.datastore["number_of_honks"] += 1
    sound.play(invent.media.sounds.honk.mp3)

# Subscibe the handler to messages on the honk channel.
invent.subscribe(
  make_honk,
  to_channel="honk",
  when_subject=["press", "touch"]
)

# An app contains pages.
app = invent.App(
  name="Honk Italia!",
  pages=[
    # Pages have children that are UI components.
    Page(children=[
        # An image displays media, and publishes events
        # on the honk channel.
        Image(image=invent.media.images.scooter.png,
              channel="honk",
              horizontal_align="center"),
        # A button publishes events on the honk channel.
        Button(text="HONK! ๐ŸคŒ", channel="honk"),
        # A label whose text value is reactively updated
        # from the specified value in the datastore.
        Label(text=from_datastore("number_of_honks"),
              horizontal_align="center"),
    ]),
])

invent.go()

HONK! ๐Ÿ‡ฎ๐Ÿ‡น๐ŸคŒ

Life lessons

  • Opportunity follows imagination ๐Ÿ’ญ
  • Aesthetic attention prompts expression ๐Ÿฅณ
  • Aligned vision attracts allies ๐Ÿ˜Š

A Quick aside...

Allies ๐Ÿ‡ฎ๐Ÿ‡น

(PyScript is actually mostly Italian!)

Andrea Giammarchi ~ JavaScript virtuoso

a.k.a. WebYoda ๐Ÿป

Life Lesson

Perspective is worth 80 IQ points
~ Alan Kay

What do these stories tell us about coding? ๐Ÿค”

Paying attention is important

โ˜ ๏ธ The danger is we are... โ˜ ๏ธ

  • Finding problems that don't exist
  • Creating thoughtless solutions
  • Writing complicated code
  • Measuring success in dubious ways
  • Following shallow "best practices"

Problems that don't exist ๐Ÿ”

Thoughtless solutions ๐ŸงŸ

The fundamental design flaws are completely hidden by the superficial design flaws.

Complicated (crap) code ๐Ÿ’ฉ


          print("Hello, world!")  # Beginner ๐Ÿ‘ถ
          

          def hello(name="world!"):  # Junior coder ๐Ÿง‘โ€๐ŸŽ“ 
            return f"Hello, {name}"

          print(hello())
          

          class Hello:  # Enterprise programmer ๐Ÿ‘”

            def __init__(self, name="world!"):
              self.name = name

            @property
            def greet(self):
              return f"{self.__class__.__name__} {name}"

          print(Hello().greet)
          

          print("Hello, world!")  # Experienced engineer ๐Ÿ‘ท
          

          # YAGNI ;-) a virtuoso coder ๐Ÿคฆ
          

Measuring success? ๐Ÿ“ˆ

"Best practices" ๐Ÿคฃ๐Ÿ˜ฑ๐Ÿ˜ญ

๐Ÿ”.py


"""
Chicken chicken chicken chicken chicken chicken chicken.

Chicken (c) 2021 Nicholas H.Tollervey.

Chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken. Chicken chicken chicken chicken chicken chicken chicken
chicken. Chicken, chicken chicken chicken, chicken chicken, chic-
ken chicken chicken โ€œchicken chickenโ€ chicken โ€œchicken chickenโ€
chicken.

Chicken chicken chicken chicken chicken. Chicken-chicken chic-
ken chicken chicken chicken chicken chicken, chicken chicken chi-
cken chicken, chicken, chicken chicken chicken โ€œchickenโ€ chicken.

CHICKEN, CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHI-
CKEN (CHICKEN CHICKEN) CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN,
CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN
CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN. cHICKEN CHICKEN CHICKEN
CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN, CHICKEN CHICKEN
CHICKEN, CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN CHICKEN.
"""
import sys as chk
from builtins import print as chicken
from builtins import range as freerange
from random import choice as Chicken


EGG = 0
CHICKEN = 1

#: Chicken.
__CHICKEN__ = f"{CHICKEN}.{EGG}.{CHICKEN}"


#: Chicken chicken CHICKEN "chicken"
_CHICKEN = [
    "CHICKEN",
    "chicken",
    "Chicken",
    "chicken",
    "'Chicken'",
    "chicken",
    "Chicken-chicken",
    "chicken",
    '"Chicken"',
    "chicken",
    "(Chicken)",
    "chicken",
]


def chckn():
    """
    Chicken chicken chicken chicken. Chicken _CHICKEN chicken chicken.

    Chicken: chicken.
    """
    return Chicken(_CHICKEN)


def _chckn(chickens=EGG):
    """
    Chicken chicken chicken CHICKEN Chicken-chicken.

    chickens: Chicken chicken 'Chicken' chicken. (Chicken: EGG)

    >>> assert _chckn() == CHICKEN
    >>> assert _chckn(CHICKEN) == CHICKEN + CHICKEN
    >>> assert _chckn() + _chckn() == _chckn(_chckn())
    """
    # CHICKEN: Chicken chicken (Chicken) Chicken-chicken "Chicken" (#2)
    return chickens + CHICKEN


def _chicken(argchicken=f"{CHICKEN}{EGG}"):
    """
    Chicken chicken chicken chicken chicken 'chicken'.

    Chicken chicken, chicken chicken chicken chicken:

    * Chicken chicken.
    * Chicken CHICKEN chicken.
    * Chicken-chicken CHICKEN.

    (Chicken chicken chicken chicken?)
    """
    if chk.argv[CHICKEN:]:
        # Chicken chicken.
        argchicken = chk.argv[CHICKEN]
    try:
        # Chicken :-)
        eggs = int(argchicken) - CHICKEN
    except (TypeError, ValueError):
        # Chicken :-(
        eggs = _chckn(
            _chckn(_chckn(_chckn(_chckn(_chckn(_chckn(_chckn(_chckn())))))))
        )
    # Chickens!
    chicken(
        "Chicken " + " ".join([chckn() for chick in freerange(eggs)]) + "."
    )


if __name__ == "__main__":
    _chicken(chk.argv[CHICKEN:])
          

๐Ÿšซ๐Ÿ”๐Ÿšซ

Chicken

Paying attention as engineers. ๐Ÿ”

The Secret:

STUDENT: O Guru, what is the secret of success?

GURU: Good judgement.

STUDENT: How do you get good judgement?

GURU: Experience.

STUDENT: How do you get experience?

GURU: Bad judgement!

To what we pay attention is important. How we pay attention is equally consequential but often unconscious. Considering why we pay attention is perhaps most significant ~ an engaging, poignant and sadly neglected opportunity for self-examination.

A herd of tech bros circle together,
  bleating about the Pythonic weather.

Don't be the sheep cut off from the mass,
  unable to pass,
  as someone,
  with something,
  interesting
  to
  say...

Their mental masturbation ejaculates
  ever-fruitless discourse:

Repackaged reportage from Hacker News,
  Performative patronising technical reviews,
Name dropping semi-famous nerds,
  An infinite garbage of computer-y words.
Detached and empty with no spark of life.
  The real world ignored, to cut off its strife.
So clever they lack the intelligence to know,
  We are vital and luminous souls who grow
Through connections and feelings and deep self revealings,
  But their work fills the world with VC funded dealings.
Squeezing huge profits through inhumane code,
  We're exploitable data points, with privacy to erode.

What do we call such a desperate crew?
A wank of tech bros, that'll do.

Thank you

Questions & Debate

</rant>

๐Ÿค— ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ