Wednesday, August 30, 2017

Python in Nigeria

In 2015, the PSF sponsored the first Python event in Nigeria - the Codesses Workshop in Lagos. In 2016, the number of events increased to 13, and there have been 28 events funded so far in 2017! What has happened in the last 2 ½ years to create such a demand for learning Python in this part of the world?

Aisha Bello
I spoke with Aisha Bello about this. She serves as vice-chair for the Python Nigeria community. She has helped co-organize and support a number of Django Girls workshops in Namibia and Nigeria, and also co-organizes PyLadies Nigeria. Aisha is enthusiastic about the  Python community, with a strong desire and passion for social change, women’s tech education and empowerment in Africa. She currently works as an Associate Systems Engineer for Cisco Systems.

Chukwudi Nwachukwu
Sharing his thoughts as well, is Chukwudi Nwachukwu, PSF Board Director, and Team Lead Integrations, TechAdvance. He is also a volunteer member of the PSF Grants Work Group, helping to review requests from Africa and all over the world. He has also been invited to speak at PyCon NG in September. When I asked why he’s passionate about Python, he said, “Python is easy on the brain and I thank Guido [van Rossum]for such a concept.”

Python + Community

Smart Girls Project
According to Aisha, Python is popular in Nigeria because it’s one of the easiest ways to learn programming. Knowing how to code opens up many career options. The advantages of open source software are becoming more well-known in this region, and have allowed the community to grow because they’re not tied to any one vendor. She notes: “What we have is community. It means a lot to people that there is a common place or forum where they’re not afraid to share their struggles and ideas with people with like minds. We took the Python language and community and made it our own.”

Django Girls Lagos
Chukwudi believes that “the recent urge for more women to be in the workforce of Nigeria through IT has been a huge factor in the growth of Python programming. The Federal Government of Nigeria has also keyed into this drive by choosing Flask as a framework of choice to be taught in their Npower programme.” In addition, Django Girls events nationwide, startup companies incorporating Python as part of their stack, and IT companies training people to code in Python, have all made Python a leading programming language in Nigeria.

Funding for Events

Aisha and Chukwudi agree that getting funding for events in Nigeria is challenging. Often, it’s startups that come forward to help sponsor events. Aisha believes that “By creating more awareness and putting ourselves more out there, we’re hopeful things will change. Organizations like Github, the PSF, and the Django Software Foundation believe in us, and sponsor our events even when no one else will.”

Fortunately, the Django Girls Foundation offers help through their Organizer’s Manual and a template for how to run a workshop: the Coaching Manual. These documents provide a framework to help groups get started. Having a professional-looking proposal goes a long way toward convincing organizations to support these events.

Positive Outcomes

Many of the participants of these workshops have gone into IT careers, received internships, become mentors, organized workshops, and are actively involved in helping out the community.  Outreach to girls in primary and high schools is working too. Girls are learning to program in Python, and most importantly, they’re learning how to use the tools to continue in their journey toward a career.

One very real example is what Abocoders did in collaboration with DjangoGirls in Lagos. Girls who had been displaced from their homes due to Bokoharam in the North were able to learn about computers and programming. In addition, they each got a refurbished computer to use during and after the workshop.

#GirlCodersRock came out of one of the events. An attendee of a Django Girls event in Nigeria is now an intern at TechAdvance, where Chukwudi works. She’s now coding Python full time. There are many Python-related jobs being advertised right now in Nigeria - Google Nigeria and Upperlink are hiring, and has 40+ listings. It looks like the trend will continue.

Chukwudi has seen a large increase in members both on slack channels and mailing lists. The community is very excited about the first PyCon Nigeria, September 15-16, 2017, in Lagos. It’s the largest gathering for the Python community in Nigeria, and is organised by members of the Python Users Nigeria Group, a nonprofit organisation dedicated to advancing and promoting the use of the Python programming language in the country.

Django Girls Lagos
Chukwudi suggested that I speak with a woman he mentors, Hamdalah Adetunji, about her road to a career in programming. She explained: “It is all a step towards growth and progress, but I hope one day in the near future, I get to do more than wish I wasn't the only female on the team. I hope to mentor women to give back the amazing support I have received all through my journey, and also let them know they can be anything they want to be as long as they are focused and determined."

Thursday, August 10, 2017

The Ethical Maintainer: Community Service Award Recipient Glyph Lefkowitz

Glyph Lefkowitz was barely 20 years old when he promised himself, "I am never going to use a proprietary programming language again!" He had been writing a Java application for his first professional programming job, which he had started directly after high school. The firm was a mom and pop shop that sold inventory software. Glyph was hired to rewrite their application for a contemporary platform: Java's Abstract Window Toolkit. With the hubris of the young, he promised, "Sure, I can rewrite your whole application in a new language." He could do it working only four days a week, too, and make time to work on his multiplayer online game.

"I had a pretty terrible experience with Java," he says. In those early days of the Java AWT, on classic Mac OS it leaked a tiny bit of memory every time it opened and closed a window, and in his application, nearly every task a user desired required opening and closing a window. On the constrained Macs of the time, the application would crash after about 100 tasks, often taking the whole OS down with it. The AWT was proprietary, so there was no way to fix the bug himself. "I was fired," says Glyph, "because I was having a nervous breakdown over this."

The Birth of Twisted

Meanwhile, Glyph was also building his multi-user text adventure in Java. He wanted to rapidly experiment with varied gameplay logic, and to avoid constantly restarting the server as he tried new code, he built a system in Java that could load new modules at runtime. When, burned by his Java defeat, he switched to Python, he found that practically all of the Java code required to load modules and execute them simply disappeared.

The switch from Java to Python had another effect, which profoundly determined the direction of Glyph's career. He discovered async.

Glyph's friend James Knight, who would become an original contributor to Twisted, helped with the Python port. The initial code for the Python server ran a thread per player, but Knight used a select call to determine, within each thread, whether it was time to read a message from the player or send one. When young Glyph saw that code he was astonished. "It's doing two things at once! But it's also kind of one thing." After all the bugs he'd battled in his multithreaded Java, he thought, "Couldn't we just do one thing all the time?" He and Knight rewrote the entire game server as a single-threaded event loop. He liked how it simplified the code. Only one thread accessed a shared data structure at a time. His original motivation to use an event loop was not efficiency: rather, it was how much easier it was to make his code correct.

Glyph says that his strength, in his 20s, was knowing what he didn't know. His father is a programmer, and he taught Glyph that most programming techniques are already well-known. Therefore when Glyph and James Knight got their event loop working, Glyph thought, "Someone must have done this before." He searched on Alta Vista and found the ACE project, which included a C++ event loop. Glyph refined his Python event loop based on the best practices he found in ACE, and this became the basis for Twisted, which is now one of the oldest and most influential of all Python libraries.

Based on this early experience discovering that event loops were a well-known technique, Twisted's motto is "no new ideas allowed." Twenty years later, however, Glyph has begun to innovate on the margins. For example, his Tubes library implements asynchronous I/O as "flows" of data with flow control and backpressure. But when it comes to event loops, he says, "There's so much prior art that coming up with new inventions is not worthwhile."

Twisted's Influence On Python

In the second quarter of 2017, the Python Software Foundation recognized Glyph Lefkowitz with a Community Service Award for his work on Twisted and his contributions to the Python community. Nick Coghlan nominated him, saying that Twisted "predates almost all other Python event handling systems by years, and still has by far the most comprehensive set of network protocol handlers." The decade-long journey from PEP 342's generators-as-coroutines, which enabled Twisted's inlineCallbacks feature and Tornado's Futures, to native coroutine support with "async" and "await", began with Twisted. Coghlan says that evolution could be reasonably described as taking the concepts first embodied in Twisted and drawing them ever closer to the center of the language.

In 2012, Guido van Rossum began writing asyncio, an async framework for the Python standard library. He collaborated closely with Glyph, as well as Tornado's maintainer Ben Darnell, to incorporate their best ideas in asyncio. He was interested in Twisted's notion of a Deferred, but he couldn't seem to understand it. Glyph says that trying to explain Deferred to Guido "was the worst time I've ever had on a mailing list." Guido wrote, "I really don't get Deferreds. Don't bother pointing me to docs or tutorials; I tried and failed." He said that Glyph's "snarky tone is seriously affecting my ability to process your response." Then he went silent for a week.

Glyph was devastated. He felt like he'd been flamed and ghosted by the founder of the language itself. Then Guido suddenly returned to the mailing list, with what Glyph calls "the most trenchant and keenly observed critique of the Deferred module. It was possibly the best code review I've ever received." It was suddenly clear that Twisted's Deferred would interoperate just fine with the new asyncio event loop. "We were all on board."

Responsibilities of Open Source Programmers

Glyph is distinct among Python programmers for his outspoken views on ethics. In his 2015 PyCon talk he proposed that programmers write a code of ethics, similar to other professions such as medicine and journalism. If we don't, he says, "someone else is going to do it for us, and they are not going to understand our field well enough to do it correctly." Since software is eating the world and it influences nearly all economic activity, we have a grave obligation to write code ethically.

Open source programmers often think we owe our users nothing, because we give away code for free. But this attitude ignores the benefits that we've gained. "Being an open source maintainer has opened all sorts of doors for me," says Glyph. "Whenever anyone does anything with Twisted the credit accrues to me. That's not really accurate, because there are lots of other maintainers like Amber Brown, David Reid, Ashwini Oruganti, Jean-Paul Calderone, Moshe Zadka, and Christopher Armstrong." Regardless, anyone who releases open source code engages in a subtle exchange with users, which obliges the coder to uphold some responsibilities. In my conversation with him, Glyph identified three responsibilities for open source programmers: to make clear promises, to secure our code, and to release code of appropriate quality.

Open source maintainers are uniquely obliged to make clear promises. If a maintainer abandons a project, her main obligation is to announce her departure and to transfer control. "Being an open-source maintainer is not a life sentence," says Glyph. But it is irresponsible to make a worthy piece of software, gain users, then disappear without a word.

We also have a responsibility to protect our personal information security; for example, a Python project maintainer must protect her PyPI account so her users know they won't be hacked when they install her package. That responsibility is shared with the community's infrastructure maintainers, and Glyph cites PyPI as one of the best modern examples. "It doesn't get enough credit because of Python's checkered history with packaging," he says, "but the way Donald Stufft thinks about practical information security, and the other folks who work on PyPI as well, and the resources the PSF has invested there," have laid a foundation for securely distributing open source Python.

And finally, many of us set a low bar for the quality of code that we release: if the project scratched our own itch, we might as well open-source it. In Glyph's opinion, we must more carefully consider the impact of the code we give away, because we can't predict how it will be used. Glyph knows that many of the largest sites run Twisted somewhere in their stack, and he feels the responsibility keenly.

"A lot of our software completely escapes its originating context," says Glyph. The author might intend to release a mere prototype, but downstream packagers come to depend on her code, and other programmers even farther downstream might not know they depend on it at all. Of course, software users share some responsibility for auditing what code they use. "This responsibility is not black or white," says Glyph. "There's small tradeoffs and fractional proportions. It's not 100% yours or not, but you've got to think about it."