Oooh!

I'm seeing a fair amount of agreement on this, and "catching parse errors" has sort of become a thing of mine lately. So lemme try to answer this question in a way that an 8 year old might appreciate.

1/
FIRST: I see these "There's no semicolons in Python" replies

I suspect the kid's ACTUAL example was some Python-specific thing, so Joe switched it for something more programmers would recognize and y'all seized the opportunity to get pedantic. You must be a riot at parties.
SECOND: if you're gonna deliberately miss the point of a lighthearted tweet to well-actually someone about how there's no semicolons in Python, you deserve this:

There are semicolons in Python. You delineate multiple statements on the same line with semicolons.

ANYWAY, ONWARD
Now that I've told off the programmers treating internet humor as a zero sum game

Lemme start here: the computer runs a program to understand YOUR program. That program is called a compiler. Python also has an interpreter: a program that RUNS your program. But this error...
...is a compilation error. Which means, the compiler caught it while trying to understand your program.

Compilers can be very, very complicated. There are lots of opinions about how to write them. You can even find DIFFERENT compilers for the same language! For example...
...the compiler YOUR computer has for Python is probably the 'standard' one. We call it CPython because it is written in C, another programming language.

There is also Jython, written in Java (another programming language), and PyPy, a Python compiler written in Python!!
For now, we won't get into how Pypy works. That's a thing an 8 year old might enjoy looking up on her own.

Anyway, handling compilation errors. Have you ever heard that phrase about how "Every happy family is the same, but every unhappy family is unhappy in their own way?"
What it means is that there's a lot more ways to get something WRONG than there are to get it RIGHT.

And the number of people who write Python, globally, is 8.2 MILLION! (data: SlashData)

Imagine that. Writing a compiler that has to catch the ways 8.2 million people mess up.
A colon (it turns out Joe meant to write colon) or a semicolon (if we're talking about a lot of programming languages where every line ends in a semicolon) seems obvious, when it's just you coding, and when the compiler is right about what's wrong with your program.

BUT, imagine
...imagine if it's even 99% right when it catches a colon error (remember, it is hard to predict how things will go wrong. 99% is pretty good.)

Let's pretend 8.2 million people each make one colon error a day.

8200000 * .01 = 82,000.

82,000 times the compiler is wrong. Daily.
Now, there are three 'risk amplifiers' to consider when you are deciding how to deal with things that could go wrong. Each one makes the risk 'worse.'

1. It's catastrophic (breaks very important things)
2. It's likely (it happens a lot)
3. It's insidious (it could go uncaught)
So in the case of the Python colon error, we're talking about this number of 82,000 a day. That's a made up number, but it illustrates the point that Python is used by enough people that even RARE compilation error mistakes happen pretty often.

They're likely, in other words.
Most of them are not too catastrophic, right? They're easy to fix, most of the time, and even in the 82,000 cases where the compiler is mistaken about what, EXACTLY, the programmer has done wrong, drawing attention to that AREA will help the PROGRAMMER figure it out.
Now let's talk about insidiousness. This is the most underappreciated and, probably for that reason, often the most dangerous of the risk amplifiers.
Example: NASA lost the Mars Climate Orbiter in 1999 because some of the hardware assumed English units, some of the software assumed metric units, and no one caught it until the thing was already lost.

Even in cases where errors are rare, we want mechanisms to catch them.
The compiler error being wrong about the colon sometimes, even if it's usually right, is already likely because of the sheer number of people writing colons in Python.

What if the compiler adds a colon when that's the wrong thing, and it's in, like, a space launch program?
There are a couple of programming languages that are notorious for this kind of thing: Most famously, JavaScript, and to some extent Ruby.

These languages will try with all their might to divine something runnable from what you wrote. How kind of them, right? But the thing is...
...that can make it really, really hard to figure out why your program is not working properly, because it's still doing SOMETHING. Just, it's the WRONG thing.

The wat video shows some funny, salient examples of this:

destroyallsoftware.com/talks/wat
So a common, risk-averse approach in compiler design is to surface compilation errors to the programmer and let them—you—figure out exactly what's wrong.

Because, as smart as we compiler designers think we are, YOU, dear programmer, know your program better than we do.
We THINK we know what's wrong. We're PRETTY sure. But we don't assume.

We say:

"We think something is wrong here. We think you want a colon. But we want you to look at it, too. Because you might know something we don't, and we don't want to make your program wrong by accident."
Not to belabor the point, but just to make it clear I'm not lying: Here's Python asking for that semicolon it supposedly does not have ImageImage
And for good measure, an example of Python getting the colon compilation error wrong.

It says it wants a colon. The actual problem here is that I typo'd "and" to "nd." But as you can see, there actually IS a colon in the right spot.

This'll happen 81,999 more times today. ImageImage
If the compiler tried to automatically add a colon, I'd have two colons and the code is even wronger.

Or it might do so over and over, resulting in a never-ending string of colons and a hung compiler!

("hung" means "never finishes running and we have to shut it down manually")
So the compiler avoids causing those kinds of things by leaving it up to the programmer what the problem is, and accepting the 'cost' that in most cases, the programmer will be like 'Ahp, yep, missing a comma. Lemme add that.'

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Chelsea Troy @heychelseatroy@social.clawhammer.net

Chelsea Troy @heychelseatroy@social.clawhammer.net Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @HeyChelseaTroy

Apr 4, 2023
(QT'ing to credit the OP. Screenshot without the handle in case, at some point, the OP wants to delete their association with the idea. The idea will remain in the screenshot so this thread retains context.)

There is nuance to this topic. Twitter has stripped it. Let's talk. A tweet that says "I had a film professor ask why a stu
Example 1: In my second-ever computer science class as an undergrad, I went to my teacher's office hours asking for help.

The teacher speculated that I "lack the intellectual firepower" for a programming career.
Fast-forward to now: I'm a professional software engineer, I teach some extremely highly-regarded programming classes at the U Chicago Master's Program in CS, and I do workshops for O'Reilly and at cons.

I roast that teacher constantly on purpose to make a point.
Read 28 tweets
Apr 3, 2023
I'm really excited about the potential for this workshop. It has forced me to grapple with some really hard pedagogical challenges.

See, the things that are hard about designing pedagogy for legacy code are not what you'd expect.

A thread.
SCENE DESCRIPTION: like 80% of "coding education," from Academia to O'Reilly to YouTube to TikTok, is "How to build X from scratch."

But software engineers spend, TOPS, 20% of their time doing that.

We're mostly reading, modifying, debugging, documenting.

Why the mismatch?
3 reasons:

1. Building from scratch is fun and sexy and works as clickbait, basically.
2. Building from scratch is what programmers get monetarily rewarded for, so it's what they're incentivized to learn.
3. It's WAY f**king easier to teach.

Why so much easier?
Read 27 tweets
Mar 17, 2023
I am not on the RailsConf committee this year, but I have been on it in the past. So I am in a good position to shed light here, from a removed position, on the CFP process.

I'd...recommend this reading for anyone submitting to conference CFPs.
The way MOST CFPs work is that a group of volunteers raise their hands to participate in talk selection for a variety of different tracks or topics. All of these people are doing this on top of their full time jobs.

In 2022 I reviewed 278 RailsConf proposals while on vacation.
Reviewers don't know who submitted which proposal. We know the title and the abstract, and if the submitter sent an outline, we have that too. Most submitters don't submit a very complete outline.

So we've got VERY little info to evaluate on.
Read 13 tweets
Jan 18, 2023
It did not occur to me that this would happen, but so far it has happened twice (AMAZING) so...I have a solution!

Suppose you want your WHOLE TEAM to take the tech debt course, but you don't want everyone to have to submit their own individual expense report.

What we do is...
1. Email me how many instances of the workshop you need for your team.
2. I send you an invoice for that amount.
3. I make you a custom 100% discount code with that many instances.
4. Your team can all use that code to get the course on their own accounts!
Nota Bene: it would not surprise me if I eventually hit a platform limit on the number of "free" instances I can create.

If that happens I'll call them and ask that I be allowed to continue to do this until they make it possible to purchase multiple course instances.
Read 6 tweets
Jan 17, 2023
Okay, I made a thread and scheduled it. Go me :)

Let's talk about the pedagogical principles that went into the design of "Technical Debt: An Analytical Approach."

I'll go over 3 things:
1. Length
2. Exercises
3. Format

(I'll link the course itself at the end of this 🧵)

1/
First, an analogy: home design.

The design elements that make a home "high value," in the eyes of real estate agents, tend to make the home good FOR ENTERTAINING.

High ceilings create space in crowded rooms.
Marble countertops are impressive.
Open plans seat large groups.

2/
Those same elements often make the home worse for living.

High ceilings make the space harder to heat.
Marble countertops have limited resistance to heat and acid, which...come on, kitchens are for COOKING
Open plans mean fewer people can concentrate in the same floorspace.

3/
Read 13 tweets
Aug 26, 2022
So it sounds like, in a month, @heroku is going to end free plans. Apps deployed and hosted for free until now will have to pay, migrate, or perish.

Let's talk about the sustainability of internet businesses for a second. You will not like what I have to say.
In what I'll call the Centralized Software as a Service Industry, it's actually not that easy to break even and the companies that are doing it aren't who you think they are.

How did we get here? Have a seat.

Once upon a time, making money on the internet was extremely easier.
The market was not as saturated, the public was not as jaded toward ads, and programmers did not cost as much as they do now.

I've talked about this period some; why it was so easy to make something "visionary" back then, and why it's not like that now:

chelseatroy.com/2021/07/30/the…
Read 21 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(