This content originally appeared on Level Up Coding - Medium and was authored by Tom McIntosh
Software development is hard. The programmer is expected to understand the platform they’re developing for, memorise and conform to syntactic rules, create re-usable functionality where possible, and respond to complex and ever-changing business requirements.
It makes sense then, that many programmers invest time into optimising their tooling and environment. With so many technical details to manage, anything that reduces unnecessary complexity or gives more immediate access to information can improve your chances of staying in a productive flow-state, where all the best work happens.
I’m pretty fascinated by these little optimisations. In isolation, each keyboard shortcut or IDE extension is pretty minor, but the value is obvious when you view your setup as a whole. There’s huge value in cultivating a tight-nit environment where you feel empowered to tackle any problem; a place with minimal friction between computer and brain. Tweaking the best performance out of this environment is somewhat of a hobby, so I’m constantly trialing new tools, and retiring the unused or ineffective.
This is how I discovered Tabnine, an editor plugin that promises to bring the power of Artificial Intelligence to your coding workflow. By reading your code, learning from your development style and analysing huge repos of open source code, Tabnine claims to bring a new level of intelligence to code auto-complete that (in theory) make your job just a little bit easier. For the past month I’ve been putting Tabnine Pro to the test, so let’s see if it lives up to the hype.
Intelligent Suggestions
Most IDEs offer suggestions while coding. These systems follow imports and references to understand what properties and methods might be available. This is already a killer feature, but it has some basic limitations.
If you had to make a guess, how would you complete this line?

Even if you’re not a developer, you probably guessed:
const three = sentence.three. We can see a pattern, but the IDE can’t.
Let see what this looks like with Tabnine.

Tabnine recognises the pattern and makes an intelligent suggestion. So how does it work?
Under the Hood
Tabnine tells us that the AI’s knowledge comes from three main sources: open-source code, learning about your project, and the context of the current line.

Our earlier example is a trivial one, and just requires Tabnine to be aware of the context that this line is being written in. However, because it also knows everything about your repository, it’s able to pick up patterns from all over the codebase. Even though we know that good code has low duplication and abstracts logic where possible, all software has patterns, and those patterns are what Tabnine sees.
React Hooks are a great example. Let’s say our app has the hook useCheckout that returns state for a checkout page.
Per convention, you’d call it like so:const checkout = useCheckout() , and even though this is not enforced by the language, the framework or the codebase, this is how you call it every time. In this case, as you soon as you write const checkout, Tabnine will make a suggestion of = useCheckout() .
It excels at suggestions like this, because it sees the usage patterns across your project.
Another great use case is what I like to call “magic strings”. They’re not assigned to a constant and they can’t be imported; you just have to know what strings are valid. Vuex’s mapGetters is a great example:
...mapGetters([
'doneTodosCount',
'anotherGetter',
// ...
])
Your IDE can’t give any autocomplete, but Tabnine will give you some great suggestions as soon as you open the array. The same is true for some simpler implementations of Redux. If you haven’t followed the classic pattern of mapping strings to constants (const ADD_USER = 'add_user') and you’re not using Redux Toolkit, you might be dispatching actions like this:
store.dispatch({ type: 'todo/complete' })Again, your IDE has no way to infer what these strings might be. In all of these cases you could (and maybe should) create constants, but the reality of working in a large codebase with established conventions often means you need to comply with the patterns that already exists, instead of making some sweeping refactors.
Another monthly subscription
Do you need more monthly subscriptions in your life? Probably not, but unfortunately Tabnine is a commercial product.

There is a free tier, but the model will only scan 100 source files, and make just 2 suggestions at once. In my testing I used the Pro version for $12US/month, which scans all your source files and makes up to 5 suggestions at a time.
When comparing the free to the Pro experience, Pro wins out by a long shot. In free mode the suggestions feel annoying and ill-informed, but the Pro suggestions are constantly surprising me and helping me discover new functions in our large codebase.
The other main feature of Pro is Cloud Completion: a service that lets your system reach out to specialised deep-learning GPUs to improve suggestions. By default, this is switched off, and there’s some good reasons why you might want to keep it that way.
With Cloud Completion, snippets of your code are read as plaintext by a remote, closed-source server; an unsettling thought by itself. The company does make all the usual claims of industry-standard security and promises to delete the snippets immediately, but it’s not unreasonable to imagine that API keys and other secrets could be leaked this way.
For that reason, you should always disable Cloud Completion when working on a commercial codebase, and use it with discretion on your own work. Remember, the code doesn’t have to be in Git for it to be sent to the server, so dotfiles and passwords could be sent over the air too. All that being said, I didn’t notice a marked improvement in suggestion quality when using this feature. Perhaps it could help lighten the load on less powerful machines, but on my latest model MacBook Pro 16, it seemed to have no discernible effect.
Productivity upgrade, or a new distraction?
Developers are constantly fighting against noise. Slack messages, meetings, people tapping you on the shoulder, GIFS embedded in medium articles; these things prevent you from getting the bulk of your work done.
This was my biggest reservation about adding Tabnine to my IDE: more noise. Fortunately, I haven’t found this to be an issue. Even though there are a few more suggestions than usual, it’s no more intrusive than what your IDE does by default.
Because the Tabnine suggestions come from an AI, they can be a little ‘creative’ at times. Though the suggestions are always syntactically valid, they might include functions that don’t exist, or properties that are not on an object. This is always caught by your linter, but it would be nice to see the system do some more linting on suggestions before it reaches the user.
Another annoying quirk is that accepting a Tabnine suggestion doesn’t run an auto import like your IDE might. I imagine this is because your IDE will only really suggest and import one thing at a time, but Tabnine might offer you a whole line with a bunch of things that need importing. If you’re good with shortcuts, it’s not too hard to auto-import these after, but I do hope they work this out in the future.
My AI replacement?
There’s something a little strange about training an AI to do your job. Obviously it’s not going to understand the business rules, speak to stakeholders or respond to scope creep, but what’s holding an AI back from implementing? Nothing.
Open AI has already shown us how far this can go, and even though that’s just a demonstration, it seems to be a good glimpse into a future where AI augmentation is a standard feature of IDEs.
Seeing it like this reminds us that there’s nothing special about code. It’s just the text that we need to write to make something else happen, so why not get some extra help? Most of the time, the developers actual job is understanding and designing systems, so any help I can get with a tedious implementation is more than welcome.
From what I’ve seen so far, Tabnine is tool that makes my life easier, and that has huge value. So far the results have surprised me by making suggestions that are on the ‘tip of my fingers’, and often saving me from doing a global string search. As much as I dislike the monthly subscription model, I think $12/month is worth it, especially if you write code full time.
And if it does become sentient, I, for one, welcome our new AI overlords.

I’m Training An AI To Write My Code was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.
This content originally appeared on Level Up Coding - Medium and was authored by Tom McIntosh
Tom McIntosh | Sciencx (2021-04-18T20:46:43+00:00) I’m Training An AI To Write My Code. Retrieved from https://www.scien.cx/2021/04/18/im-training-an-ai-to-write-my-code/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.