Code faster with AI using tabnine

 Background

Artificial Intelligence (AI) is getting infused into every sphere of our life. We find AI-powered smartphone cameras, devices, and voice assistants like Cortana, Alexa, Bixby, and various other alternatives. AI and Machine Learning (ML) is used to predict thing based on past patterns. In every industry, there are use cases related to AI and ML which can help improve people's lives in one way or the others.

One such area which is of keen interest is software developers. There are various studies done across the globe to improve developer productivity. Software developers spend a lot of time writing code and looking for information over the internet. We use things like code editors such as Notepad++, Sublime, Visual Studio Code, a full-blown integrated development environment such as Visual Studio Code, IntelliJ, PyCharm, Goland, Eclipse, Rider, etc., database connectivity tools, and many other things to get our work done. This involves context-switching between different tools depending on the type of application and the programming language or backend databases used for the application development. 

AI-powered assistant for developers

Many of the code snippets that we write are following a specific pattern. Some of the common examples are listed below

  • Query database table and fetch top 100 Orders, sort by highest order value
  • Perform sentiment analysis on a tweet / social media post
  • Make an API call to query some data
  • Write a function to find the average size of the basket from a given carts
These are just a few examples. But you can get a sense of the pattern that is being used. What varies is the programming language used and the syntax of the language. Nowadays it is possible to use Natural Language Processing (NLP) to specify the intent of what the code intends to do and let AI generate the code.

One such tool I came across is called tabnine. The tagline for tabnine says that it is an AI assistant for software developers. It helps developers to write code faster. It has two modes of operation. First is the single line mode where it recommends code for one single line. Ans second is the whole function code.

It integrates with the most common Integrated Development Environments (IDE) and supports most of modern-day programming languages and frameworks. The screenshots below list the IDEs and programming languages that it supports.


Refer to the install section to get the most updated list of IDEs and programming languages. If the language you are using or the IDE you are using is not on the list, most probably you are not working with a modern tech stack :)

My experience with Tabnine

I used Tabnine with my favorite code editor Visual Studio Code. I used it to generate C# code, document the project using Markdown files, and to write Powershell scripts. It was quite accurate in terms of its suggestions and recommendations with an accuracy rate of about 75-80%. It saved me quite a lot of time while writing the docs for a project. 

Although Markdown and Powershell are not listed in the supported languages, tabnine did a fantastic job in terms of proving context-aware recommendations.

I shared my experience of using Tabnine in a YouTube video.

Summary / Conclusion

Personally, I found Tabnine very useful. It avoided the context switching for me to look for information. It helped me to generate code faster. Documenting the code or project with markdown files was a breeze saving me at least 70% of the typing efforts. 

I think a tool like Tabnine can be very handy when we are learning a new programming language. It can help us quickly understand code syntax and best practices. The machine learning model used to train the assistant can scan different types of repositories within the organization as well as public repositories. This can help to implement best practices.

Hope you find this useful. I would love to hear about your experience.

Until next time, Code with Passion and Strive for Excellence.


spacer

Zero downtime deployment with Kubernetes using Rolling update Strategy

 Background

Nowadays modern cloud-native applications are developed and deployed at a rapid scale and pace. The legacy techniques used for upgrading applications and services are no longer relevant. We want to give the best user experience to end users. One of the things which are gaining popularity and is already a mainstream technique is progressive delivery. This allows us to upgrade the application version in a progressive manner by reducing the blast radius. In this post, we will look at how to achieve zero downtime deployment using the Rolling Update strategy with Kubernetes.

Quick overview of the rolling update strategy

The rolling update strategy allows applications with multiple instances or replicas to upgrade from one version to another in a controlled manner. Instead of upgrading all the replicas together, this strategy applies changes in batches and replaces the older version with a new one. As a result of this, the application can continue to run with the reduced number of instances while the upgrade is progressing. 

One of the pre-requisite for implementing a rolling update strategy is that the application needs to have multiple replicas or instances running. If there is only a single instance of the application, there will be a slight downtime. Kubernetes supports the rolling update strategy natively. We do not need any additional things to implement it with Kubernetes. When we use Kubernetes Deployment to deploy our pods, the rolling update is the default strategy. 

If you have been using Kubernetes deployments, you would have unknowingly used the rolling update strategy when upgrading the application version. 

Use the Rolling update strategy for zero downtime deployment

If we don't override any settings related to rolling updates, by default Kubernetes will apply 25% MaxSurge and 25% MaxUnavailable settings. What this means is that at the time of the upgrade maximum of 25% of the replicas will be added. Same way, when the old version of the replica is replaced with the new one, a maximum of 25% would be replaced at a time.

By doing this, it ensures that there are 80% of replicas in working condition during the upgrade process and the end users are not impacted. If we have exposed the deployment outside of the Kubernetes cluster using a Service, then the LoadBalancer will route the traffic accordingly between the new and older versions.

Youtube video demo

Refer to the YouTube video to see this in action.


Other alternatives to Rolling Update Strategy

There are other alternatives to the rolling update strategy. Modern-day cloud-native applications support advanced deployment strategies or techniques such as Blue-Green deployment or Canary deployment which also allow zero downtime deployment with progressive delivery. Refer to the links to watch YouTube videos on my channel to understand how these can be applied to your Kubernetes applications.

Conclusion

Gone are the days of bringing down servers and applications to upgrade them. With the cloud, we can easily upgrade applications and services with minimal impact on end users. Use modern techniques such as rolling update, Blue Green deployment or Canary deployment to achieve 100% availability for your application.

Until next time, Code with Passion and Strive for Excellence.


spacer