Monitor performance issues & errors in your code

#101: Adding a full featured Python environment to Visual Studio Code Transcript

Recorded on Tuesday, Jan 17, 2017.

00:00 Michael Kennedy: You know the two questions I ask at the end of each episode? What's your favorite editor for writing Python code and what less well-known PyPI package do you recommend? This time we're gonna make an entire episode out of what's your favorite editor. You'll meet Don Jayamanne who created the wildly popular and open source Python add-in for Visual Studio Code. That's not the Windows-only Visual Studio, but Microsoft's free cross-platform editor. This is Talk Python to Me, episode 101, recorded January 23rd, 2017. Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem and the personalities. This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy. Keep up with the show and listen to past episodes at talkpython.fm and follow the show on Twitter, via @talkpython. This episode is brought to you by Talk Python Training and Hired. Be sure to check out what we both have to offer during our segments. It helps support the show. Don, welcome to Talk Python.

01:24 Don Jayamanne: Hi Michael, it's a pleasure to be here.

01:26 Michael Kennedy: It's great to have you here. We're gonna talk about Visual Studio Code and I know Visual Studio and Python, while they do have the Python tools for Visual Studio, that's not what we're talking about. Typically people think of Visual Studio as this thing being a Windows thing, mostly for .net and Windows C developers and so on, but what we're going to talk about is a really amazing plug-in or extension that you've created for Visual Studio Code which is actually a cross-platform editor based on JavaScript that Microsoft has released so we're gonna talk about a pretty excellent Python editor that you've had a lot of influence in creating.

02:04 Don Jayamanne: Yes, this is a little project that I've worked on and as you mentioned, Visual Studio Code is not Visual Studio IDE that's been developed for Windows. Most people think it is, but it's more of a cross-platform editor.

02:19 Michael Kennedy: Yeah it's really, really nice and it's gaining so much traction and the Python tools you built were really cool so I want to talk about those but let's do first things first. Let's hear about your background. How did you get into programming in the first place?

02:29 Don Jayamanne: Back in 2000, that's when I started a course in computer science and I was looking for a permanent role, permanent part-time role in information technology. That's when I joined a company named EDMS. It's basically a branch off of the company in Australia and QA software. The way they hired people was they took kids just after year 12 and you were given an IQ test. If you did well you were hired. They hired me and--

02:58 Michael Kennedy: That's a really interesting way to get a job. It's like we know you're smart, you're driven and we think we could teach you programming.

03:06 Don Jayamanne: Yes. It was a really great place. As the name says, QA software, it stands for Quality Assured Software. They were really keen on ensuring the program is worth the very basics of programming. That was writing unit tests, writing technical specifications and writing quality assured code. It was really great. It had a really great foundation. I started learning, I started programming with Visual FoxPro. I don't know if many people know about that life.

03:41 Michael Kennedy: I don't know if they do. It's kind of like an access sort of language for databases, right? Can you maybe tell people what that is?

03:49 Don Jayamanne: Yes, that's exactly right. It's known as FoxPro and if I'm not mistaken, Microsoft bought it over and turned it into Visual FoxPro. Again, they had Visual, I think it was Visual Studio 5 and then they added FoxPro onto it and then it became Visual Studio 6 because it became one of the six little components to Visual Studio. Eventually they killed it off.

04:15 Michael Kennedy: It's not a thing anymore but it was a big language for rapid development, right?

04:20 Don Jayamanne: Oh yes. Personally I thought it was better than Visual Basic.

04:24 Michael Kennedy: Okay, very interesting. So where did you go from there?

04:29 Don Jayamanne: From there, stayed there for a couple of years and eventually migrated to Australia in 2004. While I was at that place, we were using .net as well. Once I migrated to Australia then I was just using .net primarily and .net and desk key as well.

04:51 Michael Kennedy: Yeah, interesting. Those are a lot of ways away from Python so what got you into Python?

04:57 Don Jayamanne: Simple, it was the Raspberry Pi micro controller. I don't know what it's called exactly, a micro computer. Once I heard about the Raspberry Pi I just wanted to get my hands on one of those and I learned that the best language to work on Raspberry Pi was Python and figured that was a really great excuse or great reason to learn another programming language and yes, that's how I learned it.

05:24 Michael Kennedy: Yes, that's really nice. Did you end up building anything interesting or just sort of played around with Raspberry Pi's?

05:29 Don Jayamanne: Initially I start playing around with it, but my first project was building a little timer/remote for my pool motor because I had just moved in and the pool pump had to be turned on manually, the timer wasn't working so I had to hook in the Raspberry Pi with a timer and that would turn the pump on and off late in the night.

05:55 Michael Kennedy: Nice. Did you internet-enable it so you could see the status of it or anything?

05:59 Don Jayamanne: Oh, no, no, no. It was just a timer and just turned the pump on and off and I was just happy with that.

06:05 Michael Kennedy: That's really cool. I love how you used it to solve a real-world problem. Like, you know what? I can program this silly pump.

06:14 Don Jayamanne: There were times when the pump, there's a little thing called a creepy crawly that gets, it would get stuck and tangled up at night so this was just the early days. I didn't know how to look after the pool or maintain the pool so I'd even hooked up a camera to it so I could see in the middle of the night whether it's functioned or whether it's stuck somewhere and yes, that's what I did. I don't have any of those things anymore but It was just in the first couple of months.

06:42 Michael Kennedy: That sounds really cool. How did you find learning Python to be? Did you pick it up pretty easily?

06:47 Don Jayamanne: Yes, amazingly really simple language. Initially, the only thing that I found annoying was the indentation. Blocks of code had to be indented. Coming from other languages I just felt that was a little weird and it took me I guess a week or two to get used to that. I just felt it was, initially I felt it was a poor language having to do that but over time I realized it was a really, very powerful, I would say a very cool language.

07:16 Michael Kennedy: Yeah that's really cool. I had a similar experience. I think a lot of people that come from C-based languages where blocks and curly braces and parentheses and things like that, you're so used to white space not mattering that it catches you off guard and you're like wait, that's crazy but once you realize the editors really, really help you, they kind of make that almost transparent and invisible and they manage it and you don't have to, well all of the sudden it's pretty sweet once you get your mind around it. I absolutely prefer that kind of programming now but I remember it being a bit of a mind shift the first time I saw it too. Interesting. Cool, so let's talk about Visual Studio Code and your plug-in. We mentioned a little bit about Visual Studio Code. It's built on something that I actually am a fan of is this thing called Electron. Can you maybe give us the history of Electron and it's weird intersection with Microsoft?

08:13 Don Jayamanne: Electron started out as a project that from, what's this, Github.

08:17 Michael Kennedy: Yeah, Github I think yeah.

08:19 Don Jayamanne: They started out, it didn't start out as a standalone project. Initially they built, to my knowledge they build Atom and then they realized wait a minute, "We've got this really cool framework that can build desktop applications" and from there they took out parts of Atom and built Electron. Basically the way, if you would look at it, Atom is build on top of Electron. For some time people had been using Atom to build extensions and basically that turned into an editor. Microsoft came along and they realized "We could do the same thing because we need to provide a editor for C-Sharp and a couple other languages as well." They came in and took Electron as the basis for Visual Studio Code.

09:03 Michael Kennedy: That's interesting. It used to be called even Atom Shell before they were like "It needs it's own name," which is really interesting. I guess the origins, it just seemed weird to me that Microsoft the company is coming along and shipping one of their major new projects on Chrome and NodeJS. It's not where I thought they would be focusing but it's a cool thing.

09:30 Don Jayamanne: Yes, it's interesting that you mention Chrome and NodeJS. For people who don't really know what Electron is, the best way to describe it is it's a desktop application using Chrome and NodeJS. Again, if people don't know what No JS is, its Javascript. That's pretty much it, Javascript--

09:48 Michael Kennedy: That's interesting and it packages it up and you just get a .app on your mac and whatever. You could care less or you don't really know that it is unless you actually know the internals. One of the things you said that was interesting was how it makes heavy use of extensions to give it any functionality.

10:08 Don Jayamanne: Yes, that's Atom. Atom uses a lot of extensions. Basically there's not much built or baked into the extension apart from the editors. This is where Visual Studio Code differs significantly. Microsoft came in and they had the benefit of fine chat so they could see where Atom and Sublime had their drawbacks and they built Visual Studio Code to resolve those issues. For instance, Atom had some serious problems with editing or loading of large files and Visual Studio code did not. One of the major reasons for people adopting Visual Studio Code was because it's efficiency in dealing with large files.

10:47 Michael Kennedy: Yeah if you had to categorize it in it's size, on one hand, and sort of a, I just rented the terminal, very lightweight. We've got things like Vim. We've got middle-sized tooling like Sublime Text and maybe throw Atom in there. We've got heavier weight things that do many, many things that are quite large applications like Pycharm or Wing IDE or Visual Studio even, itself. Where do you think Visual Studio falls in this category?

11:20 Don Jayamanne: Somewhere halfway there, I would say in the middle because of it's debugging capabilities and integration with the Git and a couple of other capabilities. It's a very mature and very capable editor. I would have to say it's definitely halfway there.

11:37 Michael Kennedy: Sure okay. It seems like Sublime Text but a little bit larger in terms of size but not a full blown IDE, maybe in how it feels when you work with it.

11:47 Don Jayamanne: That's good, yes.

11:49 Michael Kennedy: People may be wondering "What's all this about on this Python show," but let's talk about your Python plug-in for Visual Studio. This is called Python for Visual Studio Code, right?

11:59 Don Jayamanne: Yes, it is.

12:00 Michael Kennedy: When I first saw that I went "Oh cool". When I first started playing with Visual Studio Code it didn't support Python and so the white space indentation was not working right and I was like "This is not gonna work, put that away." Then I checked back, I talked to some of the guys but mentioned it and I'm like "Let me have a look at this" and then I found your plug-in. I'm like "Wow this is thing is really rich and nice." First of all, let's start by how many downloads does it currently have? Before that, how old is it?

12:28 Don Jayamanne: It's a little over a year old. If I remember correctly, I started work on this sometime in late 2015, somewhere around November or December 2015, late night to early mornings of December 2015. It's just over a year old now.

12:47 Michael Kennedy: Okay cool, now with that in mind, how many downloads does it have?

12:51 Don Jayamanne: It's got over a million downloads, if I were to be a bit more accurate, maybe 1,150,000 downloads, yeah.

13:00 Michael Kennedy: That probably, that number's climbing. That really got my attention because I'm like "Wow, how many people really use Python and Visual Studio Code, come on." Then I realized this is the second most popular extension or something and it is really, really used. As I looked into it, there's a lot of features there.

13:17 Don Jayamanne: Yes. As you mentioned, it is really surprising. Surprising because one, this is a Microsoft product, Visual Studio Code and the most popular extension is the C-Sharp extension so one would've expected the next most popular one to be something to do with, I don't know, Typescript or something else. However, it's Python so it just shows that Python is really up there in terms of popularity for language. For me, it was something very new. That's not what I was expected at all.

13:50 Michael Kennedy: That's really surprising, yeah.

13:52 Don Jayamanne: Yeah and there were others in the community too who were really surprised to see it. Pythons really doing very well, it's very interesting.

13:59 Michael Kennedy: It must've felt really good to put out something that got over a million downloads. You have over a million people using it, that's amazing.

14:07 Don Jayamanne: Yes indeed.

14:08 Michael Kennedy: So what got you, you said back in late 2005 you started working in evenings and skipping sleep and stuff. What got you started? Why were you like "This thing must exist. I have to create it." Where you like me, like "I wish this would indent my code correctly," but you actually took some action and made that happen?

14:26 Don Jayamanne: This is how I would say it. I was primarily looking for a really cross-platform editor. When I say cross-platform, I was using a Mac at that time. I was learning to do some development on the Mac and Windows as well. I was still working on Raspberry Pi. As I was jumping between the two platforms, I wanted a consistent look and feel for the editor. PyCharm was the only one that fix the box, however, as a Visual Studio developer, someone who had been using Visual Studio all my life, I just preferred that look and feel. Though PyCharm was great I still preferred something else. I guess in the back of my mind I was still hoping for something from Microsoft. When Microsoft released Visual Studio Code, I was using that as a replacement for a Notepad++. When they released that I was really looking forward to them providing the API for developers to build extensions. As soon as they did that, I thought to myself "This is a great opportunity." "Let's just provide an extension for developers." At least myself, who can use it to edit Python files on both a Mac and Windows. I was also looking for a really simple project to work on while I was at home using NodeJS because I wanted to play around with NodeJS. I was looking for a project to work on.

15:52 Michael Kennedy: So obviously the tooling is for Python developers but how much, what type of code did you write to create this thing?

15:59 Don Jayamanne: I would say primarily NodeJS.

16:01 Michael Kennedy: So it was really like writing almost an Electron app, right?

16:07 Don Jayamanne: Yes, that is correct. If you want to write any extensions for Visual Studio Code, you've got to do it in NodeJS. NodeJS is the framework, the language is TypeScript. TypeScript is a language that Microsoft developed. It's basically a superset of JavaScript. Those who don't know that TypesSript is--

16:30 Michael Kennedy: Right, like adding static typing to Javascript in a sentence, a little bit more too.

16:34 Don Jayamanne: Precisely, yes, that's right.

16:36 Michael Kennedy: Interesting, interesting. You talked about PyCharm, you said there was Sublime. Why didn't you pick, it just, just use Sublime over here, that works on both platforms as well.

16:48 Don Jayamanne: For some reason I never did like Sublime. I don't know, I guess it's just font and the way the Intellisense was displayed, I don't know. As I mentioned, as a Visual Studio developer, the look and feel was completely different so I preferred the way Visual Studio laid things out whereas Sublime, I was still getting used to using editors. PyCharm was an IDE, Sublime was an editor and it just didn't feel rich and powerful enough to me, so it was just preference.

17:17 Michael Kennedy: Sounds good. So your project, when I first talked to you it had over 600 stars on Github. That's a pretty serious project, 635. What's it been like to, all the code for this is on Github right?

17:32 Don Jayamanne: Yes it is.

17:34 Michael Kennedy: Okay, cool. What's it been like to run a project with that much popularity? Have you been getting a lot of feedback from the community, are people helping out?

17:43 Don Jayamanne: Oh yes, I've been getting quite a lot of feedback. For instance, plenty of people provide the feedback while submitting issues on Github or maybe on the extensions page and it's very humbling to know that this little pet project of mine has made a big difference in the development experience of people and the professional workspace. For instance, when people say that they've switched over from Sublime or some other IDE because of feature X, Y, Z, it feels really great. There are others that talk about the efficiency of the extension and they say that they love Visual Studio Code. For me as a person who just loves Microsoft products, I'm like "Oh wow, this is really good." Something Microsoft has done really well and is finally doing well.

18:28 Michael Kennedy: Yeah it's definitely interesting in that they seem to have given up on the idea of, the answer is always Windows, now what is the question? Just trying to be more part of the community and I think this is one of the places where we're starting to see some cool things out of that. This portion of Talk Python to Me is brought to you by us. As many of you know, I have a growing set of courses to help you go from Python beginner to Python novice to Python expert and there are many more courses in the works, so please consider Talk Python training for you and your team's training needs. If you're just getting started, I've built a course to teach you Python the way professional developers learn, by building applications. Check out my Python Jumpstart by building 10 apps at talkpython.fm/course. Are you looking to start adding services to your app? Try my brand-new Consuming HTTP Services in Python. You'll learn to work with RESTful HTTP services as well as SOAP, JSON, and XML data formats. Do you want to launch an online business? Well, Matt Makai and I have built an entrepreneur's playbook with Python for Entrepreneurs. This 16 hour course will teach you everything you need to launch your web-based business with Python. Finally there's a couple of new course announcements coming really soon, so if you don't already have an account, be sure to create one at training.talkpython.fm to get notified. For all of you who have bought my courses, thank you so much. It really, really helps support the show. How many contributors are working on the project?

19:55 Don Jayamanne: If you were to look at the total number of contributors, I believe there are 200, sorry, 29 contributors.

20:01 Michael Kennedy: Okay cool. Do you have the concept of a core development team or are you just managing it yourself among all these people or how does it work?

20:10 Don Jayamanne: Unfortunately it's just myself so the other contributors just contribute maybe, some of them fixes or typos here and there and I would say the major contribution has been something like adding a new linter, for instance, prospector to the extension. It's here and there but I have to acknowledge the fact that there are significant contributions.

20:34 Michael Kennedy: I'm sure it's great to have all the help. Yeah, you brought up some of the features. Let's go ahead and talk about them. One of the things that you have in there is linting and you said, somebody added just prospectors. What's the story for people who don't know? What is linting and then tell people about some of the options there.

20:51 Don Jayamanne: Yes, linting is basically just the ability to see what all of the error messages, the errors that you could have in your program. For instance, if you've written a Python code, block of code, if something isn't indented properly or if you've got some typos, some keywords are misspelled, this is where the linters would come in and tell you before the program is run these are potential issues, here are some warnings or these are some definite errors. You've got different sorts of categories. Basically a linter is like a pre-compile time error checker.

21:28 Michael Kennedy: There's a number of tools within the Python space. Which ones are built-in or do you have support for?

21:33 Don Jayamanne: In the Python space there are plenty of packages that provide linting capabilities. For instance, if I'm not mistaken the most popular ones are Pylint, Prospector, Pydoxtile, Flake8, and so on and so forth. If I were to look at these linters there are two categories. One is that checks for formatting and the other one is it looks at your code itself to check whether there are errors within the code.

21:57 Michael Kennedy: Yeah so on one hand you might have PEP8 checks. There should be no space after this comma, there should be no extra parentheses or whatever. The others might be here's an unused variable, is that a problem? Those are maybe the two categories if you put some examples on it right?

22:14 Don Jayamanne: That's correct. What's really great is I don't really have to write much code because people, our communities out there have built these tools. All I'm doing is utilizing those and displaying those results through Visual Studio Code, just surfacing it through Visual Studio Code in a consistent manner. This is where again, Visual Studio Code really excels because it provides a consistent look and feel across all languages. Whether you're using C# (C-Sharp), TypeScript or any other language, the error messages would be displayed in the same way.

22:46 Michael Kennedy: I see, your extension plugs in to that error message notification system or whatever, right?

22:52 Don Jayamanne: Yes, yes it does.

22:53 Michael Kennedy: Nice, okay so linting built in, that's pretty awesome. Lots of support for different linters, cool. Then we have Intellisense or auto-completion, including support for type-ins right?

23:04 Don Jayamanne: Yes.

23:05 Michael Kennedy: So let's talk about that a bit.

23:06 Don Jayamanne: This one's supported again, through a Python package that's been developed through David Halter, Mr. David Halter. I hope I'm pronouncing his name directly but yes, that's a great little package because all of the hard work has been done by this particular package.

23:25 Michael Kennedy: How nice, and that's called Jedi, right?

23:26 Don Jayamanne: Yes, it's called Jedi. It was developed by this individual and this particular package is used today in a couple of other editors as well. I know Atom uses it, Sublime uses it, including, if I'm not mistaken, Pycharm 2 uses it to provide Intellisense when you're debugging Python code. It's a serious package that's used by some major players out there. I've made use of it as well to provide the Intellisense capabilities for the extension. It's not just Intellisense. It gives you the ability to inspect a code and understand the structure of your code as well.

24:04 Michael Kennedy: I was pretty impressed how much of the structure of, if I'm working on a package, it understands my code and not just the standard library, things like that.

24:12 Don Jayamanne: Yes, so as you mentioned it's a really great little package so kudos to David.

24:19 Michael Kennedy: And it's awesome that you're not necessarily starting from scratch but you're able to build on this really mature thing and benefits or improvements to Jedi are improvements to your tooling as well, right?

24:30 Don Jayamanne: Yes, I think it was sometime mid to late last year that when he added support for PEP 484 and the new version. Yes I got the benefit of supporting PEP 484 and the extensions. People don't realize that the support comes through another Python package. They just seem "Wow, the extension now supports this". Well in fact, yes it does, but thanks to the Jedi plug-in.

24:58 Michael Kennedy: Yeah that's really really cool. You can look good just building on the shoulders of giants as they say. And you have support for PySpark and things like Jupyter and iPython notebooks too. What's that look like?

25:12 Don Jayamanne: Support for Pyspark and Jupyter is really very basic at this stage so what we do is we can execute certain code against one of these engines and the results, whether they are just raw output or whether you've got graphical output can be displayed. You could have two forms of graphical output. One is just a static graph or the other one is a graph that you can interact with, or interactive drafts. Those are supported as well. The reason this was added is because sometime around mid to late last year I noticed, we, when I say we, back then I was working at Microsoft. We noticed that there was quite a lot of interest in the data science community for Python developers and that's when we felt we need to add some tooling around that space so that we could draw the data science community into the Visual Studio editor.

26:09 Michael Kennedy: And also the Azure team, thee Azure Data Science Team does a lot of stuff with Python as well, right?

26:14 Don Jayamanne: That's correct. They use PySpark for some of their work. In fact, they had made some contributions to the extension to resolve some issues to ensure it worked properly with PySpark.

26:25 Michael Kennedy: So another thing you have obviously is auto-indenting. How much work was that and how did you pull that off? That's the one thing where I'm like I can't use Visual Studio Code for Python, even though I thought it was cool, I just didn't understand how to work with the structure.

26:40 Don Jayamanne: It's interesting that you ask how much work went into that. In fact, very little work went in there. If I'm not mistaken, maybe half a page of code or even less. Again, this is where Visual Studio Code excels. It just provides a capability for me to give it the rules for indentation with the use of regular expressions, and that's exactly what I did. Visual Studio Code just handles the rest. It was a really simple block of code and Visual Studio Code does everything.

27:11 Michael Kennedy: Yeah, very very cool. It's nice that that's built in. That makes adding these extensions to be cool.

27:17 Don Jayamanne: Oh yes, it made my life easier as well so I wouldn't have to just tab, tab and it was just awesome.

27:24 Michael Kennedy: You also have code formatting, like code clean-up, almost like linting?

27:28 Don Jayamanne: Yes, code formatting, just like linting as you mentioned, we've got two popular linters up there, autopep8 and yapf so once again, I'm not doing much of the work if at all, any. I'm just making use of some pre-built packages. Taking the packages that someone out there has built and provide the capabilities in Visual Studio Code. The developer using Visual Studio Code can choose the format of choice, either autopep8 or yapf and they could configure it as well. They could configure autopep8 or yapf by using the corresponding configuration files and adding in turn to the project directory.

28:07 Michael Kennedy: Oh yes, just put a config file right there and it just works.

28:10 Don Jayamanne: It just works, that is correct. That is the intention.

28:13 Michael Kennedy: That's nice, and it integrates with the command line that way as well so if you do it in Visual Studio Code it'll pick up the config files but also automated builds or something.

28:22 Don Jayamanne: Yes, so when developing this extension, one of the main requirement was people should be able to use either PyCharm or Sublime or whatever editor they prefer without trying to restrict users to keep using Visual Studio Code. There are a few places where you'd have to add custom settings into Visual Studio Code but as much as possible, you're not tied to Visual Studio Code.

28:47 Michael Kennedy: That's a really great goal or thing to keep in mind, nice. You have pretty decent refactoring support as well. Not all the refactorings maybe, but the most popular ones right?

28:58 Don Jayamanne: Yes.

28:59 Michael Kennedy: What does it support?

29:00 Don Jayamanne: The most popular ones that we felt was necessary was renaming a method name or function or variable so it's rename and extracting variables and extracting methods. Those are the two main refactoring capabilities that we wanted to add. Once again, I didn't have to do much in there. I just made use of a popular package named rope. This is rope for Python and that provides all of the refactoring capabilities Apart from the rename and extract refactoring capabilities, there's also the sorting of inputs. Again, I just made use of isort package which does the sorting of the inputs.

29:45 Michael Kennedy: That's excellent. You said that there was something about the maintainer with rope that it's a great package but it had gone dormant or something?

29:53 Don Jayamanne: Yes. When I started using rope I came across a couple of issues and then what I did was, as any other developer, was raise those issues on Github and notice that it wasn't getting looked at. That's when I learned it had gone fairly dormant. After getting in touch with the contributor, I learned that he was unable to maintain it. That's when they were, he was looking for another contributor. I've got to bring this up because it's really sad that you've got such popular tools that's in the public space that are used by hundreds of users and plenty of people rely on them and you only have just one contributor. It's really important that we all pitch in and try to pitch in as contributors.

30:38 Michael Kennedy: It can be hard too. There have been a few things wrong, this just needs a little tweak and it'll be nicer. I'll raise an issue on Github or I'll do a pull request. It feels the worst when you go, fork the repo, make the fix, you're like "This is really good now" and you do a PR and people aren't even bothered to even merge it. It's so close, just press merge! It won't even conflict. What do you do, it's tough. But on the flip side, these people have lives beyond the projects that they create. You can't really be too upset with somebody for not maintaining a thing for free, right?

31:19 Don Jayamanne: Yes, yes.

31:21 Michael Kennedy: It's just the challenge of open source. Do you think that's gonna grow? I feel like as open source grows and more people come in to this community and this way of working that it's going to be a bigger problem.

31:32 Don Jayamanne: I wouldn't say it's a problem, it's just the responsibility falls on us, the developers who are using it. We've got to pitch in as well. It's a little bit of give and take. If we're going to take something from the community, we need to give something back as well. We need to take the time to contribute, to help the contributors to resolve issues, look at some of the questions. I can see quite a lot of that happening in my project. Plenty of people come in and they answer questions that other people have and it's really great. It's really great. I guess that's what we need a lot more of.

32:10 Michael Kennedy: Nice, okay. Another thing that you have built in is viewing references in code navigation and viewing signatures and stuff and you said that also is basically just standing on the shoulders of Jedi, right?

32:23 Don Jayamanne: That's correct. Again, Jedi is the one, package that's developed by David so it provides the ability to look at your code. When you say look at your code, it gives you the structure of your code and that's where you have the ability to look at the references, code navigation or signatures.

32:40 Michael Kennedy: Nice. Code navigation and signatures, that's pretty explanatory. Viewing your references, you mean if I write a function or a class or something showing all the places in which it's used in the rest of the code across my other files.

32:52 Don Jayamanne: Yes, that's correct.

32:53 Michael Kennedy: Pretty excellent.

32:54 Don Jayamanne: So this is where again, Visual Studio Code is really great because it provides a really consistent way of navigating or viewing references. Whatever, irrespective of your language, the UX is consistent whereas if you were to go to something, I'm not mistaken, in Atom there is no consistent UX file viewing references because each author of extensions, they've got to build their own UI around these things. If I'm not mistaken, that's how it is.

33:24 Michael Kennedy: It is pretty cool that I can be there working on a Python web app and the CSS support and the Javascript support and Python support and the HTML support all have the same basic gestures and UI's and way of doing things. That's a cool extension system they built in, very nice

33:42 Don Jayamanne: Yes.

33:43 Michael Kennedy: So you have some pretty serious debugging support. When I read that I thought wow, you guys are really adding a lot of interesting things. On your page it says you have excellent debugging support including remote debugging over SSH, multiple threads, Djano, Flask and so on. How did you pull that off?

33:58 Don Jayamanne: I have to say this is one of my favorite features. I say it's one of my favorites because it's something that I use quite a lot of and it made my life a lot easier as well. Initially I have to say just add a little bit of history, the debugger was built on PDB and then once I added the debugger I noticed that plenty of people were using it and commenting on some of the issues and then I realized people are using this. Back then I was looking for a way to improve the debugging capabilities. At that time I was using both PyCharm and PTVS so that's Python Tools for Visual Studio. When I looked at the source code for PTVS I realized that their debugger was built completely in Python and that's when a lightbulb went ding and I was like "Oh." Since I've used all of these packages for Intellisense and linting, I could do the same here as well. All I did was took this Python package or Python code and built a debugger around that. Again, thanks to Microsoft and the PTVS team, the support for debugging is awesome in this, simply because of the awesome work that they've done in PTVS.

35:10 Michael Kennedy: Yeah that's really cool you're able to pull it out of there. The Python tools for Visual Studio, that's the big, more heavyweight IDE that runs on Windows. That's also open source, isn't it?

35:18 Don Jayamanne: Yes it is.

35:19 Michael Kennedy: So that was pretty easy to merge those things together. Yes.

35:36 Don Jayamanne: This portion of Talk Python to Me is brought to you by Hired. Hired is the platform for top Python developer jobs. Create your profile and instantly get access to 3,500 companies who will work to compete with you. Take it from one of Hired's users who recently got a job and said, "I had my first offer on Thursday. After going live on Monday, I ended up getting eight offers in total. I've worked with recruiters in the past, but they've always been pretty hit-and-miss. I tried LinkedIn but I found Hired to be the best." "I really like knowing the salary up front. Privacy was also a huge seller for me." Sounds awesome, doesn't it? Well, wait until you hear about the signing bonus. Everyone who accepts a job from Hired gets $1,000 signing bonus, and as Talk Python listeners, it gets way sweeter. Use the link hired.com/talkpythontome and Hired will double the signing bonus to $2,000. Opportunity is knocking. Visit hired.com/talkpythontome and answer the door. And of course, unit testing with all the frameworks.

36:35 Michael Kennedy: Yes, unit testing. It supports the three major frameworks. Unit test built into Python, there's pytest and nose test. Initially I started out with just adding support for unit tests and then from that, adding support for pytests and nose tests was very easy as well. Just as the linters and formaters, these are just treated as separate packages. All we do is we just need, if one were to run unit tests as a Python developer, you would just go the command prompt and run these tests. That's pretty much what I am doing, I'm just running these things in a shell and capturing the output and surfacing it to the user.

37:17 Don Jayamanne: Does it appear in a console or does it do more like, highlight some of the code with coverage? Does it affect the UI and the editor or is it more like here's the console and the outcome?

37:28 Michael Kennedy: At this stage it's primarily in a little console because there is, Microsoft, if I'm not mistaken, they do not have a UI for unit test. Back when I was working on this extension which was last year, they did not have anything. They were looking at adding support for some UI because this is something they need across other languages as well. Just as viewing references or debugging where you've got consistent look and feel for these capabilities, it's something that they didn't have for unit tests. At this stage, it's just console window.

38:03 Don Jayamanne: Yeah, that makes sense. There's a little console that can be in the bottom of the editor, a little like Pycharm right?

38:08 Michael Kennedy: Yes, however what we have added is for each class or method, there is something that, what we've got is we've got something called Code Linters. Basically it's just this floating link or floating text you can click on to run or debug a unit test. It's fairly easy. Once you've got a block of code and if it's a unit test, you've got some link within the code that you can click on.

38:34 Don Jayamanne: That's cool, there's a little button next to the test method in your unit test itself and you can just click that and run the one?

38:40 Michael Kennedy: Yes, that's correct.

38:41 Don Jayamanne: Oh sweet. Do you have any support for profiling?

38:44 Michael Kennedy: At this stage, no. It's something that has been requested by a number of people so it's something that I'm looking at adding. No, it isn't supported at this stage.

38:54 Don Jayamanne: One thing I thought was cool that seems like you support pretty well is virtual environments and Python versions and things like that. Do you want to talk about how, whether you've got that or how it works?

39:06 Michael Kennedy: Yes, virtual environments are supported. Initially it took me a while to get this working. I would say it took a couple of iterations to get this working. The way virtual environments are supported, in the extension, all I do is it's up to the developer to define the location of the virtual environment. You could have virtual environments within the project directory or somewhere else, so I have no idea. I'm not going to try looking for it. It's up to the developer to define it in the settings files. This is one of those places where you have custom Visual Studio Code specific settings. It's a file named settings.json. You have to find the path and the name of the setting is Python Path. So you define the name, the path to the Python interpreter. To make life easier, what we've got is a little shortcut. You go into this particular menu item and launch a particular command palette which says select the Python interpreter. What we do is in the extension, try to look for the common locations where you could have the Python interpreters or your virtual environments, whether it's in the current directory or some other known locations. We looked through those directories and list it out to you so all you have to do is, from that list box, you just select it and done. If it's not there, you'd have to just manually type it and that's it.

40:30 Don Jayamanne: That's pretty nice because I do almost all of my, at least my web projects, almost all of them from... Each website gets it's own virtual directory and having that there I'm like I don't know if I can edit this thing because of Virtual Studio Code, 'cause it's all the stuff installed over here, I'm like, oh wait I totally have support for that, it's very cool. You also have like little Python terminals and local help, those are all great. I guess the last major feature is our snippets. What are snippets and what are the nice ones you got?

40:59 Michael Kennedy: Snippets, I won't say they're nice ones but it's basically, certain snippets like having a try-snippet just for a class. Those are the kind of snippets that I have in there. I wouldn't say there are some really great snippets but it's something that just makes life a little bit easier.

41:17 Don Jayamanne: I see, so I can just type and hit try and hit tab and it will expand out to tricolon pass, accept expression, as identifier, or I could do, could I do width?

41:28 Michael Kennedy: Yes.

41:28 Don Jayamanne: With blocks? Just the common structures of if and whatnot.

41:34 Michael Kennedy: That's correct.

41:36 Don Jayamanne: Very nice. Can we add our own? If we're like "This is cool, I'd like to have it do this when I hit tab" and it doesn't.

41:43 Michael Kennedy: Good question. I have no idea. I haven't had this question been asked by anyone on Github so I wouldn't be surprised if it were possible, however I'm not sure. I have no idea to answer the question, I don't know. That's a really good question though.

41:59 Don Jayamanne: Alright, maybe I'll file a Github issue and you can say yes or no, we'll add it. It sounds to me like to some degree you've done obviously a large amount of work, but what makes it look like it would be extreme work, the remote debugging, multi-threading over SSH shells, things like that come from other packages actually. How much of this is pulling other packages together?

42:24 Michael Kennedy: I would say the majority of it if not all of it has been done by the other packages. As I mentioned earlier, the code is primarily written in NodeJS or TypeScript because that's what Visual Studio Code is built on top of and to provide the capabilities for individual language features like Intellisense, debugging, linting, all of that is done through individual Python packages so all I'm doing is just making use of them.

42:50 Don Jayamanne: That's really cool. How do you do the interprocess communication between Python, the Python packages and the NodeJS stuff that is running Visual Studio Code?

43:01 Michael Kennedy: That's fairly simple. For something such as linting or code formatting, all I'm doing is, in the background I'm launching a particular process, a Python process and running the corresponding Python package against the particular file, particular block of code. I just capture the output and display it. For some of them it's not as straightforward as that. For instance, with the debugger, what I've got to do is I start the Python package which is the debugging package and communicate with that process using sockets. Some places it's different, for instance, debugging and running unit tests I'd use sockets and the others it's basically simple communication, just reading the output from the--

43:45 Don Jayamanne: Just shell out and capture it. How much time did you spend on getting this all up and running do you think? How long from December till it's more or less looking like what it is now?

43:57 Michael Kennedy: Around May it was, we had quite a lot of the capabilities built in apart from running unit tests and adding support for Pyspark and Jupiter. Until then there was plenty of support for linters, debugging and code formatting. I would say half of it around May and then the remainder was completed around November of last year. Just under a year, it took just under a year to complete everything.

44:29 Don Jayamanne: That was mostly you, right?

44:31 Michael Kennedy: Yes, that's correct.

44:33 Don Jayamanne: That's a lot of cool stuff that you got out in that short amount of time, nice.

44:37 Michael Kennedy: It was really interesting working on this. As I mentioned, when I started out this pet project of mine it was just early in the morning and then over time I realized it was getting really popular and that kept motivating me because there are plenty of people using it. Like, this is really doing well. Let's just keep turning more code, putting more features in there.

44:59 Don Jayamanne: That's awesome. I think two really motivating things about writing software are, one of them is you get to either work with a really cool technology or the thing that you're actually building is a cool technology or some combination thereof and the other is that lots of people use and appreciate whatever it is you built, right?

45:17 Michael Kennedy: Yes, I think the most important thing was the appreciation because even though there was plenty of people downloading it, getting to know that people appreciate the work that you've done, it makes a big difference.

45:30 Don Jayamanne: Yeah, I'm sure. What other, if you get something with a million downloads, what other opportunities come with that? Have people reached out to you to do cool stuff?

45:41 Michael Kennedy: I did get one opportunity and that was Microsoft. They approached me around early May last year. They approached me and they asked me if I would like to join the Visual Studio Code team and work full time on this extension. They saw that it was a great extension and they wanted me to spend full time on it so that it could be polished and it would be featured complete. When I saw feature complete we could take the time out to iron out some wrinkles and ensure it integrates well with Visual Studio Code and if there was something that I wanted added into the code product I could do that myself as well.

46:16 Don Jayamanne: That's pretty awesome.

46:17 Michael Kennedy: It was really great, it was. That's when I gave up my 10 year role at a previous place and was like yes, I will jump ship.

46:27 Don Jayamanne: Yeah you get to get paid to work on such a cool project. I've seen them do that before, hire people to basically continue to work on something they saw really valuable that was integrating in the style, that's great. Are you still working there on it or have you got it where it needs to be?

46:42 Michael Kennedy: My contract ended last year. It was a six-month contract but no regrets there. Enjoyed the time while there, working for Microsoft. I've moved on since then.

46:54 Don Jayamanne: I want to ask you about the other extensions you've written because you have a habit of writing Visual Studio Code extensions apparently. There's some cool ones. Before I do, I want to ask you is there a way to write extensions for your Python thing? If I had something I wanted to add, is there a way, how can I exchange or extend what you've done? Do I have to go to a PR directly against it or is there some other way to get in there?

47:19 Michael Kennedy: It's just a PR so pull the recode down to your local machine and make the changes. As I mentioned, it's all done in NodeJS so you've got to use TypeScript to make the changes.

47:31 Don Jayamanne: Okay, very cool. Let's just really briefly touch on some of the others that you've written.

47:36 Michael Kennedy: I'll just go through the major extensions that I've developed. One is the Java debugger. Back then I was playing around a little bit with Java as well and I was looking around for the ability to debug Java code and I really hated the Eclipse or the others because it was just too bulky and it took a long time to load up. Then I had some experience with PDB and I figured I could build a Java debugger as well using the similar concepts and that's exactly what I did. I built a Java debugger. It's not as popular but there are plenty of people using that. The other extension is Create Unique IDs. Basically it's just the ability to create unique IDs like GUIDs or random numbers and it inserts it into the text. Then there's Boa or Boa, it's just a little tool to restore Boa packages. It was popular in the early days when Visual Studio Code didn't have an integrated terminal but now it does. For Python developers, basically it's a tool to restore dependencies from your requirements of TXT file. That's pretty much it. If you've got the terminal, you can do it using the terminal. That's why it's no longer popular. The next most popular extension that I have is Git History. I built this again for personal use. I was offering an extension that I could use to look at the git history log. Built this one again, using TypeScript and it's just a wraparound to Git. At this stage it's quite popular. If I were to bring numbers, it's the 12th most popular extension out there with around 350,000 downloads. I have to say that currently it's being maintained primarily by Mike Surcouf, not sure how it's pronounced. He's the one who's looking at all of the contributions at this stage while I focus on Python and the others.

49:40 Don Jayamanne: Yeah, that's cool.

49:41 Michael Kennedy: Lastly, the other extension is JQuery Code Snippets. That's a simple extension that gives you a lot of snippets for JQuery.

49:48 Don Jayamanne: Okay that will be really nice. Are you working on any new ones?

49:51 Michael Kennedy: There is one that I'm trying to work on. I just haven't been doing much work on that for the past couple of weeks. It's pulling the code which supports Jupyter out of the Python extension because there are other languages that could use the Jupyter kernel, it's not just Python. I'm just trying to pull that out so others could use that, or other languages could make use of it.

50:16 Don Jayamanne: Okay, that'll be really nice to separate those if people want to use them in R or whatever. Okay nice. I think people have a pretty good idea of this extension. It's all open source, it's all free so if you're looking to try a pretty seriously rich Python editor across platform for Linux, OS10, or macOS and Windows, then check out Visual Studio Code and go check out the extensions and pick... Basically pull up the extensions and you're number two, right? I guess search for Python if it doesn't show up. There's more than just your extension for Python. Yours is, what's the exact name?

50:55 Michael Kennedy: It's just Python.

50:58 Don Jayamanne: Just Python. So you got the straight up name all by itself, awesome. Let me ask you two questions before we go and give you a chance to let people know what they can do to get started or help out. I'm not really expecting a surprise here but what's your favorite editor when you write some Python Code?

51:17 Michael Kennedy: I would say it is Visual Studio Code simple. That is something I can use across both the Mac and Windows and it's very lightweight. I can go to a different PC, just download it, install, done. It's just super lightweight and easy to use.

51:33 Don Jayamanne: Okay, very nice. Favorite PyPI package?

51:36 Michael Kennedy: I would say there are two. One is the Jedi. It's not something that I use on a day-to-day basis on every project, but it's something that I've used in the Python extension and I really value that. As a developer, the favorite package would be requests.

51:55 Don Jayamanne: That's definitely a popular one. That's a really great package.

51:58 Michael Kennedy: Alright Don, final call to action. Are you looking for people to work on this project, help out, give you feedback? What can the listeners do?

52:06 Don Jayamanne: Oh yes, any contribution is really welcome. At this stage, there are two major items that I need to work on. One is profiling and that doesn't look too complicated. The other is adding support for remote interpreters. This is where you do not have Python installed locally but it's running on a different machine, maybe on a docker container or something and you're editing your Python files locally. That's something that plenty of people have requested. It's not just that. Any contribution really welcome, I really appreciate that. Alright and the future for the extension? Where are you going with this thing?

52:44 Michael Kennedy: I'll just keep trying to extend it and adding more capabilities. The way I do this is by looking at other IDE's and adding capabilities from there for instance. Looking at a PTVS is or PyCharm support and I'd think maybe I can add that and try to plug it in here.

53:03 Don Jayamanne: Very cool. Thank you for contributing this editor. It's definitely got a lot of features and is pretty unique. Thanks for creating it and thanks for sharing your story with everyone.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon