This week's build of Elements gives a first peek at an exciting new feature we've been working on for the Fire IDE: CodeBot.

CodeBot is a smart coding assistant that can help you write, analyze and correct your code in any of the six Elements languages. You can ask it to explain code you don't understand (whether it was written by someone else or your younger self), or have it review new code for potential bugs or improvement suggestions. You can even ask it to write a new method or class for you from scratch. It can also explain general programming-related concepts to you.

You'll usually start by right-clicking the Fire Code Editor, either in "empty" space, or having selected a snippet of code, and choosing one of the options in the CodeBot submenu.

For example, you might want to ask it to explain a complex piece of code you don't quite understand:

CodeBot understands context, so you can ask it follow-up questions, for example, to go into even more detail about the method in question, helping you to explore the functionality step by step:

You can even ask it for improvements — which can cover anything from actual bugs or renaming and/or restructuring code for clarity:

Invoking the context menu without code selected lets you ask CodeBot to generate new code for you, based on your requirements described in plain English:

Within seconds you will have a rough solution, and with a single click can paste it into your existing code base.

General Questions

You can also just invoke CodeBot from the "Windows" menu (or ⇧⌘8) and talk to it in plain English. For example, you could ask it what "future types" (a much-overlooked Oxygene language feature) do:

Limits

Do keep in mind that CodeBot is just that – a chatbot powered by AI (or, really, machine learning; there's no such thing as AI, but it seems we've collectively given up on making that distinction ;). It is really good (better than you'd expect, in most cases), but it's not perfect or infallible. It might not know about all language or platform features helpful to answer a given question. And it might give you code that's not one hundred percent quite there yet and might need some tweaks. But it will get you a good head start — especially when it comes to getting the basics for well-known algorithms.

Keep in mind that you can challenge Codebot, and you can teach it. If it gets something wrong, don't hesitate to tell it, and it will usually be able to correct its mistake. For example, you might tell it, "I don't believe you can use the nullable keyword like you did there", and it will probably go ahead and rewrite the code it suggested to fix the issue.

Note: You should always, always, always review generated code before using it in production or even before running it locally (I don't believe CodeBot is quite ready yet to trick you into letting it take over your machine – but you never know ;).

CodeBot is backed by OpenAI's GPT Large Language Model (LLM) "AI".

Requirements

What's needed to use CodeBot? Right now, you will need two things:

  • Fire*, build .2831 or later (shipped April 14, 2023).
  • An OpenAI API key which you can get here (and which will come with $5 in free start-up credits — enough to use CodeBot for quite a while).

(*Support for Water will come at a later time)

Your Feedback is Needed

As stated up front, CodeBot is an early preview, and I believe there are many improvements we can still make to it. Your feedback will be appreciated and very helpful in shaping where CodeBot will go from here.