1 00:00:00,420 --> 00:00:05,910 [Music] 2 00:00:10,880 --> 00:00:17,760 Hello everyone and welcome back to talk 3 00:00:14,400 --> 00:00:19,840 two of this session. So today we have uh 4 00:00:17,760 --> 00:00:22,000 Ramon Perez talking about building with 5 00:00:19,840 --> 00:00:25,760 multiple languages a Python first 6 00:00:22,000 --> 00:00:30,080 approach and this is Ramon's first PyCon 7 00:00:25,760 --> 00:00:32,719 AU. So give him a big warm PON welcome 8 00:00:30,080 --> 00:00:34,880 and uh I'll hand it over to you. 9 00:00:32,719 --> 00:00:36,960 Fantastic. Thank you Ash. Um good 10 00:00:34,880 --> 00:00:40,239 morning everyone. Yep. It is my first 11 00:00:36,960 --> 00:00:43,040 time speaking at PyCon Australia. I have 12 00:00:40,239 --> 00:00:45,440 all um nonetheless spoke at quite a few 13 00:00:43,040 --> 00:00:48,480 conferences uh fortunately across the 14 00:00:45,440 --> 00:00:50,480 world and some of them PyCon some of them 15 00:00:48,480 --> 00:00:52,719 uh sci 16 00:00:50,480 --> 00:00:55,520 uh different conferences around 17 00:00:52,719 --> 00:00:57,280 programming. Uh but I also don't want to 18 00:00:55,520 --> 00:00:58,559 perk up myself too much cuz then I don't 19 00:00:57,280 --> 00:01:01,039 want to disappoint you guys if it's too 20 00:00:58,559 --> 00:01:03,120 bad. Um and if I make a mistake as well. 21 00:01:01,039 --> 00:01:04,640 So yeah. So at the beginning of the year 22 00:01:03,120 --> 00:01:05,680 and throughout the last two years I have 23 00:01:04,640 --> 00:01:07,920 been building with a with different 24 00:01:05,680 --> 00:01:09,119 languages. And in particular since the 25 00:01:07,920 --> 00:01:13,920 beginning of this year I was working on 26 00:01:09,119 --> 00:01:17,439 a tool that um uses C++ and uses Python. 27 00:01:13,920 --> 00:01:21,200 And before I had a lot of appreciation 28 00:01:17,439 --> 00:01:24,080 for the things that Python does really 29 00:01:21,200 --> 00:01:26,159 well. And after working with C++, I have 30 00:01:24,080 --> 00:01:29,119 an even greater appreciate appreciation 31 00:01:26,159 --> 00:01:31,840 of what Python does well. So take that 32 00:01:29,119 --> 00:01:34,479 as you may. It's not not negative nor uh 33 00:01:31,840 --> 00:01:36,720 it is uh you know it's a very neutral 34 00:01:34,479 --> 00:01:38,960 comment. Uh so yeah, so today we're 35 00:01:36,720 --> 00:01:40,320 going to be talking about how to uh 36 00:01:38,960 --> 00:01:41,680 build with multiple languages. I'm going 37 00:01:40,320 --> 00:01:43,759 to show you a bunch of examples. I have 38 00:01:41,680 --> 00:01:46,000 a lot of live examples and I have 39 00:01:43,759 --> 00:01:48,880 figured out how to connect components on 40 00:01:46,000 --> 00:01:50,320 the browser to my slides with a server 41 00:01:48,880 --> 00:01:51,520 running on the background with the 42 00:01:50,320 --> 00:01:53,280 things that I'm going to show you. So 43 00:01:51,520 --> 00:01:55,600 hopefully that that goes well. We all 44 00:01:53,280 --> 00:01:59,600 know the demo gods sometimes are not 45 00:01:55,600 --> 00:02:02,479 very welcoming of people of of us mere 46 00:01:59,600 --> 00:02:04,479 mortals in the programming lab. So all 47 00:02:02,479 --> 00:02:06,719 right so let's begin. So the usual 48 00:02:04,479 --> 00:02:08,640 options when you want to build with uh 49 00:02:06,719 --> 00:02:10,640 multiple languages are usually you 50 00:02:08,640 --> 00:02:12,879 accept the pain uh you know it is fine 51 00:02:10,640 --> 00:02:14,720 we can wait 30 seconds uh you know the 52 00:02:12,879 --> 00:02:16,319 famous last words without getting fired 53 00:02:14,720 --> 00:02:18,000 those might be and then the option two 54 00:02:16,319 --> 00:02:19,840 is like let's rewrite everything our 55 00:02:18,000 --> 00:02:22,319 entire ML pipeline in roster or whatever 56 00:02:19,840 --> 00:02:23,680 it might be. um 18 months later, you're 57 00:02:22,319 --> 00:02:25,040 still sort of trying to figure it out, 58 00:02:23,680 --> 00:02:26,400 but it's coming along. It's coming along 59 00:02:25,040 --> 00:02:28,560 well. Now, that's not to say that 60 00:02:26,400 --> 00:02:30,480 there's not fantastic 61 00:02:28,560 --> 00:02:33,440 programs and projects that have 62 00:02:30,480 --> 00:02:35,519 absolutely nailed execution on both uh 63 00:02:33,440 --> 00:02:37,200 ends of the spectrum, the low-level 64 00:02:35,519 --> 00:02:38,640 programming language and also the more 65 00:02:37,200 --> 00:02:41,280 high level programming language. So, 66 00:02:38,640 --> 00:02:43,760 that's just, you know, a very broad take 67 00:02:41,280 --> 00:02:45,519 on both aspects. Um but then, so if you 68 00:02:43,760 --> 00:02:47,040 think about Python, I think this analogy 69 00:02:45,519 --> 00:02:48,480 has been used before, but I'm also going 70 00:02:47,040 --> 00:02:51,599 to take it as well like it's kind of 71 00:02:48,480 --> 00:02:53,840 like an orchestrator. um or a maestro in 72 00:02:51,599 --> 00:02:55,360 an orchestra orchestra where you have 73 00:02:53,840 --> 00:02:57,440 all these programming languages and you 74 00:02:55,360 --> 00:02:59,519 want to bring them all into one place. 75 00:02:57,440 --> 00:03:02,000 So you have the JavaScript where you can 76 00:02:59,519 --> 00:03:03,519 do real-time UIs. Um you have Rust where 77 00:03:02,000 --> 00:03:05,440 you can do a lot of heavy data 78 00:03:03,519 --> 00:03:06,959 processing um and not just data 79 00:03:05,440 --> 00:03:08,879 processing but a lot of a lot of things 80 00:03:06,959 --> 00:03:10,480 that perhaps are better handled by 81 00:03:08,879 --> 00:03:12,480 taking advantage of all of the resources 82 00:03:10,480 --> 00:03:15,599 in your machine versus only some 83 00:03:12,480 --> 00:03:19,120 resources in your machine. And then um 84 00:03:15,599 --> 00:03:20,800 the other piece uh so oops I went a 85 00:03:19,120 --> 00:03:22,800 little bit ahead. So but rather than 86 00:03:20,800 --> 00:03:25,680 orchestrate everything we can actually 87 00:03:22,800 --> 00:03:28,640 glue a lot of things with Python. Um and 88 00:03:25,680 --> 00:03:32,319 so this is not new. Python was released 89 00:03:28,640 --> 00:03:34,159 uh officially in 1991. Um and it was 90 00:03:32,319 --> 00:03:36,400 designed as a glue language for C 91 00:03:34,159 --> 00:03:38,319 libraries. Um, and as a matter of fact, 92 00:03:36,400 --> 00:03:39,760 the actual name, I don't know if some of 93 00:03:38,319 --> 00:03:43,360 you know this, uh, but the actual name 94 00:03:39,760 --> 00:03:47,200 of Python in, uh, the repo of Python in 95 00:03:43,360 --> 00:03:49,440 GitHub is actually CPython. And so it 96 00:03:47,200 --> 00:03:52,400 also alludes to the fact that it is 97 00:03:49,440 --> 00:03:55,120 built on top of C. Uh, so in 1995, 98 00:03:52,400 --> 00:03:58,239 Numpai started wrapping blast and lapac, 99 00:03:55,120 --> 00:04:02,239 which are for libraries. uh in 2007, 100 00:03:58,239 --> 00:04:04,319 Syon uh made its debut where it started 101 00:04:02,239 --> 00:04:07,439 giving us a nicer interface for writing 102 00:04:04,319 --> 00:04:10,560 low-level co code in C and then also 103 00:04:07,439 --> 00:04:14,400 being able to still stay in Python lung. 104 00:04:10,560 --> 00:04:18,160 Then in 2016, Py PyTorch was officially 105 00:04:14,400 --> 00:04:20,239 released uh with a uh Python bindings on 106 00:04:18,160 --> 00:04:23,680 top of C++. I believe before that it was 107 00:04:20,239 --> 00:04:25,199 written in Lua. Um, and then in 2023, 108 00:04:23,680 --> 00:04:27,199 half of Python's ecosystem is now 109 00:04:25,199 --> 00:04:28,639 written uh running on ROSS. That's a bit 110 00:04:27,199 --> 00:04:31,280 of a that's a bit of a joke. No, it's 111 00:04:28,639 --> 00:04:33,280 not every project out there, but so the 112 00:04:31,280 --> 00:04:34,880 web stack that you're using right now 113 00:04:33,280 --> 00:04:36,000 most likely also have a little bit of a 114 00:04:34,880 --> 00:04:37,759 component with Python. You might have 115 00:04:36,000 --> 00:04:39,360 the front end or you will most likely 116 00:04:37,759 --> 00:04:41,600 have the front end in JavaScript and so 117 00:04:39,360 --> 00:04:43,360 on. Uh, but the most notable examples 118 00:04:41,600 --> 00:04:45,919 today that you might recognize is that 119 00:04:43,360 --> 00:04:47,840 Jupyter notebooks um are in the front 120 00:04:45,919 --> 00:04:49,199 end. They have pure JavaScript. I 121 00:04:47,840 --> 00:04:51,199 believe the actual notebook and there 122 00:04:49,199 --> 00:04:52,960 are some implementations that also use 123 00:04:51,199 --> 00:04:55,199 frameworks frameworks in JavaScript that 124 00:04:52,960 --> 00:04:56,720 are react and so on. But then you also 125 00:04:55,199 --> 00:04:58,400 you have the kernel which is the thing 126 00:04:56,720 --> 00:04:59,680 that runs the code that you execute from 127 00:04:58,400 --> 00:05:02,240 the front end and send it to the back 128 00:04:59,680 --> 00:05:04,560 end and that is written in Python. You 129 00:05:02,240 --> 00:05:07,199 have PyTorch which is core C++ and CUDA. 130 00:05:04,560 --> 00:05:09,039 CUDA is also in C++ with bindings into 131 00:05:07,199 --> 00:05:11,280 Python and then it compiles using the 132 00:05:09,039 --> 00:05:13,919 LVM compiler. Then you have mother 133 00:05:11,280 --> 00:05:16,320 tooling like UV uh written in Ross. You 134 00:05:13,919 --> 00:05:18,639 have rough, you have paidantic uh which 135 00:05:16,320 --> 00:05:21,680 recently released their v1. Um they have 136 00:05:18,639 --> 00:05:24,000 a really fantastic um fantastic product. 137 00:05:21,680 --> 00:05:26,639 So u then you also have the Linux kernel 138 00:05:24,000 --> 00:05:28,080 who has that has the committee and the 139 00:05:26,639 --> 00:05:31,520 people behind the Linux kernel has 140 00:05:28,080 --> 00:05:33,120 recently um accepted to my knowledge a 141 00:05:31,520 --> 00:05:36,560 couple of contributions written written 142 00:05:33,120 --> 00:05:38,240 in Ross. So the division of labor for 143 00:05:36,560 --> 00:05:40,400 this talk is that we have a few 144 00:05:38,240 --> 00:05:43,520 practical patterns. I want to show you 145 00:05:40,400 --> 00:05:45,199 um one of the most to me at least 146 00:05:43,520 --> 00:05:46,560 difficult things to do when you get 147 00:05:45,199 --> 00:05:49,039 started building with multiple languages 148 00:05:46,560 --> 00:05:51,520 is how do I architect the project that I 149 00:05:49,039 --> 00:05:53,919 have what do I put in each directory and 150 00:05:51,520 --> 00:05:56,160 what do I put in this other one how do I 151 00:05:53,919 --> 00:05:57,840 build the skeleton of my pi project 152 00:05:56,160 --> 00:05:59,280 tommo if I'm still using that if I'm 153 00:05:57,840 --> 00:06:02,000 using that one there are people that 154 00:05:59,280 --> 00:06:03,520 still are still using setup uh setup py 155 00:06:02,000 --> 00:06:05,360 and so on there's nothing wrong with 156 00:06:03,520 --> 00:06:07,440 either approach but how do I architect a 157 00:06:05,360 --> 00:06:08,560 project if I have decided to go down the 158 00:06:07,440 --> 00:06:09,440 route of building with multiple 159 00:06:08,560 --> 00:06:10,800 languages 160 00:06:09,440 --> 00:06:13,600 And then we're going to talk about a 161 00:06:10,800 --> 00:06:14,960 little bit of production ready in quotes 162 00:06:13,600 --> 00:06:17,840 because I am going to show you a couple 163 00:06:14,960 --> 00:06:20,800 of things that work in here. But um from 164 00:06:17,840 --> 00:06:22,880 here to a server um that you have to 165 00:06:20,800 --> 00:06:24,400 monitor. There's a few caveats. So I am 166 00:06:22,880 --> 00:06:27,120 also going to show you how would you 167 00:06:24,400 --> 00:06:29,840 approach deploying those service 168 00:06:27,120 --> 00:06:31,440 services and um and put them in 169 00:06:29,840 --> 00:06:33,199 production and test them. I'm going to 170 00:06:31,440 --> 00:06:35,199 give you a matrix of steps that you can 171 00:06:33,199 --> 00:06:37,680 take and follow so that you can scratch 172 00:06:35,199 --> 00:06:39,600 each one of those off as you do. So the 173 00:06:37,680 --> 00:06:42,639 far one let's talk about architecture. 174 00:06:39,600 --> 00:06:45,120 So when you think about a decision tree 175 00:06:42,639 --> 00:06:47,039 um you or just a decision a set of 176 00:06:45,120 --> 00:06:50,160 decisions to start to say like I am 177 00:06:47,039 --> 00:06:52,560 going to use or follow the polyglot 178 00:06:50,160 --> 00:06:55,520 route. You say is part is python 179 00:06:52,560 --> 00:06:57,199 actually the bottleneck or is it I am 180 00:06:55,520 --> 00:06:59,599 guilty of this. Is it really bad written 181 00:06:57,199 --> 00:07:02,960 code? Uh it could it could very well be. 182 00:06:59,599 --> 00:07:05,199 Um so profile first. Uh is Python slow? 183 00:07:02,960 --> 00:07:07,199 Python is slow. It's not the profiling. 184 00:07:05,199 --> 00:07:09,520 Okay fine. Fair enough. Can you solve it 185 00:07:07,199 --> 00:07:11,120 with a better algorithm? Sometimes uh we 186 00:07:09,520 --> 00:07:13,120 can throw a bunch of numbers and the 187 00:07:11,120 --> 00:07:15,520 complexity grows linearly. Sometimes it 188 00:07:13,120 --> 00:07:17,919 doesn't. Uh but if it doesn't, okay, 189 00:07:15,520 --> 00:07:20,240 fine. Is it worth the complexity? Well, 190 00:07:17,919 --> 00:07:23,199 let's rewrite it in ROS. Things said 10 191 00:07:20,240 --> 00:07:25,440 minutes before disaster. And which again 192 00:07:23,199 --> 00:07:26,560 is so it's all a fun take on it. I I 193 00:07:25,440 --> 00:07:29,440 like the language. I think it's 194 00:07:26,560 --> 00:07:31,280 fantastic. Um I 195 00:07:29,440 --> 00:07:32,720 there's some value to get from every 196 00:07:31,280 --> 00:07:34,880 single one of the languages that have 197 00:07:32,720 --> 00:07:38,000 had so much love and care put into it 198 00:07:34,880 --> 00:07:40,160 out there. So if yes then do embrace the 199 00:07:38,000 --> 00:07:42,800 poly and then go follow that route. So 200 00:07:40,160 --> 00:07:45,039 the 9010 rule is that whatever you can 201 00:07:42,800 --> 00:07:46,880 offload to Python actually do keep it in 202 00:07:45,039 --> 00:07:48,319 Python. So if you have some data loading 203 00:07:46,880 --> 00:07:50,000 and that has already been written don't 204 00:07:48,319 --> 00:07:51,440 rewrite it just because you think you 205 00:07:50,000 --> 00:07:53,280 can make a better data loader and it's 206 00:07:51,440 --> 00:07:55,120 already there. Um and and also I'm just 207 00:07:53,280 --> 00:07:57,120 giving you rules of thumbs. Um the 208 00:07:55,120 --> 00:07:59,280 configuration piece Python is fantastic 209 00:07:57,120 --> 00:08:01,039 as a configuration language. So perhaps 210 00:07:59,280 --> 00:08:03,039 there's no need to rewrite that in the 211 00:08:01,039 --> 00:08:05,440 other language that you're about to add 212 00:08:03,039 --> 00:08:08,080 to your um to your project. and then 213 00:08:05,440 --> 00:08:09,840 error handling, APIs and UIs. Perhaps 214 00:08:08,080 --> 00:08:12,080 all of that can actually be managed by 215 00:08:09,840 --> 00:08:14,240 Python. There are instances where it 216 00:08:12,080 --> 00:08:16,720 perhaps shouldn't, but that's up to you 217 00:08:14,240 --> 00:08:18,160 and your team to decide. Um, the 10% of 218 00:08:16,720 --> 00:08:20,400 your code that does do the heavy 219 00:08:18,160 --> 00:08:22,080 lifting, then do the number crunching, 220 00:08:20,400 --> 00:08:23,599 do the real-time processing, do the 221 00:08:22,080 --> 00:08:25,680 graphics rendering, do the network 222 00:08:23,599 --> 00:08:28,080 protocols and so on. So, optimize the 223 00:08:25,680 --> 00:08:30,879 10% and offload the rest is the key 224 00:08:28,080 --> 00:08:32,880 takeaway of that. So, common patterns. 225 00:08:30,879 --> 00:08:34,560 Now, we get into what exactly are we 226 00:08:32,880 --> 00:08:36,719 going to do. So the first one is the 227 00:08:34,560 --> 00:08:38,800 sidecar. Um there's a fantastic book 228 00:08:36,719 --> 00:08:41,360 book called data science at the command 229 00:08:38,800 --> 00:08:43,120 line that teaches you how to do a lot of 230 00:08:41,360 --> 00:08:44,880 really cool stuff and really interesting 231 00:08:43,120 --> 00:08:47,360 stuff from the command line. And one of 232 00:08:44,880 --> 00:08:49,440 the easiest places to get started with 233 00:08:47,360 --> 00:08:50,800 when you are building using multiple 234 00:08:49,440 --> 00:08:53,120 languages is that if you already have 235 00:08:50,800 --> 00:08:55,440 the package that gives you the 10 10x 236 00:08:53,120 --> 00:08:57,360 boost or you already have the library 237 00:08:55,440 --> 00:09:01,120 that allows you to do a lot of complex 238 00:08:57,360 --> 00:09:03,200 stuff and is it is implemented as a CLI 239 00:09:01,120 --> 00:09:04,959 then you can call the subprocess.run run 240 00:09:03,200 --> 00:09:06,480 and then run that thing from Python so 241 00:09:04,959 --> 00:09:08,320 long as it is available in the host 242 00:09:06,480 --> 00:09:10,080 operating system. So then the second 243 00:09:08,320 --> 00:09:12,160 pattern is well perhaps we do a 244 00:09:10,080 --> 00:09:13,440 microser. So if you don't interact with 245 00:09:12,160 --> 00:09:16,880 a different programming language with 246 00:09:13,440 --> 00:09:19,120 the kernel of a uh a operating system 247 00:09:16,880 --> 00:09:20,880 directly with a specific functions that 248 00:09:19,120 --> 00:09:22,240 you really need to tackle directly then 249 00:09:20,880 --> 00:09:23,839 the next best thing is to put them in a 250 00:09:22,240 --> 00:09:26,720 server and then connect to them or talk 251 00:09:23,839 --> 00:09:29,839 to them via local host via httpx via 252 00:09:26,720 --> 00:09:31,839 https sorry http and then the third 253 00:09:29,839 --> 00:09:34,160 pattern is uh well build an extension 254 00:09:31,839 --> 00:09:36,399 build bindings for that uh for that 255 00:09:34,160 --> 00:09:39,040 module. So what I'm trying to hint with 256 00:09:36,399 --> 00:09:41,040 this or what I'm trying to um allude is 257 00:09:39,040 --> 00:09:42,399 that there's two steps before you 258 00:09:41,040 --> 00:09:45,360 actually have to create bindings for 259 00:09:42,399 --> 00:09:47,920 another pro for um connecting Python to 260 00:09:45,360 --> 00:09:50,560 another project. And then the last step 261 00:09:47,920 --> 00:09:52,480 is like you can actually create a bridge 262 00:09:50,560 --> 00:09:54,240 where you are talking via real time via 263 00:09:52,480 --> 00:09:56,720 websockets. That's a little bit that has 264 00:09:54,240 --> 00:09:58,880 a little bit of um it can add a little 265 00:09:56,720 --> 00:10:00,399 bit of um complexity but it can 266 00:09:58,880 --> 00:10:02,800 definitely improve the speed. And I 267 00:10:00,399 --> 00:10:05,040 would actually move this one before the 268 00:10:02,800 --> 00:10:06,959 extension before the actual bindings. 269 00:10:05,040 --> 00:10:09,120 Um, okay. So if you think about a data 270 00:10:06,959 --> 00:10:10,880 flow archite architecture, you have your 271 00:10:09,120 --> 00:10:12,800 Python orchestrator, you have the data 272 00:10:10,880 --> 00:10:14,640 validation, and then you have the switch 273 00:10:12,800 --> 00:10:17,279 where you say, is this performance 274 00:10:14,640 --> 00:10:18,640 performance critical or not? If so, then 275 00:10:17,279 --> 00:10:21,040 can I offload it to another programming 276 00:10:18,640 --> 00:10:22,399 language to something low-level or is is 277 00:10:21,040 --> 00:10:24,800 this something that I just cannot 278 00:10:22,399 --> 00:10:26,320 display? Can anybody tell me why why is 279 00:10:24,800 --> 00:10:30,560 the main reason why we combine 280 00:10:26,320 --> 00:10:32,480 JavaScript uh with Python? 281 00:10:30,560 --> 00:10:34,640 The browser. Exactly. And why do we go 282 00:10:32,480 --> 00:10:36,959 to the browser and not to Pygame for 283 00:10:34,640 --> 00:10:37,920 example to create a game or to do 284 00:10:36,959 --> 00:10:38,560 something? 285 00:10:37,920 --> 00:10:39,279 Sorry. 286 00:10:38,560 --> 00:10:41,040 Accessibility. 287 00:10:39,279 --> 00:10:43,519 Accessibility. Yeah. Distribution. The 288 00:10:41,040 --> 00:10:45,279 browser is the biggest graphics engine 289 00:10:43,519 --> 00:10:48,000 that just gives us access to 290 00:10:45,279 --> 00:10:49,200 distribution immediately. And um 291 00:10:48,000 --> 00:10:50,720 sometimes the decision is not 292 00:10:49,200 --> 00:10:54,240 necessarily about performance, but it's 293 00:10:50,720 --> 00:10:56,959 just about flexibility. Should I make a 294 00:10:54,240 --> 00:10:58,800 native application and spend a lot more 295 00:10:56,959 --> 00:11:00,240 time configuring that and making sure it 296 00:10:58,800 --> 00:11:02,000 runs on every device and every operating 297 00:11:00,240 --> 00:11:04,160 system or should I just worry about the 298 00:11:02,000 --> 00:11:06,640 browser that the user has? Sometimes the 299 00:11:04,160 --> 00:11:09,040 latter is better than the former. Okay, 300 00:11:06,640 --> 00:11:11,760 so the integration matrix go via soft 301 00:11:09,040 --> 00:11:13,040 processes if the tool is already if you 302 00:11:11,760 --> 00:11:14,560 can assume that the tool is already 303 00:11:13,040 --> 00:11:16,399 available in the operating system. If 304 00:11:14,560 --> 00:11:18,240 you're putting this on a server, you you 305 00:11:16,399 --> 00:11:20,000 have complete control onto what gets 306 00:11:18,240 --> 00:11:21,519 installed into that server as well. So 307 00:11:20,000 --> 00:11:25,440 go via the subprocess route if it's 308 00:11:21,519 --> 00:11:29,279 already there. Uh go via the HTTP HTTP 309 00:11:25,440 --> 00:11:30,800 route if you um if you know you can put 310 00:11:29,279 --> 00:11:34,560 that thing on a server and you can 311 00:11:30,800 --> 00:11:36,399 communicate via uh via APIs and then 312 00:11:34,560 --> 00:11:39,360 build the native extensions if you do 313 00:11:36,399 --> 00:11:42,560 have to. So sort of increase the 314 00:11:39,360 --> 00:11:45,680 complexity as you need to not because 315 00:11:42,560 --> 00:11:47,680 you want to. Sometimes it's really fun. 316 00:11:45,680 --> 00:11:49,279 Um okay so so yeah the rules of thumb is 317 00:11:47,680 --> 00:11:50,880 start green move right and then when 318 00:11:49,279 --> 00:11:52,079 necessary. Okay. So when things go 319 00:11:50,880 --> 00:11:53,519 wrong, don't rewrite it in another 320 00:11:52,079 --> 00:11:55,360 language for the sake of it. I think I 321 00:11:53,519 --> 00:11:57,120 alluded to all of this. Uh profile 322 00:11:55,360 --> 00:11:58,000 first. Clear out the requirements. I 323 00:11:57,120 --> 00:11:59,279 think that's the biggest thing that we 324 00:11:58,000 --> 00:12:00,640 need to that we need to take into 325 00:11:59,279 --> 00:12:02,480 consideration. Clear out the 326 00:12:00,640 --> 00:12:04,640 requirements. Um assume that you can 327 00:12:02,480 --> 00:12:07,040 write don't assume that you can rewrite 328 00:12:04,640 --> 00:12:08,639 faster than you can optimize. Um start 329 00:12:07,040 --> 00:12:10,639 don't start without a performance target 330 00:12:08,639 --> 00:12:13,040 and be careful to not uh not to 331 00:12:10,639 --> 00:12:14,480 microoptimize the wrong thing as well. I 332 00:12:13,040 --> 00:12:16,399 have been very guilty of that one as 333 00:12:14,480 --> 00:12:17,440 well. Um document the integration. 334 00:12:16,399 --> 00:12:19,600 document everything you do and 335 00:12:17,440 --> 00:12:21,680 especially these days if you are using 336 00:12:19,600 --> 00:12:26,399 um AI to help you write your code always 337 00:12:21,680 --> 00:12:28,639 have a to-do u MD file have a 338 00:12:26,399 --> 00:12:30,160 explanation MD file and something that I 339 00:12:28,639 --> 00:12:32,399 do if I have AI help when I'm writing 340 00:12:30,160 --> 00:12:34,560 code is that I have a tutorial MD file 341 00:12:32,399 --> 00:12:35,920 and I force it to write in the rules I 342 00:12:34,560 --> 00:12:37,360 force it to write to rewrite the 343 00:12:35,920 --> 00:12:39,519 tutorial if something has changed 344 00:12:37,360 --> 00:12:42,399 massively or if I have changed something 345 00:12:39,519 --> 00:12:44,160 um to for better or for the worst okay 346 00:12:42,399 --> 00:12:45,920 so the bill patterns u so let's talk 347 00:12:44,160 --> 00:12:46,959 about the project d uh structure this is 348 00:12:45,920 --> 00:12:49,120 probably the most important thing that 349 00:12:46,959 --> 00:12:51,440 you need to keep in mind because you are 350 00:12:49,120 --> 00:12:52,880 going to have to um attach thing and put 351 00:12:51,440 --> 00:12:54,639 things in different places and sometimes 352 00:12:52,880 --> 00:12:58,720 it's just not obvious where should we 353 00:12:54,639 --> 00:13:00,399 put things where and why. So um in the 354 00:12:58,720 --> 00:13:02,160 evolution of a repository you're going 355 00:13:00,399 --> 00:13:04,880 to have your project your pipe project 356 00:13:02,160 --> 00:13:06,240 tomo these days which is a fantastic way 357 00:13:04,880 --> 00:13:07,519 of organizing all of the things that are 358 00:13:06,240 --> 00:13:08,480 going to go into your project. Then 359 00:13:07,519 --> 00:13:10,480 you're going to have your source 360 00:13:08,480 --> 00:13:12,160 directory your package is going to be in 361 00:13:10,480 --> 00:13:15,040 there and perhaps other packages that 362 00:13:12,160 --> 00:13:16,720 are part of the bigger eos e ecosystem. 363 00:13:15,040 --> 00:13:18,880 Then you're going to have your app. py 364 00:13:16,720 --> 00:13:20,959 and then your in it to let it know that 365 00:13:18,880 --> 00:13:22,720 it is that it is a package. So you're 366 00:13:20,959 --> 00:13:24,079 going to have your test and then 367 00:13:22,720 --> 00:13:25,200 everything is going to be in those like 368 00:13:24,079 --> 00:13:28,320 if you want to keep it as minimal as 369 00:13:25,200 --> 00:13:31,120 possible, you can have this three things 370 00:13:28,320 --> 00:13:33,279 and that's it. But if you want to make 371 00:13:31,120 --> 00:13:36,399 it a little bit more uh if you want if 372 00:13:33,279 --> 00:13:39,680 you are going to add JavaScript then the 373 00:13:36,399 --> 00:13:43,519 thing that this moves around a little 374 00:13:39,680 --> 00:13:45,040 bit. So the biggest component or the 375 00:13:43,519 --> 00:13:47,200 biggest switch that you need to keep in 376 00:13:45,040 --> 00:13:49,600 mind here is that you could have the 377 00:13:47,200 --> 00:13:51,760 front end inside the source directory 378 00:13:49,600 --> 00:13:53,839 but the caveat is that when you build 379 00:13:51,760 --> 00:13:55,920 the wheel the wheels when you build your 380 00:13:53,839 --> 00:13:57,680 your Python package it is going to take 381 00:13:55,920 --> 00:14:00,079 everything inside that source directory. 382 00:13:57,680 --> 00:14:03,040 So the reason I have the front end out 383 00:14:00,079 --> 00:14:05,360 here and the static still you still see 384 00:14:03,040 --> 00:14:07,440 the static underneath uh inside the 385 00:14:05,360 --> 00:14:09,040 source directory is because what we want 386 00:14:07,440 --> 00:14:10,480 to do with the front end is to build 387 00:14:09,040 --> 00:14:12,000 that and we're going to get something 388 00:14:10,480 --> 00:14:13,920 called the disc the distribution 389 00:14:12,000 --> 00:14:15,519 directory that distribution directory or 390 00:14:13,920 --> 00:14:16,959 that output from the builder from the 391 00:14:15,519 --> 00:14:18,720 bundler we're going to add it to the 392 00:14:16,959 --> 00:14:20,800 static folder and then from that static 393 00:14:18,720 --> 00:14:22,480 folder if you have used fast API before 394 00:14:20,800 --> 00:14:24,320 you're going to have something called 395 00:14:22,480 --> 00:14:25,839 bring in template or bring in static 396 00:14:24,320 --> 00:14:27,839 files and then you bring them into your 397 00:14:25,839 --> 00:14:29,600 API and now you have Python Python 398 00:14:27,839 --> 00:14:32,320 running in the background sending to the 399 00:14:29,600 --> 00:14:33,920 user something in the browser. Then why 400 00:14:32,320 --> 00:14:35,279 do we have the scripts there? The script 401 00:14:33,920 --> 00:14:37,279 is because you're going to have to build 402 00:14:35,279 --> 00:14:40,560 that distribution and that might be 403 00:14:37,279 --> 00:14:42,800 something that you add inside uh your CI 404 00:14:40,560 --> 00:14:44,079 pipeline inside your build process. So 405 00:14:42,800 --> 00:14:45,440 you add that little script over there. 406 00:14:44,079 --> 00:14:47,040 It might be somewhere else. It might be 407 00:14:45,440 --> 00:14:49,839 part of the CI itself and you might not 408 00:14:47,040 --> 00:14:52,800 have something here. But separate the 409 00:14:49,839 --> 00:14:54,880 concerns and where possible keep the um 410 00:14:52,800 --> 00:14:56,720 well that's my opinion. uh keep the 411 00:14:54,880 --> 00:14:58,959 front end separate just because it is so 412 00:14:56,720 --> 00:15:00,000 easy to forget that if the front end is 413 00:14:58,959 --> 00:15:01,279 in the source directory, you're gonna 414 00:15:00,000 --> 00:15:02,959 have to do some magic to get it out of 415 00:15:01,279 --> 00:15:04,399 there and only include the static files 416 00:15:02,959 --> 00:15:05,600 and that is all you want. You want the 417 00:15:04,399 --> 00:15:08,240 stuff that is going to be displayed on 418 00:15:05,600 --> 00:15:10,399 the browser to be as minimal as possible 419 00:15:08,240 --> 00:15:13,680 and also you want to reduce the size of 420 00:15:10,399 --> 00:15:16,480 your build package. So, so yeah, so this 421 00:15:13,680 --> 00:15:18,160 is the the the key component for your 422 00:15:16,480 --> 00:15:20,320 Python stuff. You have the server is 423 00:15:18,160 --> 00:15:23,040 going to bring in that file, the static 424 00:15:20,320 --> 00:15:25,760 file and so on. So then if we go to 425 00:15:23,040 --> 00:15:29,199 Rust, how is ROSS going to be u going to 426 00:15:25,760 --> 00:15:31,920 be um sort of um arranged? So we're 427 00:15:29,199 --> 00:15:34,560 going to have that cargo tommo file 428 00:15:31,920 --> 00:15:35,920 which says what uh versions what 429 00:15:34,560 --> 00:15:38,480 packages and what versions of those 430 00:15:35,920 --> 00:15:40,959 packages am I going to be pulling in to 431 00:15:38,480 --> 00:15:44,320 compile um the source code and then 432 00:15:40,959 --> 00:15:45,279 create uh the binary objects. So then 433 00:15:44,320 --> 00:15:46,720 you're going to have the Rust 434 00:15:45,279 --> 00:15:48,160 implementation and then you're also 435 00:15:46,720 --> 00:15:50,240 going to have something called perhaps 436 00:15:48,160 --> 00:15:52,320 you're using PIO3. There are a few more 437 00:15:50,240 --> 00:15:56,800 tools in Ross that you can use nowadays 438 00:15:52,320 --> 00:15:59,279 to create um to create multi- language 439 00:15:56,800 --> 00:16:00,720 uh projects. I think PIO3 is sort of the 440 00:15:59,279 --> 00:16:01,920 most popular one right now. So you're 441 00:16:00,720 --> 00:16:03,040 going to have in your source directory. 442 00:16:01,920 --> 00:16:04,240 Now you're not going to have your Python 443 00:16:03,040 --> 00:16:06,399 there. You're going to have your Python 444 00:16:04,240 --> 00:16:09,440 inside a Python directory. And again, 445 00:16:06,399 --> 00:16:11,680 this is a um a stylistic choices. I'm 446 00:16:09,440 --> 00:16:13,440 giving you a highle overview so that you 447 00:16:11,680 --> 00:16:15,839 know how to separate your projects when 448 00:16:13,440 --> 00:16:17,759 you do when you do build one. Also, the 449 00:16:15,839 --> 00:16:19,600 tools that you might use today might do 450 00:16:17,759 --> 00:16:21,440 this for you. this rearrangement of 451 00:16:19,600 --> 00:16:23,279 concerns for you which is also really 452 00:16:21,440 --> 00:16:26,560 nice. Then um you're going to have the 453 00:16:23,279 --> 00:16:27,519 whole that that is going to be um that's 454 00:16:26,560 --> 00:16:29,199 going to be your project and then you're 455 00:16:27,519 --> 00:16:30,959 going to have a directory for the target 456 00:16:29,199 --> 00:16:32,639 for the wheels the thing that you are 457 00:16:30,959 --> 00:16:35,680 going to create the Python package that 458 00:16:32,639 --> 00:16:38,560 you do pip install um in these days u 459 00:16:35,680 --> 00:16:39,519 pip installs and then for C++ you're 460 00:16:38,560 --> 00:16:40,639 going to have something similar you're 461 00:16:39,519 --> 00:16:41,839 going to have the implementation 462 00:16:40,639 --> 00:16:44,240 somewhere else and then you're going to 463 00:16:41,839 --> 00:16:45,839 have something called pi bind pi bind 11 464 00:16:44,240 --> 00:16:46,880 there's different there's different ones 465 00:16:45,839 --> 00:16:48,320 that you can use but you're going to 466 00:16:46,880 --> 00:16:49,920 have sort of the same layout and now 467 00:16:48,320 --> 00:16:51,600 you're starting to see a pattern of 468 00:16:49,920 --> 00:16:53,759 separation of concerns between the 469 00:16:51,600 --> 00:16:56,240 Python code and also the C++ code the 470 00:16:53,759 --> 00:16:58,079 low-level code and the front-end code in 471 00:16:56,240 --> 00:17:00,480 in one aspect we still want to keep 472 00:16:58,079 --> 00:17:03,279 Python sort of like the main thing of 473 00:17:00,480 --> 00:17:05,280 the um of the library of the package but 474 00:17:03,279 --> 00:17:07,679 in some others we have to treat the 475 00:17:05,280 --> 00:17:08,880 low-level um code a little bit with a 476 00:17:07,679 --> 00:17:10,880 little bit more respect let's call it 477 00:17:08,880 --> 00:17:14,079 that um so then yeah so we have the 478 00:17:10,880 --> 00:17:17,679 project we have the C++ and so on I also 479 00:17:14,079 --> 00:17:18,799 had another one I have um gotten very 480 00:17:17,679 --> 00:17:20,799 interested in a programming language 481 00:17:18,799 --> 00:17:22,319 called zig so I have a few examples here 482 00:17:20,799 --> 00:17:24,000 I not sure I'll be able to show them 483 00:17:22,319 --> 00:17:26,079 because I have so much content. There's 484 00:17:24,000 --> 00:17:28,240 90 slides and I'm only in 16 right now. 485 00:17:26,079 --> 00:17:31,280 So I I'm sure I won't I won't make it 486 00:17:28,240 --> 00:17:33,360 anywhere uh near half the the talk, but 487 00:17:31,280 --> 00:17:36,160 I hope I do. Um and I do have a couple 488 00:17:33,360 --> 00:17:37,600 of examples using um using Zig, which is 489 00:17:36,160 --> 00:17:38,480 a fantastic programming language. So I'm 490 00:17:37,600 --> 00:17:39,919 going to I'm going to skip it. I'm going 491 00:17:38,480 --> 00:17:41,360 to try to go a little bit faster here 492 00:17:39,919 --> 00:17:43,120 just because there's many things. So 493 00:17:41,360 --> 00:17:45,200 you're going to have build system. This 494 00:17:43,120 --> 00:17:47,200 is where a lot of the magic happens and 495 00:17:45,200 --> 00:17:48,960 a lot of things just get put into the 496 00:17:47,200 --> 00:17:51,440 right place where they need to be for 497 00:17:48,960 --> 00:17:53,600 the directories to be sort of put into 498 00:17:51,440 --> 00:17:54,960 one place um completely. So you're going 499 00:17:53,600 --> 00:17:58,799 to have the JavaScript, you're going to 500 00:17:54,960 --> 00:18:00,559 have to build it with npn npm uh uh run 501 00:17:58,799 --> 00:18:02,000 build and then it's going to you're 502 00:18:00,559 --> 00:18:04,960 going to have the static assets that 503 00:18:02,000 --> 00:18:06,880 your server pulls in. Then for Rust, C++ 504 00:18:04,960 --> 00:18:08,240 and Z is sort of the exact same process. 505 00:18:06,880 --> 00:18:10,640 you're going to have this binary, this 506 00:18:08,240 --> 00:18:14,559 blob object that then you're going to 507 00:18:10,640 --> 00:18:17,600 use uh Python using uh foreign functions 508 00:18:14,559 --> 00:18:19,600 interfaces to bind Python code to that 509 00:18:17,600 --> 00:18:21,600 code. 510 00:18:19,600 --> 00:18:23,200 Okay, so the devel in development mode 511 00:18:21,600 --> 00:18:25,440 you're going to see the output somewhere 512 00:18:23,200 --> 00:18:27,440 there you're going to run npm rundev 513 00:18:25,440 --> 00:18:29,840 python server it starts it captures 514 00:18:27,440 --> 00:18:31,440 everything matching develop pip install- 515 00:18:29,840 --> 00:18:33,120 e and so on and so on. Then the 516 00:18:31,440 --> 00:18:34,880 production mode you're going to have the 517 00:18:33,120 --> 00:18:36,960 package.wheel 518 00:18:34,880 --> 00:18:38,240 uh for Linux for example and then it's 519 00:18:36,960 --> 00:18:40,799 going to be very minimal. You're going 520 00:18:38,240 --> 00:18:42,240 to have the native. So the whatever 521 00:18:40,799 --> 00:18:44,720 library you're using you're going to 522 00:18:42,240 --> 00:18:46,559 have the Python specific information and 523 00:18:44,720 --> 00:18:48,640 then everything is going to be bundled 524 00:18:46,559 --> 00:18:51,600 very very specifically in one single 525 00:18:48,640 --> 00:18:54,240 place. And by the way um so this uh 526 00:18:51,600 --> 00:18:56,400 slides are in a repo. Um this is using 527 00:18:54,240 --> 00:18:58,160 slide. So I I also have the I should 528 00:18:56,400 --> 00:18:59,440 have put the repo at the front as well 529 00:18:58,160 --> 00:19:01,520 but I'm also going to show it at the at 530 00:18:59,440 --> 00:19:03,120 the end of it. So in CI the most 531 00:19:01,520 --> 00:19:05,440 important thing is this thing where is 532 00:19:03,120 --> 00:19:07,280 my pack is my package going to be used 533 00:19:05,440 --> 00:19:08,960 at. So you want to make sure that 534 00:19:07,280 --> 00:19:11,600 whatever you're doing to test that 535 00:19:08,960 --> 00:19:13,120 package you do so with the intended 536 00:19:11,600 --> 00:19:16,160 programming languages or sorry uh 537 00:19:13,120 --> 00:19:18,240 operating systems in mind. So if I am 538 00:19:16,160 --> 00:19:20,240 going to be running this in Mac OS uh or 539 00:19:18,240 --> 00:19:22,240 Windows latest like make sure you do it 540 00:19:20,240 --> 00:19:24,559 um you run tests in each one of those 541 00:19:22,240 --> 00:19:27,200 platforms so that your CI process 542 00:19:24,559 --> 00:19:28,480 screams at you if it does not like 543 00:19:27,200 --> 00:19:29,679 something. And then you're going to have 544 00:19:28,480 --> 00:19:31,440 the steps where you're going to run 545 00:19:29,679 --> 00:19:33,200 through uh how to build the static 546 00:19:31,440 --> 00:19:34,799 files, how to build the binary object, 547 00:19:33,200 --> 00:19:37,200 how to make sure everything just runs 548 00:19:34,799 --> 00:19:38,640 smooth smoothly. So I'm going to skip 549 00:19:37,200 --> 00:19:41,360 through this one. So testing with 550 00:19:38,640 --> 00:19:42,960 multiple languages. Um testing is more 551 00:19:41,360 --> 00:19:44,640 an art than a science a lot of times, 552 00:19:42,960 --> 00:19:47,120 but you want to make sure you test your 553 00:19:44,640 --> 00:19:49,039 ROS uh boundary. So you test sort of the 554 00:19:47,120 --> 00:19:51,200 intersection between is the code 555 00:19:49,039 --> 00:19:54,720 actually really being read by Python and 556 00:19:51,200 --> 00:19:57,840 am I passing the right data types into 557 00:19:54,720 --> 00:20:00,480 the into the systems level binary block 558 00:19:57,840 --> 00:20:01,919 it am I passing data fine between one or 559 00:20:00,480 --> 00:20:04,240 the other so that's probably the biggest 560 00:20:01,919 --> 00:20:07,840 takeaways that I struggle with while 561 00:20:04,240 --> 00:20:09,520 doing C++ and Python um so make sure um 562 00:20:07,840 --> 00:20:11,600 you run some tests on this don't leave 563 00:20:09,520 --> 00:20:13,440 it towards towards the end ask AI to to 564 00:20:11,600 --> 00:20:16,320 do them for you um that's what I do 565 00:20:13,440 --> 00:20:18,559 these days so um okay So the costbenefit 566 00:20:16,320 --> 00:20:20,640 analysis is that if you have a 100 567 00:20:18,559 --> 00:20:22,160 millisecond endpoint and then it takes 568 00:20:20,640 --> 00:20:23,919 10 milliseconds perhaps it's not worth 569 00:20:22,160 --> 00:20:27,039 it um doing something else. But if you 570 00:20:23,919 --> 00:20:30,000 go from 10 seconds to to 0.1 second then 571 00:20:27,039 --> 00:20:31,520 do some rewriting or h put some thought 572 00:20:30,000 --> 00:20:33,039 into how can you extract more 573 00:20:31,520 --> 00:20:35,360 performance while still staying in 574 00:20:33,039 --> 00:20:36,880 Python land. Um real time audio is 575 00:20:35,360 --> 00:20:38,640 pretty much you're going to need 576 00:20:36,880 --> 00:20:40,400 something very low level to do that 577 00:20:38,640 --> 00:20:42,480 well. And then UI interactions you're 578 00:20:40,400 --> 00:20:43,919 going to need JavaScript. All right. So 579 00:20:42,480 --> 00:20:45,840 I have a few things here on the rules of 580 00:20:43,919 --> 00:20:47,919 thumbs and development time, debugging 581 00:20:45,840 --> 00:20:49,280 complexity, team expertise. You have to 582 00:20:47,919 --> 00:20:50,960 take all those things in consideration. 583 00:20:49,280 --> 00:20:53,200 So some of them are a little bit more 584 00:20:50,960 --> 00:20:55,440 cultural and part of your organization. 585 00:20:53,200 --> 00:20:57,440 So um who is there, how much time can 586 00:20:55,440 --> 00:20:59,039 the company devote for somebody to spend 587 00:20:57,440 --> 00:21:01,520 say a couple of weeks learning something 588 00:20:59,039 --> 00:21:03,200 new versus can some can we hire somebody 589 00:21:01,520 --> 00:21:04,640 faster than somebody can acquire that 590 00:21:03,200 --> 00:21:07,280 knowledge as well. If you are going to 591 00:21:04,640 --> 00:21:08,640 go and acquire and add specifically a 592 00:21:07,280 --> 00:21:10,480 low-level programming language and 593 00:21:08,640 --> 00:21:12,000 nobody in your team has that expertise, 594 00:21:10,480 --> 00:21:13,520 there's going to be some trade trade-off 595 00:21:12,000 --> 00:21:15,919 there. 596 00:21:13,520 --> 00:21:18,080 Okay, so packaging expectations. This is 597 00:21:15,919 --> 00:21:19,520 what we all want. Uh pip install your 598 00:21:18,080 --> 00:21:21,600 package, but I'm sure everybody 599 00:21:19,520 --> 00:21:23,360 everybody here has probably gone uh to a 600 00:21:21,600 --> 00:21:24,400 repo and before you get to the pip 601 00:21:23,360 --> 00:21:25,280 install, it tells you, well, you're 602 00:21:24,400 --> 00:21:26,640 going to have this, you're going to need 603 00:21:25,280 --> 00:21:28,400 this one, this one, this one, this one, 604 00:21:26,640 --> 00:21:30,080 this one, and this one in your operating 605 00:21:28,400 --> 00:21:32,320 system. And you're like, what? How do I 606 00:21:30,080 --> 00:21:33,919 do that? And sometimes if you run Linux 607 00:21:32,320 --> 00:21:36,960 then they're only going to give you the 608 00:21:33,919 --> 00:21:38,559 Debian or the Ubuntu um explanations 609 00:21:36,960 --> 00:21:40,720 then they might have 10 different names 610 00:21:38,559 --> 00:21:43,039 in other operating systems. If you're in 611 00:21:40,720 --> 00:21:46,240 Mac then uh you just don't pay attention 612 00:21:43,039 --> 00:21:47,679 to it. If you're in Windows, no, I'm I'm 613 00:21:46,240 --> 00:21:48,640 joking. I'm joking. Uh if you're in 614 00:21:47,679 --> 00:21:51,760 Windows, you definitely don't pay 615 00:21:48,640 --> 00:21:53,520 attention to those. But um okay, so I'm 616 00:21:51,760 --> 00:21:55,039 going to skip this stuff. Um there are 617 00:21:53,520 --> 00:21:57,760 packages that out there that can help 618 00:21:55,039 --> 00:22:00,080 you quite a lot. their CI build wheel uh 619 00:21:57,760 --> 00:22:02,480 which is fantastic and it allows you to 620 00:22:00,080 --> 00:22:04,720 test for each plat each platform. So 621 00:22:02,480 --> 00:22:06,480 definitely check it out. Um I'm gonna 622 00:22:04,720 --> 00:22:07,919 put a couple of things here when builds 623 00:22:06,480 --> 00:22:10,159 break but I'm going to skip to the next 624 00:22:07,919 --> 00:22:12,240 section because I want to I want to talk 625 00:22:10,159 --> 00:22:13,840 about I want to go through some code 626 00:22:12,240 --> 00:22:16,000 examples 627 00:22:13,840 --> 00:22:18,159 um and in particular so working with 628 00:22:16,000 --> 00:22:20,320 different languages. So say for example 629 00:22:18,159 --> 00:22:22,640 we have um so I am from the Dominican 630 00:22:20,320 --> 00:22:24,640 Republic and I pick Sto Domingo here. So 631 00:22:22,640 --> 00:22:28,960 the distance from Sto Domingo to Miami 632 00:22:24,640 --> 00:22:31,520 is simple enough. Um we say um it's we 633 00:22:28,960 --> 00:22:33,760 are in this longitude and latitude and 634 00:22:31,520 --> 00:22:35,280 then Miami is in this other longitude 635 00:22:33,760 --> 00:22:39,360 and latitude and latitude. How do we 636 00:22:35,280 --> 00:22:40,799 actually um accomplish u accessing that? 637 00:22:39,360 --> 00:22:43,360 But don't pay attention to that function 638 00:22:40,799 --> 00:22:46,720 because it means nothing. Like nowadays 639 00:22:43,360 --> 00:22:49,760 is just one simple uh one one function. 640 00:22:46,720 --> 00:22:52,640 So from that to that I never want to see 641 00:22:49,760 --> 00:22:55,360 that in my life. um this is so much 642 00:22:52,640 --> 00:22:57,360 nicer. So I just wanted to scare you a 643 00:22:55,360 --> 00:22:59,440 little bit and then keep you engaged uh 644 00:22:57,360 --> 00:23:00,720 until my time runs out. So if we have 645 00:22:59,440 --> 00:23:02,240 the Python one, so say we have the 646 00:23:00,720 --> 00:23:05,039 longitude or the latitude, we have two 647 00:23:02,240 --> 00:23:06,880 places that we want to u that we want to 648 00:23:05,039 --> 00:23:08,480 uh sort of uh test calculate the 649 00:23:06,880 --> 00:23:09,840 distance of. And I have a point on 650 00:23:08,480 --> 00:23:10,960 showing you this function. I'm going to 651 00:23:09,840 --> 00:23:12,400 show it to you in four different 652 00:23:10,960 --> 00:23:13,840 languages. And also I'm going to show 653 00:23:12,400 --> 00:23:17,200 you the difference the difference in 654 00:23:13,840 --> 00:23:18,400 speed. Um so we're going to do some 655 00:23:17,200 --> 00:23:20,320 calculations. We're going to subtract 656 00:23:18,400 --> 00:23:21,440 something, add something, and so on and 657 00:23:20,320 --> 00:23:22,720 so on. and then we're going to return 658 00:23:21,440 --> 00:23:25,120 something, right? So, how does that look 659 00:23:22,720 --> 00:23:28,240 that in like what does that look like in 660 00:23:25,120 --> 00:23:30,080 different programming languages? So, it 661 00:23:28,240 --> 00:23:32,240 doesn't look that scary. It doesn't look 662 00:23:30,080 --> 00:23:34,080 that um that much more complex. There 663 00:23:32,240 --> 00:23:35,760 are nuances between switching from one 664 00:23:34,080 --> 00:23:37,840 language to another. But when you get to 665 00:23:35,760 --> 00:23:39,280 the core of it and you start seeing the 666 00:23:37,840 --> 00:23:41,840 things that we're using, say for example 667 00:23:39,280 --> 00:23:44,960 now in JavaScript, um so I am using the 668 00:23:41,840 --> 00:23:49,120 exact same arguments in a function. I am 669 00:23:44,960 --> 00:23:51,360 uh creating different or um dstructuring 670 00:23:49,120 --> 00:23:52,640 in the same way as you do in Python. Uh 671 00:23:51,360 --> 00:23:54,080 the map is a little bit different 672 00:23:52,640 --> 00:23:55,679 because they have it at the end. In 673 00:23:54,080 --> 00:23:58,159 Python, we have it at the beginning of 674 00:23:55,679 --> 00:24:01,120 the function and so on. But but things 675 00:23:58,159 --> 00:24:02,480 look relatively relatively similar. If 676 00:24:01,120 --> 00:24:04,159 you go to the low-level programming 677 00:24:02,480 --> 00:24:05,600 languages, they do a little bit of 678 00:24:04,159 --> 00:24:07,280 ceremony before they tell you what 679 00:24:05,600 --> 00:24:08,799 they're going to do. You have to like 680 00:24:07,280 --> 00:24:11,440 explain 10 times why you're going to do 681 00:24:08,799 --> 00:24:13,120 it. Uh but still, it's kind of it's kind 682 00:24:11,440 --> 00:24:15,039 of similar. If you see Rust, it has a 683 00:24:13,120 --> 00:24:19,440 lot of similarities with JavaScript. If 684 00:24:15,039 --> 00:24:22,799 you see if you see C++ then I don't know 685 00:24:19,440 --> 00:24:25,200 what they're doing to be honest. Um 686 00:24:22,799 --> 00:24:28,240 there just there's some stuff happening. 687 00:24:25,200 --> 00:24:30,799 Uh and then if you see SIG um it's a 688 00:24:28,240 --> 00:24:34,159 little bit more human friendly. Um std 689 00:24:30,799 --> 00:24:35,520 standard library math degrees to 690 00:24:34,159 --> 00:24:38,799 radians. It's a little bit more 691 00:24:35,520 --> 00:24:42,799 palatable. Um I still like you know C++ 692 00:24:38,799 --> 00:24:44,960 is still very respect and okay so 693 00:24:42,799 --> 00:24:47,200 performance check if you were to test 694 00:24:44,960 --> 00:24:49,520 this function uh and do a million 695 00:24:47,200 --> 00:24:54,080 calculations if you run it in a loop 696 00:24:49,520 --> 00:24:56,000 Python would take on um on a million a 697 00:24:54,080 --> 00:24:57,760 million of this about 2.1 seconds 698 00:24:56,000 --> 00:24:58,880 JavaScript would take 0.8 eight if 699 00:24:57,760 --> 00:25:00,000 you're running in node. If you're 700 00:24:58,880 --> 00:25:01,679 running in the browser, it's a different 701 00:25:00,000 --> 00:25:03,200 story. If you open the console there, u 702 00:25:01,679 --> 00:25:05,840 it's still technically being run in 703 00:25:03,200 --> 00:25:09,200 node. Um rust 704 00:25:05,840 --> 00:25:11,840 um 0.12 seconds and then C++ 0.08 705 00:25:09,200 --> 00:25:13,520 seconds and then z.07 seconds. But 706 00:25:11,840 --> 00:25:14,880 that's just one function. I just wanted 707 00:25:13,520 --> 00:25:17,200 to give you a highlight of the 708 00:25:14,880 --> 00:25:19,279 difference in speed. If you have 1 709 00:25:17,200 --> 00:25:21,360 million calculations and you map that to 710 00:25:19,279 --> 00:25:23,760 1 million users, you have a nice 711 00:25:21,360 --> 00:25:26,159 product. You are perhaps a startup. If 712 00:25:23,760 --> 00:25:28,799 you are somebody or uh an organization 713 00:25:26,159 --> 00:25:31,200 that has 10 million users, uh 20 million 714 00:25:28,799 --> 00:25:33,520 users, 300 million users, this is not 2 715 00:25:31,200 --> 00:25:35,120 seconds anymore. This is a lot of time 716 00:25:33,520 --> 00:25:36,799 to run something that perhaps is 717 00:25:35,120 --> 00:25:39,840 happening on the server and is going to 718 00:25:36,799 --> 00:25:41,840 be passed up to your UI. So there's a 719 00:25:39,840 --> 00:25:43,919 lot of there's a lot that we need to 720 00:25:41,840 --> 00:25:45,760 capture when we or a lot of information 721 00:25:43,919 --> 00:25:48,640 that we need to take into consideration 722 00:25:45,760 --> 00:25:51,120 when we want to increase performance. 723 00:25:48,640 --> 00:25:53,679 Five minutes. Okay. So let me see if I 724 00:25:51,120 --> 00:25:55,279 can get to uh the real world examples. 725 00:25:53,679 --> 00:25:57,279 All of my pro all of my projects they 726 00:25:55,279 --> 00:26:00,559 follow the same thing. Show the problem 727 00:25:57,279 --> 00:26:02,159 um profile and measure polylo solution 728 00:26:00,559 --> 00:26:04,880 and so on. So for the first one for the 729 00:26:02,159 --> 00:26:07,360 JavaScript I thought okay so there's 730 00:26:04,880 --> 00:26:08,880 modern agricultural monitoring uh which 731 00:26:07,360 --> 00:26:10,240 requires real-time data streams 732 00:26:08,880 --> 00:26:13,520 interactive dashboards complex 733 00:26:10,240 --> 00:26:16,159 simulations and easy deployment. 734 00:26:13,520 --> 00:26:17,520 The dream list and then you're going to 735 00:26:16,159 --> 00:26:19,120 want to do something like okay let's 736 00:26:17,520 --> 00:26:20,400 read the sensors. Let's let's get the 737 00:26:19,120 --> 00:26:21,679 stream from the sensors that create 738 00:26:20,400 --> 00:26:23,279 let's create a loop and then let's 739 00:26:21,679 --> 00:26:24,400 process that data. But when once we 740 00:26:23,279 --> 00:26:25,840 finish with that data okay what are we 741 00:26:24,400 --> 00:26:28,480 going to do? How do we pass it in real 742 00:26:25,840 --> 00:26:30,960 time to the 743 00:26:28,480 --> 00:26:32,799 um to to the UI to the user interface. 744 00:26:30,960 --> 00:26:35,520 So I have here a little package that I 745 00:26:32,799 --> 00:26:37,360 created called um outback monitoring 746 00:26:35,520 --> 00:26:40,720 because I wanted to keep a Australian 747 00:26:37,360 --> 00:26:43,279 theme. So actually out of the four um 748 00:26:40,720 --> 00:26:45,279 projects here three of them have um a 749 00:26:43,279 --> 00:26:47,360 theme with Australia. So this one is the 750 00:26:45,279 --> 00:26:48,799 outback monitoring and so I have fast 751 00:26:47,360 --> 00:26:51,200 API on the server, numpy for the 752 00:26:48,799 --> 00:26:53,279 simulations, then a little CLI and then 753 00:26:51,200 --> 00:26:55,360 JavaScript real-time uh charts, 754 00:26:53,279 --> 00:26:58,240 websockets and so on. So then in the 755 00:26:55,360 --> 00:26:59,679 Python side I have uh fast API, I have 756 00:26:58,240 --> 00:27:02,080 nonpay I have different regions, 757 00:26:59,679 --> 00:27:05,120 Queensland, New South Wales, Victoria, I 758 00:27:02,080 --> 00:27:08,320 don't know anymore. Um joking joking 759 00:27:05,120 --> 00:27:09,840 joke u data simulation. So generate the 760 00:27:08,320 --> 00:27:12,320 data, create a little bit of simulator 761 00:27:09,840 --> 00:27:14,480 data and then continuously pass it via 762 00:27:12,320 --> 00:27:16,880 web soocket towards the front end. So 763 00:27:14,480 --> 00:27:19,279 then in the front end I have the outback 764 00:27:16,880 --> 00:27:21,679 monitoring I have uh I have my local 765 00:27:19,279 --> 00:27:23,919 host setup the region I take the region 766 00:27:21,679 --> 00:27:25,760 and then I take in that influx of data 767 00:27:23,919 --> 00:27:27,600 and then I create a little chart this 768 00:27:25,760 --> 00:27:28,960 charts environment yada yada yada and 769 00:27:27,600 --> 00:27:30,080 then we pass it to the front end. So 770 00:27:28,960 --> 00:27:33,120 what does this look like? So I have the 771 00:27:30,080 --> 00:27:34,400 CLI, I start my Python server. Uh I run 772 00:27:33,120 --> 00:27:36,159 the simulations on the background 773 00:27:34,400 --> 00:27:38,159 constantly in a loop and then I pass in 774 00:27:36,159 --> 00:27:40,400 via websocket. All right. So then this 775 00:27:38,159 --> 00:27:42,640 is the outback uh monitoring thing. So 776 00:27:40,400 --> 00:27:48,480 let me see if I can uh if the demo gods 777 00:27:42,640 --> 00:27:50,080 are with me and um the outback 778 00:27:48,480 --> 00:27:54,440 monitoring and then I'm also going to 779 00:27:50,080 --> 00:27:54,440 show you run. 780 00:27:55,679 --> 00:27:59,039 Okay, 781 00:27:57,360 --> 00:28:02,640 so we're going to go with Queensland. 782 00:27:59,039 --> 00:28:05,279 Uh, okay. So, I have it now connected 783 00:28:02,640 --> 00:28:09,760 and so I didn't set it up so that if I 784 00:28:05,279 --> 00:28:11,360 put no uh no open u it still opens up a 785 00:28:09,760 --> 00:28:13,120 different UI because I have everything 786 00:28:11,360 --> 00:28:14,640 combined. So, I just started the CLI and 787 00:28:13,120 --> 00:28:16,159 then I select the region. I'm going to 788 00:28:14,640 --> 00:28:18,240 go for Queensland and then I'm going to 789 00:28:16,159 --> 00:28:20,399 click start. So, now my simulation is in 790 00:28:18,240 --> 00:28:22,320 the background running and then numpy is 791 00:28:20,399 --> 00:28:24,720 passing that data real time into the 792 00:28:22,320 --> 00:28:26,159 into the component in my slides. Um, so 793 00:28:24,720 --> 00:28:27,440 this is happening right now and it's 794 00:28:26,159 --> 00:28:29,200 really cool because you can see like 795 00:28:27,440 --> 00:28:30,960 okay cool like now I have something 796 00:28:29,200 --> 00:28:32,559 happening in Python. Python works really 797 00:28:30,960 --> 00:28:35,279 well for this and then I can pass it to 798 00:28:32,559 --> 00:28:36,880 the front end and business as usual 799 00:28:35,279 --> 00:28:38,320 right I don't need to go to a low-level 800 00:28:36,880 --> 00:28:41,039 programming language I can do it 801 00:28:38,320 --> 00:28:43,600 relatively easy easily relatively simply 802 00:28:41,039 --> 00:28:45,679 um in the repo when you capture it at 803 00:28:43,600 --> 00:28:47,200 the end of the talk um all of these 804 00:28:45,679 --> 00:28:50,240 examples are there as well so you can 805 00:28:47,200 --> 00:28:51,679 run them uh yourself so the biggest 806 00:28:50,240 --> 00:28:53,279 takeaway that I wanted you to get from 807 00:28:51,679 --> 00:28:54,399 this is that the developer experience is 808 00:28:53,279 --> 00:28:55,360 the most important where we create 809 00:28:54,399 --> 00:28:57,919 something that we're going to share with 810 00:28:55,360 --> 00:28:59,760 someone and in this use case where I 811 00:28:57,919 --> 00:29:02,559 create a static file and I can bundle 812 00:28:59,760 --> 00:29:05,360 into the into the Python uh project then 813 00:29:02,559 --> 00:29:07,679 I can start and say outback monitoring 814 00:29:05,360 --> 00:29:10,159 boom and then I can say I can start my 815 00:29:07,679 --> 00:29:11,279 CLI with one command and so on. So I 816 00:29:10,159 --> 00:29:12,880 have about two minutes so let me see if 817 00:29:11,279 --> 00:29:15,039 I can get you to the Ross one because I 818 00:29:12,880 --> 00:29:16,320 want to at least give you um a 819 00:29:15,039 --> 00:29:17,919 perspective on the low level and a 820 00:29:16,320 --> 00:29:19,440 perspective on the high level. So 821 00:29:17,919 --> 00:29:21,039 real-time web interface interactive 822 00:29:19,440 --> 00:29:24,000 visualizations and so on and so on. So 823 00:29:21,039 --> 00:29:26,640 Python and Ross. So here is where things 824 00:29:24,000 --> 00:29:28,320 get tricky. The thing that I picked was 825 00:29:26,640 --> 00:29:29,919 bushfire simulation. So this is 826 00:29:28,320 --> 00:29:32,880 important. This is very related to 827 00:29:29,919 --> 00:29:34,080 Australia. This is needed to be able to 828 00:29:32,880 --> 00:29:36,240 monitor. Okay. So what's going to 829 00:29:34,080 --> 00:29:39,120 happen? Um if we get a fire, can we 830 00:29:36,240 --> 00:29:41,360 simulate how uh quickly it is going to 831 00:29:39,120 --> 00:29:44,320 spread and to where and one of the ways 832 00:29:41,360 --> 00:29:46,880 in which we can do it is via different 833 00:29:44,320 --> 00:29:48,880 algorithms that already exist. The key 834 00:29:46,880 --> 00:29:50,720 thing is that if you're running say an 835 00:29:48,880 --> 00:29:53,039 automata algorithm and you're trying to 836 00:29:50,720 --> 00:29:56,159 calculate what happens in a grid of 100 837 00:29:53,039 --> 00:29:59,200 100 by 100 cells and which ones get 838 00:29:56,159 --> 00:30:01,600 turned on and off with the fire then you 839 00:29:59,200 --> 00:30:04,720 have multiple simulations and you have a 840 00:30:01,600 --> 00:30:07,919 synchronous um uh function running. Have 841 00:30:04,720 --> 00:30:11,120 anybody done any async work in Python? 842 00:30:07,919 --> 00:30:12,960 No. Yes. One person in a room with a lot 843 00:30:11,120 --> 00:30:14,399 of people. That is my that that is the 844 00:30:12,960 --> 00:30:17,600 point that I wanted to highlight. It's 845 00:30:14,399 --> 00:30:20,000 not extremely it's not extremely um uh 846 00:30:17,600 --> 00:30:21,279 intuitive at first. Uh after you work a 847 00:30:20,000 --> 00:30:23,520 little bit with it, then it does become 848 00:30:21,279 --> 00:30:26,799 much more intuitive. And this is also 849 00:30:23,520 --> 00:30:30,240 why Python 314 is about to I believe 850 00:30:26,799 --> 00:30:31,840 have the option to use no gill gill. I 851 00:30:30,240 --> 00:30:33,039 think uh don't quote me on that one. I 852 00:30:31,840 --> 00:30:34,559 think that's that's that's how it's 853 00:30:33,039 --> 00:30:36,880 going to run. But anyways, I wanted to 854 00:30:34,559 --> 00:30:39,279 show you the example because we have a 855 00:30:36,880 --> 00:30:41,520 simulation function that in Python just 856 00:30:39,279 --> 00:30:45,200 doesn't run very well. Uh it takes about 857 00:30:41,520 --> 00:30:48,399 for 100 by 100 grid uh with 50 steps 858 00:30:45,200 --> 00:30:51,279 each is about 5,000 sales updates. This 859 00:30:48,399 --> 00:30:53,200 runs in 2.25 seconds. Uh Australia 860 00:30:51,279 --> 00:30:55,279 doesn't you cannot cover Australia with 861 00:30:53,200 --> 00:30:57,760 a grid of 100 by 100. Let's just put 862 00:30:55,279 --> 00:31:00,399 that that way. So it takes performance 863 00:30:57,760 --> 00:31:03,360 to do a simulation when it's bushfire 864 00:31:00,399 --> 00:31:05,200 season. Let's call it that. Or and so 865 00:31:03,360 --> 00:31:06,960 same setup. Uh I'm going to skip this 866 00:31:05,200 --> 00:31:08,640 because I want to show you the demo on 867 00:31:06,960 --> 00:31:10,399 what it looks like. The pipeline is 868 00:31:08,640 --> 00:31:12,159 slightly similar and similar to what I 869 00:31:10,399 --> 00:31:15,200 show you with the bundling piece. And 870 00:31:12,159 --> 00:31:18,320 then let me see if I can get to uh this 871 00:31:15,200 --> 00:31:20,000 one. I have about one minute left, maybe 872 00:31:18,320 --> 00:31:23,200 not even. And I'm just taking advantage 873 00:31:20,000 --> 00:31:28,440 of the kindness of the um of everyone 874 00:31:23,200 --> 00:31:28,440 here. So push fire simulation. 875 00:31:43,679 --> 00:31:48,519 Okay. 876 00:31:45,519 --> 00:31:48,519 Um 877 00:31:53,200 --> 00:31:58,559 and uh the demo god said no. Uh we're 878 00:31:55,679 --> 00:32:01,600 not going to do it today. Uh so um yeah, 879 00:31:58,559 --> 00:32:05,440 sorry about that. I I don't know what I 880 00:32:01,600 --> 00:32:07,440 did here. And it's been too many um too 881 00:32:05,440 --> 00:32:10,080 many branches that I went through. Uh so 882 00:32:07,440 --> 00:32:13,760 sorry about that. But the example is 883 00:32:10,080 --> 00:32:15,760 going to be in the in the repo. Check it 884 00:32:13,760 --> 00:32:16,880 out. Um and then also you can run it 885 00:32:15,760 --> 00:32:18,880 with these slides. If you like the 886 00:32:16,880 --> 00:32:20,159 slides, copy them, use them. I have a 887 00:32:18,880 --> 00:32:21,600 lot of components that you can bring in 888 00:32:20,159 --> 00:32:24,000 and make your uh slides more 889 00:32:21,600 --> 00:32:28,159 interactive. So um for the last thing 890 00:32:24,000 --> 00:32:30,480 that um I had for all of you was um just 891 00:32:28,159 --> 00:32:31,600 a thought on Python and I'm trying to 892 00:32:30,480 --> 00:32:33,200 get to the end to just tell you that 893 00:32:31,600 --> 00:32:35,840 thought. So, I'm just going to tell you 894 00:32:33,200 --> 00:32:39,120 uh there's a lot 895 00:32:35,840 --> 00:32:41,360 there's a lot there's a lot of resources 896 00:32:39,120 --> 00:32:43,200 available out there to get started um 897 00:32:41,360 --> 00:32:46,799 running multiple programming languages 898 00:32:43,200 --> 00:32:48,480 in uh via Python and having Python be 899 00:32:46,799 --> 00:32:50,080 your orchestrator. Take advantage of 900 00:32:48,480 --> 00:32:51,600 those, explore, especially there's never 901 00:32:50,080 --> 00:32:53,360 been a better time to learn how to 902 00:32:51,600 --> 00:32:55,120 program in different languages while 903 00:32:53,360 --> 00:32:56,720 still taking advantage of Python than 904 00:32:55,120 --> 00:32:58,000 today with all these AI tools that are 905 00:32:56,720 --> 00:32:59,600 here. So, thank you very much for 906 00:32:58,000 --> 00:33:01,380 listening to me. Um it's been a 907 00:32:59,600 --> 00:33:07,039 wonderful conference so far. Thank you. 908 00:33:01,380 --> 00:33:07,039 [Applause]