<?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 Adisesha Reddy G on Medium]]></title>
        <description><![CDATA[Stories by Adisesha Reddy G on Medium]]></description>
        <link>https://medium.com/@adisesha?source=rss-aeb1cdd61bc2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LnIcKGNGMl7Nm4lS</url>
            <title>Stories by Adisesha Reddy G on Medium</title>
            <link>https://medium.com/@adisesha?source=rss-aeb1cdd61bc2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 12:33:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adisesha/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[Application Security for Developers]]></title>
            <link>https://medium.com/@adisesha/application-security-for-developers-15b8755bcc9c?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/15b8755bcc9c</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 06:14:49 GMT</pubDate>
            <atom:updated>2023-07-25T06:25:18.906Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>‘There are two types of companies: those who have been hacked, and those who don’t yet know they have been hacked.’ — John Chambers, Cisco CEO</blockquote><p>Alright, picture this: you’re part of a cool startup or a small company, working day in and day out to make this killer app that’ll turn heads and blow minds. But, in the midst of all the coding, testing, and way too much coffee, security becomes the least priority. Now, you prioritize security because you understand its importance or a vendor starts asking for a security posture. What can you do? One solution is to hire an external vendor to point out what’s broken. This process can take time which leaves your application vulnerable to attacks, and businesses turn you away until you assure them that your application is safe. Can we do better? I have been in this situation. I didn’t know where to start. Since then, the landscape has changed a lot for the better. This post is an attempt to help developers like me. Where do we start?</p><blockquote>Why do vendors care about your security?</blockquote><blockquote>Your application may not be the target, but attackers can use you as a base to attack your vendor. <a href="https://coverlink.com/cyber-liability-insurance/target-data-breach/">Target’s Data Breach</a> is an example of that. Regulatory requirements can be another reason. For example, after <a href="https://www.techtarget.com/whatis/feature/SolarWinds-hack-explained-Everything-you-need-to-know">SolarWinds hack</a> US Federal Govt introduced <a href="https://federalnewsnetwork.com/cybersecurity/2022/09/white-house-releases-post-solarwinds-federal-software-security-requirements/">regulatory requirements</a>.</blockquote><h3>‘Shift Left’ security</h3><p>Most probably, you heard this term. It’s all about making security a part of the party from the get-go, not a last-minute guest. Thanks to loads of open-source tools out there, even the smallest team can build security into their process. It involves integrating security measures into the software development lifecycle, similar to integrating code quality tools. This can greatly reduce the risk of <a href="https://en.wikipedia.org/wiki/2017_Equifax_data_breach">Equifax-like incidents</a>. It knocks out some weaknesses before you go for an external assessment. If you are diligently following and fixing npm audit reports, you already started the ‘Shift Left’ approach. Before introducing the tools, let’s set up the playground.</p><h3>Deliberately Insecure Applications</h3><p>Most of the tools I introduce fall into vulnerability assessment. You can run them on your application. One exception is <a href="https://www.zaproxy.org/">ZAP</a>; depending on the mode, it can wreak havoc. So, it’s better to try them on applications that are created for security awareness.</p><ul><li><a href="https://github.com/juice-shop/juice-shop">Juice Shop</a>: It includes a wide variety of common security vulnerabilities, making it a popular tool for learning and practicing penetration testing.</li><li><a href="https://github.com/WebGoat/WebGoat">WebGoat</a>: This is another project by OWASP. It’s a deliberately insecure web application that allows users to test vulnerabilities commonly found in Java-based applications.</li><li><a href="https://github.com/digininja/DVWA">Damn Vulnerable Web Application (DVWA)</a>: DVWA is a PHP/MySQL web application that is intentionally vulnerable. It’s designed to help security professionals test their skills and tools in a legal environment.</li><li><a href="https://sourceforge.net/projects/bwapp/">bWAPP</a>: Deliberately insecure web application. It helps security enthusiasts, developers, and students to discover and prevent web vulnerabilities.</li></ul><p>Beyond web applications-</p><ul><li><a href="https://sourceforge.net/projects/metasploitable/">Metasploitable</a>: This is an intentionally vulnerable Linux virtual machine. This VM can be used to conduct security training, test security tools, and practice common penetration testing techniques.</li><li><a href="https://www.hackthissite.org/">HackThisSite</a>: This is a legal and safe network security resource where users test their hacking skills on various challenges and learn about hacking and network security.</li></ul><h3>Tools</h3><h4>Static Application Security Testing (SAST)</h4><p>These tools statically analyze your codebase without executing them to identify potential security vulnerabilities and generate reports. The reports can contain fixes and explanations of vulnerabilities. Possible remediation includes upgrading a library, modifying your code, etc. They can be run locally or as part of your CI/CD pipeline. I will briefly introduce code scanning tools without going into how to use them, as their documentation covers that. The are other tools that are used for reconnaissance. Refer to <a href="https://projectdiscovery.io/#/">Projectdiscovery</a> for some of them. Some of these tools have feature overlap. You may end up using multiple tools.</p><ul><li><a href="https://docs.github.com/en/code-security/dependabot/dependabot-alerts/about-dependabot-alerts">GitHub Dependantbot Alerts</a>: This is the fastest way to start if you are using GitHub. It reports vulnerable dependencies and can raise pull requests with package upgrades which has the fixes. If you have Github Enterprise Plan, you can go for <a href="https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security">GitHub Advanced Security</a>. It’s free for public repos.</li><li><a href="https://github.com/returntocorp/semgrep">semgrep</a>: Identify and prevent security issues and bugs in source code, including your docker files, IaaC code, etc.</li><li><a href="https://trivy.dev/">trivy</a>: Specifically designed for container scanning but can find leaked secrets and vulnerable dependencies.</li><li><a href="https://www.checkov.io/">checkov</a>: Checkov scans IaC files to detect security issues and misconfigurations related to cloud resources, network settings, access controls, encryption, and more. <a href="https://checkmarx.com/product/opensource/kics-open-source-infrastructure-as-code-project/">KICS</a> is another notable tool in this category.</li></ul><p>Here is a screenshot of running semgrep of Juice Shop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*WaRNyYxxdRrQgLeffbpdGg.png" /></figure><h4><strong>Dynamic Application Security Testing(DAST)</strong></h4><p>DAST tools are used to identify vulnerabilities and security weaknesses in web applications and services while they are running or “live” in a real environment. Unlike Static Application Security Testing (SAST), which analyzes the source code without executing it, DAST involves interacting with the application, sending various HTTP requests, and analyzing the responses to uncover potential security issues. <strong>Do not try these tools on your application or any third-party application for which you don’t have permission. Even if you have permission, understand what these tools do and try them in a staging environment.</strong></p><p><a href="https://www.zaproxy.org/">ZAP (Zed Attack Proxy)</a> is an open-source web app scanner commonly referred to as ZAProxy or Zaproxy. It is used by security professionals, developers, and organizations to proactively identify and address security weaknesses in web applications. You provide your application URL and attack. It produces security findings in various formats. Here is a screenshot of running it on Juice Shop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VetJIZlCysLCe-P5sNTKwA.png" /></figure><p>Another popular tool in this category is <a href="https://portswigger.net/burp">Burp Suit</a>e.</p><h3>Software Development Principles</h3><p>A tool can tell if your application depends on a vulnerable package. What if you piled up so much technical debt that you can’t upgrade without making significant changes? Following principles like <a href="https://en.wikipedia.org/wiki/KISS_principle">KISS</a>, Automates Tests, CI/CD, Modularity, etc., will keep you prepared to respond to <a href="https://heartbleed.com/">Heartbleed</a> or <a href="https://en.wikipedia.org/wiki/Log4Shell">Log4Shell</a> scenarios.</p><p>If you like to learn more about building and maintaining secure systems, I recommend reading ‘Building Secure and Reliable Systems’, which is free to read online. If you don’t have time to read the entire book, go through the conclusion of the chapters.</p><p><a href="https://sre.google/books/building-secure-reliable-systems/">Google - Site Reliability Engineering</a></p><h3>Security Culture</h3><p>You may have heard this before, but I am going to remind you anyway — Tools and methods can take you so far. No matter how advanced your tool is, your company is not safe unless employees at all levels understand the importance of security and see themselves as active participants in securing the company’s data and systems. It requires training and periodic awareness sessions, which can help them personally as well.</p><p>Here are some low-hanging fruits(are they?):</p><ul><li>Enable multi-factor authentication across all the services.</li><li>Use a password manager like <a href="https://bitwarden.com/">Bitwarden</a>.</li><li>Don’t share secrets through Email or Slack. Don’t hardcode secrets. Use a service like <a href="https://www.doppler.com/">Doppler</a> or a cloud secret manager like <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html">AWS Secret Manager</a>. These services usually support key rotation.</li><li>Delete unused code, repos, dependencies, and services. <strong><em>Treat them like an expired credit card.</em></strong> Clean them as you go. It reduces the surface attack. Also, reduces distraction and false alarms for developers and ops.</li><li>The above practice applies to hardware as well. Turn off the hardware resources when you don’t need them. For example, if you are using a smart printer rarely. Turn it on only when you need it.</li><li>Follow the principle of least privileges from the start. It may impact initial velocity, but it will save you a lot of time later. It is easy to assign full admin permission to a service role or allow all traffic in a security group, but hard to take it back. Maintain one ACL configuration per service, not one for all services.</li><li>Frequently upgrade your dependencies. You may even benefit from performance improvements in the new version of a dependency.</li></ul><h3>External Security Audit</h3><p>Once you clean up your house, you are ready for an external audit. It is good practice to go for it. The frequency depends on the velocity of your changes. They usually produce Vulnerability Assessment and Penetration Testing(VAPT) reports. These reports contain findings from automation tools and testers discovering weaknesses in your application flows. Later is a manual effort. You can present these reports to your customer, which gives them confidence.</p><h3>References</h3><p>This section contains my learning resource and bookmarks I hoarded. I never went through some of the bookmarks. Please feel free to suggest any tools and learning resources.</p><ul><li><a href="https://training.linuxfoundation.org/training/developing-secure-software-lfd121/">Developing Secure Software (LFD121) - Linux Foundation - Training</a></li><li><a href="https://training.linuxfoundation.org/training/cybersecurity-essentials-lfc108/">Cybersecurity Essentials (LFC108) - Linux Foundation - Training</a></li><li><a href="https://portswigger.net/web-security">Web Security Academy: Free Online Training from PortSwigger</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FacI335IOmdg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DacI335IOmdg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FacI335IOmdg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b85581f44fd53f14e5f64a8835ad57bf/href">https://medium.com/media/b85581f44fd53f14e5f64a8835ad57bf/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FcBkfk0VbvLw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DcBkfk0VbvLw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FcBkfk0VbvLw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/54f250e570b7f4c7ebb31dba4d3f3f59/href">https://medium.com/media/54f250e570b7f4c7ebb31dba4d3f3f59/href</a></iframe><ul><li><a href="https://a.co/d/acC7xCP">This Is How They Tell Me the World Ends: The Cyberweapons Arms Race</a></li><li><a href="https://a.co/d/j3GZeRe">You&#39;ll See This Message When It Is Too Late: The Legal and Economic Aftermath of Cybersecurity Breaches (Information Policy)</a></li><li><a href="https://a.co/d/9OajWbr">Ghost in the Wires: My Adventures as the World&#39;s Most Wanted Hacker</a></li><li><a href="https://owasp.org/www-project-secure-coding-dojo/">OWASP Secure Coding Dojo</a></li><li><a href="https://github.com/Anof-cyber/Application-Security">GitHub - Anof-cyber/Application-Security: Resources for Application Security including Web, API, Android, iOS and Thick Client</a></li><li><a href="https://github.com/bluscreenofjeff/Red-Team-Infrastructure-Wiki">GitHub - bluscreenofjeff/Red-Team-Infrastructure-Wiki: Wiki to collect Red Team infrastructure hardening resources</a></li><li><a href="https://github.com/NationalSecurityAgency/ghidra">GitHub - NationalSecurityAgency/ghidra: Ghidra is a software reverse engineering (SRE) framework</a></li><li><a href="https://github.com/mikeprivette/awesome-sec-challenges">GitHub - mikeprivette/awesome-sec-challenges: A curated list of Awesome Security Challenges.</a></li><li><a href="https://github.com/six2dez/reconftw">GitHub - six2dez/reconftw: reconFTW is a tool designed to perform automated recon on a target domain by running the best set of tools to perform scanning and finding out vulnerabilities</a></li><li><a href="https://www.virustotal.com/gui/home/upload">VirusTotal</a></li><li><a href="https://github.com/xeol-io/xeol">GitHub - xeol-io/xeol: A package scanner for end-of-life (EOL) packages in container images, systems, and SBOMs</a></li><li><a href="https://github.com/Lissy93/web-check">GitHub - Lissy93/web-check: 🕵️‍♂️ All-in-one OSINT tool for analysing any website</a></li><li><a href="https://snyk.io/">Snyk AI-powered Developer Security Platform | AI-powered AppSec Tool &amp; Security Platform | Snyk</a></li><li><a href="https://socket.dev/">Socket - Secure your supply chain. Ship with confidence.</a></li><li><a href="https://observatory.mozilla.org/">Mozilla Observatory</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15b8755bcc9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Kotlin for TypeScript Programmers]]></title>
            <link>https://medium.com/@adisesha/introduction-to-kotlin-for-typescript-programmers-d15f35f23907?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/d15f35f23907</guid>
            <category><![CDATA[kotlin-beginners]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Tue, 30 May 2023 13:04:36 GMT</pubDate>
            <atom:updated>2023-05-30T13:04:36.355Z</atom:updated>
            <content:encoded><![CDATA[<p>I have experience in coding in <a href="https://kotlinlang.org/docs/getting-started.html">Kotlin</a> and <a href="https://www.typescriptlang.org/">TypeScript</a>. If you look at the syntax, the two languages look so familiar that it is easy to pick up one language if you know the other. I aim to point out the familiarities and differences to help you add one more language to your toolkit. Wherever possible, I link it to Kotlin&#39;s official documentation, which explains the concepts better; even if you are unfamiliar with TypeScript, you can follow this post.</p><p>Kotlin is a statically-typed programming language developed by <a href="https://www.jetbrains.com/">JetBrains</a>, the company behind many developer tools. Kotlin is designed to be more concise. I have experience in migrating Java code to Kotlin. It results in significantly less codebase. Kotlin compiler converts the source code to a format that can be executed on the target. The target can be <a href="https://kotlinlang.org/docs/server-overview.html">Java Virtual Machine(JVM)</a>, <a href="https://kotlinlang.org/docs/js-overview.html">JavaScript</a>, or <a href="https://kotlinlang.org/docs/native-overview.html">platform-specific</a>. <a href="https://kotlinlang.org/docs/wasm-overview.html">WASM</a> target is in the experimental stage. The compiler is typically used via an IDE like IntelliJ IDEA or through build tools like Gradel or Maven. We use Kotlin&#39;s playground with JVM as the target for this post. Without further delay, let&#39;s see the customary &#39;Hello, world&#39;:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2F-zTQEgNZF&amp;display_name=Kotlin+Playground&amp;url=https%3A%2F%2Fpl.kotl.in%2F-zTQEgNZF&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=kotl" width="800" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/71e33df5e7eedc0d6a08afc0f819105c/href">https://medium.com/media/71e33df5e7eedc0d6a08afc0f819105c/href</a></iframe><p>That&#39;s it. No imports, semi-colons, and unused args to main function. The main function is the entry point for a program intended to run as an application. This is equivalent to running TypeScript in a Node.js environment — the entry point of your application is typically the top level of the first script file you run. Depending on how you&#39;ve organized your application, this could be any function or line of code. Then you specify the entry point in a project file like package.json.</p><p>From here on, I will roughly follow Kotlin&#39;s documentation to introduce you to the language. I have average knowledge of TypeScript, so I mostly stick to the basics.</p><h3>Organizing Code</h3><p>In TypeScript, code is generally organized based on the conventions of Node.js. You use JavaScript module syntaximport/export to share code between different packages. In Kotlin, code organization typically follows the conventions of <a href="https://docs.gradle.org/current/userguide/organizing_gradle_projects.html">Gradle project</a>. This allows a build tool like Gradle, application code, and tests. The code is further organized into <a href="https://kotlinlang.org/docs/packages.html#default-imports">packages</a>. You don&#39;t need to export Classes, objects, interfaces, etc. You can use <a href="https://kotlinlang.org/docs/visibility-modifiers.html">visibility modifiers</a> to control if an element of a package is visible in another package or not. In TypeScript, a &#39;package&#39; is generally associated with the npm ecosystem. For example, you can publish your npm package or use packages published by other people. An equivalent of this is a maven package published in a <a href="https://maven.apache.org/guides/introduction/introduction-to-repositories.html">maven repository</a>. One such repository is <a href="https://central.sonatype.com/">maven central</a>, which is the default repository.</p><h3>Comments</h3><p>Kotlin supports single and multiline comments similar to TypeScript. In addition, it supports documentation comments which a documentation engine like Dokka can process to generate API documentation.</p><pre>// This is a single-line comment in Kotlin<br><br>/*<br>  This is a<br>  multi-line<br>  comment in Kotlin<br>*/<br><br>/**<br> * This is a documentation comment in Kotlin.<br> * You can use this to describe a function, class, or other element in your code.<br> */</pre><h3>Types</h3><p>As both are statically typed languages, type checking is performed during compile time. Both have support for <a href="https://en.wikipedia.org/wiki/Type_inference">Type Inference</a>.</p><p><a href="https://kotlinlang.org/docs/basic-types.html">Types</a> in Kotlin have diverse numeric types. TypeScript has a single number type and Kotlin has Byte, Short, Int , Long, Float, Double. Similar to TypeScript, it also has Boolean, String, Char, Unit(void in TypeScript). Kotlin does not have a direct equivalent for bigint, symbol, any, and object.</p><p>Kotlin includes <a href="https://kotlinlang.org/docs/null-safety.html">null safety</a> built into its type system. You need to specify if a type is nullable by appending a ? to its type.</p><pre>// name can be null<br>var name: String? = null<br>// name can not be null. This is compilation error<br>var name: String = null</pre><p>Kotlin does not have <a href="https://stackoverflow.com/questions/61370779/typescript-understanding-union-and-intersection-types">union and intersection types</a>. Check the feature <a href="https://discuss.kotlinlang.org/t/union-and-intersection-types-feature-request/4191">discussion</a>.</p><p>In TypeScript, you can declare an array using type syntax(type[]) or the generic array type syntax(Array&lt;type&gt;). In Kotlin, <a href="https://kotlinlang.org/docs/arrays.html">arrays</a> are represented by Array class. Arrays are declared using array type syntax.</p><pre>val names1: Arrya&lt;String&gt; = arrayOf(&quot;Alice&quot;, &quot;Bob&quot;, &quot;Charlie&quot;)<br>// You can omit type<br>val names2 = arrayOf(&quot;Alice&quot;, &quot;Bob&quot;, &quot;Charlie&quot;)<br></pre><p>Kotlin also has specialized classes to represent arrays of primitive types without boxing overhead: ByteArray, ShortArray, IntArray, LongArray, CharArray, FloatArray, DoubleArray, and BooleanArray.</p><h3>Control flow</h3><p><a href="https://kotlinlang.org/docs/control-flow.html">Control flow</a> statements, if , while , and for are similar in both languages. if can be used as an expression, so it can return value. Here is an example from the documentation.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2FJFvbXMpCg&amp;display_name=Kotlin+Playground&amp;url=https%3A%2F%2Fpl.kotl.in%2FJFvbXMpCg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=kotl" width="800" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7d38e8253ced34e7923ebe0d5b6e2ac/href">https://medium.com/media/d7d38e8253ced34e7923ebe0d5b6e2ac/href</a></iframe><p><a href="https://kotlinlang.org/docs/control-flow.html#when-expression">when</a> in Kotlin is a close equivalent of switch , but with when is more flexible than traditional switch statements in other languages. Key features include:</p><ol><li>It is an expression, so it can return a value.</li><li>It doesn&#39;t require break statements to prevent fall-through between branches (unlike switch in TypeScript and many other languages).</li><li>The else clause is mandatory unless the compiler can verify that all possible cases are covered.</li><li>It allows more complex conditions like ranges, collection membership, type checks, etc.</li></ol><p>Here are some examples from the documentation:</p><pre>enum class Color {<br>    RED, GREEN, BLUE<br>}<br><br>when (getColor()) {<br>    Color.RED -&gt; println(&quot;red&quot;)<br>    Color.GREEN -&gt; println(&quot;green&quot;)<br>    Color.BLUE -&gt; println(&quot;blue&quot;)<br>    // &#39;else&#39; is not required because all cases are covered<br>}<br><br>when (getColor()) {<br>    Color.RED -&gt; println(&quot;red&quot;) // no branches for GREEN and BLUE<br>    else -&gt; println(&quot;not red&quot;) // &#39;else&#39; is required<br>}<br><br>when (x) {<br>    in 1..10 -&gt; print(&quot;x is in the range&quot;)<br>    in validNumbers -&gt; print(&quot;x is valid&quot;)<br>    !in 10..20 -&gt; print(&quot;x is outside the range&quot;)<br>    else -&gt; print(&quot;none of the above&quot;)<br>}<br><br>// Example of a type check. <br>// The function return type is boolean which is inferred from `when` return type<br>fun hasPrefix(x: Any) = when(x) {<br>    is String -&gt; x.startsWith(&quot;prefix&quot;)<br>    else -&gt; false<br>}</pre><p>break and continue works similarly to TypeScript. Kotlin, additionally, supports labels to <a href="https://kotlinlang.org/docs/returns.html#break-and-continue-labels">jump control</a>. I never felt the need to use them.</p><h4><a href="https://kotlinlang.org/docs/exceptions.html">Exceptions</a></h4><p>Exception handling is similar in both languages.</p><pre>try {<br>    throw new Error(&quot;This is an error&quot;);<br>} catch (e) {<br>    console.error(e.message);<br>}</pre><pre>try {<br>    throw Exception(&quot;This is an error&quot;)<br>} catch (e: Exception) {<br>    println(e.message)<br>}</pre><p>Although Kotlin can target a JVM, it does not require that checked exceptions be caught or declared in the method&#39;s throws clause. This makes exception handling in Kotlin more similar to TypeScript.</p><h3>Classes and objects</h3><h4><a href="https://kotlinlang.org/docs/classes.html">Classes</a></h4><p>Being <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">OOP</a> languages, Classes, and objects are foundational concepts of both languages, examples of defining a class and creating an instance.</p><pre>class MyClass {<br>    property: string;<br><br>    constructor(property: string) {<br>        this.property = property;<br>    }<br><br>    method() {<br>        console.log(&#39;Method called: &#39; + this.property);<br>    }<br>}<br><br>let obj = new MyClass(&#39;Hello World&#39;);<br>obj.method(); // Method called: Hello World</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2FH66ATtpAT&amp;display_name=Kotlin+Playground&amp;url=https%3A%2F%2Fpl.kotl.in%2FH66ATtpAT&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=kotl" width="800" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/f86bde0111cae4ca9a760826a0c8778c/href">https://medium.com/media/f86bde0111cae4ca9a760826a0c8778c/href</a></iframe><p>Kotlin doesn&#39;t require new keyword to create an instance. In the example, property is read-only (immutable) property because it is declared as val. If you want it to be mutable, you can declare it as var. A Kotlin class can have a primary constructor and any number of secondary constructors. Constructor parameters can also have default values.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2FudTIrak-h&amp;display_name=Kotlin+Playground&amp;url=https%3A%2F%2Fpl.kotl.in%2FudTIrak-h&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=kotl" width="800" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/67f0d14a6d2589ccdd38f0a96f610065/href">https://medium.com/media/67f0d14a6d2589ccdd38f0a96f610065/href</a></iframe><p>Kotlin supports <a href="https://kotlinlang.org/docs/object-declarations.html#companion-objects">class-level functions</a> (companion object methods), which TypeScript supports through the static keyword. Kotlin also supports object expressions and object declarations for creating singleton objects.</p><h4><a href="https://kotlinlang.org/docs/inheritance.html">Inheritance</a></h4><p>Both languages support the key features of class-based inheritance, including subclasses, superclasses, and the ability to override methods. In Kotlin, classes are final by default. You can&#39;t extend from a class unless they are marked open or abstarct.</p><pre>class Animal {<br>    name: string;<br><br>    constructor(name: string) {<br>        this.name = name;<br>    }<br><br>    move(distance: number) {<br>        console.log(`${this.name} moved ${distance} meters.`);<br>    }<br>}<br><br>class Dog extends Animal {<br>    constructor(name: string) {<br>        super(name);<br>    }<br><br>    bark() {<br>        console.log(&quot;Woof! Woof!&quot;);<br>    }<br>}<br><br>const dog = new Dog(&quot;Rover&quot;);<br>dog.bark(); // &quot;Woof! Woof!&quot;<br>dog.move(10); // &quot;Rover moved 10 meters.&quot;</pre><pre>open class Animal(val name: String) {<br>    open fun move(distance: Int) {<br>        println(&quot;$name moved $distance meters.&quot;)<br>    }<br>}<br><br>class Dog(name: String): Animal(name) {<br>    fun bark() {<br>        println(&quot;Woof! Woof!&quot;)<br>    }<br>}<br><br>val dog = Dog(&quot;Rover&quot;)<br>dog.bark() // &quot;Woof! Woof!&quot;<br>dog.move(10) // &quot;Rover moved 10 meters.&quot;</pre><h4><a href="https://kotlinlang.org/docs/properties.html">Properties</a></h4><p>Property declaration in classes differs in TypeScript and Kotlin, though both languages provide ways to define and control the accessibility of properties.</p><p>In TypeScript, properties can be defined directly in the class body, and you can specify their accessibility level (public, protected, or private), whether they&#39;re readonly, and their type. The TypeScript language also supports a concise syntax for defining constructor parameters and automatically assigning them to properties:</p><pre>class MyClass {<br>    public readonly property1: string;<br>    private property2: number;<br><br>    constructor(property1: string, private property3: boolean) {<br>        this.property1 = property1;<br>        this.property2 = 0;<br>    }<br>}</pre><p>In this TypeScript code, property1 is publicly readable but cannot be changed after it&#39;s assigned in the constructor (because it&#39;s readonly). property2 is private and can only be accessed within the class. property3 is automatically assigned from a constructor parameter and is also private.</p><p>In Kotlin, properties are declared in the class body or in the primary constructor, and you can specify their accessibility level (public, internal, protected, or private). All properties must be initialized or declared abstract. Kotlin properties implicitly come with getters and can optionally have setters, which can be controlled with val (read-only) and var (mutable):</p><pre>class MyClass(property1: String) {<br>    val property1: String = property1<br>    private var property2: Int = 0<br>    private val property3: Boolean<br><br>    init {<br>        property3 = true<br>    }<br>}</pre><p>In this Kotlin code, property1 is publicly readable but cannot be changed after it&#39;s assigned in the constructor (because it&#39;s a val). property2 is private and can be changed because it&#39;s a var. property3 is also private and read-only, and it&#39;s assigned in the init block.</p><h4><a href="https://kotlinlang.org/docs/interfaces.html">Interfaces</a></h4><p>Interfaces are used for similar purposes but differ in syntax and capabilities.</p><p>In TypeScript, interfaces are purely a compile-time construct with no runtime representation. TypeScript interfaces can include properties, methods, and index signatures and can be implemented by classes. Here&#39;s a basic example:</p><pre>interface Animal {<br>    name: string;<br>    move(distance: number): void;<br>}<br><br>class Dog implements Animal {<br>    constructor(public name: string) {}<br><br>    move(distance: number) {<br>        console.log(`${this.name} moved ${distance} meters.`);<br>    }<br>}<br><br>const dog = new Dog(&quot;Rover&quot;);<br>dog.move(10); // &quot;Rover moved 10 meters.&quot;</pre><p>TypeScript interfaces can also be used to describe function types and can be extended using the extends keyword, and can be used to describe indexable types.</p><p>In Kotlin, interfaces can contain definitions of abstract methods and method implementations. They can&#39;t have any state (meaning they can&#39;t hold property values that can be changed), but they can declare properties that need to be implemented in subclasses. Classes and objects can implement interfaces using the : operator. Here&#39;s the equivalent Kotlin code to the TypeScript example above:</p><pre>interface Animal {<br>    val name: String<br>    fun move(distance: Int)<br>}<br><br>class Dog(override val name: String) : Animal {<br>    override fun move(distance: Int) {<br>        println(&quot;$name moved $distance meters.&quot;)<br>    }<br>}<br><br>val dog = Dog(&quot;Rover&quot;)<br>dog.move(10) // &quot;Rover moved 10 meters.&quot;</pre><p>Kotlin interfaces can also extend other interfaces and have default method implementations.</p><h4><a href="https://kotlinlang.org/docs/fun-interfaces.html">Functional Interfaces</a></h4><p>In Kotlin, functional interfaces (also known as SAM Interfaces — Single Abstract Method Interfaces) can be used similarly to function types in TypeScript:</p><pre>interface StringTransformer {<br>    (input: string): string;<br>}<br><br>const upperCaseTransformer: StringTransformer = (input) =&gt; input.toUpperCase();<br><br>console.log(upperCaseTransformer(&quot;hello&quot;)); // Outputs: HELLO</pre><pre>fun interface StringTransformer {<br>    fun transform(input: String): String<br>}<br><br>val upperCaseTransformer = StringTransformer { it.toUpperCase() }<br><br>println(upperCaseTransformer.transform(&quot;hello&quot;)) // Outputs: HELLO</pre><p>Kotlin also supports higher-order functions directly, allowing you to pass functions as parameters and return them from other functions. This is similar to TypeScript function types:</p><pre>type StringTransformer = (input: string) =&gt; string;<br><br>const upperCaseTransformer: StringTransformer = (input) =&gt; input.toUpperCase();<br><br>console.log(upperCaseTransformer(&quot;hello&quot;)); // Outputs: HELLO</pre><pre>val upperCaseTransformer: (String) -&gt; String = { it.toUpperCase() }<br><br>println(upperCaseTransformer(&quot;hello&quot;)) // Outputs: HELLO</pre><h4><a href="https://kotlinlang.org/docs/extensions.html">Extensions</a></h4><p>Extension functions are a powerful Kotlin feature that allows you to &quot;add&quot; new functions to an existing class without modifying its source code. TypeScript does not support extension functions in the same way, but there are alternative patterns you can use to achieve similar functionality. You can define an extension function by prefixing the function&#39;s name with the name of the class you&#39;re extending. Here&#39;s an example:</p><pre>fun String.surroundWithStars(): String = &quot;***$this***&quot;<br><br>val myString = &quot;Hello, world&quot;<br>println(myString.surroundWithStars()) // Outputs: ***Hello, world***</pre><h4><a href="https://kotlinlang.org/docs/data-classes.html">Data Classes</a></h4><p>Data classes are a feature of Kotlin that makes it easier to create classes whose primary purpose is to hold data. TypeScript does not have a direct equivalent to Kotlin&#39;s data classes, but you can achieve similar functionality using TypeScript&#39;s features.</p><p>You can create a data class using the data keyword. Data classes automatically have equals(), hashCode(), toString(), copy(), and componentN() functions generated:</p><pre>data class Person(val name: String, val age: Int)<br><br>val bob = Person(&quot;Bob&quot;, 30)<br>println(bob) // Outputs: Person(name=Bob, age=30)</pre><h4><a href="https://kotlinlang.org/docs/sealed-classes.html">Sealed classes and interfaces</a></h4><p>Sealed classes and interfaces are features in Kotlin that restrict the hierarchy of a class or an interface, meaning you can control which other classes or interfaces are allowed to inherit from them. TypeScript does not directly support sealed classes or interfaces.</p><p>In Kotlin, a sealed class or interface can be subclassed only in the same file where it&#39;s declared. This is useful when you want to represent a restricted set of types in a type-safe manner. Here&#39;s an example:</p><pre>sealed class Expr {<br>    data class Const(val number: Double) : Expr()<br>    data class Sum(val e1: Expr, val e2: Expr) : Expr()<br>    object NotANumber : Expr()<br>}<br><br>fun eval(expr: Expr): Double = when (expr) {<br>    is Expr.Const -&gt; expr.number<br>    is Expr.Sum -&gt; eval(expr.e1) + eval(expr.e2)<br>    Expr.NotANumber -&gt; Double.NaN<br>}</pre><p>In the above Kotlin code, Expr is a sealed class with three subclasses: Const, Sum, and NotANumber. The eval function uses a when expression to handle each subclass of Expr in a type-safe way. Because Expr is a sealed class, the compiler knows that these are the only subclasses that exist, so there&#39;s no need for an else clause in the when expression.</p><p>Similar code in TypeScript:</p><pre>type Expr =<br>    | { type: &#39;Const&#39;, number: number }<br>    | { type: &#39;Sum&#39;, e1: Expr, e2: Expr }<br>    | { type: &#39;NotANumber&#39; }<br><br>function eval(expr: Expr): number {<br>    switch (expr.type) {<br>        case &#39;Const&#39;:<br>            return expr.number;<br>        case &#39;Sum&#39;:<br>            return eval(expr.e1) + eval(expr.e2);<br>        case &#39;NotANumber&#39;:<br>            return NaN;<br>    }<br>}</pre><p>In this TypeScript code Expr is a discriminated union type that can represent three different objects. The eval function uses a switch statement to handle each possible kind of Expr in a type-safe way. This is a common pattern in TypeScript for representing a closed set of types.</p><p>Although TypeScript&#39;s approach doesn&#39;t have the same level of enforcement at the language level as Kotlin&#39;s sealed classes and interfaces, it provides a flexible and type-safe way to represent a restricted set of types.</p><h4><a href="https://kotlinlang.org/docs/generics.html">Generics</a></h4><p>In both languages, the overall goal of generics in both languages is the same: to provide a way to create reusable, type-safe code that can operate on various types. One major feature that Kotlin&#39;s generics has and TypeScript lacks is type variance annotations. Kotlin supports declaration-site variance annotations (out for covariance, in for contravariance), allowing for more expressive type hierarchies. TypeScript, on the other hand, uses use-site variance, meaning that variance is determined by how the types are used rather than being declared with the types. Here are examples in both languages:</p><pre>function identity&lt;T&gt;(arg: T): T {<br>    return arg;<br>}<br><br>let output = identity&lt;string&gt;(&quot;myString&quot;);  // type of output will be &#39;string&#39;<br><br>class GenericNumber&lt;T&gt; {<br>    zeroValue: T;<br>    add: (x: T, y: T) =&gt; T;<br>}</pre><pre>fun &lt;T&gt; identity(arg: T): T {<br>    return arg<br>}<br><br>val output = identity(&quot;myString&quot;)  // type of output will be String<br><br>class GenericBox&lt;T&gt;(val value: T)</pre><h4><a href="https://kotlinlang.org/docs/nested-classes.html">Nested and inner classes</a></h4><p>In Kotlin, classes can be nested within other classes, which can help keep related classes grouped together and encapsulate them from the outer class. Here’s an example:</p><pre>class Outer {<br>    class Nested {<br>        fun hello() = &quot;Hello from Nested&quot;<br>    }<br>}<br><br>val message = Outer.Nested().hello()  // Outputs: &quot;Hello from Nested&quot;</pre><p>Kotlin also supports inner classes, which are nested classes that can access members of the outer class. You declare an inner class using the inner keyword:</p><pre>class Outer {<br>    private val greeting: String = &quot;Hello&quot;<br><br>    inner class Inner {<br>        fun hello() = &quot;$greeting from Inner&quot;<br>    }<br>}<br><br>val message = Outer().Inner().hello()  // Outputs: &quot;Hello from Inner&quot;</pre><p>TypeScript does not directly support nested or inner classes in the same way as Kotlin. However, you can mimic nested classes by defining a class within the scope of another class:</p><pre>class Outer {<br>    static Nested = class {<br>        hello() {<br>            return &quot;Hello from Nested&quot;;<br>        }<br>    }<br>}<br><br>let message = new Outer.Nested().hello();  // Outputs: &quot;Hello from Nested&quot;</pre><p>Both languages support anonymous inner classes, but you may use them less frequently in TypeScript, as the language encourages a more functional style.</p><h4><a href="https://kotlinlang.org/docs/enum-classes.html">Enum classes</a></h4><p>In Kotlin, an enum class is defined using the enum keyword. Each enum constant is an object and can have methods and properties. Commas separate enum constants:</p><pre>enum class Color(val rgb: Int) {<br>    RED(0xFF0000),<br>    GREEN(0x00FF00),<br>    BLUE(0x0000FF);<br><br>    fun hex(): String {<br>        return &quot;#${Integer.toHexString(rgb)}&quot;<br>    }<br>}</pre><p>Color is an enum class with three constants: RED, GREEN, and BLUE. Each constant is associated with a rgb value. The hex function converts the rgb value to a hexadecimal string.</p><p>In TypeScript, an enum is defined using the enum keyword. Each enum member is initialized with a numeric value, starting from 0 and incremented by 1 for each member. However, you can also manually set the value of an enum member to a numeric or string literal:</p><pre>enum Color {<br>    Red = &quot;#FF0000&quot;,<br>    Green = &quot;#00FF00&quot;,<br>    Blue = &quot;#0000FF&quot;<br>}<br><br>function getHexColor(color: Color): string {<br>    return color;<br>}<br><br>console.log(getHexColor(Color.Red));  // Outputs: &quot;#FF0000&quot;</pre><p>Color is an enum with three members: Red, Green, and Blue. Each member is associated with a hexadecimal string.</p><p>While enums in both languages can associate data with each enum constant, Kotlin’s enums can also include methods and properties. However, TypeScript’s enums have more flexibility in initializing, allowing both numeric and string literal values and even computed initializers.</p><h4><a href="https://kotlinlang.org/docs/object-declarations.html">Object expressions and declarations</a></h4><p>While TypeScript doesn’t have direct analogous to object expressions or declarations, it does have similar constructs.</p><p>You can create an object that implements an interface using a simple object literal:</p><pre>// Kotlin<br>val listener = object : EventListener {<br>    override fun onEvent(event: Event) {<br>        // ...<br>    }<br>}</pre><pre>interface EventListener {<br>    onEvent(event: Event): void;<br>}<br><br>let listener: EventListener = {<br>    onEvent(event: Event): void {<br>        // ...<br>    }<br>};</pre><p>In Kotlin, an object declaration defines a singleton, an object of which there is precisely one instance. You cannot create instances of an object declaration, and it cannot take a constructor. Here’s an example:</p><pre>object MySingleton {<br>    val info = &quot;I am a singleton&quot;<br><br>    fun doSomething() {<br>        // ...<br>    }<br>}</pre><p>In TypeScript, singleton patterns can be created in a variety of ways, one of them being:</p><pre>class MySingleton {<br>    private static _instance: MySingleton = new MySingleton();<br>    public info = &quot;I am a singleton&quot;;<br><br>    private constructor() {}<br><br>    public static get instance() {<br>        return this._instance;<br>    }<br><br>    public doSomething() {<br>        // ...<br>    }<br>}<br><br>console.log(MySingleton.instance.info);</pre><h4><a href="https://kotlinlang.org/docs/delegation.html">Delegation</a></h4><p>Delegation is a design pattern that allows an object to delegate part or all of its functionality to another object. It’s a way of composing complex objects without using inheritance. In Kotlin, delegation is a first-class language feature, while in TypeScript, it can be achieved manually using its powerful type system.</p><p>In Kotlin, you can use the by keyword to delegate the implementation of an interface to another object. Here&#39;s an example:</p><pre>interface SoundBehaviour {<br>    fun makeSound()<br>}<br><br>class ScreamBehaviour : SoundBehaviour {<br>    override fun makeSound() = println(&quot;Scream!!!&quot;)<br>}<br><br>class RockStar(val soundBehaviour: SoundBehaviour) : SoundBehaviour by soundBehaviour<br><br>fun main() {<br>    val rockStar = RockStar(ScreamBehaviour())<br>    rockStar.makeSound()  // Outputs: &quot;Scream!!!&quot;<br>}</pre><p>In this Kotlin code, RockStar delegates its SoundBehaviour to the soundBehaviour object. When you call makeSound on a RockStar, it forwards the call to its soundBehaviour.</p><p>In TypeScript, you can achieve something similar using classes and interfaces. However, it’s more manual and not as concise as in Kotlin:</p><pre>interface SoundBehaviour {<br>    makeSound(): void;<br>}<br><br>class ScreamBehaviour implements SoundBehaviour {<br>    makeSound() {<br>        console.log(&quot;Scream!!!&quot;);<br>    }<br>}<br><br>class RockStar {<br>    constructor(private soundBehaviour: SoundBehaviour) {}<br><br>    makeSound() {<br>        this.soundBehaviour.makeSound();<br>    }<br>}<br><br>const rockStar = new RockStar(new ScreamBehaviour());<br>rockStar.makeSound();  // Outputs: &quot;Scream!!!&quot;</pre><h4><a href="https://kotlinlang.org/docs/delegated-properties.html">Delegated properties</a></h4><p>Delegated properties are a unique feature of Kotlin, allowing you to define custom logic invoked when a property’s getter or setter is called. TypeScript does not provide an exact equivalent feature out of the box. However, TypeScript’s getters and setters can be used to achieve something similar. Here’s an example using the built-in Delegates.observable:</p><pre>import kotlin.properties.Delegates<br><br>class User {<br>    var name: String by Delegates.observable(&quot;&lt;no name&gt;&quot;) {<br>        prop, old, new -&gt;<br>        println(&quot;$old -&gt; $new&quot;)<br>    }<br>}<br><br>fun main() {<br>    val user = User()<br>    user.name = &quot;first&quot;<br>    user.name = &quot;second&quot;<br>}</pre><p>In this Kotlin code, the User class has a name property. The getter and setter logic for name is delegated to Delegates.observable. Every time name is changed, it prints the old and new values.</p><p>In TypeScript, you can use getters and setters to define custom logic that’s run when a property is accessed or changed:</p><pre>class User {<br>    private _name: string = &quot;&lt;no name&gt;&quot;;<br><br>    get name(): string {<br>        return this._name;<br>    }<br><br>    set name(value: string) {<br>        console.log(`${this._name} -&gt; ${value}`);<br>        this._name = value;<br>    }<br>}<br><br>const user = new User();<br>user.name = &quot;first&quot;;<br>user.name = &quot;second&quot;;</pre><h4><a href="https://kotlinlang.org/docs/type-aliases.html">Type aliases</a></h4><p>While typealias in both languages essentially do the same thing, there are some subtle differences. For example, in TypeScript, a type can also represent more complex types such as union types, intersection types, mapped types, etc., which makes it more versatile than its Kotlin counterpart.</p><pre>type UserName = string;<br><br>function greet(user: UserName) {<br>    console.log(`Hello, ${user}!`);<br>}</pre><pre>typealias UserName = String<br><br>fun greet(user: UserName) {<br>    println(&quot;Hello, $user!&quot;)<br>}</pre><h3>Functions</h3><h4><a href="https://kotlinlang.org/docs/functions.html">Functions</a></h4><p>Both languages support higher-order functions and closures, and their syntax and capabilities are somewhat similar, but there are also some differences.</p><p>Function declaration:</p><pre>function greet(name: string): string {<br>    return `Hello, ${name}`;<br>}</pre><pre>fun greet(name: String)= &quot;Hello, $name&quot;</pre><p>Function Expressions / Anonymous Functions:</p><pre>let greet = function(name: string): string {<br>    return `Hello, ${name}`;<br>};</pre><pre>val greet = fun(name: String): String {<br>    return &quot;Hello, $name&quot;<br>}</pre><p>Arrow Functions:</p><pre>let greet: (name: string) =&gt; string = name =&gt; `Hello, ${name}`;</pre><pre>val greet: (String) -&gt; String = { name -&gt; &quot;Hello, $name&quot; }</pre><p>Higher Order Functions :</p><pre>function applyGreeting(name: string, greetingFunction: (name: string) =&gt; string): string {<br>    return greetingFunction(name);<br>}</pre><pre>fun applyGreeting(name: String, greetingFunction: (String) -&gt; String): String {<br>    return greetingFunction(name)<br>}</pre><p>Both Kotlin and TypeScript support varargs (variable number of arguments), optional parameters, and default parameter values. Kotlin also has named parameters, which TypeScript does not have, but you can <a href="https://stackoverflow.com/questions/42108807/using-named-parameters-in-javascript-based-on-typescript">simulate</a> it.</p><h4><a href="https://kotlinlang.org/docs/inline-functions.html">Inline functions</a></h4><p>In Kotlin, the keyword inline can be used to mark a function to be inlined at the point of use, which means the function body is copied directly into the calling code rather than being invoked normally. This can eliminate the overhead of a function call and allows certain kinds of syntax, like lambda expressions, to work more efficiently.</p><p>TypeScript doesn’t directly provide a mechanism for function inlining. The TypeScript compiler and the JavaScript runtime engine often perform optimizations that might inline a function if they determine it would be more efficient, but there’s no way to control this in the language explicitly.</p><p>While TypeScript does allow for higher-order functions and passing around of lambda expressions, similar to Kotlin, it can’t guarantee the same level of optimization that Kotlin’s inline functions provide.</p><p>It’s also worth noting that minification/uglification tools commonly used in the JavaScript ecosystem can perform some form of inlining as part of their optimization. However, the main goal is to reduce code size, not necessarily to optimize execution speed.</p><h4><a href="https://kotlinlang.org/docs/operator-overloading.html">Operator Overloading</a></h4><p>In Kotlin, operators are overloads of corresponding functions. This means you can overload an operator by implementing a specific function in your class. The function must be marked with the operator modifier. For example:</p><pre>data class Point(val x: Int, val y: Int)<br><br>operator fun Point.plus(other: Point): Point = Point(x + other.x, y + other.y)<br><br>val p1 = Point(1, 1)<br>val p2 = Point(2, 2)<br>val p3 = p1 + p2  // Result is Point(3, 3)</pre><p>While TypeScript doesn’t have operator overloading in the same way as Kotlin, you can still define similar behavior using methods.</p><pre>class Point {<br>    constructor(public x: number, public y: number) {}<br><br>    plus(other: Point): Point {<br>        return new Point(this.x + other.x, this.y + other.y);<br>    }<br>}<br><br>let p1 = new Point(1, 1);<br>let p2 = new Point(2, 2);<br>let p3 = p1.plus(p2);  // Equivalent result, Point {x: 3, y: 3}</pre><h3>Equality</h3><p>In both languages, the concept of equality can be split into two different types: structural equality (equivalent to ‘==’) and referential equality (equivalent to ‘===’ in JavaScript).</p><p>Kotlin differentiates between structural equality and referential equality.</p><p>Structural Equality (==): It checks if the values of two objects are equal. This uses the equals() method under the hood, which can be overridden in custom classes for custom equality. If the objects being compared are null, then == checks for null equality.</p><pre>val a = &quot;Kotlin&quot;<br>val b = &quot;Kotlin&quot;<br>println(a == b)  // Prints: true</pre><p>Referential Equality (===): It checks if two references point to the exact same object (i.e., they are the same in memory).</p><pre>val a = &quot;Kotlin&quot;<br>val b = StringBuilder().append(&quot;Kot&quot;).append(&quot;lin&quot;).toString()<br>println(a === b)  // Prints: false</pre><p>In summary, Kotlin provides more safety regarding equality comparison by not implicitly converting types like TypeScript (JavaScript) does. It’s always recommended to use strict equality (===) in TypeScript to avoid unexpected results due to type coercion.</p><h3>Asynchronous programming techniques</h3><p>In Kotlin, the primary way to handle <a href="https://kotlinlang.org/docs/async-programming.html">asynchronous programming</a> is through coroutines, a feature that allows you to write asynchronous code in a sequential style, which is easier to understand and modify. Coroutines are lightweight threads that do not block the main thread, and the syntax is built into the language.</p><p>Here is an example of using a coroutine in Kotlin:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fpl.kotl.in%2FHJRMA-6k8&amp;display_name=Kotlin+Playground&amp;url=https%3A%2F%2Fpl.kotl.in%2FHJRMA-6k8&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=kotl" width="800" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/0beb715b1aa76df5bb959fa3bdc9be1d/href">https://medium.com/media/0beb715b1aa76df5bb959fa3bdc9be1d/href</a></iframe><p>TypeScript (JavaScript) primarily uses callbacks, promises, and async/await.</p><h3>Annotations</h3><p>Kotlin supports <a href="https://kotlinlang.org/docs/annotations.html">annotations</a>, which can be used to annotate classes, functions, properties, variables, parameters, and expressions. Here’s an example of a Kotlin annotation:</p><pre>annotation class MyAnnotation<br><br>@MyAnnotation<br>fun someFunction() {<br>    // ...<br>}</pre><p>In this example, @MyAnnotation is an annotation on the someFunction function. You can create your own annotations in Kotlin by declaring a class with the annotation modifier.</p><p>Kotlin annotations are a powerful feature and can influence how the Kotlin compiler generates bytecode. They can also be used to change code behavior at runtime or for code generation purposes.</p><p>TypeScript does not have annotations in the same way that Kotlin does. However, TypeScript supports decorators, a feature that is similar to annotations in other languages. Decorators allow you to annotate and modify classes and class members at design time. Decorators use the form @expression, where expression must evaluate to a function that will be called at runtime.</p><p>Here’s an example of a TypeScript decorator:</p><pre>function MyDecorator(target) {<br>    // do something with &#39;target&#39;...<br>}<br><br>@MyDecorator<br>class MyClass {<br>    // ...<br>}</pre><p>In this example, @MyDecorator is a decorator for MyClass. Decorators can be used on class declarations, methods, accessors, properties, or parameters. Notably, decorators are still an experimental feature in TypeScript and JavaScript.</p><h3>Destructuring declarations</h3><p>In Kotlin, <a href="https://kotlinlang.org/docs/destructuring-declarations.html">destructuring declarations</a> are a simple syntax for creating multiple variables simultaneously. For example, if you have a data class Person, you can create two variables name and age from a Person object like this:</p><pre>data class Person(val name: String, val age: Int)<br><br>val john = Person(&quot;John&quot;, 31)<br>val (name, age) = john<br><br>println(name) // prints &quot;John&quot;<br>println(age) // prints 31</pre><p>In TypeScript, destructuring can be used with both arrays and objects. For example:</p><pre>let person = { name: &quot;John&quot;, age: 31 };<br><br>let { name, age } = person;<br><br>console.log(name); // prints &quot;John&quot;<br>console.log(age); // prints 31</pre><p>Destructuring can also be used in function parameters:</p><pre>function greet({ name, age }: { name: string, age: number }) {<br>    console.log(`Hello, ${name}. You are ${age} years old.`);<br>}<br><br>greet(person); // prints &quot;Hello, John. You are 31 years old.&quot;</pre><h3>Standard library</h3><p>Kotlin’s <a href="https://kotlinlang.org/api/latest/jvm/stdlib/">standard library</a> provides a set of useful functions and types fully interoperable with Java. It includes standard functions like print(), println(), and readLine(), as well as <a href="https://kotlinlang.org/docs/collections-overview.html">collections</a> (like List, Set, Map), I/O classes, text manipulation functions, date and time classes, and much more. You can go through <a href="https://play.kotlinlang.org/byExample/overview">Learn Kotlin by Example</a> to learn more.</p><p>TypeScript does not have a dedicated standard library per se, but it has access to the extensive set of JavaScript APIs available in various environments, like the browser (DOM APIs, Fetch API, etc.) or Node.js (fs, net, etc.). It also adds static types and interfaces to these APIs, making them more robust and easier to use.</p><p>Furthermore, TypeScript benefits from the vast ecosystem of npm packages available for JavaScript. These libraries can be used directly in TypeScript, and many have TypeScript declaration files (.d.ts files) available, either included in the package itself or available through DefinitelyTyped.</p><h3>Final Thoughts</h3><p>I hope I have provided enough information to get started and dive into Kotlin. If you are using Kotlin for server-side programming, please share your experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d15f35f23907" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dive into Airbyte]]></title>
            <link>https://medium.com/@adisesha/dive-into-airbyte-24a7e90892c8?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/24a7e90892c8</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[airbyte]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Sun, 23 Apr 2023 12:04:55 GMT</pubDate>
            <atom:updated>2023-04-23T12:04:55.193Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://airbyte.com/">Airbyte</a> is a popular ELT tool in the Data Engineering community. The purpose of the post is to dive into some of the internals of Airbyte. This will help to reason about issues faced during development and operations. This post uses v0.44.1 Open Source code as a reference. Airbyte Cloud may differ from Open Source.</p><p>Its code is changing fast. Before Feb-2020, all code was in a single repo, <a href="https://github.com/airbytehq/airbyte">airbyte</a>. Now only connectors-related code lives there. Platform-related code is moved to <a href="https://github.com/airbytehq/airbyte-platform">airbyte-platform</a>. According to their <a href="https://airbytehq.slack.com/archives/C01A4CAP81L/p1675872901163449">announcement</a> in Slack, this is done for efficiency and maintenance. I will refer to both projects in this post. I assume that you have complete access to Airbyte and know how to set up a connection. If not, start with the <a href="https://docs.airbyte.com/quickstart/deploy-airbyte">Getting Started</a> guides.</p><h4>What is Airbyte?</h4><p>Airbyte is an Open-Source Data Integration Platform that simplifies transferring and consolidating data from various sources to data warehouses, lakes, or other sources. For example, you want to move data from MySql to Snowflake. Here is a simple view of how the data flows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*8jH0fQVjiopPbbTLqAzyUA.png" /></figure><p>How does it all work? First, let’s go through the operations and touch on its components.</p><h4>Connecting to a Data source or destination</h4><p>One of the <a href="https://docs.airbyte.com/cloud/core-concepts">core concepts</a> of Airbyte is <a href="https://docs.airbyte.com/cloud/core-concepts#connector">Connector</a>. A connector is a Docker Image that implements <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol/">Airbye Protocol</a>. A connector accepts specific commands(spec, check, discover, etc.), depending on the type of connector(source or destination), and produces various <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol/#airbytemessage">messages</a>. Check the <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol-docker">Docker Protocol Interface</a>. To warm up, try spec on MySql source:</p><pre>&gt; docker run airbyte/source-mysql:2.0.15 spec<br>{&quot;type&quot;:&quot;LOG&quot;,&quot;log&quot;:{&quot;level&quot;:&quot;INFO&quot;,&quot;message&quot;:&quot;INFO i.a.i.s.m.MySqlSource(main):385 starting source: class io.airbyte.integrations.source.mysql.MySqlSource&quot;}}<br>{&quot;type&quot;:&quot;LOG&quot;,&quot;log&quot;:{&quot;level&quot;:&quot;INFO&quot;,&quot;message&quot;:&quot;INFO i.a.i.b.IntegrationCliParser(parseOptions):126 integration args: {spec=null}&quot;}}<br>{&quot;type&quot;:&quot;LOG&quot;,&quot;log&quot;:{&quot;level&quot;:&quot;INFO&quot;,&quot;message&quot;:&quot;INFO i.a.i.b.IntegrationRunner(runInternal):108 Running integration: io.airbyte.integrations.base.ssh.SshWrappedSource&quot;}}<br>{&quot;type&quot;:&quot;LOG&quot;,&quot;log&quot;:{&quot;level&quot;:&quot;INFO&quot;,&quot;message&quot;:&quot;INFO i.a.i.b.IntegrationRunner(runInternal):109 Command: SPEC&quot;}}<br>{&quot;type&quot;:&quot;LOG&quot;,&quot;log&quot;:{&quot;level&quot;:&quot;INFO&quot;,&quot;message&quot;:&quot;INFO i.a.i.b.IntegrationRunner(runInternal):110 Integration config: IntegrationConfig{command=SPEC, configPath=&#39;null&#39;, catalogPath=&#39;null&#39;, statePath=&#39;null&#39;}&quot;}}<br>{&quot;type&quot;:&quot;SPEC&quot;,&quot;spec&quot;:{&quot;documentationUrl&quot;:&quot;https://docs.airbyte.com/integrations/sources/mysql&quot;,&quot;connectionSpecification&quot;:{&quot;$schema&quot;:&quot;http://json-schema.org/draft-07/schema#&quot;,&quot;title&quot;:&quot;MySql Source Spec&quot;,&quot;type&quot;:&quot;object&quot;,&quot;required&quot;:[&quot;host&quot;,&quot;port&quot;,&quot;database&quot;,&quot;username&quot;,&quot;replication_method&quot;],&quot;properties&quot;:{&quot;host&quot;:{&quot;description&quot;:&quot;The host name of the database.&quot;,&quot;title&quot;:&quot;Host&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:0},&quot;port&quot;:{&quot;description&quot;:&quot;The port to connect to.&quot;,&quot;title&quot;:&quot;Port&quot;,&quot;type&quot;:&quot;integer&quot;,&quot;minimum&quot;:0,&quot;maximum&quot;:65536,&quot;default&quot;:3306,&quot;examples&quot;:[&quot;3306&quot;],&quot;order&quot;:1},&quot;database&quot;:{&quot;description&quot;:&quot;The database name.&quot;,&quot;title&quot;:&quot;Database&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:2},&quot;username&quot;:{&quot;description&quot;:&quot;The username which is used to access the database.&quot;,&quot;title&quot;:&quot;Username&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:3},&quot;password&quot;:{&quot;description&quot;:&quot;The password associated with the username.&quot;,&quot;title&quot;:&quot;Password&quot;,&quot;type&quot;:&quot;string&quot;,&quot;airbyte_secret&quot;:true,&quot;order&quot;:4},&quot;jdbc_url_params&quot;:{&quot;description&quot;:&quot;Additional properties to pass to the JDBC URL string when connecting to the database formatted as &#39;key=value&#39; pairs separated by the symbol &#39;&amp;&#39;. (example: key1=value1&amp;key2=value2&amp;key3=value3). For more information read about &lt;a href=\&quot;https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-jdbc-url-format.html\&quot;&gt;JDBC URL parameters&lt;/a&gt;.&quot;,&quot;title&quot;:&quot;JDBC URL Parameters (Advanced)&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:5},&quot;ssl&quot;:{&quot;title&quot;:&quot;SSL Connection&quot;,&quot;description&quot;:&quot;Encrypt data using SSL.&quot;,&quot;type&quot;:&quot;boolean&quot;,&quot;default&quot;:true,&quot;order&quot;:6},&quot;ssl_mode&quot;:{&quot;title&quot;:&quot;SSL modes&quot;,&quot;description&quot;:&quot;SSL connection modes. Read more &lt;a href=\&quot;https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html\&quot;&gt; in the docs&lt;/a&gt;.&quot;,&quot;type&quot;:&quot;object&quot;,&quot;order&quot;:7,&quot;oneOf&quot;:[{&quot;title&quot;:&quot;preferred&quot;,&quot;description&quot;:&quot;Automatically attempt SSL connection. If the MySQL server does not support SSL, continue with a regular connection.&quot;,&quot;required&quot;:[&quot;mode&quot;],&quot;properties&quot;:{&quot;mode&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;preferred&quot;,&quot;order&quot;:0}}},{&quot;title&quot;:&quot;required&quot;,&quot;description&quot;:&quot;Always connect with SSL. If the MySQL server doesn’t support SSL, the connection will not be established. Certificate Authority (CA) and Hostname are not verified.&quot;,&quot;required&quot;:[&quot;mode&quot;],&quot;properties&quot;:{&quot;mode&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;required&quot;,&quot;order&quot;:0}}},{&quot;title&quot;:&quot;Verify CA&quot;,&quot;description&quot;:&quot;Always connect with SSL. Verifies CA, but allows connection even if Hostname does not match.&quot;,&quot;required&quot;:[&quot;mode&quot;,&quot;ca_certificate&quot;],&quot;properties&quot;:{&quot;mode&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;verify_ca&quot;,&quot;order&quot;:0},&quot;ca_certificate&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;CA certificate&quot;,&quot;description&quot;:&quot;CA certificate&quot;,&quot;airbyte_secret&quot;:true,&quot;multiline&quot;:true,&quot;order&quot;:1},&quot;client_certificate&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;Client certificate&quot;,&quot;description&quot;:&quot;Client certificate (this is not a required field, but if you want to use it, you will need to add the &lt;b&gt;Client key&lt;/b&gt; as well)&quot;,&quot;airbyte_secret&quot;:true,&quot;multiline&quot;:true,&quot;order&quot;:2,&quot;always_show&quot;:true},&quot;client_key&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;Client key&quot;,&quot;description&quot;:&quot;Client key (this is not a required field, but if you want to use it, you will need to add the &lt;b&gt;Client certificate&lt;/b&gt; as well)&quot;,&quot;airbyte_secret&quot;:true,&quot;multiline&quot;:true,&quot;order&quot;:3,&quot;always_show&quot;:true},&quot;client_key_password&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;Client key password&quot;,&quot;description&quot;:&quot;Password for keystorage. This field is optional. If you do not add it - the password will be generated automatically.&quot;,&quot;airbyte_secret&quot;:true,&quot;order&quot;:4}}},{&quot;title&quot;:&quot;Verify Identity&quot;,&quot;description&quot;:&quot;Always connect with SSL. Verify both CA and Hostname.&quot;,&quot;required&quot;:[&quot;mode&quot;,&quot;ca_certificate&quot;],&quot;properties&quot;:{&quot;mode&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;verify_identity&quot;,&quot;order&quot;:0},&quot;ca_certificate&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;CA certificate&quot;,&quot;description&quot;:&quot;CA certificate&quot;,&quot;airbyte_secret&quot;:true,&quot;multiline&quot;:true,&quot;order&quot;:1},&quot;client_certificate&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;Client certificate&quot;,&quot;description&quot;:&quot;Client certificate (this is not a required field, but if you want to use it, you will need to add the &lt;b&gt;Client key&lt;/b&gt; as well)&quot;,&quot;airbyte_secret&quot;:true,&quot;multiline&quot;:true,&quot;order&quot;:2,&quot;always_show&quot;:true},&quot;client_key&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;Client key&quot;,&quot;description&quot;:&quot;Client key (this is not a required field, but if you want to use it, you will need to add the &lt;b&gt;Client certificate&lt;/b&gt; as well)&quot;,&quot;airbyte_secret&quot;:true,&quot;multiline&quot;:true,&quot;order&quot;:3,&quot;always_show&quot;:true},&quot;client_key_password&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;Client key password&quot;,&quot;description&quot;:&quot;Password for keystorage. This field is optional. If you do not add it - the password will be generated automatically.&quot;,&quot;airbyte_secret&quot;:true,&quot;order&quot;:4}}}]},&quot;replication_method&quot;:{&quot;type&quot;:&quot;object&quot;,&quot;title&quot;:&quot;Replication Method&quot;,&quot;description&quot;:&quot;Replication method to use for extracting data from the database.&quot;,&quot;order&quot;:8,&quot;oneOf&quot;:[{&quot;title&quot;:&quot;Standard&quot;,&quot;description&quot;:&quot;Standard replication requires no setup on the DB side but will not be able to represent deletions incrementally.&quot;,&quot;required&quot;:[&quot;method&quot;],&quot;properties&quot;:{&quot;method&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;STANDARD&quot;,&quot;order&quot;:0}}},{&quot;title&quot;:&quot;Logical Replication (CDC)&quot;,&quot;description&quot;:&quot;CDC uses the Binlog to detect inserts, updates, and deletes. This needs to be configured on the source database itself.&quot;,&quot;required&quot;:[&quot;method&quot;],&quot;properties&quot;:{&quot;method&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;CDC&quot;,&quot;order&quot;:0},&quot;initial_waiting_seconds&quot;:{&quot;type&quot;:&quot;integer&quot;,&quot;title&quot;:&quot;Initial Waiting Time in Seconds (Advanced)&quot;,&quot;description&quot;:&quot;The amount of time the connector will wait when it launches to determine if there is new data to sync or not. Defaults to 300 seconds. Valid range: 120 seconds to 1200 seconds. Read about &lt;a href=\&quot;https://docs.airbyte.com/integrations/sources/mysql/#change-data-capture-cdc\&quot;&gt;initial waiting time&lt;/a&gt;.&quot;,&quot;default&quot;:300,&quot;min&quot;:120,&quot;max&quot;:1200,&quot;order&quot;:1},&quot;server_time_zone&quot;:{&quot;type&quot;:&quot;string&quot;,&quot;title&quot;:&quot;Configured server timezone for the MySQL source (Advanced)&quot;,&quot;description&quot;:&quot;Enter the configured MySQL server timezone. This should only be done if the configured timezone in your MySQL instance does not conform to IANNA standard.&quot;,&quot;order&quot;:2}}}]},&quot;tunnel_method&quot;:{&quot;type&quot;:&quot;object&quot;,&quot;title&quot;:&quot;SSH Tunnel Method&quot;,&quot;description&quot;:&quot;Whether to initiate an SSH tunnel before connecting to the database, and if so, which kind of authentication to use.&quot;,&quot;oneOf&quot;:[{&quot;title&quot;:&quot;No Tunnel&quot;,&quot;required&quot;:[&quot;tunnel_method&quot;],&quot;properties&quot;:{&quot;tunnel_method&quot;:{&quot;description&quot;:&quot;No ssh tunnel needed to connect to database&quot;,&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;NO_TUNNEL&quot;,&quot;order&quot;:0}}},{&quot;title&quot;:&quot;SSH Key Authentication&quot;,&quot;required&quot;:[&quot;tunnel_method&quot;,&quot;tunnel_host&quot;,&quot;tunnel_port&quot;,&quot;tunnel_user&quot;,&quot;ssh_key&quot;],&quot;properties&quot;:{&quot;tunnel_method&quot;:{&quot;description&quot;:&quot;Connect through a jump server tunnel host using username and ssh key&quot;,&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;SSH_KEY_AUTH&quot;,&quot;order&quot;:0},&quot;tunnel_host&quot;:{&quot;title&quot;:&quot;SSH Tunnel Jump Server Host&quot;,&quot;description&quot;:&quot;Hostname of the jump server host that allows inbound ssh tunnel.&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:1},&quot;tunnel_port&quot;:{&quot;title&quot;:&quot;SSH Connection Port&quot;,&quot;description&quot;:&quot;Port on the proxy/jump server that accepts inbound ssh connections.&quot;,&quot;type&quot;:&quot;integer&quot;,&quot;minimum&quot;:0,&quot;maximum&quot;:65536,&quot;default&quot;:22,&quot;examples&quot;:[&quot;22&quot;],&quot;order&quot;:2},&quot;tunnel_user&quot;:{&quot;title&quot;:&quot;SSH Login Username&quot;,&quot;description&quot;:&quot;OS-level username for logging into the jump server host.&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:3},&quot;ssh_key&quot;:{&quot;title&quot;:&quot;SSH Private Key&quot;,&quot;description&quot;:&quot;OS-level user account ssh key credentials in RSA PEM format ( created with ssh-keygen -t rsa -m PEM -f myuser_rsa )&quot;,&quot;type&quot;:&quot;string&quot;,&quot;airbyte_secret&quot;:true,&quot;multiline&quot;:true,&quot;order&quot;:4}}},{&quot;title&quot;:&quot;Password Authentication&quot;,&quot;required&quot;:[&quot;tunnel_method&quot;,&quot;tunnel_host&quot;,&quot;tunnel_port&quot;,&quot;tunnel_user&quot;,&quot;tunnel_user_password&quot;],&quot;properties&quot;:{&quot;tunnel_method&quot;:{&quot;description&quot;:&quot;Connect through a jump server tunnel host using username and password authentication&quot;,&quot;type&quot;:&quot;string&quot;,&quot;const&quot;:&quot;SSH_PASSWORD_AUTH&quot;,&quot;order&quot;:0},&quot;tunnel_host&quot;:{&quot;title&quot;:&quot;SSH Tunnel Jump Server Host&quot;,&quot;description&quot;:&quot;Hostname of the jump server host that allows inbound ssh tunnel.&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:1},&quot;tunnel_port&quot;:{&quot;title&quot;:&quot;SSH Connection Port&quot;,&quot;description&quot;:&quot;Port on the proxy/jump server that accepts inbound ssh connections.&quot;,&quot;type&quot;:&quot;integer&quot;,&quot;minimum&quot;:0,&quot;maximum&quot;:65536,&quot;default&quot;:22,&quot;examples&quot;:[&quot;22&quot;],&quot;order&quot;:2},&quot;tunnel_user&quot;:{&quot;title&quot;:&quot;SSH Login Username&quot;,&quot;description&quot;:&quot;OS-level username for logging into the jump server host&quot;,&quot;type&quot;:&quot;string&quot;,&quot;order&quot;:3},&quot;tunnel_user_password&quot;:{&quot;title&quot;:&quot;Password&quot;,&quot;description&quot;:&quot;OS-level password for logging into the jump server host&quot;,&quot;type&quot;:&quot;string&quot;,&quot;airbyte_secret&quot;:true,&quot;order&quot;:4}}}]}}},&quot;supportsNormalization&quot;:false,&quot;supportsDBT&quot;:false,&quot;supported_destination_sync_modes&quot;:[]}}<br>{&quot;type&quot;:&quot;LOG&quot;,&quot;log&quot;:{&quot;level&quot;:&quot;INFO&quot;,&quot;message&quot;:&quot;INFO i.a.i.b.IntegrationRunner(runInternal):186 Completed integration: io.airbyte.integrations.base.ssh.SshWrappedSource&quot;}}<br>{&quot;type&quot;:&quot;LOG&quot;,&quot;log&quot;:{&quot;level&quot;:&quot;INFO&quot;,&quot;message&quot;:&quot;INFO i.a.i.s.m.MySqlSource(main):387 completed source: class io.airbyte.integrations.source.mysql.MySqlSource&quot;}}<br></pre><p>Airbyte supports multiple sources and destinations. You can check available connectors from the <a href="https://airbyte.com/connectors">website</a> or check source_definitions.yaml and destination_definitions.yaml in the <a href="https://github.com/airbytehq/airbyte/tree/v0.44.1/airbyte-config-oss/init-oss/src/main/resources/seed">seed</a> folder. You can always <a href="https://docs.airbyte.com/connector-development/">build a connector</a> if you don’t find what you need. You can find the source code of various connectors in <a href="https://github.com/airbytehq/airbyte/tree/v0.44.1/airbyte-integrations">airbyte-integrations</a> module.</p><p>Source or destination definitions is the metadata for Aibyte to start a connector operation. When you create a connector, Airbyte needs to know which Docker image to run, what resources it requires, etc. These details are available in the definition. For example, look at Faker Source Connector:</p><pre>- name: Sample Data (Faker)<br>  sourceDefinitionId: dfd88b22-b603-4c3d-aad7-3701784586b1<br>  dockerRepository: airbyte/source-faker<br>  dockerImageTag: 2.0.3<br>  documentationUrl: https://docs.airbyte.com/integrations/sources/faker<br>  icon: faker.svg<br>  sourceType: api<br>  releaseStage: beta<br>  resourceRequirements:<br>    jobSpecific:<br>      - jobType: sync<br>        resourceRequirements:<br>          cpu_limit: &quot;4.0&quot;<br>          cpu_request: &quot;1.0&quot;<br>  allowedHosts:<br>    hosts: []<br>  suggestedStreams:<br>    streams:<br>      - users<br>      - products<br>      - purchases</pre><p>The next step in creation is knowing what configuration or credentials the connector requires to pull or push data to a system like MySql or Snowflake. A connector spec defines the configuration it needs. Airbyte runs the docker image of a connector with thespec command and the connector outputs a spec message, which is processed and presented in the UI for the user’s input. From the MySql connector log above, you can see the SPEC message. Alternatively, you can check a connector spec from its source. For example, <a href="https://github.com/airbytehq/airbyte/blob/v0.44.1/airbyte-integrations/connectors/source-mysql/src/main/resources/spec.json">spec.json</a> of source-mysql connector.</p><p><em>By default, Airbyte uses Postgres as a persistence store. You </em><a href="https://docs.airbyte.com/operator-guides/configuring-airbyte-db/"><em>configure</em></a><em> it to point to an external Postgres Server. You can explore </em><a href="https://github.com/airbytehq/airbyte-platform/tree/v0.44.1/airbyte-db"><em>airbyte-db</em></a><em> module for schema and repository interfaces. For storing sensitive credentials data, you can </em><a href="https://docs.airbyte.com/operator-guides/security/#credential-management"><em>configure</em></a><em> it to store in Google Secret Manager.</em></p><p>Once a user provides connector inputs, Airbyte runs the connector container with <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol#check">check</a> command and passes the input, in JSON format, as config argument. This tests whether the connector can reach the data source with the user inputs. In response, a connector container produces <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol#airbyteconnectionstatus-message">AirbyteConnectionStatus</a> message. Here is the sample Postgres Source configuration in YAML format. You can retrieve it using <a href="https://medium.com/@jeremysrgt/airbyte-configuration-as-code-with-octavia-cli-dccd2046b764">ocatvia-cli</a>.</p><pre>resource_name: Postgres<br>definition_type: source<br>definition_id: decd338e-5647-4c0b-adf4-da0e75f5a750<br>definition_image: airbyte/source-postgres<br>definition_version: 2.0.21<br>configuration:<br>  host: localhost<br>  port: 5532<br>  schemas:<br>  - public<br>  database: postgres<br>  password: &#39;**********&#39;<br>  ssl_mode:<br>    mode: disable<br>  username: airbyte_user<br>  tunnel_method:<br>    tunnel_method: NO_TUNNEL<br>  replication_method:<br>    method: Standard</pre><p>Once the test passes, a connector gets created.</p><h4>Creating Connection</h4><p>The next step in moving data is creating a <a href="https://docs.airbyte.com/cloud/core-concepts#connection">Connection</a> between a source and destination connector. This is a data pipeline where a user configures what to sync, when, and where to sync. Airbyte runs the source connector Docker image with discover command to get what Streams are available. The connector container produces <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol/#catalog">AirbyteCatalog</a> messages.</p><p>Optionally, a <a href="https://www.getdbt.com/">dbt</a> transformation project can be configured. Some destinations support <a href="https://docs.airbyte.com/understanding-airbyte/basic-normalization">basic transformations</a>. The transformation project runs once data is synced to a destination. These base transformations are also Docker images. Check base-normalization <a href="https://github.com/airbytehq/airbyte/blob/v0.44.1/airbyte-integrations/bases/base-normalization/README.md">README</a> for more. This will help you in creating custom transformations for a connection. Here is a connection configuration, retrieved using octavia-cli, that syncs data from Postgres to MySql:</p><pre>definition_type: connection<br>resource_name: Postgres &lt;&gt; MySQL<br>source_configuration_path: sources/postgres/configuration.yaml<br>destination_configuration_path: destinations/mysql/configuration.yaml<br>configuration:<br>  sync_catalog:<br>    streams:<br>    - stream:<br>        name: staff_list<br>        json_schema:<br>          type: object<br>          properties:<br>            country:<br>              type: string<br>            zip code:<br>              type: string<br>            address:<br>              type: string<br>            city:<br>              type: string<br>            phone:<br>              type: string<br>            name:<br>              type: string<br>            id:<br>              airbyte_type: integer<br>              type: number<br>            sid:<br>              airbyte_type: integer<br>              type: number<br>        supported_sync_modes:<br>        - full_refresh<br>        - incremental<br>        default_cursor_field: []<br>        source_defined_primary_key: []<br>        namespace: public<br>      config:<br>        sync_mode: full_refresh<br>        destination_sync_mode: overwrite<br>        cursor_field: []<br>        primary_key: []<br>        alias_name: staff_list<br>        selected: true<br>        field_selection_enabled: false<br>  status: active<br>  schema_change: no_change<br>  notify_schema_changes: false<br>  non_breaking_changes_preference: ignore<br>  namespace_definition: destination<br>  namespace_format: ${SOURCE_NAMESPACE}<br>  prefix: &#39;&#39;<br>  schedule_type: basic<br>  schedule_data:<br>    basic_schedule:<br>      time_unit: hours<br>      units: 24<br>  operations:<br>  - name: Normalization<br>    operator_configuration:<br>      operator_type: normalization<br>      normalization:<br>        option: basic<br>  geography: auto<br>  notifySchemaChangesByEmail: false</pre><p>I mentioned that connectors are Docker Images. Where will the Docker Containers run, and what schedules them? <a href="https://docs.airbyte.com/operator-guides/scaling-airbyte/#what-to-scale">Workers</a> do the <a href="https://docs.airbyte.com/understanding-airbyte/jobs/#worker-responsibilities">heavy lifting</a>. Every connector command is executed on a worker node. If the deployment environment is Kubernetes, which is recommended for production, workers create the connector pods using fabric8 <a href="https://github.com/fabric8io/kubernetes-client">Kubernetes Client</a>.</p><h4>Syncing Data</h4><p>Syncing data involves the following steps from Airbyte:</p><ol><li>Start sync job on a worker.</li><li>The job runs source and destination connector containers.</li><li>The source container starts pulling data from the source data source and produces several <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol#airbyterecordmessage">AirbyteRecordMessage</a>s</li><li>The job listens to stdout of the source container and passes them to stdin of the destination container. Before passing the message, it can modify it based on connector configuration. For example, prefix table names.</li><li>The destination container receives the message and passes it to the destination data source in the format that destination understands.</li><li>Once all the messages are processed, the job shuts down source and destination containers.</li><li>If a transformation is configured, the job runs it.</li></ol><p>For incremental sync, a source container produces <a href="https://docs.airbyte.com/understanding-airbyte/airbyte-protocol#airbytestatemessage-v1">AirbyteStateMessage</a>. This message is stored in the Airbyte DB. The state is passed to the source container during the next sync.</p><p>As you can see, this process involves coordinating various systems. There are several failure points. A source or destination data source can go down; a source connector container can run out of memory; resources may not be available to start source or destination containers, etc. How can Airbyte mitigate these issues?</p><p>Airbyte uses <a href="https://temporal.io/">Temporal</a> to solve reliability, fault tolerance, and scalability issues. Each of the connector operations is implemented as Temporal <a href="https://docs.temporal.io/workflows">workflows</a>. Any external interactions are implemented as <a href="https://docs.temporal.io/activities">activities</a> and are called during workflow execution. Check implementations of <a href="https://github.com/airbytehq/airbyte-platform/blob/v0.44.1/airbyte-workers/src/main/java/io/airbyte/workers/temporal/spec/SpecWorkflowImpl.java">SpecWorkflow</a> and <a href="https://github.com/airbytehq/airbyte-platform/blob/v0.44.1/airbyte-workers/src/main/java/io/airbyte/workers/temporal/spec/SpecActivityImpl.java">SpecActivity</a> to get the feel. Similarly, you can find the sync workflow and its related activities <a href="https://github.com/airbytehq/airbyte-platform/tree/v0.44.1/airbyte-workers/src/main/java/io/airbyte/workers/temporal/sync">here</a>.</p><h4>Conclusion</h4><p>Simplifying data movement is a complex job. Airbyte already has a good framework and is Open Source. The challenges are in <a href="https://dzone.com/articles/defining-day-2-operations">Day-2 ops</a> considering systems like Kubernetes, Temporal, Postgres, and Airbyte’s components. Based on your team’s strengths, you can decide to host it yourself or go for Airbyte Cloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24a7e90892c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Man-Computer Symbiosis: Unraveling J.C.R. Licklider's Vision]]></title>
            <link>https://medium.com/@adisesha/man-computer-symbiosis-unraveling-j-c-r-lickliders-vision-18232274bc07?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/18232274bc07</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[arpa]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Sat, 01 Apr 2023 08:23:05 GMT</pubDate>
            <atom:updated>2023-04-01T08:23:05.603Z</atom:updated>
            <content:encoded><![CDATA[<p>I finished reading <a href="https://www.goodreads.com/author/show/113943.M_Mitchell_Waldrop">Mitchell </a>Waldrop&#39;s book, <em>&#39;The Dream Machine: J.C.R. Licklider and the Revolution That Made Computing Personal.&#39; </em>This book chronicles the work of J.C.R Licklider and his far-reaching impact on developing various technologies we use today. In this post, I want to explore his seminal paper, <a href="https://groups.csail.mit.edu/medg/people/psz/Licklider.html">Man-Computer Symbiosis</a>, and how much his vision is realized. I took the help of ChatGPT and Grammarly for this post, which is a testament to the fulfillment of his vision of AI helping humans to produce content. Without that, it would have taken a few days, instead of a few hours, to write this post.</p><p><a href="https://www.goodreads.com/book/show/41431734-the-dream-machine">The Dream Machine: J.C.R. Licklider and the Revolution ...</a></p><h3>Who is J.C.R Licklider?</h3><p>Joseph Carl Robnett Licklider, commonly known as <a href="https://en.wikipedia.org/wiki/J._C._R._Licklider">J.C.R Licklider</a>, was an American psychologist and computer scientist who played a pivotal role in developing the internet, computer graphics, and interactive computing. As the head of the Information Processing Techniques Office(IPTO) at the Advanced Research Projects Agency(ARPA), he was responsible for identifying and generously funding research projects that aligned with his vision for the future of computing, including:</p><ol><li>MIT&#39;s Project MAC (Multiple Access Computer) — A pioneering effort in time-sharing systems and the development of computer networks.</li><li>Stanford Artificial Intelligence Laboratory (SAIL) — Directed by John McCarthy, the lab focused on artificial intelligence research.</li><li>The development of the ARPANET — The precursor to the modern internet, which connected multiple research institutions and enabled them to share resources and information.</li></ol><p>Some prominent figures who were influenced by him:</p><ol><li>Douglas Engelbart — Inventor of the computer mouse and a pioneer of human-computer interaction. Licklider&#39;s vision of the Man-Computer Symbiosis heavily influenced Engelbart&#39;s work. Licklider provided crucial financial support to Engelbert and his Stanford Research Institute(SRI) resource group. He reigned on Engelbert&#39;s superiors to give freehand to Engelbert. I recommend watching ‘<a href="https://www.youtube.com/watch?v=yJDv-zdhzMY">The Mother of All Demos</a>.’</li><li>Robert Taylor — A computer scientist who worked with Licklider at ARPA and later at Xerox PARC, Taylor played a crucial role in developing the ARPANET and was instrumental in creating the graphical user interface (GUI) and the Xerox Alto computer.</li><li>Ivan Sutherland — Known for his groundbreaking work in computer graphics, Sutherland collaborated with Licklider at MIT and ARPA. He developed Sketchpad, an early graphical computing program, and is often called the &quot;father of computer graphics.&quot;</li><li>Lawrence G. Roberts — A computer scientist who worked with Licklider on the development of the ARPANET, Roberts was responsible for designing and implementing the first wide-area computer network.</li><li>Marvin Minsky — A pioneer in artificial intelligence, Minsky co-founded the MIT Media Lab and worked closely with Licklider on various projects. He was one of the foremost proponents of Licklider&#39;s vision of human-computer collaboration.</li><li>Alan Kay — A computer scientist and visionary, Alan Kay worked at Xerox PARC, where Licklider&#39;s ideas inspired him. Kay contributed to the development of the Xerox Alto and is known for his pioneering work in object-oriented programming and the Smalltalk programming language.</li></ol><h4>Contribution to the Internet</h4><p>In 1962, Licklider wrote a series of memos discussing the concept of an &#39;<a href="http://worrydream.com/refs/Licklider-IntergalacticNetwork.pdf">Intergalactic Computer Network</a>,&#39; which outlined a globally interconnected set of computers, enabling users to access data and programs from any site. This vision was the foundation for the ARPANET, which later evolved into the internet we know today. He provided crucial support for developing time-sharing systems, packet-switching technology, and research on network protocols.</p><p>In 1968, Licklider and <a href="https://en.wikipedia.org/wiki/Robert_Taylor_(computer_scientist)">Bob Taylor</a> authored &#39;<a href="https://internetat50.com/references/Licklider_Taylor_The-Computer-As-A-Communications-Device.pdf">The Computer as a Communication Device</a>,&#39; in which they believed that by connecting computers, people could share information and resources, leading to a more interconnected world. They touched upon online communities, where users can collaborate and exchange ideas. They also discussed the importance of user-friendly interfaces.</p><h3>Man-Computer Symboisis</h3><p>Licklider wrote &#39;Man-Computer Symboisis&#39; in 196o, which envisions a future where humans and computers work symbiotically to solve complex problems. He put forward that this partnership would maximize human creativity and problem-solving abilities by leveraging the speed and accuracy of computers. He identifies critical areas where the symbiosis is highly beneficial. So let&#39;s look at those areas and compare them with the progress made in those areas.</p><h4>Real-time control systems</h4><p>He foresaw the development of sophisticated control systems requiring humans and computers to collaborate for effective decision-making and control. Today, real-time control systems are used extensively in industrial automation, automotive, power generation and distribution, and aerospace, traffic management, healthcare, among other sectors. These systems often involve humans and computers collaborating in real-time to monitor and control complex processes.</p><h4>Decision-making</h4><p>Licklider predicted that computers could help humans make better decisions by processing large amounts of data quickly and accurately. As a result, computers now play a vital role in data-driven decision-making. For example, businesses rely on big data analytics, machine learning algorithms, and artificial intelligence to process vast amounts of data and make better decisions.</p><h4>Large-scale information processing</h4><p>He believed that humans and computers could work together to handle the growing scale and complexity of information-processing tasks. The rise of the internet, cloud computing, and distributed systems has allowed humans and computers to process and manage massive amounts of information collaboratively, just as Licklider envisioned.</p><h4>Language Translation</h4><p>Licklider envisioned a future where computers could perform automatic language translation, facilitating communication across language barriers. Automatic language translation has become a reality with services like Google Translate, allowing users to translate text between multiple languages instantly. While these translations are imperfect, they continuously improve and have made global communication more accessible.</p><h4>Simulation and modeling</h4><p>He foresaw the potential of computers to simulate and model complex systems, enabling humans to understand better and analyze them. As a result, computers now play a crucial role in simulating and modeling complex systems in various fields, such as weather forecasting, financial modeling, and scientific research. These simulations are leading us to more informed decision-making and innovation.</p><h4>Problem-solving and creativity</h4><p>Licklider believed that computers could assist humans in solving complex problems and stimulating creative thinking. AI and machine learning algorithms are increasingly used to augment human problem-solving and creativity. For instance, AI-powered tools like DeepMind&#39;s AlphaGo and OpenAI&#39;s GPT series have demonstrated the ability to tackle complex problems and generate creative content.</p><h3>Conclusion</h3><p>Despite these successes, there are still challenges in achieving the full potential of man-computer symbiosis. For example, developing more intuitive human-computer interfaces and ensuring that AI systems are transparent and ethically responsible remain important areas of ongoing research.</p><p>Licklider died on June 26, 1990, at the age of 75. He lived to see many of his dreams become reality by 1990. In recognition of his contributions, several awards and honors have been established in Licklider&#39;s name, such as the J.C.R. Licklider Award for Research in Human-Computer Interaction, presented by the American Psychological Foundation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18232274bc07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The cost of Spring Auto-configuration and Boot starters]]></title>
            <link>https://medium.com/@adisesha/the-cost-of-spring-auto-configuration-and-boot-starters-3a40b9ff17b7?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a40b9ff17b7</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 15:03:05 GMT</pubDate>
            <atom:updated>2023-03-26T15:03:05.205Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring Auto-configuration and Boot starters help shorten bootstrap application time and simplify configuration. The convenience comes at a cost in various phases — Startup time, CI/CD pipelines, Native Images, etc. Here is how they impact:</p><ol><li><strong>Startup Time:</strong> Additional time to preconfigure components, configuration scanning, and bean initialization. This can be acceptable considering the productivity gains. The startup time may impact <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/">readiness and liveness probes</a> if you run the application in a Kubernetes environment<a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/">.</a></li><li><strong>Build time in CI/CD pipelines:</strong> They pull additional dependencies, which can slightly slow build times, thus increasing rollout time. This can be mitigated to an extent using <a href="https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows">build caches</a>.</li><li><strong>Native Images:</strong> Spring’s <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.introducing-graalvm-native-images">Native Image</a> support can significantly improve startup time. Auto configurations can slightly increase image size and slow down native compilation.</li></ol><p>I created projects with and without startups to demonstrate the impact and measured the times. <strong>Note this is very far from a rigorous study.</strong> You need to do measurements for your project and decide whether it’s even worth moving away from the auto configurations. During the early stages of development, it should not even be a concern. You can find the source code here:</p><p><a href="https://github.com/adisesha/spring-config-blog">GitHub - adisesha/spring-config-blog</a></p><p>The root has two projects:</p><p><strong>starter:</strong> It is created using <a href="https://start.spring.io/">Spring Initializer</a> with web and actuator starter. I followed some suggestions from <a href="https://www.baeldung.com/spring-boot-startup-speed">this</a> post. It has a simple REST API that pretends to do some work during initialization. Usually, if a component does some job during initialization, it has to be made lazy. Otherwise, it will add up to startup time. Remove @Lazy from <a href="https://raw.githubusercontent.com/adisesha/spring-config-blog/main/starter/src/main/kotlin/me/spring/starter/StarterApplication.kt">HelloController</a> , and see it yourself. Here are the measured times:</p><pre>Native Compile: 2 min 30 sec<br>Native Run Startup Time: 110 ms<br>Boot Jar Run Startup Time: 1.6 sec<br>Native Application Size: 80 MB</pre><p>To understand the actuator Impact, I removed it and measured again:</p><pre>Native Compile: 2 min 20 sec<br>Native Run Startup Time: 60 ms<br>Boot Jar Run Startup Time: 1.2 sec<br>Native Application Size: 78 MB</pre><p>But removing it is not the answer if you need health probes.</p><p><strong>nostarter:</strong> In this project, I made the following changes:</p><ol><li>Replace Web starter with auto-configuration.</li><li>Removed actuator auto configurations. Replaced with manual configuration and exposed a health check API. See the <a href="https://github.com/adisesha/spring-config-blog/blob/main/no-starter/src/main/kotlin/me/spring/starter/health-config.kt">config</a> and the <a href="https://github.com/adisesha/spring-config-blog/blob/main/no-starter/src/main/kotlin/me/spring/starter/health-api.kt">controller</a> .</li><li>Explicitly add tomcat dependencies. See dependencies in the <a href="https://github.com/adisesha/spring-config-blog/blob/main/no-starter/build.gradle.kts">gradle file</a>. Web starter brings in the tomcat starter, which also brings in Websocket support which is not required for this project.</li></ol><p>Here are the measured times:</p><pre>Native Compile: 2 min 20 sec<br>Native Run Startup Time: 55 ms<br>Boot Jar Run Startup Time: 1.2 sec<br>Native Application Size: 75 MB</pre><p>As you can see, these times are similar to what you get by completely removing the actuator. This also shows you can achieve some gains by partially moving away from the auto configurations. So the question is if these gains are significant for your application.</p><p>Can you suggest more improvements?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a40b9ff17b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveraging ChatGPT and LangChain to Enhance Recruitment: A POC]]></title>
            <link>https://medium.com/@adisesha/leveraging-chatgpt-and-langchain-to-enhance-recruitment-a-poc-b97ce2d01e82?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b97ce2d01e82</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 15:42:18 GMT</pubDate>
            <atom:updated>2023-03-19T15:42:18.379Z</atom:updated>
            <content:encoded><![CDATA[<p>More often than not, you would have got an initial screening call from a recruiter whose questions could have been more precise about what you did. But, considering the challenges of sifting through countless resumes, it’s expected. I was curious if there is a way to improve this using AI. As a proof of concept, I built a command line app. The app summarizes the uploaded resume concisely, giving recruiters a quick overview of the candidate’s qualifications. After that, it enters into Q&amp;A mode. You can find the complete code here:</p><p><a href="https://github.com/adisesha/profile-copilot-poc">GitHub - adisesha/profile-copilot-poc</a></p><p>I ran the app with <a href="https://en.wikipedia.org/wiki/Leslie_Lamport">Leslie Lamport’s</a> resume, generated through ChatGPT with <a href="https://openai.com/research/gpt-4">GPT-4</a>. Here is the screenshot of the run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xEISgPfY0eDmECCCOLCEDg.png" /></figure><p>The project was built on <a href="https://langchain.readthedocs.io/en/latest/">LangChain</a>, OpenAI API through LangChain and <a href="https://rich.readthedocs.io/en/stable/introduction.html#">Rich</a> for terminal UI. Apart from LangChain documentation and samples, this <a href="https://youtube.com/playlist?list=PLqZXAkvF1bPNQER9mLmDbntNfSpzdDIU5">Youtube Playlist</a> helped me a lot.</p><p>The meat of the code is here:</p><pre>from langchain import LLMChain<br>from langchain.document_loaders import UnstructuredPDFLoader<br>from langchain.chat_models import ChatOpenAI<br>from langchain.schema import SystemMessage<br>from langchain.prompts.chat import ChatPromptTemplate,  HumanMessagePromptTemplate<br><br>class Chatbot:<br>    def __init__(self, model_name=&#39;gpt-3.5-turbo&#39;, temperature=1, verbose=False):<br>        llm = ChatOpenAI(model_name=model_name, temperature=temperature, verbose=verbose)<br>        # initial message or instruction given to the model to set the context, role, or goal for the conversation<br>        system_message = SystemMessage(content=&#39;You are a chatbot helping a recruiter to evaluate job applications and question the candidates.&#39;)<br>        human_message_prompt = HumanMessagePromptTemplate.from_template(&#39;{human_input}: {resume_data}&#39;)<br>        self.chat_prompt = ChatPromptTemplate.from_messages([system_message, human_message_prompt])<br>        self.chatgpt_chain = LLMChain(llm=llm, verbose=verbose, prompt=self.chat_prompt)<br>        self.resume_data = None<br><br>    def summarize_resume(self, resume_path):<br>        resume_loader = UnstructuredPDFLoader(resume_path)<br>        self.resume_data = resume_loader.load()[0].page_content<br>        resume_summary = self.chatgpt_chain.predict(human_input=&#39;Summarize this resume&#39;, resume_data=self.resume_data)<br>        return resume_summary<br>    def answer(self, question):<br>        return self.chatgpt_chain.predict(human_input=question, resume_data=self.resume_</pre><p>You can modify the code to flip the case: You are applying for a job and preparing for the potential questions. You can do it by changing thesystem_message in the above code. I planned to add features like comparing profiles with job descriptions, ranking profiles, etc. I ran into token limits of OpenAI API. I may try when <a href="https://crfm.stanford.edu/2023/03/13/alpaca.html">Alpaca</a> can be used with LangChain.</p><h3>Final Thoughts</h3><blockquote>‘Coding is to programming what typing is to writing’ — Leslie Lamport</blockquote><p>I like to share my experience with new generative AI technologies. My usage of GitHub Copilot and ChatGPT is increasing day by day. It’s saving hours of work. I am typing less, thinking more about how to articulate the problem. While developing the POC, I generated the UI code in 10 mins. I had no prior experience with the Rich package. This is a colossal disruptor; I have never seen anything like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b97ce2d01e82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Notes on Firebase’s push IDs]]></title>
            <link>https://medium.com/@adisesha/notes-on-firebases-push-ids-bbb6469529?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbb6469529</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 14:32:27 GMT</pubDate>
            <atom:updated>2023-02-27T14:36:17.181Z</atom:updated>
            <content:encoded><![CDATA[<p>I came across Firbase Push Ids while developing <a href="https://play.google.com/store/apps/details?id=com.optobizz.readybee">ReadyBee</a> app. Since then, it’s been my go-to method for generating unique String ids. I mainly use it when an Id is needed before saving an object. Apart from uniqueness, it has the following properties:</p><ul><li>Ids are sorted chronologically but require clock sync across systems where it is generated.</li><li>If your system can sacrifice chronological order, it can be used in distributed systems. I used it to solve <a href="https://fly.io/dist-sys/2/">fly.io Unique Id Generation Challenge</a>. You can find the source code <a href="https://github.com/adisesha/flyio-distsys-challenge/tree/main/maelstrom-unique-ids">here</a>.</li></ul><p>You can read about the algorithm for generating the ids from the post, <a href="https://firebase.blog/posts/2015/02/the-2120-ways-to-ensure-unique_68"><strong>The 2¹²⁰ Ways to Ensure Unique Identifiers</strong></a><strong>.</strong></p><p>Here is my Dart implementation, but it removes ‘_’ and ‘-’ from allowed Id characters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15ad6c27a1fdd47f5dbfe61f46129519/href">https://medium.com/media/15ad6c27a1fdd47f5dbfe61f46129519/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbb6469529" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JWT signature with AWS KMS]]></title>
            <link>https://medium.com/@adisesha/jwt-signature-with-aws-kms-3cb69a97fcdd?source=rss-aeb1cdd61bc2------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cb69a97fcdd</guid>
            <category><![CDATA[aws-kms]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Adisesha Reddy G]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 16:09:14 GMT</pubDate>
            <atom:updated>2023-02-20T02:43:39.875Z</atom:updated>
            <content:encoded><![CDATA[<p>This post explains how you can generate a JWT signature using keys managed by AWS KMS. If you like to see the code first, head to <a href="https://github.com/adisesha/jwt-kms-poc">jwt-kms-poc</a>. The code is a port of<a href="https://github.com/righettod/poc-jwt"> jwt-poc</a> which is the code repository for <a href="https://www.owasp.org/index.php/JSON_Web_Token_(JWT)_Cheat_Sheet_for_Java">JSON Web Token (JWT) Cheat Sheet for Java</a>.</p><p><a href="https://github.com/adisesha/jwt-kms-poc">GitHub - adisesha/jwt-kms-poc: Port of https://github.com/righettod/poc-jwt which the code repository for OWASP Java cheatsheet.</a></p><p>I assume you have basic knowledge of <a href="https://jwt.io/">JWT</a>. I will head to the signature part. A JWT has three parts: header, payload, and signature. It looks like header.payload.signature. The header and payload are base64url encoded. The signature verifies the authenticity and integrity of the information in the payload.</p><h4>Signature Algorithm</h4><p>To create the signature, you need an algorithm. Here are the recommended/required algorithms from <a href="https://www.rfc-editor.org/rfc/rfc7518#section-3">rfc7518</a>:</p><ul><li>HMAC using SHA-256. Symmetric algorithm.</li><li>RSASSA-PKCS1-v1_5 using SHA-256. Asymmetric algorithm.</li><li>ECDSA using P-256 and SHA-256. Asymmetric algorithm.</li></ul><p>HMAC, a symmetric algorithm, is not recommended for JWT signatures. We are going to use an asymmetric algorithm RSASSA-PKCS1-v1_5 using SHA-256 . You can modify the example to use ECDSA using P-256 and SHA-256. Check this <a href="https://security.stackexchange.com/questions/220185/jwt-choosing-between-hmac-and-rsa">StackExchange</a> question on why you need to choose an asymmetric algorithm.</p><h4>Keys Generation</h4><p>An asymmetric algorithm uses a private key for signing and a public key for verification. Only issuers can access a private key, while the public key can be shared. You can generate these keys using a library like <a href="https://www.openssl.org/">OpenSSL</a> or a key management system like <a href="https://aws.amazon.com/kms/">AWS KMS</a> or <a href="https://cloud.google.com/security-key-management">Google KMS</a>. There are several advantages of using a KMS. Some are:</p><ul><li>Fine-grained access control to who can access the private key, sign payload, verify payload, etc. Check <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">AWS KMS permissions.</a></li><li><a href="https://docs.aws.amazon.com/kms/latest/developerguide/security-logging-monitoring.html">Montor key access.</a></li><li>Minimise <a href="https://en.wikipedia.org/wiki/Attack_surface">attack surface</a>.</li></ul><p>To generate keys in AWS, follow the instructions <a href="https://docs.aws.amazon.com/kms/latest/developerguide/asymm-create-key.html">here</a>. Select Sign and verify as Key usage , and RSA_2048 as Key spec . Note down the Key Id.</p><h4>Signature Generation</h4><p>The signature is generated by signing header.payload. Check <a href="https://jwt.io/introduction">this</a> for how to arrive at this. In the header, alg the value is RS256 . Change the alg value according to the algorithm you used. For ECDSA, using P-256 and SHA-256, it is ES256.</p><p>Once you have header.payload you can invoke <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html">Sign API</a> using <a href="https://docs.aws.amazon.com/kms/latest/developerguide/programming-top.html">SDK</a> in your favorite language. Here is a sample code in Kotlin,</p><pre>fun sign(headerBytes: ByteArray, payloadBytes: ByteArray): String {<br>    val contentBytes = headerBytes + &#39;.&#39;.code.toByte() + payloadBytes<br>    val signRequest = SignRequest.builder()<br>        .keyId(signVerifyKeyId)<br>        .messageType(MessageType.RAW)<br>        .message(SdkBytes.fromByteArray(contentBytes))<br>        .signingAlgorithm(SigningAlgorithmSpec.RSASSA_PKCS1_V1_5_SHA_256)<br>        .build()<br>    val signResponse = kmsClient.sign(signRequest)<br>    return base64UrlEncoder.encodeToString(signResponse.signature().asByteArray())<br>}</pre><h4>Verification</h4><p>Invoke <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_Verify.html">Verify API</a> with header.payload and signature . Here is a sample code,</p><pre>//Verify signature with KMS<br>val signableContent = &quot;${jwt.header}.${jwt.payload}&quot;.toByteArray(StandardCharsets.UTF_8)<br>val signature = base64UrlDecoder.decode(jwt.signature)<br>val kmsVerifyRequest = VerifyRequest.builder()<br>    .keyId(signVerifyKeyId)<br>    .message(SdkBytes.fromByteArray(signableContent))<br>    .signature(SdkBytes.fromByteArray(signature))<br>    .signingAlgorithm(SigningAlgorithmSpec.RSASSA_PKCS1_V1_5_SHA_256)<br>    .build()<br>kmsClient.verify(kmsVerifyRequest)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cb69a97fcdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>