<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vasanth Bharathi on Medium]]></title>
        <description><![CDATA[Stories by Vasanth Bharathi on Medium]]></description>
        <link>https://medium.com/@vasanthbharathi07?source=rss-9855e889c0a2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ww25pAEiYVmll_UIZdpjlA.jpeg</url>
            <title>Stories by Vasanth Bharathi on Medium</title>
            <link>https://medium.com/@vasanthbharathi07?source=rss-9855e889c0a2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:08:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vasanthbharathi07/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[7 Surprising Lessons from the Numpy Documentation]]></title>
            <link>https://python.plainenglish.io/7-surprising-lessons-from-the-numpy-documentation-087bc8c9c999?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/087bc8c9c999</guid>
            <category><![CDATA[numpy-performance]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[fortran]]></category>
            <category><![CDATA[c-programming]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Sun, 25 May 2025 11:24:36 GMT</pubDate>
            <atom:updated>2025-05-26T00:55:31.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*uT9tty9fu1tJf8_p_JPdtw.png" /><figcaption>Credits: NumPy Website</figcaption></figure><p>I usually try to read the official documentation of libraries I use — not just to learn about the API, but because it often reveals things I didn’t even know existed.</p><p>Recently, I’ve been digging into the NumPy documentation more seriously, as some of my projects rely heavily on it. Let me be clear: this article isn’t a rehash of the NumPy docs or a list of well-known features. These are things I either didn’t know at all or had only heard of vaguely — and only now, after reading the documentation, do I realize their potential.</p><h3>SIMD:</h3><p>I had <em>never</em> heard of SIMD before reading about it in the NumPy docs. I always assumed NumPy was fast simply because it’s a C-based library. I also often heard that <strong>“vectorization”</strong> is what makes NumPy fast, but I never truly understood what that meant — until recently.</p><p>SIMD stands for <strong><em>Single Instruction, Multiple Data</em></strong>. It’s a hardware feature that allows a single instruction to process multiple pieces of data simultaneously. For example, if you have an array of five numbers and you want to multiply all of them by 2, SIMD allows the processor to perform all the multiplications in parallel. This is possible due to special hardware elements called <strong>registers</strong>, and it turns out this idea originated with Intel Processors!</p><h3>‘C_CONTIGUOUS’ or ‘F_CONTIGUOUS’ ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*ow3_vxBpRP8Yu1Qeeugvxg.png" /><figcaption>Credits: Arda Usta From Medium Article</figcaption></figure><p>In several NumPy APIs, you’ll come across terms like C_CONTIGUOUS and F_CONTIGUOUS. What do they mean? They refer to the <em>memory layout</em> of arrays: C-style (row-major) vs. Fortran-style (column-major). This affects how data is stored and accessed in memory.</p><p>Here’s the surprising part: scientific computing problems can sometimes run <strong>up to 25x faster</strong> when using column-major memory (like in MATLAB, R, or Fortran), compared to row-major memory (used by C, Java, Python, etc.). Knowing which layout to use can have serious performance implications.</p><h3>BLAS or LAPACK:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*4H8Fn8fivimdSFRo_K2Yog.jpeg" /><figcaption>Credits: LAPACK Github</figcaption></figure><p>These names were totally unfamiliar to me — until I ran into them while exploring how NumPy achieves such high performance. Because these libraries are written in machine language</p><ul><li><strong>BLAS (Basic Linear Algebra Subprograms)</strong> is a collection of low-level routines written in assembly that interface directly with the hardware.</li><li><strong>LAPACK (Linear Algebra Package)</strong> is a high-level library built on top of BLAS, written in <strong>FORTRAN</strong> language.</li><li>I used to think <strong>FORTRAN</strong> was a “dead language,” but nope — NumPy’s insane speed is thanks in part to these Fortran-based libraries.</li></ul><h3>BBC…Not that one :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*AbfEjGON0C52GcwQ18bvTw.jpeg" /><figcaption>Credits: TutorialsPoint Numpy</figcaption></figure><p>Okay, hear me out. I used to associate the word <strong>“broadcast”</strong> with the BBC <strong>(British Broadcasting Corporation).</strong> So when I first saw “broadcasting” in the NumPy docs, I genuinely thought it was something related to <strong>messaging or media.</strong></p><p>Turns out, <strong>broadcasting</strong> is a core feature in NumPy that enables operations on arrays of different shapes. If the shapes are compatible, NumPy automatically expands the smaller array to match the larger one — without making actual copies — so that element-wise operations can proceed smoothly.</p><p><strong>Out of curiosity, I looked up the meaning of the verb <em>broadcast</em>. It means “to disseminate” — and then I looked up <em>disseminate</em>, which means “to spread information.”</strong> In NumPy’s case, it’s literally about spreading values to enable fast computation. English, right?</p><p>And speaking of English, I also came across the word <strong>ravel</strong> for the first time in the NumPy docs. It means to “untangle” or “unroll” something — which maps beautifully to what numpy.ravel() does: it flattens an array. <strong>Fun fact: <em>unravel</em> is both a synonym <em>and</em> an antonym, depending on context. That day, I learned vocabulary <em>and</em> NumPy!</strong></p><h3>Little Endian Vs Big Endian :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/1*dicRL34faZS20I43FrkXKQ.gif" /><figcaption>Credits: Chortle CSS edu</figcaption></figure><p>Well if you are 90’s kid you would have heard this for sure . This one wasn’t new to me, but I thought it might be for newer generations.Little endian and big endian refer to how data (like integers) is stored in memory. Take the number 7523, for example:</p><p>In <strong>big endian</strong>, it’s stored starting with the most significant byte</p><p>In <strong>little endian</strong>, it’s the opposite — starting with the least significant byte.</p><p>Most modern processors (like x86, x64, and ARM) use little endian, but some older processors and network protocols still use big endian.</p><p>What does this have to do with NumPy? Well, it has a feature called <strong>byte swapping</strong> that allows you to switch the byte order of an array to match the target system’s architecture. The original array stays unchanged, but you get a new one with the bytes rearranged. Super handy for interoperability.</p><h3>ASV:</h3><p>Okay, this isn’t in the main NumPy documentation, but I stumbled upon it while trying to clone and build NumPy locally.</p><p>NumPy is performance-critical software. Any code change must not degrade performance — but you can’t test everything manually. That’s where <strong>Airspeed Velocity (ASV)</strong> comes in. It’s a benchmarking tool that tracks performance over time. It’s especially useful for projects like NumPy with C/C++ integrations.</p><p>I work with a lot of Python libraries that integrate C code, and I can already see how ASV could help me track performance regressions in my own work.Not only that you can use ASV to benchmark your own code from different branches or over the entire lifetime .</p><h3>Meson:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3npnSUeQGOBn1wO4q2ZQdw.png" /><figcaption>Credits: Wikipedia</figcaption></figure><p>If you’re from the C++ or Java world, <strong>Meson</strong> is kind of like CMake or Gradle. It’s a build system written in Python that uses a domain-specific language (DSL), similar to how Gradle uses Groovy or Kotlin.</p><p>Meson is modern, fast, and cross-platform. It can be used to build not just C and C++ projects but also Python and others. I haven’t had the chance to play with it yet, but it’s now on my list.</p><h3><strong>Final Thoughts:</strong></h3><p>If you think some of these things are trivial — well, I wouldn’t entirely disagree. But for me, they were eye-opening, and I found them genuinely fascinating. So I wanted to share them with others who might also appreciate these “aha!” moments.</p><p>Let me know if you’ve had similar discoveries reading documentation — you never know what gems are hidden in plain sight.</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://differ.blog/inplainenglish"><strong>Differ</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=087bc8c9c999" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/7-surprising-lessons-from-the-numpy-documentation-087bc8c9c999">7 Surprising Lessons from the Numpy Documentation</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State of the Internet 2024: Surprising Trends, Global Shifts, and the AI Impact]]></title>
            <link>https://medium.com/@vasanthbharathi07/state-of-the-internet-2024-surprising-trends-global-shifts-and-the-ai-impact-b7ab6ae3305b?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7ab6ae3305b</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[2024]]></category>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[internet]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Sat, 01 Feb 2025 19:33:25 GMT</pubDate>
            <atom:updated>2025-02-02T16:06:48.321Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_ahs94flpitAjQKEZyC4Q.png" /><figcaption>Credits: Cloudflare 2024</figcaption></figure><h3>What’s Cloudflare &amp; Why Should You Care?</h3><p>Imagine the Internet as a chaotic highway — data zipping around like caffeinated bikers, some cruising smoothly, others crashing into roadblocks . Enter <strong>Cloudflare</strong>, the ultimate traffic cop, keeping things fast, secure, and congestion-free. It’s a <strong>Content Delivery Network (CDN)</strong> that makes websites and apps load faster, fight off cyberattacks, and stay online even when the Internet throws a tantrum.</p><p>Now, let’s talk about <strong>Cloudflare Radar</strong> — a giant telescope peering into the depths of Internet traffic worldwide. Every year, Cloudflare drops its <strong>Year in Review</strong>, revealing surprising, hilarious, and sometimes downright weird trends about how we humans use (and abuse) the Internet.</p><p>And this year? I’m diving into the <strong>2024 report</strong>, with a special focus on <strong>India</strong> — because, let’s be honest, we Indians don’t just “use” the Internet, we <strong>dominate</strong> it. I’ll also throw in comparisons with other countries whenever the data gets spicy. Buckle up — this is going to be an eye-opening ride through the digital highways of 2024!</p><h3>Internet usage/Traffic:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XkO7XxYbLA4qJn7EIIlNhA.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>Internet traffic shot up by <strong>17.2%</strong> in 2024, but here’s where things get weird — until <strong>September</strong>, it was just crawling along at a modest <strong>2%</strong> increase. Then, <strong>boom!</strong> It skyrocketed to <strong>18%</strong> by the end of December. Coincidence? Maybe. But let’s put on our tin foil hats for a second:</p><ul><li><strong>US Elections?</strong> Yep, that happened in November — political chaos, memes, and last-minute doomscrolling.</li><li><strong>Holiday travel?</strong> Everyone scrambling for tickets, hotel deals, and last-minute Amazon orders.</li><li><strong>Something else?</strong> Well, that’s the mystery!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i4-Uks4visQowHnx5gVd9w.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>Meanwhile, <strong>India’s internet traffic barely budged.</strong> Weird, right? Turns out, many users in India reported <strong>Cloudflare performance issues</strong> (so, not just your Wi-Fi acting up). Given that <strong>India ranks third in Cloudflare’s customer base</strong> (or so says Google — so take that with a <strong>truckload</strong> of salt), this was unexpected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_mIEcn6f8CTmNeB5XlbiQ.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>Then we have <strong>Russia</strong>, where internet traffic <strong>dropped by a massive 24.2%</strong> — no surprises there, given the sanctions. But the dip wasn’t gradual; it <strong>plunged hard</strong> around <strong>June and July</strong>, then kept sinking like a broken submarine.</p><p>And China? <strong>Cloudflare basically shrugged and said, “Sorry, no data”</strong> — which is hilarious and ominous at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K5PCTbcUKa5FBUKe7Xzuxw.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>But the real shocker? <strong>Iceland</strong>. Yes, the land of volcanoes and Ice saw <strong>a jaw-dropping 43.3% increase</strong> in traffic, dwarfing the <strong>UK and USA’s 20% growth</strong>. What’s going on up there? Is everyone in Iceland just binge-watching Netflix or Vix? Someone explain.</p><p>I haven’t checked all <strong>197 countries</strong>, but one thing’s for sure — <strong>2024 was an absolutely wild year for the Internet.</strong></p><h3>Popular Generative AI Service:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SPKzzI31BNbGrlVKOlFMpg.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>Honestly, after reading this report, I had a bit of an existential crisis — I realized just <strong>how small my AI world was</strong>. Up until now, I’ve only used <strong>ChatGPT, Claude, Perplexity, and GitHub Copilot</strong>. That’s it. My entire AI experience summed up in four platforms.But then, this report hit me like a ton of bricks. <strong>There’s a whole AI universe out there!</strong> So, like any responsible Internet user, I did what we all do in times of uncertainty — I <strong>Googled to learn about other platforms.</strong></p><h3>Popular E-Commerce:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8OKQos03KKAytcoxcSIiw.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>The biggest surprise in this list isn’t <strong>Amazon holding the #1 spot</strong> — no shocker there. What really stood out was the dominance of <strong>five Chinese companies</strong> in global e-commerce. Except for <strong>AliExpress</strong>, I actually had to <strong>Google the rest</strong> just to figure out who they were. That says a lot about how much the e-commerce landscape is shifting.</p><p>The last two entries on the list were just as unexpected. <strong>Mercado Libre</strong>, an Argentine company, and <strong>Wildberries</strong>, from the Russian Federation, made the cut. Given the <strong>sanctions on Russia</strong>, it’s possible that more people turned to domestic platforms, or maybe <strong>Wildberries was already more popular than I realized</strong>. Either way, it’s an interesting trend that shows how regional platforms are gaining ground in the global market.</p><h3>AI-BOT Traffic:</h3><p>Let’s break down what <strong>AI bot traffic</strong> actually means. All the major <strong>Generative AI companies</strong> have their own <strong>web crawlers</strong>, constantly scanning the internet to collect data for training their models. This relentless AI-driven web crawling has contributed <strong>significantly</strong> to the overall increase in internet traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*birXu3Bv8qQv7oRGr8nvXQ.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>For those unfamiliar with <strong>ByteSpider</strong>, it’s <strong>TikTok’s (ByteDance’s) official web crawler</strong>. Due to various <strong>restrictions in the US and other countries</strong>, its activity has dropped quite a bit. Meanwhile, <strong>ClaudeBot</strong> seems to be far more active than <strong>ChatGPT’s crawler</strong>, which is an interesting shift.</p><p>On the other hand, both <strong>Perplexity</strong> and <strong>OAI-SearchBot</strong> have <strong>barely made a dent</strong> in traffic. Speaking of <strong>OAI-SearchBot</strong>, its job is to create an index of websites that OpenAI can surface in its <strong>SearchGPT</strong> product.</p><p>Apparently, there are even <strong>companies dedicated to tracking bot activity on websites</strong>, which honestly sounds like a fascinating industry on its own. But the <strong>real mystery?</strong> <strong>Gemini.</strong> What’s going on there? <strong>Is it just not that popular, or does Cloudflare not have visibility into its activity?</strong> Either way, it’s a bit of a head-scratcher.</p><h3>IOS vs Android</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K5ybslktLq2BykI4PInAYQ.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>There’s a clear split between <strong>iOS-heavy</strong> and <strong>Android-heavy</strong> regions, so I decided to take a closer look — and that’s when I found this <strong>map</strong>.</p><ul><li><strong>Purple = iOS dominance</strong></li><li><strong>Dark Green = Android reigns supreme</strong></li></ul><p>Some interesting takeaways:</p><ul><li><strong>Saudi Arabia</strong> stands out — it’s almost <strong>completely iOS</strong>, unlike the rest of the Gulf countries.</li><li><strong>India?</strong> No surprises there — <strong>91% Android</strong> (glad to be doing my part!).</li><li><strong>Mongolia</strong> is right in the middle, with an almost <strong>perfect 50/50 split</strong> between iOS and Android.</li><li><strong>Macau, China</strong> — aka the <strong>“Vegas of the East”</strong> — has the <strong>highest iOS usage</strong> at <strong>65%</strong>, second only to some small regions like <strong>Faroe Islands, Jersey, and Monaco</strong>.</li></ul><p>It’s fascinating to see how smartphone preferences vary across the world — whether it’s about affordability, ecosystem loyalty, or just status symbols.</p><h3>HTTP Version Adoption:</h3><p>Before I dive deep into HTTP adoption , there are three types of HTTP currently in use HTTP1.1, HTTP 2 and HTTP 3 . I found a very good <a href="https://www.linkedin.com/pulse/http-10-vs-11-20-30-swadhin-pattnaik/">article</a> explaning the difference , take a look</p><p>HTTP3 is latest and has some really good features , the map you see below is the HTTP3 adoption</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1CD0evYkAzaWaSXJWVftTQ.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>Before diving into the numbers, let’s quickly recap the <strong>three versions of HTTP</strong> currently in use:</p><ol><li><strong>HTTP/1.1</strong> — The old reliable, still kicking around.</li><li><strong>HTTP/2</strong> — Faster, more efficient, and widely adopted.</li><li><strong>HTTP/3</strong> — The latest, packed with some <strong>serious upgrades</strong>.</li></ol><p>I came across a great article explaining the differences — <a href="https://www.linkedin.com/pulse/http-10-vs-11-20-30-swadhin-pattnaik/"><strong>definitely worth checking out</strong>.</a></p><p>Now, onto the data. The map below highlights <strong>HTTP/3 adoption</strong> worldwide, and here are some key takeaways:</p><ul><li><strong>India</strong> has a solid adoption rate at <strong>24%</strong>.</li><li><strong>Iran and Turkmenistan</strong> are at the bottom with the lowest adoption rates.</li><li><strong>Mongolia and Sri Lanka</strong> are the <strong>outliers</strong>, boasting around <strong>35% adoption</strong> — way higher than many other countries.</li><li>The <strong>biggest irony?</strong> The <strong>United States</strong>, where a lot of <strong>HTTP/3 innovation actually happens</strong>, has an adoption rate of just <strong>16.6%</strong> — lower than several other nations.</li></ul><p>It’s interesting to see how cutting-edge tech spreads unevenly, even when it originates from a particular region.</p><h3>Adoption of Website Technologies:</h3><p>If you’re a <strong>developer</strong>, this section will either <strong>validate your tech choices</strong> or <strong>leave you questioning everything</strong> — because some of these trends <strong>completely caught me off guard</strong>.</p><h4>Popular Web Programming Language:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ymbbftxqSEM56s-aKoBbxA.png" /><figcaption>Credits: Cloudflare radar 2024</figcaption></figure><p>Let’s start with the <strong>biggest shocker</strong>:</p><ul><li><strong>PHP is still alive.</strong> Seriously? I thought we buried that one for good.</li><li><strong>Java, Python, and Node.js</strong> — thankfully, these are still <strong>top-tier</strong>.</li></ul><p>Now, onto the <strong>mysteries and missing pieces</strong>:</p><ul><li><strong>Where is .NET? Go?</strong></li><li><strong>What the heck is KPHP?</strong> I had to <strong>Google it</strong> — turns out, it’s <strong>a fascinating read</strong>.</li></ul><h4><strong>Popular Web Frameworks:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTiEXgIlLjLvX_hi37qToQ.png" /><figcaption>Credits: Cloudlfare Radar 2024</figcaption></figure><p>For <strong>JavaScript frameworks</strong>, the dominance continues:</p><ul><li><strong>Next.js is everywhere</strong> — and for good reason. With <strong>server-side rendering</strong> and its parent company <strong>Vercel gaining traction</strong>, it makes sense.</li><li><strong>Nuxt.js (Vue), Yii (PHP), Livewire (PHP)</strong> — never heard of them, but now I’m intrigued.</li></ul><p>In programming, <strong>not knowing</strong> something is fine — but <strong>never having heard of it? That’s embarrassing</strong>. Time to dig deeper and see <strong>why these are gaining popularity</strong>!</p><h4>Popular Javascript frameworks:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6TGHz3ufpczVjxvcUnwKbw.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><ul><li><strong>React? Still king.</strong></li><li><strong>Wait, Gatsby? RequireJS? AlpineJS? AMP? Stimulus?</strong> Had no idea these were even a thing.</li></ul><h3>Browser Market Share:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnI62BZeKPlZVhlS0yUr7Q.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>Even with the <strong>U.S. government pushing for Chrome to be spun off</strong>, it’s still <strong>my go-to browser</strong> — and honestly, I can’t seem to get comfortable with anything else.</p><p>A few things stood out in the rankings:</p><ul><li><strong>Internet Explorer is finally gone</strong> (about time).</li><li><strong>Firefox is dropping fast — even below Edge?!</strong> That’s wild. I still think Firefox is <strong>better than Edge in so many ways</strong>.</li><li><strong>Samsung Internet? Tried it. Hated it.</strong> (Just my opinion)</li></ul><p>At this point, Chrome’s dominance is almost <strong>too strong</strong> — but if it works, it works.</p><h3>IPV6 Adoption:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*04CEGcLP9_eh3qCFDtRegg.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>I can finally <strong>brag</strong> — India leads the world in <strong>IPv6 adoption</strong> at <strong>68.9%</strong>! Not far behind are <strong>Saudi Arabia, Brazil, Israel, and Mexico</strong>.</p><p>On the flip side, some countries are <strong>stuck in the IPv4 era</strong>:</p><ul><li><strong>Turkmenistan is barely moving forward</strong> — <strong>99.6%</strong> of their IPs are still <strong>IPv4</strong>.</li><li><strong>Syria, Iran, and Iraq</strong> also show <strong>very low IPv6 adoption</strong>.</li><li><strong>Ireland</strong>, despite being home to <strong>tons of data centers</strong>, has surprisingly <strong>low IPv6 adoption</strong>.</li></ul><h3>Bot Traffic Sources:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*su1Jv_CSFT7gTPEv6Fjrew.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>It’s no shock to see the <strong>United States</strong> at the top, but <strong>Iran</strong> at <strong>#3</strong> for bot traffic? That raised an eyebrow. Could it be a strategy to fend off cyberattacks from other countries?</p><p>What <strong>really surprised me</strong> was seeing <strong>India</strong> on the list. I always thought we were lagging behind in <strong>AI</strong> — but we’re clearly <strong>catching up</strong> fast, especially when compared to <strong>China, the UK, and Singapore</strong>.</p><p>I’m definitely excited about how much ground India is making up in the world of <strong>AI and tech</strong>!Commonly Exploited Vulnerabilities:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4MdFSENhZCa0ARZZ6dZjA.png" /><figcaption>Credits: Cloudflare Radar 2024</figcaption></figure><p>I still vividly remember when my previous company got hit by the infamous <strong>Log4j CVE</strong>. I was part of the <strong>Cybersecurity team</strong>, and we used our app to scan all customer-facing binaries. To our surprise, nearly <strong>25%</strong> of them were <strong>impacted</strong>.</p><p>Fast forward to now, and it looks like <strong>Log4j</strong> is still <strong>the most exploited CVE</strong> out there. Some vulnerabilities just seem to have <strong>staying power</strong>, and this one is definitely a reminder to keep our systems on high alert!</p><h3><strong>Conclusion:</strong></h3><p>A huge <strong>thank you</strong> to the <strong>Cloudflare team</strong> for capturing and presenting such fascinating data so clearly for the public. The insights shared are truly <strong>intriguing</strong> and offer a wealth of information about the <strong>state of the internet</strong>.</p><p>If you’ve made it this far, I highly recommend visiting the <a href="https://radar.cloudflare.com/year-in-review/2024?compareWith=CN"><strong>Cloudflare Radar 2024</strong> </a>site. There are bound to be some <strong>interesting correlations</strong> waiting for you to explore.</p><p>If you found this article interesting, feel free to <strong>give a clap</strong> and <strong>follow me</strong> for more engaging and thought-provoking content. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7ab6ae3305b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Peek at Python Implementations: CPython, PyPy, Jython & Brython]]></title>
            <link>https://python.plainenglish.io/a-peek-at-python-implementations-cpython-pypy-jython-brython-9751c393b2f0?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/9751c393b2f0</guid>
            <category><![CDATA[jython]]></category>
            <category><![CDATA[cpython]]></category>
            <category><![CDATA[pypy]]></category>
            <category><![CDATA[brython]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Sat, 18 Jan 2025 05:21:39 GMT</pubDate>
            <atom:updated>2025-01-20T07:25:34.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7PtKWclESRGsfjd3_ng8A.jpeg" /><figcaption>Credits: Bite Code</figcaption></figure><p>When I first started learning Python, I discovered through documents and video tutorials that it was easy to learn. Its simple syntax, lack of need for variable declarations, and no concerns about memory management or pointers made it very approachable. I kept learning and using Python for a long time.</p><p>One day, while reading the official Python documentation, I came across the term “PyPy.” Curious, I delved into it and learned that PyPy is an implementation of Python. This sparked my interest in understanding what a Python implementation actually is.</p><p>Rather than just providing theoretical explanations — since there are already many resources available — I will explore the differences between various Python implementations and compare their performance. I’ll also discuss at a high level when it’s best to use and not to use each implementation.</p><h3>How to Know Your Current Python Implementation<strong>:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*WNmhyP_62Vi7qwTChPVcNA.png" /><figcaption>Credits: GIPHY</figcaption></figure><p>To find out which Python implementation you are using, you can utilize the platform module and query it for the implementation name.</p><pre>import platform<br>print(platform.python_implementation())</pre><p>If this is your first time hearing about Python implementations, you’re likely using the default one: CPython. However, those intentionally using alternative implementations may already know this trick.</p><p>Now that you’re reading this, you’re in the know circle too — kudos!</p><h3>Why Not Just Use Pure Python? Why Do We Need Python Implementations?<strong>:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*o48BzhY3LzoHZqnhWTmR5A.gif" /><figcaption>Credits: BigFooty-Forum</figcaption></figure><p>When Guido van Rossum created Python, he designed it as an interpreted language — what we call “Pure Python.” While this approach is elegant and easy to work with, it’s not exactly a speed demon. Pure Python, interpreted directly, tends to be slower compared to implementations that integrate compiled languages like C.</p><p>This can become a real bottleneck for computationally heavy tasks. Plus, interacting directly with the operating system or hardware can feel like trying to win a race with a tricycle — technically possible, but not ideal.</p><p>So, the next time someone asks you which Python implementation you’re using, don’t be caught off guard — just casually drop some knowledge (and maybe a smirk). You’re officially in the know now!</p><h3>Benchmarking Different Python Implementations</h3><p>Before diving into the specifics of each Python implementation, let’s set some ground rules.</p><p>I’ll be using as many online Python implementation compilers as possible for this benchmarking exercise. Why? Because installing each implementation locally is not only tedious but could also require an entire separate Medium article just to explain the setup for each one.</p><p>So, let’s skip the hassle and get straight to the fun part. Buckle up — let’s rock and roll!</p><h3><strong>CPython</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*COXVHZ4g24jaEvkeZdWqVg.png" /><figcaption>Credits: Real Python</figcaption></figure><p>Let’s get one thing straight — CPython and Cython are <em>not</em> the same thing, so don’t let the similar names confuse you.<strong>CPython</strong> is the reference implementation of Python, <strong>written in C</strong>. It’s the default and most widely used Python interpreter.If you’ve installed Python based on a quick Google search, there’s a 99% chance you’re using CPython.</p><p>To see how CPython handles compute-intensive tasks, I wrote a small piece of code and ran it using an online <a href="https://www.programiz.com/python-programming/online-compiler/">Cpython compiler</a>. The code involved a nested loop that calculates the square of the sum of i and j, assigning the result to a variable. The complexity of this operation is O(n2)</p><pre>import platform<br>import time<br><br>def generateNumbers():<br>    result = 0<br>    for i in range(1,10000):<br>        for j in range(1,10000):<br>            result = (i+j) ** 2<br>    return result<br><br>print(platform.python_implementation())<br>start_time = time.time()<br>print(generateNumbers())<br>elapsed_time = time.time() - start_time<br>print(elapsed_time)</pre><p><strong>Output as follows:</strong></p><p>Took ~12 seconds to execute the loop.This demonstrates that while CPython is highly versatile, its performance can lag for computationally intensive operations.</p><pre>CPython<br>399920004<br>11.920317649841309<br><br>=== Code Execution Successful ===</pre><p><strong>When not to use CPython:</strong></p><ol><li>For CPU-intensive tasks that take forever to run, like solving optimization problems.</li><li>When memory usage is a concern — CPython’s high memory footprint can become a bottleneck.</li><li>If you need to integrate Python with other languages like Java or .NET.</li></ol><p>So, if you’re stuck in a long computation and wondering, “Is there a better way?” — the answer might be trying out a different Python implementation. After all, there’s a whole world beyond CPython!</p><h3>PyPy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*jC8QiC2ZsUXw7YIkyXCLXw.jpeg" /><figcaption>Credits: Wikipedia</figcaption></figure><p>PyPy is an alternative Python implementation that originated in the early 2000s and gained popularity around 2007. The key difference compared to CPython lies in its use of a JIT (Just-In-Time) compiler, which significantly speeds up code execution. So, what does that mean? While CPython interprets bytecode directly, PyPy analyzes the running code and dynamically compiles frequently executed parts into machine code (native code tailored to the hardware). This compiled machine code runs much faster than interpreted bytecode. If you know the specific hardware where your application will run, PyPy can deliver a tremendous performance boost. To demonstrate, I ran the same nested loop code on anonline <a href="https://ideone.com/l/python-pypy">PyPy Compiler</a></p><p>Output from PyPy Compiler:</p><p>Completed just in ~0.12 seconds , woah !! what a difference !</p><pre>PyPy<br>399920004<br>0.138823032379</pre><p><strong>When not to use PyPy:</strong></p><ol><li>If your application relies heavily on CPython-specific extensions or libraries like NumPy, PyPy might not perform as expected.</li><li>PyPy’s performance relies on optimizing for the hardware it runs on. If the hardware architecture is not well-defined, the benefits of dynamic compilation may be limited.</li><li>PyPy is not the best choice if your Python code has extensions written in C++ or C, as compatibility can pose significant challenges.</li></ol><h3>Jython</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5vSV9uJ3xI0lin4RJdmjA.png" /><figcaption>Credits: Github</figcaption></figure><p>Jython, developed by Jim Hugunin in 1997, works by converting Python code into Java bytecode, which is then executed by the Java Virtual Machine (JVM). If your application requires Java integrations, Jython is the ideal choice, and it also offers cross-platform support.</p><p>I tried running the same code on the Lets try the <a href="https://www.tutorialspoint.com/execute_jython_online.php">Jython online compiler</a>—here’s how it performed.</p><p>Output from Jython Compiler</p><p>Took ~9 seconds</p><pre>Jython<br>399920004<br>8.73699998856</pre><p><strong>When not to use Jython:</strong></p><ol><li>If your application requires high performance, Jython may not be the best option, as it doesn’t benefit from certain optimizations found in other Python implementations.</li><li>If your application doesn’t interact with Java, Jython won’t provide significant advantages.</li><li>The Jython community has slowed down on new releases, so if you need the latest features and updates in Python, Jython might not keep up with CPython’s rapid development.</li></ol><h3>Brython:</h3><p>Brython, first created by French computer scientist Pierre Quentel, is designed to enable web developers to write web applications using Python within the browser environment. It allows you to write Python code that directly executes inside the user’s browser. Brython works by converting Python code into JavaScript, which is then executed in the browser.</p><p>If you want to integrate Python with web pages, JavaScript, or HTML, Brython is an excellent choice. It’s also particularly useful for rapid prototyping, learning, and experimentation.</p><p>Lets try same code on <a href="https://brython.info/tests/editor.html?lang=en">online Brython compiler</a></p><p>Output for the same code in Brython compiler</p><p>It took ~9 seconds</p><pre>Brython<br>399920004<br>8.683000087738037</pre><p><strong>When not to use Brython:</strong></p><p>1)For complex, large-scale web applications with significant server-side logic, Brython might not be the most efficient or scalable solution.</p><p>2) Since Brython relies on JavaScript transpilation, performance might not always be as optimal as native JavaScript code, especially for computationally intensive tasks.</p><p>3) If your project heavily relies on specific JavaScript libraries or frameworks, integrating them with Brython might require additional effort and potentially introduce compatibility issues.</p><p>If you enjoyed this article, don’t forget to give <strong>claps</strong> and <strong>follow me</strong> for more articles on Software Engineering. Stay tuned for more!</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://cofeed.app/"><strong>Check out CoFeed, the smart way to stay up-to-date with the latest in tech</strong></a> <strong>🧪</strong></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9751c393b2f0" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/a-peek-at-python-implementations-cpython-pypy-jython-brython-9751c393b2f0">A Peek at Python Implementations: CPython, PyPy, Jython &amp; Brython</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can PostgreSQL Handle All Database Needs?]]></title>
            <link>https://medium.com/@vasanthbharathi07/can-postgresql-handle-all-database-needs-34f860d4a9a8?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/34f860d4a9a8</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[distributed]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[unified]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Mon, 16 Dec 2024 10:20:32 GMT</pubDate>
            <atom:updated>2024-12-16T11:41:58.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2WxOTB_zG8m-py-7fpmiMA.jpeg" /><figcaption>Credits To: Pigsty</figcaption></figure><p>I was briefly involved in developing an open-source framework called <strong>OpenMBEE</strong>, where leading aerospace organizations collaborated to create a model-based systems engineering tool. This framework aimed to make it easier for engineers to collaborate on and review models efficiently.</p><p>While building the application, we used Elasticsearch as our primary database to store and index documents. References to these documents were stored in PostgreSQL. This approach was chosen because Elasticsearch excelled at storing and indexing documents, outperforming PostgreSQL in this specific use case.</p><p><strong>With the rise of AI, IoT, and social networking, we’ve seen an explosion of specialized databases like Elasticsearch, Pinecone, Neo4j, Milvus, InfluxDB, and more</strong>. However, PostgreSQL, being an open-source database, has evolved significantly. It now offers numerous extensions, making it capable of handling a wide variety of applications. In fact, in many cases, PostgreSQL can replace the need for specialized databases entirely.</p><p>Next, I’ll compare some popular databases with their equivalents in PostgreSQL to highlight its versatility.</p><h3>Vector Database:</h3><p>A vector database is designed to store and search high-dimensional vector data for similarity queries. This makes it ideal for applications in machine learning, recommendation systems, and tasks involving image or text embeddings.</p><p>Popular vector databases include <strong>Pinecone</strong>, <strong>Weaviate</strong>, and <strong>Milvus</strong>. In PostgreSQL, the <strong>pgVector</strong> extension provides support for vector similarity search, enabling similar functionality within the PostgreSQL ecosystem.<strong>DiskANN algorithms</strong> were integrated in pgVector to enhance performance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*uTn154me82jC9Brn1n713w.jpeg" /><figcaption>Courtesy: EWOTA</figcaption></figure><h3><strong>Time-Series Database:</strong></h3><p>A <strong>time-series database (TSDB)</strong> is optimized for storing, querying, and analyzing time-stamped (temporal) data. This type of data typically consists of sequential measurements, events, or observations recorded over time, often at regular intervals.</p><p>Famous examples of TSDBs are <strong>InfluxDB</strong> and <strong>Prometheus</strong>. PostgreSQL offers <strong>TimeScaleDB</strong> as an extension to handle time-series data efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O66_le6R0Pl97AYPm1sQYw.png" /><figcaption>Courtesy: Timescale</figcaption></figure><h3>Distributed “SQL” Databases:</h3><p>There is a key distinction between distributed databases and distributed SQL databases. A <strong>distributed database</strong> is designed for NoSQL use cases, with <strong>Cassandra</strong> being a notable example, initially developed by Facebook.</p><p>In contrast, <strong>distributed SQL databases</strong> bring the principles of distributed systems to relational databases. The concept gained prominence in 2012 when Google introduced its <strong>Spanner</strong> database — a groundbreaking distributed SQL database built for global scale.</p><p>Other leading distributed SQL databases include <strong>CockroachDB</strong> and <strong>YugabyteDB</strong>. PostgreSQL can achieve similar capabilities with <strong>Citus</strong>, an extension that transforms PostgreSQL into a distributed database with sharding and parallel processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1clxQURveQeHdu4kne0VBw.png" /><figcaption>Courtesy: Github — Citus Data Repo</figcaption></figure><h3>Full Text search databases:</h3><p>A full-text search database specializes in storing and efficiently searching large amounts of unstructured text data. Unlike traditional databases, these are optimized for querying content within documents.</p><p>Prominent examples include <strong>Apache Lucene</strong>, <strong>Solr</strong>, and <strong>Elasticsearch</strong>. PostgreSQL supports full-text search capabilities through <strong>ParadeDB</strong>, an extension designed for fast performance in search and analytics, eliminating the need for external search engines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*HQQONzt8zV3xh2vfyRziNg.png" /><figcaption>Courtesy: Parade DB</figcaption></figure><h3>Geo Spatial Database:</h3><p>Geospatial databases are designed to store, manage, and analyze geographic data, such as points, lines, and polygons, along with their attributes. They are optimized for spatial queries like finding nearby locations, calculating distances, and analyzing spatial relationships.</p><p>Well-known geospatial databases include <strong>ESRI</strong>, <strong>Oracle Spatial</strong>, <strong>Snowflake (with GS support)</strong>, and <strong>SAP HANA (with GS support)</strong>. PostgreSQL offers <strong>PostGIS</strong>, a robust extension that adds geospatial data types and functions, enabling advanced storage, querying, and analysis of spatial data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*LZilzefampA9LZXVfE651g.png" /><figcaption>Courtesy: Dev Community</figcaption></figure><h3>Graph Database:</h3><p>A graph database uses graph structures to represent data as a network of nodes (entities) and edges (relationships), unlike relational databases that use tables. This makes them ideal for applications requiring relationship modeling, like social networks or recommendation engines.</p><p>Popular graph databases include <strong>Neo4j</strong>, <strong>Dgraph</strong>, and <strong>ArangoDB</strong>. PostgreSQL has <strong>Apache AGE (A Graph Extension)</strong>, which allows users to store and query graph data within PostgreSQL. AGE supports the <strong>openCypher</strong> query language, enabling intuitive graph queries while maintaining PostgreSQL’s relational model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*IUw41unPMC2Ae9yNY0hvOg.png" /><figcaption>Courtesy: Github</figcaption></figure><h3><strong>The Missing Piece: Redis</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ypPfBVlh8wZnK5JF_4zF7A.png" /><figcaption>Courtesy: Wikipedia</figcaption></figure><p>While PostgreSQL offers numerous extensions to support a variety of database types, it currently lacks an equivalent for <strong>Redis</strong>, a popular in-memory data store known for its high performance and low latency.</p><p>If PostgreSQL were to introduce Redis-like capabilities, it could potentially serve as a single, unified database solution for all types of applications. Having one database for storing and managing all data would simplify application architecture, improve performance, reduce maintenance overhead, and minimize monitoring efforts.</p><p>If you enjoyed this article, don’t forget to give <strong>claps</strong> and <strong>follow me</strong> for more articles on Software Engineering. Stay tuned for more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34f860d4a9a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to migrate apps from Java 8 to Java 17 with a single command?]]></title>
            <link>https://medium.com/@vasanthbharathi07/how-to-migrate-apps-from-java-8-to-java-17-with-a-single-command-fae32aba8922?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/fae32aba8922</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[rewrite]]></category>
            <category><![CDATA[refactor]]></category>
            <category><![CDATA[java17]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Sun, 24 Nov 2024 12:13:22 GMT</pubDate>
            <atom:updated>2024-11-24T12:26:08.525Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*f69Ve593j8_vxQg0Cu7hAw.jpeg" /><figcaption>Credits: OpenRewrite</figcaption></figure><p>Before I transitioned into cloud-native development, I spent my days as a Java developer, primarily customizing commercial off-the-shelf (COTS) applications and building web solutions with Spring Boot. Back then, one of the recurring debates in our team revolved around upgrading from Java 8 to Java 11.</p><p><strong>One of our <em>favourite</em> recurring topics was upgrading from Java 8 to Java 11. Sounds simple, right? Wrong</strong>. Every time the conversation started, it felt like selecting a movie in Netflix (popularly called as infinite browsing), you keep browsing for a good movie and then doze off. Similary migration efforts were affected by resource constraints, shifting priorities, budget drama, you name it. Inevitably, the upgrade would get shoved into the “we’ll do it later” bucket, where tech debt grows up into a full-blown monster.</p><p><strong>Fast forward a couple of years, and that simple Java 8-to-Java 11 upgrade turned into a Java 8-to-Java 17 ordeal</strong>. It felt like trying to roll back all your grandma’s knitting threads into a neat ball — every tug revealed another tangled mess, knots you didn’t expect, and the occasional <strong><em>“How did this even happen?” </em></strong>moment. What started as a small task quickly turned into an overwhelming mission of untangling chaos, leaving you wondering, <strong><em>“Why didn’t we just deal with this earlier?</em></strong>. Even tech giants face these challenges. It’s a universal truth in software development: ignoring tech debt today often means paying for it with compounded interest tomorrow.</p><h3>What is OpenReWrite:</h3><p><strong>Meet Jonathan Schneider, who was a developer at Netflix</strong>, encountered similar challenges with tech debt. In case you didn’t know, Netflix relies heavily on Java for product development and they have contributed a lot to the open source. To address this, Jonathan developed a framework called <strong>OpenRewrite</strong>. Initially, it was created to help Netflix automate and simplify their code migrations. Later, he made the framework open source, enabling other developers to benefit from it. <strong>He has since founded a company called Moderna, which extends the capabilities of OpenRewrite to support multiple programming languages such as Python, C#, and more.</strong></p><p>The primary purpose of OpenRewrite is to <strong>automate code refactoring at scale</strong>. It allows developers to perform large-scale transformations of source code across multiple repositories, programming languages, and frameworks, ensuring consistency and adherence to modern best practices.You can take a look at his Github repo (<a href="https://github.com/openrewrite/rewrite">here</a>).</p><h3><strong>What Is A Recipe In OpenReWrite:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*bD9RlRg-jzKMOv0HYdbwkA.png" /><figcaption>Credits: Dreamstime.com</figcaption></figure><p>Using OpenRewrite is straightforward. All you need to do is add the OpenRewrite plugin to your Gradle or Maven build. I won’t go into the details of setting up Gradle or Maven here — those are well-covered in the link below.</p><p><strong><em>Gradle &amp; Maven based builds can refer below links:</em></strong></p><ul><li><a href="https://docs.openrewrite.org/running-recipes/running-rewrite-on-a-gradle-project-without-modifying-the-build">Running Rewrite on a Gradle project without modifying the build | OpenRewrite Docs</a></li><li><a href="https://docs.openrewrite.org/running-recipes/running-rewrite-on-a-maven-project-without-modifying-the-build">Running Rewrite on a Maven project without modifying the build | OpenRewrite Docs</a></li></ul><p><strong>The key feature of OpenRewrite is its use of recipes.</strong> <strong>There are over 2,000 recipes available, designed to help automate various migration and refactoring tasks.</strong></p><p>So, what exactly are recipes? Think of them like cooking recipes, but for your code. In OpenRewrite, recipes are predefined or custom sets of rules that guide how to “cook up” transformations in your codebase. Just like a cooking recipe provides steps to create a consistent and delicious dish, OpenRewrite recipes automate tasks like refactoring, modernization, and cleanup, ensuring consistent, large-scale changes across your codebase. They are the foundation of OpenRewrite’s automation, helping developers make changes quickly, safely, and efficiently — without the risk of “burning the code.”</p><h3>How to use OpenReWrite:</h3><p>Let’s talk about refactoring your code to migrate from Java 8 to Java 17. Sounds daunting, right? But here’s the good news: OpenRewrite makes it much simpler. All you need is the built-in recipe called <strong>“Java8toJava17.”</strong></p><pre>plugins {<br>    id &#39;org.openrewrite.rewrite&#39; version &#39;5.0.0&#39;<br>}<br><br>dependencies {<br>    rewrite &#39;org.openrewrite.recipe:rewrite-migrate-java:2.0.0&#39;<br>}</pre><p>First, pull the required dependencies as shown below. Once you’re set up, it’s just a matter of running a single Gradle command and invoking the recipe name. And just like that, your codebase is transformed from Java 8 to Java 17.</p><pre>./gradlew rewriteRun -Drewrite.recipe=org.openrewrite.java.migrate.Java8toJava17</pre><p>Now, here’s the catch — it’s not <em>entirely</em> that simple. You’ll still need to perform extensive testing to confirm everything works as expected. But here’s the real magic: by automating the heavy lifting of refactoring, you significantly reduce the manual effort required for the upgrade. This frees up your time and resources to focus on what truly matters — verification and validation.</p><p>Pretty cool, right? <strong>Rewrite doesn’t just save time; it makes daunting tasks feel achievable.</strong></p><h3><strong>Some Eye Catching Interesting Recipes:</strong></h3><p><strong>SimplifyBooleanExpressions:</strong></p><pre>if (myObj == true) { ... }  // Before Refactor<br>if (myObj) { ... }          // After Automated Refactor</pre><p><strong>UseStringIsEmpty:</strong></p><pre>myString.length() == 0 //Before Refactor<br>myString.isEmpty()     //After Automated Refactor</pre><p><strong>UseJavaStreamAPI: (This is my favourite)</strong></p><pre><br>for (String s : myList) <br>{ <br>  if (s.startsWith(&quot;Magic&quot;)) <br>  { <br>  filtered.add(s); <br>  } <br>} // Before Refactor<br>list.stream().filter(s -&gt; s.startsWith(&quot;Magic&quot;))<br>      .collect(Collectors.toList()); // After Automated Refactor</pre><p><strong>Junit4To5Migration:</strong></p><p>Before using this recipe, ensure that your Gradle build is configured with the correct libraries, such as JUnit5 dependencies, to support the migration process effectively.</p><pre>//Junit 4 sample test<br>import org.junit.Test;<br>import org.junit.Before;<br>import org.junit.After;<br>import org.junit.Ignore;<br><br>import static org.junit.Assert.assertEquals;<br>import static org.junit.Assert.assertThrows;<br><br>public class CalculatorTest {<br><br>    private Calculator calculator;<br><br>    @Before<br>    public void setUp() {<br>        calculator = new Calculator();<br>    }<br><br>    @After<br>    public void tearDown() {<br>        calculator = null;<br>    }<br><br>    @Test<br>    public void testAddition() {<br>        assertEquals(5, calculator.add(2, 3));<br>    }<br><br>    @Test(expected = ArithmeticException.class)<br>    public void testDivisionByZero() {<br>        calculator.divide(5, 0);<br>    }<br><br>    @Ignore(&quot;Not implemented yet&quot;)<br>    @Test<br>    public void testSubtraction() {<br>        // Test logic not implemented<br>    }<br>}</pre><pre>//Junit 5 Tests<br>import org.junit.jupiter.api.Test;<br>import org.junit.jupiter.api.BeforeEach;<br>import org.junit.jupiter.api.AfterEach;<br>import org.junit.jupiter.api.Disabled;<br><br>import static org.junit.jupiter.api.Assertions.assertEquals;<br>import static org.junit.jupiter.api.Assertions.assertThrows;<br><br>public class CalculatorTest {<br><br>    private Calculator calculator;<br><br>    @BeforeEach<br>    public void setUp() {<br>        calculator = new Calculator();<br>    }<br><br>    @AfterEach<br>    public void tearDown() {<br>        calculator = null;<br>    }<br><br>    @Test<br>    public void testAddition() {<br>        assertEquals(5, calculator.add(2, 3));<br>    }<br><br>    @Test<br>    public void testDivisionByZero() {<br>        assertThrows(ArithmeticException.class, () -&gt; calculator.divide(5, 0));<br>    }<br><br>    @Disabled(&quot;Not implemented yet&quot;)<br>    @Test<br>    public void testSubtraction() {<br>        // Test logic not implemented<br>    }<br>}</pre><p>Like this there are a lot of recipes thats helps developers get to the migration finish line</p><h3><strong>What Would Be My Migration Strategy?</strong></h3><p><strong>Using the Java8ToJava17 Migration recipe to upgrade all your source code in one go sounds great, doesn’t it? But should you take that approach?</strong> Well, it really depends on the size and complexity of your application.</p><p>For small, simple apps, this approach might work perfectly — it’s quick and efficient. But if you’re dealing with a large repository, especially a big Monorepo like one I’ve managed before, this could lead to more chaos than comfort. Developers may feel hesitant or lack confidence making such sweeping changes all at once.</p><p>So, what’s the alternative? For large, complex codebases, a piecemeal approach works better — especially if building developer confidence is key. Start small by running recipes that address trivial issues, like <strong>cleanup UnnecessaryThrows</strong>, <strong>RemoveUnusedImports</strong>, or <strong>FinalizeLocalVariables</strong>. Once those changes are applied, create a merge request, review the code, and merge it into the main branch.Then go for a bit more complex tasks like <strong>SimplifyBooleanExpressions,UseStringIsEmpty and UseJavaStreamAPI</strong></p><p>If you already have automated functional tests in place, they can help validate the changes, giving you confidence to move on to the next set of recipes. With this step-by-step approach, you’re still moving fast — but in a controlled, manageable way that minimizes risk and builds trust in the process.</p><h3><strong>How this refactor works?</strong></h3><p>OpenRewrite originally used a concept called the <strong>Abstract Syntax Tree (AST)</strong> to represent the structure of your code. <strong>The AST breaks down code into a tree-like structure, with nodes for syntax elements like classes, methods, and annotations</strong>. This structure allows OpenRewrite to identify and modify code precisely while preserving its formatting and semantics. However, during parsing, some data is omitted when converting the code to an AST.</p><p>Now, OpenRewrite has adopted a new approach called the <strong>Lossless Semantic Tree (LST)</strong>. <strong>Unlike the AST, the LST retains every detail of your code — comments, whitespace, indentation, and more — ensuring nothing is left out</strong>. This makes the transformation process even more reliable and comprehensive.</p><p>For a more detailed explanation of LSTs, check out the link below</p><p><a href="https://www.moderne.ai/blog/lossless-semantic-tree-the-complete-code-data-model-for-automated-code-refactoring-and-analysis">What is the Lossless Semantic Tree (LST)?</a></p><h3>Why AI Can’t do this refactor?</h3><p>The answer lies in how <strong>OpenRewrite</strong> performs its refactoring, using the <strong>Lossless Semantic Tree (LST)</strong>. For generative AI to take on the same task, it would need access to the entire codebase to perform the refactoring, which can be incredibly time-consuming and labor-intensive — especially for complex, large codebases.</p><p>Until AI evolves to efficiently process and infer solutions from huge codebases, <strong>OpenRewrite</strong> remains the best tool for the job. Give this tool a try , finish your refactoring faster and use the remaining time to play Grand theft Auto (lol!)</p><p>If you enjoyed this article, don’t forget to give <strong>claps</strong> and <strong>follow me</strong> for more articles on Software Engineering. Stay tuned for more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fae32aba8922" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Apps Without the Need for Local Installations or Environments]]></title>
            <link>https://python.plainenglish.io/build-apps-without-the-need-for-local-installations-or-environments-a1b38740a0a9?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1b38740a0a9</guid>
            <category><![CDATA[devcontainer]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Mon, 18 Nov 2024 03:30:27 GMT</pubDate>
            <atom:updated>2024-11-19T07:21:38.221Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*HOAaQ13dTS__d8cNwoMmmA.png" /></figure><p>As a full stack developer,I often juggle multiple projects. And I’m sure many developers out there can relate — they don’t work on just one codebase or technology stack.</p><p>Take a classic scenario of a full-stack developer. You might have a backend Python project and a React frontend in active development. At the same time, you’re tasked with maintaining a legacy Java project. Meanwhile, to expand your skills, you decide to learn Go and experiment with some new Python libraries or frameworks.</p><p>Now, think about the tools and environments you’d need to manage for all these projects. You’d have multiple Python virtual environments with various libraries, Node.js for frontend dependencies, and Java build tools like Maven or Gradle, along with different JDK versions. Very quickly, your local machine becomes bloated with installations, and keeping everything up-to-date while avoiding dependency conflicts turns into a nightmare.</p><p><strong>The Solution? DevContainers!.</strong></p><p>Four years ago, I had an eye-opening moment when I realized the power of Docker. Since then, I haven’t installed a single language, framework, or library directly on my local machine.</p><p>Using Dev containers for development has completely changed how I work. It allows me to isolate environments for each project, eliminate dependency conflicts, and keep my local machine clean and lightweight. This approach has been a game-changer for me, and I’d never go back to the old way of doing things.</p><p><strong>How to develop python apps in Devcontainers?</strong></p><p>Pre-Requisite:</p><ol><li>Install VSCode</li><li>Install Docker</li><li>Install Docker extension for vscode</li><li>Install Devcontainers vscode extension</li><li>Install Remote SSH vscode extension</li></ol><p>In this article, I’ll show you how simple it is to set up a DevContainer for Python development. This setup isn’t just limited to Python; it can be easily extended to other languages and frameworks like Java, .NET, Go, React, and more.</p><p>As a personal project, I’m working on a FastAPI application that extracts images from various types of documents, including PDFs, Word files, DXF, DWG, EPUB, MOBI, and DICOM. While the application code itself involves setting up a FastAPI app and implementing the logic for extracting images, this article focuses on the steps needed to set up the DevContainer.</p><p>To set up the DevContainer, you need to perform three key steps, apart from writing the actual application code. I won’t dive into the specifics of building the FastAPI app or extracting images here, but I’ll guide you through creating a streamlined development environment that makes working on such projects efficient and hassle-free.</p><p><strong>1.Write Dockerfile.dev:</strong></p><p>Apart from the obvious fact that a <strong>Dockerfile.dev</strong> is specifically designed for development purposes, it offers some distinct advantages. It allows you to include only the bare minimum required to run the container, keeping it lightweight and flexible. Additionally, instead of defining a fixed <strong>CMD</strong> or <strong>ENTRYPOINT</strong>, you can leave those decisions to the developer. This approach gives more control over how the application is started, enabling developers to tailor the execution based on their specific needs during development.</p><pre>FROM python:3.11<br><br><br>WORKDIR /app<br><br><br>COPY requirements.txt /app<br><br><br>RUN pip install -r requirements.txt<br><br><br>COPY src/ /app/</pre><p><strong>2. Write devContainer.json:</strong></p><p>The use of DevContainers today is made possible by the <strong>Developer Container Specification</strong>, which was created to simplify the use of containers as development environments. One key outcome of this specification is the <strong>devcontainer.json</strong> file, which serves as the backbone of DevContainer configurations.</p><p>In this article, we’ll write a <strong>devcontainer.json</strong> file for our Python application and break it down step-by-step for a clearer understanding of its structure and purpose.</p><pre>{<br>    &quot;name&quot;: &quot;Image Extraction Service&quot;,<br>    &quot;build&quot;: {<br>      &quot;dockerfile&quot;: &quot;../Dockerfile.dev&quot;,<br>      &quot;context&quot;: &quot;..&quot;<br>    },<br>    &quot;forwardPorts&quot;: [<br>      5000<br>    ],<br>    &quot;mounts&quot;: [<br>      &quot;source=${localWorkspaceFolder},target=/app,type=bind,consistency=cached&quot;<br>    ],<br>    &quot;workspaceFolder&quot;: &quot;/app&quot;,<br>    &quot;postCreateCommand&quot;: &quot;fastapi run src/app.py --port 5000&quot;,<br>    &quot;customizations&quot;: {<br>      &quot;vscode&quot;: {<br>        &quot;extensions&quot;: [<br>          &quot;ms-python.python&quot;,           // Python extension<br>          &quot;ms-python.vscode-pylance&quot;   // Pylance for better Python IntelliSense<br>        ]<br>      }<br>    }<br>  }</pre><p>(a) Define the <strong>devcontainer</strong> name</p><p>(b) Define the <strong>build</strong> portion of the image , here we are using Dockerfile.dev to build our images and the context is the relative file path from the devcontainer.json that is used to build the app image</p><p><strong>(©) Port mapping </strong>between the container and the host machine</p><p>(d) So the <strong>mount</strong> is interesting , let me break it down further</p><ul><li><strong><em>source=${localWorkspaceFolder} </em></strong>Specifies the <strong>source directory</strong> on the host machine that will be mounted into the container.Here, ${localWorkspaceFolder} is likely a variable referencing the root directory of your local project (e.g., in VS Code, this refers to the opened workspace folder).</li><li><strong><em>target=/app</em></strong> -&gt; Defines the <strong>mount point</strong> inside the container.In this case, the contents of the source directory will be accessible within the container at the path /app.</li><li><strong><em>type=bind</em></strong> -&gt; A bind mount directly links a file or directory on the host system to a location inside the container. Any changes made in one are immediately reflected in the other. <strong>Without this feature whatever change you make inside the container will not be reflected once you kill the container</strong></li><li><strong><em>consistency=cached</em></strong> -&gt; A performance-related option for macOS and Windows hosts.It optimizes file system performance by allowing the container to use a cached version of the data when possible, reducing I/O operations.<strong>Changes made to files on the host are synchronized lazily to the container.</strong></li></ul><p><strong>(e) Workspace</strong> folder is the path inside the container where you use it as a workspace</p><p><strong>(f) PostCreateCommand</strong>: This flexibility is why I chose not to use ENTRYPOINT or CMD in the Dockerfile.dev. This approach is incredibly powerful, as it allows you to customize how your development environment is bootstrapped. <strong>Whether you need to initialize a complex setup or execute specific commands, you can define them here or use a bash script to run when the container starts</strong>. In my case, I use this method to launch the FastAPI application on a specific port, ensuring a seamless development workflow.</p><p><strong>(g) Customizations</strong>: This section is a playground for development enthusiasts — you can customize it with an endless array of configurations. For my setup, I focus on ensuring that essential tools are ready to go as soon as the container starts. Specifically, I include the VS Code extensions I need, so they’re automatically installed, creating a more streamlined and efficient development experience.</p><p><strong>3. Run Devcontainer:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqj5Omn9PS_rjntfqqdoQA.gif" /><figcaption>Copyright: Vasanth</figcaption></figure><p>With just a single click of the run button, your development environment is ready to go — no fuss, no hassle. This approach eliminates the need to install Python, dependency management tools like PIP, libraries, or even virtual environments locally. While there are both advantages and disadvantages to this setup, I’ve found that the benefits far outweigh the drawbacks, making it a game-changer for efficient and clutter-free development.</p><h3>Advantages</h3><h4>Platform Independence</h4><ul><li><strong>Environment Isolation:</strong> You can avoid dependency conflicts between projects by using containerized or remote environments. Each environment remains self-contained.</li><li><strong>Cross-Platform Development:</strong> Your code runs in the same environment across different operating systems, ensuring consistency.</li></ul><h4>Simplified Setup</h4><ul><li><strong>No Installation Overhead:</strong> No need to install the programming language, build tools (e.g., Java, Gradle, Maven), or manage versions locally.</li><li><strong>Quick Onboarding:</strong> New developers can start working immediately without complex local setups.</li></ul><h4>Consistency:</h4><ul><li>All team members use the same runtime and tool versions, reducing “works on my machine” issues.</li><li><strong>Easy Upgrades:</strong> Switching to newer versions of a language or tools is as simple as updating a Docker image or cloud configuration.</li></ul><h3>Disadvantage:</h3><h4>Performance</h4><ul><li><strong>Latency:</strong> Remote environments may have latency issues, especially for large-scale builds or debugging sessions.</li></ul><h4>Complexity in Some Scenarios</h4><ul><li><strong>Learning Curve:</strong> Developers unfamiliar with Docker or cloud platforms may face a steep learning curve.</li></ul><h4>Debugging</h4><ul><li><strong>Remote Debugging:</strong> Debugging applications in a container or cloud instance may require additional setup, such as port forwarding or configuring remote debugging tools.</li></ul><p><strong>Setting up DevContainers isn’t limited to Python — it’s a versatile solution that works with any programming language or framework. Whether you’re working with Java, React, Go, or anything else, DevContainers provide a consistent and efficient development environment. For me, this has become the new norm, transforming the way I approach development across all projects.</strong></p><p>If you enjoyed this article, don’t forget to give <strong>claps</strong> and <strong>follow me</strong> for more articles on Software Engineering. Stay tuned for more!</p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1b38740a0a9" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/build-apps-without-the-need-for-local-installations-or-environments-a1b38740a0a9">Build Apps Without the Need for Local Installations or Environments</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Need for Speed: Cython — Python on Steroids!]]></title>
            <link>https://python.plainenglish.io/need-for-speed-cython-python-on-steroids-de99221cb4b0?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/de99221cb4b0</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cython]]></category>
            <category><![CDATA[vectorization]]></category>
            <category><![CDATA[matrix]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Sat, 09 Nov 2024 09:26:09 GMT</pubDate>
            <atom:updated>2024-11-19T07:20:59.101Z</atom:updated>
            <content:encoded><![CDATA[<h3>Need for Speed: Cython — Python on Steroids!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*62qgAVrjVBu_o8uk_Iv3rA.png" /><figcaption>Courtsey: Wikipedia</figcaption></figure><p>As a Python developer, I’ve built numerous applications, but performance optimization has always been a challenging frontier. There are a variety of strategies to improve performance, including:</p><ul><li>Multithreading</li><li>Parallel processing</li><li>Loop optimization</li><li>Efficient algorithms</li><li>Using caches, and more.</li></ul><p>Recently, I encountered a powerful concept called <strong>vectorization</strong>, which opened new doors in making applications faster.</p><h3><strong>What is Vectorization?</strong></h3><p><strong>Vectorization</strong> is a method for performing array operations without relying on traditional for-loops. Instead, libraries like <strong>NumPy</strong> allow operations to be executed in a vectorized way, making them significantly faster and more efficient. It was a revelation to me that these operations avoid for-loops altogether, relying instead on optimized, underlying mechanisms.</p><p>This discovery led me down a path to explore not only NumPy but also related libraries like <strong>Pandas</strong> ,<strong>Scikit-Learn</strong>. I noticed they all had something in common: <strong>Cython</strong>.</p><h3>What is Cython?</h3><p>To understand Cython, let’s look at a bit of Python’s history. When <strong>Guido van Rossum</strong> introduced Python, its simplicity made it incredibly popular among developers worldwide. But there was a trade-off: Python’s interpreted, dynamically-typed nature made it slower in performance compared to compiled languages like C.</p><p>This posed a challenge for the scientific community, where tasks such as <strong>mathematical computations, genome sequencing,</strong> and <strong>fluid dynamics simulations</strong> demanded higher performance. Python’s simplicity was ideal, but its speed limitations were a significant drawback.</p><p>To address this, <strong>a blend of Python’s ease and C’s performance</strong> was needed.</p><h3><strong>Enter Pyrex:</strong></h3><p>In the early 2000s, developer Greg Ewing created <strong>Pyrex</strong>, a tool designed to bridge the performance gap. Pyrex allowed Python developers to write code that resembled Python but could be translated to C, drastically improving execution speed. This was especially useful for CPU-intensive tasks and for projects that required interfacing with existing C libraries.</p><h3><strong>The Birth of Sage:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*KPILfytiJCqeBRLUOaibxQ.png" /><figcaption>Courtesy: Open-Collective</figcaption></figure><p>Around 2005, William Stein embarked on creating an open-source alternative to costly mathematical software like <strong>Mathematica</strong>, <strong>Maple</strong>, and <strong>MATLAB</strong>. His goal was to build a robust tool for advanced mathematical computation and research, especially in areas like number theory and algebra and open source them. <strong>Sage</strong> emerged from this vision, incorporating many Python libraries but soon faced performance challenges, prompting the development of <strong>SageX</strong>, a Pyrex variant aimed at integrating C-like performance within Sage’s Python codebase.</p><h4><strong>Genesis of Cython:</strong></h4><p>As SageX gained traction, Cython was born from a collaboration between <strong>Stefan Behnel, Robert Bradshaw,</strong> and <strong>Dag Sverre Seljebotn</strong>. This project, a merger of Pyrex and SageX, evolved into Cython, a tool that combines Python’s ease with C’s performance.</p><h3>How Cython Works</h3><p>Cython enhances Python’s speed by converting Python code into optimized C or C++ code, enabling performance close to that of native C programs. Let’s walk through the Cython process:</p><ol><li><strong>Writing Cython Code (.pyx file):</strong><br>Developers write Cython code in a <strong>.pyx</strong> file, which closely resembles Python. For better performance, they can use static typing by declaring types (e.g., <strong>int</strong> or <strong>double</strong>) for variables and functions, reducing the overhead of Python’s dynamic typing.</li><li><strong>Translation to C/C++:</strong><br>Cython compiles the .<strong>pyx</strong> file into a .<strong>c</strong> or .<strong>cpp</strong> file, generating optimized C code that mimics the original Python code. This step transforms Python objects and operations into efficient, low-level C constructs using the Python C API.</li><li><strong>Compiling the Translated Code:</strong><br>The generated C/C++ code is compiled with a C compiler (like GCC or Clang) into a shared object file (.<strong>so</strong> on Unix or .<strong>pyd</strong> on Windows), allowing it to be imported directly into Python as a native extension module. This compiled code bypasses the Python interpreter, enabling direct, machine-level execution and impressive speed improvements, particularly for loops and heavy computations.</li><li><strong>Seamless Integration with C Libraries:</strong><br>Because Cython translates Python code to C, it’s straightforward to integrate external C libraries. By including C headers and function declarations, Cython code can interface directly with C code, enabling powerful extensions without the complexities of the Python C API.</li><li><strong>Integration with Python Code:</strong><br>Once compiled, the resulting shared object file can be imported into Python like any other module. This enables calling Cython-optimized functions from Python scripts, delivering performance gains where needed while retaining Python’s ease of use.</li></ol><p><strong>In summary:</strong> Cython boosts performance by generating low-level C code from high-level, Python-like code, allowing Python programs to leverage C’s speed while seamlessly integrating within the Python ecosystem.</p><p><strong>How Fast is Cython?</strong></p><p>After learning about Cython, I was eager to test its speed for myself. I set up a simple benchmark in a<strong> Jupyter notebook within VSCode</strong>. The task: <strong>multiply a 1000 x 1000 matrix using random values</strong> and compare the time taken in standard Python versus Cython.</p><p><strong>Setup and Execution:</strong></p><p>I wrote a straightforward Python matrix multiplication function using NumPy in a naive way, focusing on the performance difference rather than optimization. The code was executed on my MacBook Air M2 chip<strong>(you may see some difference in time based on where the code gets processed)</strong></p><p>Before running the code, install the Cython extension in Jupyter to execute Cython code.</p><pre>import numpy as np<br>%load_ext Cython</pre><p>The cython extension is need to run the cython code in jupyter playbook</p><p><strong>Python Way:</strong></p><pre>import numpy as np<br>%load_ext Cython<br><br>def matrix_multiply_python(A, B):<br>    C = np.zeros_like(A)<br>    for i in range(A.shape[0]):<br>        for j in range(B.shape[1]):<br>            for k in range(A.shape[1]):<br>                C[i, j] += A[i, k] * B[k, j]<br>    return C<br><br>A = np.random.randint(0, 10, (1000, 1000))<br>B = np.random.randint(0, 10, (1000, 1000))<br>C_python = matrix_multiply_python(A, B)</pre><p>Let’s see the results after I ran them in Jupyter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v5h4w2R71g1a4WgcWLxwig.png" /><figcaption>Copyright: Vasanth</figcaption></figure><p>It took around ~285 seconds to execute this code in python , now lets see the time it took to run the same process in cython</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bU2ZEtvuj9bJzGT60w5kSQ.png" /><figcaption>Copyright: Vasanth</figcaption></figure><p>Switching to Cython with explicit typing and optimization, the execution time dropped to just <strong>2.5 seconds</strong> — a whooping <strong>114x speedup</strong>!. So if a program takes 1 hour in python , it just runs in 30 seconds.</p><h3>Which Python Libraries Are Built with Cython?:</h3><h4><strong>Pandas:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*u57hdEsvpdVBkBMyUr3xfg.png" /><figcaption>Courtesy: Wikipedia</figcaption></figure><p>A powerful data analysis and manipulation library, Pandas uses Cython to speed up its DataFrame and Series operations, which are critical for handling large datasets efficiently</p><h4><strong>Dask:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*0NUAMoS6ysNHMwW0LEwfiQ.png" /><figcaption>Courtesy: Wikipedia</figcaption></figure><p>Dask, a parallel computing library, uses Cython to accelerate certain operations, particularly in its data frame and array modules, to enhance performance when processing large datasets across multiple cores or clusters. I’m planning a future article on Dask, showcasing an exciting, real-world use case</p><h4><strong>PyTorch:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*MU0q4rSUJssUwJUGnsR3LA.png" /><figcaption>Courtesy: Wikipedia</figcaption></figure><p>The popular deep learning library PyTorch uses Cython for certain components, particularly for operations that need to bridge Python and C++ code for efficient neural network computations.</p><h4><strong>Spacy:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HTtQseukwrBiREJf8MSVcA.jpeg" /><figcaption>Courtesy: Wikipedia</figcaption></figure><p>Spacy, an industrial-strength natural language processing (NLP) library, uses Cython to boost performance for various NLP tasks, including tokenization, parsing, and named entity recognition.</p><h4><strong>Scikit-Learn:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pK4pZvlBi6wH0-CTK64RrQ.png" /><figcaption>Courtesy: Wikipedia</figcaption></figure><p>This popular machine learning library uses Cython for certain algorithms (like k-means clustering) to enhance performance, allowing it to handle large datasets and complex computations more efficiently.</p><h3><strong>When To Use Cython:</strong></h3><p>If your application is computationally intensive but you want to retain Python’s simplicity and leverage its powerful libraries, Cython is an excellent choice. By integrating Cython, you can solve complex, performance-critical problems efficiently without sacrificing Python’s ease of use.</p><h4><strong>Cython Reference Blogs:</strong></h4><ol><li><a href="https://www.peterbaumgartner.com/blog/intro-to-just-enough-cython-to-be-useful/">https://www.peterbaumgartner.com/blog/intro-to-just-enough-cython-to-be-useful/</a></li><li><a href="https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html">https://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html</a></li><li><a href="https://www.digitalocean.com/community/tutorials/boosting-python-scripts-cython">https://www.digitalocean.com/community/tutorials/boosting-python-scripts-cython</a></li></ol><p>In my next article, I’ll dive into Prefect — an amazing Python library for orchestrating workflows!</p><p>If you enjoyed this article, don’t forget to give <strong>claps</strong> and <strong>follow me</strong> for more articles on Software Engineering. Stay tuned for more!</p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de99221cb4b0" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/need-for-speed-cython-python-on-steroids-de99221cb4b0">Need for Speed: Cython — Python on Steroids!</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build US Election Map in React with GeoJSON]]></title>
            <link>https://medium.com/@vasanthbharathi07/creating-an-interactive-us-election-map-in-react-with-geojson-8dcf22d7a1f8?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dcf22d7a1f8</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[geojson]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[geospatial]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 09:46:35 GMT</pubDate>
            <atom:updated>2024-11-01T09:53:52.735Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zD9w6rLjnZE2-HIdt-kmvg.gif" /><figcaption>U.S. Election Results Map Visualization- by vasanth</figcaption></figure><p>In my last article, I demonstrated how to build an interactive map app using Leaflet and OpenStreetMap in React to display real-time weather data. Now, we’re taking that map to the next level by adding an election feature!</p><p>With U.S. election season in full swing, you’ve probably seen plenty of maps on news channels — highlighted with bold state boundaries and shaded in red for Republicans or blue for Democrats. The focus is all about who’s winning, who’s losing, and how the numbers stack up (though, we’ll leave that analysis to the political experts, for now).</p><p>In this article, I’ll walk you through building a similar interactive election map in React. We’ll use some code to make it happen, but there are many ways to achieve this with little to no coding. I’ll cover those in a future article, too.</p><p>If you’re ready to dive in, make sure you’ve reviewed the prerequisites in my previous article (<a href="https://medium.com/@vasanthbharathi07/build-an-interactive-weather-map-app-in-10-minutes-with-react-and-leaflet-fdfcc2253ba8"><strong>link</strong></a>). Now, let’s get started by listing out what we’ll need to build this feature!</p><h3>What Data Set Do We Need for This App?</h3><h4><strong>US State GeoJSON:</strong></h4><p>Before we dive into building the election map, let’s clarify a crucial component: <strong>GeoJSON</strong>.</p><p><strong>What is GeoJSON?</strong> GeoJSON is an open-standard format for structuring geographical data. It’s built on JSON (JavaScript Object Notation), a versatile data format created by <strong>Douglas Crockford</strong>, one of the contributors to JavaScript itself. JSON is widely used for web data, and in 2016, GeoJSON was released to make geographical data easy to use in web applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCwrNrt-7t9EupHkYeKnfw.jpeg" /><figcaption>Douglas Crockford : Courtesy Wikipedia</figcaption></figure><h4><strong>GeoJSON in Simple Terms<em>:</em></strong></h4><p>Imagine a paper map marked with shapes representing cities, parks, and countries. Now, picture turning that map into a digital file so a computer can display it on your screen. GeoJSON lets us do exactly that.</p><p>In a GeoJSON file, each location on the map is defined as a “feature” with:</p><ul><li>A <strong>shape</strong> (such as a line, circle, or detailed outline) representing the size and position of that place.</li><li>A <strong>label or tag</strong> containing extra information, like the name of the place or other relevant details.</li></ul><p>For example, in a GeoJSON file of the U.S., each state is represented by:</p><ul><li>The <strong>shape</strong> of the state boundary.</li><li>Information like election results (indicating whether it’s red or blue), population, or other demographic data.</li></ul><p>This digital format allows applications to create colorful, interactive maps with endless customization options — highlighting states by election outcome, population density, weather patterns, and more.</p><h4>Where to Find GeoJSON Data for the U.S.</h4><p>GeoJSON data for U.S. states can be found in numerous open-source repositories on GitHub, making it easy to find pre-structured data. However, I recommend a specific website that provides U.S. state data in various formats, including GeoJSON, for ease of use (<a href="https://public.opendatasoft.com/explore/dataset/us-state-boundaries/export/"><strong>link</strong></a>).</p><h3>2.US State Election Results Data:</h3><p>To accurately display election outcomes on our map, we need a reliable data source for state election results. There are several options available, but I used a source with archived election results spanning from 2020 to 1982(<a href="https://www.fec.gov/introduction-campaign-finance/election-results-and-voting-information/">link here</a>). The data is provided in Excel format, so I made some modifications to make it easier to work with in our app. After cleaning and restructuring the data, I converted it into a CSV file, which is more suitable for quick data manipulation and integration into our application.</p><h3>Building an Interactive Election Results Map in React</h3><p>The full React application is available in the GitHub repository (<a href="https://github.com/vasanthbharathi07/MapViz/tree/develop"><strong>link</strong></a>), where you can explore the code and see how the data sets come together to create an engaging election results map. Here’s an overview of the three main components we’ll focus on, beyond setting up Leaflet.js and OpenStreetMap (<a href="https://medium.com/@vasanthbharathi07/build-an-interactive-weather-map-app-in-10-minutes-with-react-and-leaflet-fdfcc2253ba8"><strong>check out my previous tutorials for a refresher on those</strong></a>).</p><h4><strong>1. Adding GeoJSON Data to the Map:</strong></h4><pre>return (<br>    &lt;&gt;<br>      &lt;MapContainer<br>        key={selectedGeoCoords.join(&quot;,&quot;)}<br>        center={selectedGeoCoords}<br>        zoom={zoomLevel}<br>        style={{ height: &quot;100vh&quot;, width: &quot;100%&quot; }}<br>      &gt;<br>        &lt;ResuableMapTile /&gt;<br>        {electionResultsData &amp;&amp; geoJsonData &amp;&amp; (<br>          &lt;GeoJSON<br>            data={geoJsonData}<br>            style={(feature) =&gt; {<br>              const stateName = feature.properties.name; // Accessing the state&#39;s name from the feature&#39;s properties<br>              return getStyleForState(stateName); // Function that returns style based on the state name<br>            }}<br>            onEachFeature={onEachStateMouseHover}<br>          /&gt;<br>        )}<br>      &lt;/MapContainer&gt;<br>      {currentSelectedState &amp;&amp; democratVotesRef.current &amp;&amp; republicanVotesRef.current &amp;&amp; otherVotesRef.current &amp;&amp;<br>        &lt;SideBoardComponent stateName={currentSelectedState} democratVotes={democratVotesRef.current} republicanVotes={republicanVotesRef.current} otherVotes={otherVotesRef.current} /&gt;<br>      }<br>       &lt;LegendComponent /&gt;<br>    &lt;/&gt;<br>  );</pre><p>First, we integrate GeoJSON data to display state boundaries. The app loads a GeoJSON file containing data for all 50 U.S. states, where each state is represented by its unique shape and color-coded based on party affiliation — blue for Democrat and red for Republican. This coloring is dynamically set based on the election results data, allowing us to create a visually intuitive map</p><h4><strong>2. Handling GeoJSON Events:</strong></h4><pre>const onEachStateMouseHover = (feature, layer) =&gt; {<br>    // Mouseover event: highlight the state<br>    layer.on(&quot;mouseover&quot;, function () {<br>      layer.setStyle({<br>        fillColor: &quot;Green&quot;, // Change the color on hover<br>        fillOpacity: 0.7, // Adjust opacity<br>        weight: 2,<br>      });<br>    });<br><br>    // Mouseout event: reset to the original style<br>    layer.on(&quot;mouseout&quot;, function () {<br>      layer.setStyle(getStyleForState(feature.properties.name));<br>    });<br><br>    layer.on(&quot;click&quot;, function(){<br>      getElectionDataForGivenState(feature.properties.name);<br>    });<br>  };</pre><ol><li>GeoJSON provides a built-in event handler, onEachFeature, which allows us to customize interactions for each state. We’ve added three main interactions:</li><li>Events<strong>:</strong></li></ol><ul><li><strong>mouseOver</strong>: Highlights the state with a different color (green) to draw attention.</li><li><strong>mouseOut</strong>: Returns the state to its original color.</li><li><strong>click</strong>: Displays detailed voting data for the selected state in a sidebar, including the total vote count and breakdown by party.</li></ul><p>By combining these elements, we can create an intuitive, interactive map that visually communicates election results at a glance.</p><p><strong>In my next article, get ready to dive into the world of graphics! I’ll be showcasing exciting projects that harness the power of WebGL frameworks to create stunning visuals and interactive experiences you won’t want to miss.</strong></p><p>If you enjoyed this tutorial, don’t forget to like and follow me for more articles on web development and interactive applications. Stay tuned for more exciting projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dcf22d7a1f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No Daemons to Tame, No Containers to Dock: Buildah — The Continuous Integration Rockstar!]]></title>
            <link>https://medium.com/devsecops-community/no-daemons-to-tame-no-containers-to-dock-buildah-the-continuous-integration-rockstar-1636c72e8491?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1636c72e8491</guid>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[buildah]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Sat, 19 Oct 2024 01:32:36 GMT</pubDate>
            <atom:updated>2024-12-18T09:42:53.773Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Containers Without Docker: A Guide to Using Buildah</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RiwI1bncwp1R1DUzZ1W1CQ.png" /><figcaption>Courtesy: Fedora Magazine</figcaption></figure><p>For the past six years, I have relied exclusively on Docker as my containerization tool, using it extensively to build applications both professionally and in my personal projects. My experience spans a variety of industries, where Docker has been integral in development workflows and enhancing deployment processes.</p><p><strong>What is DIND:</strong></p><p>When building a containerized application locally, Docker Desktop runs the Docker daemon (or engine), and we typically use the docker build command to create images from the Dockerfile. However, when code is committed to version control platforms like GitLab, Azure DevOps (ADO), or GitHub, it triggers a CI/CD pipeline. This pipeline usually includes stages such as build, lint checks, static typing (for languages like Python), unit testing, security checks, image publishing, and deployment.</p><p>In these CI pipelines, the build operation is executed on runner machines, which are typically Linux-based and equipped with Docker daemons. The images are built using a method called Docker-in-Docker (DIND). However, running Docker daemons inside servers requires elevated privileges or root access, which can introduce security vulnerabilities. As a result, many organizations prefer to avoid this approach.</p><p>Due to these security concerns, I recently transitioned some of our pipelines away from DIND to more secure alternatives that eliminate the need for daemons. One of these tools is Buildah, which I discovered (albeit a bit late, since it was released in 2017) and found to be a powerful, daemon-less solution for building container images securely.</p><p><strong>What is Buildah?</strong></p><p>Buildah is like Docker’s slick, security-conscious cousin — it’s an open-source tool for building container images that comply with the Open Container Initiative (OCI). The best part? It’s small, secure, and daemon-less, meaning it skips the security risks that come with running Docker daemons. Whether you’re building images from scratch, from an existing image, or even a Dockerfile, Buildah has got you covered. It’s especially handy in CI/CD pipelines where you need something lightweight and reliable.</p><p>Now, why is it called <em>Buildah</em>? Here’s where it gets fun! Daniel Walsh, a senior engineer at Red Hat, led the team that created Buildah. Originally, he called it “Builder” — but with his thick Boston accent, it came out sounding more like “Buildah.” And, well, the name stuck.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*Hmwi57ICxRgKhSbG8eFLbA.jpeg" /><figcaption>Daniel Walsh Courtsey: Red hat blog</figcaption></figure><p><strong>How do we build an application image without a container :</strong></p><p>Imagine being able to build container images without actually needing a container. Sounds interesting, right? That’s exactly what Buildah allows you to do. In this tutorial, I’ll walk you through building a small Python FastAPI application image without using Docker, Docker-in-Docker (DIND), or any containers at all. All you need is Buildah installed on a Linux machine, and you’re good to go!</p><p>If your CI runner machines typically rely on containers to build images, no worries — Buildah supports that too. However, in this tutorial, we’re going full containerless. I’ll be demonstrating this on Ubuntu, but the steps can easily be adapted for other Linux distributions.</p><p>Steps to create the application Image:</p><ol><li><strong>Update your package manager:</strong></li></ol><p>First, open your terminal and ensure your system is up to date by running the following command:</p><pre>apt-get update<br></pre><p>2. <strong>Install Buildah:</strong></p><p>Next, we’ll install Buildah, the magic tool that allows us to build images without any daemons or root privileges:</p><pre>apt-get install buildah</pre><p><strong>3. Set Up Your FastAPI Application</strong></p><p>Why FastAPI? Well, because it’s fast, lightweight, and, let’s be honest — I know it like the back of my hand (lol). Plus, who wouldn’t want to build blazing-fast APIs while feeling like a coding ninja?</p><p>Now let’s create the basic files needed for a Python FastAPI application. Start by creating a directory for your app:</p><pre>mkdir fastapi-app &amp;&amp; cd fastapi-app</pre><pre>from fastapi import FastAPI<br><br>app = FastAPI()<br><br>@app.get(&quot;/&quot;)<br>def read_root():<br>    return {&quot;message&quot;: &quot;Hello World!&quot;}</pre><p>4. <strong>Add the Requirements file:</strong></p><p>Next, create a requirements.txt file in the same directory and add the following packages:</p><pre>fastapi<br>uvicorn</pre><p><strong>5. Create the Dockerfile</strong></p><p>Even though we’re not using Docker, we still need a Dockerfile to define how the image should be built. Create a Dockerfile in the app directory with the following content</p><pre># Dockerfile<br>FROM python:3.10-slim<br><br>WORKDIR /app<br><br>COPY requirements.txt .<br>RUN pip install -r requirements.txt<br><br>COPY . .<br><br>CMD [&quot;uvicorn&quot;, &quot;main:app&quot;, &quot;--host&quot;, &quot;0.0.0.0&quot;, &quot;--port&quot;, &quot;8000&quot;]</pre><p><strong>6. Build the Image Using Buildah:</strong></p><p>Now for the fun part — building the image without using a container! We’ll use Buildah’s bud command, which stands for “build using Dockerfile”:</p><pre>buildah bud -t fastapi-app .</pre><p><strong>7. Use the New Image:</strong></p><p>Once the image is built, you can use it just like any other container image. You can spin up a container, push the image to a repository, or modify it further for your needs:</p><p>Throughout these steps, we didn’t use any Docker daemons, containers, or elevated privileges — just Buildah doing what it does best. That’s why its becoming increasingly popular in CI/CD pipelines, especially when security is a concern.</p><p>By building images without daemons or root access, you significantly reduce vulnerabilities while still keeping your workflow efficient and scalable. Give Buildah a try in your next project and see how it can simplify your containerization process!</p><p>In my next article, I’ll explore another alternative to Buildah, focusing on where it might fall short in features and flexibility, and how this option can fill those gaps.</p><p>If you enjoyed this tutorial, don’t forget to like and follow me for more articles on software development and DevOps.</p><h3>DevSecOps — Community 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://medium.com/devsecops-community/devopsin90days/home"><strong><em>DevSecOps — Community</em></strong></a><strong><em> </em></strong><em>community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> ️ the Author👏<strong>️️</strong></li><li>Follow: <a href="https://medium.com/devsecops-community/newsletters/devsecops"><strong>Newsletter</strong></a> |<a href="https://www.linkedin.com/groups/14547253/"> <strong>LinkedIn Group</strong></a><strong>s </strong>|</li><li>More content at <a href="https://medium.com/devsecops-community/devopsin90days/home"><strong>DevSecOps — Community</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1636c72e8491" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devsecops-community/no-daemons-to-tame-no-containers-to-dock-buildah-the-continuous-integration-rockstar-1636c72e8491">No Daemons to Tame, No Containers to Dock: Buildah — The Continuous Integration Rockstar!</a> was originally published in <a href="https://medium.com/devsecops-community">devsecops-community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Weather Map App in 10 Minutes]]></title>
            <link>https://medium.com/@vasanthbharathi07/build-an-interactive-weather-map-app-in-10-minutes-with-react-and-leaflet-fdfcc2253ba8?source=rss-9855e889c0a2------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdfcc2253ba8</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-ui]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[leafletjs]]></category>
            <dc:creator><![CDATA[Vasanth Bharathi]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 17:09:19 GMT</pubDate>
            <atom:updated>2024-11-01T09:52:31.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*z8p9H4XPJ63B5xvXDLMHgw.png" /><figcaption>Courtsey: AQICN website — Tracks real time air quality index</figcaption></figure><p>Bangalore, the city where I work, is notorious for its traffic. I used to frequently check the Air Quality Index (AQI) to avoid highly polluted areas. I was always fascinated by how these interactive maps worked — allowing users to zoom, pan, move, and even select and interact with map elements. This led me to explore how I could build something similar.</p><p>Instead of creating a map to display air quality, I decided to build a simple interactive web application that allows users to select countries, states, or cities and view their weather data. In this article, I’ll walk you through how to create this app easily using some popular libraries.</p><h3>Prerequisites</h3><ul><li>A code editor like VSCode (or equivalent IDE)</li><li>React installed</li><li>Bootstrap a React project</li><li>Node.js installed</li></ul><h3>Overview</h3><p>Before we dive into the code, let’s briefly cover the key components of this app.</p><h4>1. Interactive Maps with Leaflet</h4><p>Volodymyr Agafonkin, a Ukrainian developer, created Leaflet, an open-source JavaScript library that provides all the functionalities needed for interactive maps. If you’re building a React app, there’s also a React version of Leaflet that works seamlessly.</p><h4>2. Loading Maps with OpenStreetMap</h4><p>There are several ways to load maps, but I’ll show you a simple and effective option. OpenStreetMap, founded by Steve Coast in 2004, is a project that offers free, open-source geospatial data for anyone to use. It’s a great resource for map data and provides a strong foundation for building map-based applications.</p><h4>3. Fetching Weather Data</h4><p>There are many APIs available to fetch weather data, most of which require an API key. However, I found a website that allows you to retrieve weather data without needing any keys: <a href="https://wttr.in/bangalore">https://wttr.in/bangalore</a>.</p><h4>4. Accessing Cities Data</h4><p>To include data for countries, states, and cities, you can use various open-source repositories. For this app, I sourced the data from a dataset on Kaggle: <a href="https://www.kaggle.com/datasets/tanweerulhaque/countries-states-cities-dataset">Countries, States, Cities Dataset</a>, which provides geospatial information in a single JSON file.</p><h3>Let’s Get Coding!</h3><p>Now that we’ve covered the basics, it’s time to start building the app. For this demo, I’ll be using React, but you can follow the same approach with any other UI framework using the four steps above.</p><ol><li>Create a MapComponent to bring the map interaction capability from leaflet.</li></ol><pre>import { React, useEffect, useState } from &quot;react&quot;;<br>import { MapContainer, TileLayer, Marker, Popup } from &quot;react-leaflet&quot;;<br>import DropDownComponent from &quot;./DropdownComponent&quot;;<br>import { FontAwesomeIcon } from &quot;@fortawesome/react-fontawesome&quot;;<br>import { faWind, faThermometerHalf } from &quot;@fortawesome/free-solid-svg-icons&quot;;<br>import getIconsBasedOnWeather from &quot;./IconFinder&quot;;<br>import &quot;leaflet/dist/leaflet.css&quot;;<br>import L from &quot;leaflet&quot;;<br><br>delete L.Icon.Default.prototype._getIconUrl;<br><br>L.Icon.Default.mergeOptions({<br>  iconRetinaUrl: require(&quot;leaflet/dist/images/marker-icon-2x.png&quot;),<br>  iconUrl: require(&quot;leaflet/dist/images/marker-icon.png&quot;),<br>  shadowUrl: require(&quot;leaflet/dist/images/marker-shadow.png&quot;),<br>});<br><br>function MapComponent() {<br>  const [selectedGeoCoords, setSelectedGeoCoords] = useState([<br>    20.5937, 78.9629,<br>  ]);<br>  const [zoomLevel, setZoomLevel] = useState(5);<br>  const [weatherData, setWeatherData] = useState(null);<br>  const [windData, setWindData] = useState(null);<br>  const [temperatureData, setTemperatureData] = useState(null);<br>  const [weatherDescription, setWeatherDescription] = useState(null);<br><br>  useEffect(() =&gt; {<br>    if (weatherData) {<br>      const windSpeed = weatherData.wind;<br>      const temperature = weatherData.temperature;<br>      const weatherDesc = weatherData.description;<br><br>      setWindData(`Wind Speed: ${windSpeed}`);<br>      setTemperatureData(`Temperature: ${temperature}`);<br>      setWeatherDescription(`Weather: ${weatherDesc}`);<br>    }<br>  }, [weatherData]); // Runs when weatherData changes<br><br><br>  function onPlaceSelectionChange(latitude, longitude, zoomlevel, weatherData) {<br>    setSelectedGeoCoords([latitude, longitude]);<br>    setZoomLevel(zoomlevel);<br>    setWeatherData(weatherData);<br>  }<br><br>  return (<br>    &lt;&gt;<br>      &lt;DropDownComponent<br>        onPlaceChange={onPlaceSelectionChange}<br>      /&gt;<br>      &lt;MapContainer<br>        key={selectedGeoCoords.join(&quot;,&quot;)} <br>        center={selectedGeoCoords} <br>        zoom={zoomLevel}<br>        style={{ height: &quot;100vh&quot;, width: &quot;100%&quot; }}<br>      &gt;<br>        &lt;TileLayer<br>          url=&quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;<br>          attribution=&#39;&amp;copy; &lt;a href=&quot;https://www.openstreetmap.org/copyright&quot;&gt;OpenStreetMap&lt;/a&gt; contributors&#39;<br>        /&gt;<br>        &lt;Marker position={selectedGeoCoords}&gt;<br>          &lt;Popup&gt;<br>          { windData &amp;&amp; temperatureData &amp;&amp; weatherDescription &amp;&amp;<br>          &lt;div&gt;<br>            &lt;p&gt;<br>              &lt;FontAwesomeIcon icon={faWind} /&gt; {windData}<br>            &lt;/p&gt;<br>            &lt;p&gt;<br>              &lt;FontAwesomeIcon icon={faThermometerHalf} /&gt; {temperatureData}<br>            &lt;/p&gt;<br>            &lt;p&gt;<br>              {/* Display sun or cloud based on weather condition */}<br>              {weatherDescription &amp;&amp; getIconsBasedOnWeather(weatherDescription)}<br>            &lt;/p&gt;<br>          &lt;/div&gt;<br>          }<br>          &lt;/Popup&gt;<br>        &lt;/Marker&gt;<br>      &lt;/MapContainer&gt;<br>    &lt;/&gt;<br>  );<br>}<br><br>export default MapComponent;</pre><p>This is the main page of our application , let me break down whats going on</p><ol><li><strong>Leaflet icons</strong>: The default icons for markers are set using Leaflet’s L.Icon.Default options, ensuring custom icons for Retina displays, regular displays, and shadows.</li><li><strong>Rendering the Map</strong>:</li></ol><ul><li><strong>MapContainer</strong>: Displays the map using the current selectedGeoCoords and zoomLevel.</li><li><strong>TileLayer</strong>: Defines the base layer using OpenStreetMap tiles.</li><li><strong>Marker &amp; </strong><strong>Popup</strong>: Displays a marker at the selected location. Inside the popup, weather details like wind speed, temperature, and weather icons (based on description if its sunny show a sun icon , if its snow show snow icon) are shown if available.</li></ul><blockquote>3. <strong>OnPlaceSelectionChange Function</strong>:</blockquote><p>This function updates the selected coordinates, zoom level, and weather data when a new place is selected from the dropdown (DropDownComponent). It&#39;s triggered by a callback from the dropdown</p><p>4. <strong>Effect Hook for Weather Data</strong>:</p><ul><li><strong>useEffect on </strong><strong>weatherData</strong>: When weatherData changes, it extracts wind speed, temperature, and weather description from the data and updates the respective states (windData, temperatureData, weatherDescription)</li></ul><p>5. <strong>DropDown Component:</strong></p><p>Allows the user to select a new location and updates the map and weather info accordingly.</p><pre>import { React, useRef } from &quot;react&quot;;<br>import countries_cities_state from &quot;../resources/countries_states_cities.json&quot;;<br>import { getWeatherForGivenCity } from &quot;../services/ApiService&quot;;<br><br>function DropDownComponent({ onPlaceChange }) {<br>  const selectedCountryRef = useRef(null);<br>  const selectedStateRef = useRef(null);<br>  const selectedCityRef = useRef(null);<br>  const selectedCityWeatherDataRef = useRef(null);<br><br>  function handleCountryChange(event) {<br>    const matched_country = countries_cities_state.find(<br>      (country) =&gt; country.name === event.target.value<br>    );<br>    selectedCountryRef.current = matched_country;<br>    onPlaceChange(matched_country.latitude, matched_country.longitude, 5);<br>  }<br><br>  function handleStateChange(event) {<br>    const matched_state = selectedCountryRef.current.states.find(<br>      (state) =&gt; state.name === event.target.value<br>    );<br>    selectedStateRef.current = matched_state;<br>    onPlaceChange(matched_state.latitude, matched_state.longitude, 10);<br>  }<br><br>  function  handleCityChange(event) {<br>    const matched_city = selectedStateRef.current.cities.find(<br>      (city) =&gt; city.name === event.target.value<br>    );<br>    selectedCityRef.current = matched_city;<br>    getWeatherForGivenCity(matched_city.name).then(function (weatherData) {  <br>      selectedCityWeatherDataRef.current = weatherData;<br>      onPlaceChange(matched_city.latitude, matched_city.longitude, 13,selectedCityWeatherDataRef.current);<br>    });<br>  }<br><br>  return (<br>    &lt;div className=&quot;leaflet-top leaflet-right&quot;&gt;<br>      &lt;div className=&quot;leaflet-control leaflet-bar&quot;&gt;<br>        &lt;div className=&quot;dropdown-container&quot;&gt;<br>          &lt;select onChange={handleCountryChange}&gt;<br>            &lt;option value=&quot;&quot;&gt;Select a Country&lt;/option&gt;<br>            {countries_cities_state.map((country) =&gt; (<br>              &lt;option key={country.name} value={country.name}&gt;<br>                {country.name}<br>              &lt;/option&gt;<br>            ))}<br>          &lt;/select&gt;<br>        &lt;/div&gt;<br>        &lt;div className=&quot;dropdown-container&quot;&gt;<br>          &lt;select onChange={handleStateChange}&gt;<br>            &lt;option value=&quot;&quot;&gt;Select a State or Province&lt;/option&gt;<br>            {selectedCountryRef.current &amp;&amp;<br>              selectedCountryRef.current.states.map((state) =&gt; (<br>                &lt;option key={state.name} value={state.name}&gt;<br>                  {state.name}<br>                &lt;/option&gt;<br>              ))}<br>          &lt;/select&gt;<br>        &lt;/div&gt;<br>        &lt;div className=&quot;dropdown-container&quot;&gt;<br>          &lt;select onChange={handleCityChange}&gt;<br>            &lt;option value=&quot;&quot;&gt;Select a City&lt;/option&gt;<br>            {selectedStateRef.current &amp;&amp;<br>              selectedStateRef.current.cities.map((city) =&gt; (<br>                &lt;option key={city.name} value={city.name}&gt;<br>                  {city.name}<br>                &lt;/option&gt;<br>              ))}<br>          &lt;/select&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default DropDownComponent;</pre><p>6. Created an Icons component that fetches the icons (Eg: Sunny , Rainy , snow , cloudy ..etc) based on the waether description we get from the API response</p><pre><br>import { FontAwesomeIcon } from &quot;@fortawesome/react-fontawesome&quot;;<br>import { faSun, faCloud, faSnowflake, faCloudRain, faHurricane, faThunderstorm } from &quot;@fortawesome/free-solid-svg-icons&quot;;<br><br>function getIconsBasedOnWeather({weatherDescription}){<br><br><br>    if(weatherDescription.toLowerCase().includes(&quot;sunny&quot;)){<br>        return &lt;FontAwesomeIcon icon={faSun} /&gt; <br>    } else if(weatherDescription.toLowerCase().includes(&quot;snow&quot;)){<br>        return &lt;FontAwesomeIcon icon={faSnowflake} /&gt;<br>    } else if(weatherDescription.toLowerCase().includes(&quot;cloudy&quot;)){<br>        return &lt;FontAwesomeIcon icon={faCloud} /&gt;<br>    } else if(weatherDescription.toLowerCase().includes(&quot;rain&quot;)){<br>        return &lt;FontAwesomeIcon icon={faThunderstorm} /&gt;<br>    }<br>}<br><br>export default getIconsBasedOnWeather;</pre><p>Run this react app locally and open the browser with <a href="http://localhost:3000/">http://localhost:3000</a></p><p>If you enjoyed this tutorial, don’t forget to like and follow me for more articles on web development and interactive applications. Stay tuned for more exciting projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdfcc2253ba8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>