Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tortuga.py Expanding Turtle.py Beyond English

Similar presentations


Presentation on theme: "Tortuga.py Expanding Turtle.py Beyond English"— Presentation transcript:

1 Tortuga.py Expanding Turtle.py Beyond English
@AlSweigart (last name rhymes with “why dirt”) bit.ly/tortugapy “Hello. I’m Al Sweigart. My main claim to fame in the Python community is writing Automate the Boring Stuff and other books for beginner programmers, including books aimed at young adults, not just adult adults.”

2 “Python is famously referred to as having ‘batteries included’
“Python is famously referred to as having ‘batteries included’. It’s standard library of modules has everything, including things like a GUI toolkit, called tk-inter, and an IDE, called IDLE, that uses this GUI toolkit. This is weird. It’s weird for a language to come with an editor; no other language does this. But I’m convinced that IDLE plays a much larger part of Python’s adoption than we think it does. An interactive shell that requires zero configuration and set up has been a huge benefit in my books for beginners. I don’t have to explain how to download an IDE, install the IDE, configure the IDE, change path environment variables, and then repeat this for Windows, Mac, and Linux. And I’m certain it’s a huge benefit for others as well. If you’re a teacher, you don’t have to deal with getting permissions to install an IDE in addition to Python, and you don’t have to install it on 30 laptops because it comes with Python. It just works.”

3 >>> import turtle
“Another thing that comes included with Python is a full implementation of turtle graphics. You might remember this from when you were learning to code, because turtle graphics is a programming education paradigm that has stuck around for five decades. It’s a great way to learn to program: You have an object on the screen called a turtle, and you can tell it to move forward 100 steps, turn right 90 degrees, move forward 50 steps… all while drawing colorful lines behind it. It doesn’t take much programming to create really interesting artwork.

4 “These spirograph-like images are really common turtle programs to make, but there are many more.

5 “Many, many, many, many, many, many, many, many, many, more.”

6 $ python –m turtledemo “And those are just some demos that I made. Python also comes with its own set of turtle demos. You can run “python –m turtledemo” to view-

7 Many, many, many, many, many, many, many, many, many, of these turtle
Many, many, many, many, many, many, many, many, many, of these turtle.py demos.

8 “Turtle. py is great. But in a sense, it’s already obsolete
“Turtle.py is great. But in a sense, it’s already obsolete. You’ve probably heard of Scratch, the programming education tool created from MIT. It uses a graphical editor where you can snap code blocks together like Lego. Scratch has many great features and one of them is an implementation of turtle graphics. It’s really popular. It’s a web app, so there’s zero configuration and setup. It’s great. But eventually you’ll probably want kids to graduate from Scratch and move on to a professional language like Python, and so there’s still room for turtle.py in a world where Scratch is so popular. I’ll come back to Scratch in a moment. First I have a story to tell.

9 “I’m an American. I’m proud to be an American…”

10 “…most of the time.”

11 “But in 2013 I decided it was about time I visited not-America, parts of the world. So I spent a month in Europe.”

12 “It was amazing. You’ll never believe what I found. An entire continent of people who didn’t speak English. Can you imagine such a thing? There might even be other continents where they don’t speak English. Being an American tourist, I tried speaking loudly and slowly, but they still could not understand what I was saying. Even in the UK, where they speak English, they write their dollar sign with an L.”

13 When I got back home I started thinking about software development and the dominance of English in software development, and what this meant for kids in other countries who wanted to learn to program. Because coding is a large enough challenge, but on top of that they have a language barrier. Even if your comments and strings are in your native language, Python still uses English for all its keywords.

14 and False nonlocal as finally not assert for or break from pass
class global raise continue if return def import True del in try elif is while else lambda with except None yield These are the Python keywords. This is part of the language, it can’t be changed. Your Python scripts must literally use these words for the Python interpreter software to understand your code. And all of the major programming languages are like this, even if they were developed outside of the English speaking world: Ruby comes from Japan, Lua comes from Brazil, Python comes the Netherlands. If Guido had decided to use Dutch for Python’s keywords, all our programs would look like this:”

15 klasse globaal verhogen voortzetten als terugkeer
en vals nietlokale als tenslotte niet beweren voor of breken van slagenvoor klasse globaal verhogen voortzetten als terugkeer bepalen importeren waar verwijderen in proberen alsanders is terwijl anders lambda met behalve geen opbrengst “So this is a challenge for non-English speakers, particularly non-English speakers who are also new to programming, and particularly particularly for non-English speakers who are also new to programming who are also schoolchildren.”

16 Internationalization
“There is ‘internationalization’…”

17 Internationalization I18N
“Which software developers write as eye-eighteen-in, because we don’t have time to type the 18 letters in between the “I” and “N”. This is where your application has string tables containing text translations, and depending on your operating system’s or browser’s locale settings, the correct language is shown. But this is for the application’s users. The source code is still in English: the comments, the function names, the language keywords are all in English.

18 “Let’s go back to Scratch. Scratch has a really interesting feature
“Let’s go back to Scratch. Scratch has a really interesting feature. There’s this globe icon in the menu bar, that when you click…”

19 “…has options for dozens of languages. When you pick one of these…”

20 “…the entire user interface changes
“…the entire user interface changes. The editor changes, the code blocks (which are the effectively the Scratch language’s keywords) change, instantly. There is zero configuration and set up to get this. No plugin or language packs to install, this is in every instance of Scratch. This is weird. It’s weird for an application to do this, it’s not standard software development. Scratch is a web app, so what it should do is read your browser’s locale settings and then base its presentation off of that. But instead, Scratch reinvents the wheel and has its own language settings. But for the case of an educational tool for kids and young adults, this is much more accessible than digging through browser settings.

21 >>> import tortuga
“We can do this with turtle.py. Like Scratch, it’s an educational tool aimed at a younger audience, not professional software engineers. Having the turtle.py function names and strings in their native language removes a language barrier and encourages adoption of Python for young programmers outside the English-speaking world. So I created tortuga.py as a test of this. It’s basically turtle.py’s code with the function names and string values changed to Spanish.”

22 “Now your turtle programs that look like this…”

23 “…can look like this. The Python keywords are still in English, but the barrier to entry is significantly lowered. Especially if you have a class that isn’t a deep dive into programming, but rather just a small elective unit and turtle.py is the only coding students will see.”

24 pip install tortuga github.com/asweigart/tortuga
“Tortuga.py is complete but not widely adopted so it’s still open to revision. You can run pip install tortuga and play around with it right now. The source is posted on github, but that’s not good enough. I’d like to make it zero configuration and set up to have this language feature added to Python, and that means adding this turtle.py.”

25 End Goal: Add to turtle & turtledemo
Based on turtle.py Non-English string table (a dictionary) Add aliases for the function names 4k per language >>> import turtle >>> turtle.tortuga() “That’s the end goal: Add a language-switching feature to the turtle and turtledemo modules. Tortuga is mostly based on the existing turtle.py source code, it just has the Spanish string table added, which is just a standard Python dictionary. It has Spanish aliases for all the English function names. And altogether, this only adds about 4 kilobytes to the source code. You could have a couple dozen languages to core Python’s turtle.py without blowing up the codebase’s footprint. The end goal is to be able to import turtle and then call one function to switch the module’s language.”

26 Source Code Excerpt _SPANISH_IDENTIFIERS = {
'TurtleScreen': 'PantallaTortuga', 'RawTurtle': 'TortugaBruta', 'RawPen': 'LapizBruto', ... # Add Spanish names for all Turtle methods for englishName in _tg_turtle_functions: if englishName in _SPANISH_IDENTIFIERS and englishName in locals(): locals()[_SPANISH_IDENTIFIERS[englishName]] = locals()[englishName]

27 “But this is something I really can’t do myself
“But this is something I really can’t do myself. It’s going to require-”

28 “You. Er…”

29 Vous “You.”

30 You “I mean, you.”

31 posicion()? ¿posición()?
“Because I’m just a dumb American with a qwerty keyboard. I don’t even know if the function name for “position” should have an accent mark or not.

32 “What I have a spreadsheet for tracking translations but it’s going to require many eyeballs and many brains to do this project right.”

33 SPRINTS!!! TODO translations, verification of translations
expand unit tests “simple english” tutorial translate tutorial promote in non-english schools/websites code review & commit to python SPRINTS!!! “And there’s all sorts of things that need to be done. There’s language skills needed for doing translations. There’s programming skills needed for expanding the unit tests. And this is not a “if you build it, they will come” project: The foreign language features will need to be promoted, so we need a turtle tutorial that uses straightforward English that can be easily translated into other languages, and these tutorials need to be promoted to instructors outside the English-speaking world. And we need process and political skills to get this adopted by the Python standard library. Fortunately, there’s a great time to get started doing this. I’ll be at first couple days of sprints, and also attending the conference, so if you’re interested in contributing, find me or contact me, and we can work on Python more accessible.”

34 You open source projects tutorials documentation I18N, _() idioms
“I mean, you.”

35 Tortuga.py Expanding Turtle.py Beyond English
@AlSweigart (last name rhymes with “why dirt”) bit.ly/tortugapy “Thanks!”


Download ppt "Tortuga.py Expanding Turtle.py Beyond English"

Similar presentations


Ads by Google