Coding with AI assistance ========================= TLDR: https://youtu.be/-EJAlhqsVz8 When someone says you can just use ChatGPT to code everything for you, is it that simple? Maybe if the task is simple, but in most cases, also like if you ask a human developer to code something for you, ChatGPT does not know what exactly you want. Programming is about details, and the weaker the specification, also the outcome becomes less and less predictable. If you work with a developer that is already into your mindset and way of thinking, then you might not have to explain so much when you ask for a new feature, but in most cases when working with developers, you have to be very specific about what the result should be. This is all natural, because a programmer doesn't neccesarily know the domain that the application should serve, and then you who engage the programmer must share details and be specific on the behaviour of the application to be developed. And so it is also when using ChatGPT, or another AI assistant for that matter. It doesn't know what you want, so you have to provide details, repeat stuff, explain, give feedback in multiple iterations. The difference is that the AI is always available, it responds instantly, doesn't get tired, and don't think you ask stupid questions. However it also requires the same patience in return. So if you already know how to code, why should you use an AI assistant? One good reason is that coding today requires a lot of checking with documentation while you work. None of us know a programming language or API by heart so that we can just go on coding without consulting with reference documentation, examples or articles while we work. This was possible back in the 80s were for example coding Assembly language was limited to a comprehensable set of instructions. I remember when programming on the Commodore Amiga, it was possible to remember all the details on the hardware interfaces and the CPU, but this is impossible with the enormous functionality in programming languages today and all the APIs we use from libraries or network services. The AI assistant though, does not need to look up documentation, it already knows all progamming languages and APIs, so it can give you an example right away. Then there is all the writing. Coding often involves writing several hundreds of lines to provide functionality that can be explained with a few sentences in human language. Being able to write less, also saves a lot of time. I will give you an example. For my "WebAssembly Music" project I wanted to use a new synthesizer called [Sointu](https://github.com/vsariola/sointu). Sointu has a command line tool, that can create WebAssembly text files containing music and instruments, based on the specification in a YAML file. For my WebAssembly Music app, that runs in the browser, I rather needed a HTTP server for this, instead of a command line tool. So I provided ChatGPT with the sources of the command line tool, and asked it to write it as a HTTP server instead. It turned out quite well, first I saved a lot of time, since I don't know the go language very well, and also it was a bit to write. Still ChatGPT needed some guidance, and you can read my entire conversation here: https://chat.openai.com/share/0d677be6-6dd6-4807-b3c6-fa852d442054 Rust is another language where I need to consult with examples and documentation a lot. Also it often involves a bit different way of thinking than higher level languages, because of all the built-in safety features. I like to say that with Rust it's difficult to get it to compile, but then it also works, compared to other languages that might compile easily, but then gives you bugs to figure out in the aftermath. I did some Rust coding for the backend (smart contract) of the DevHUB which is a widget here at NEAR BOS ( where this article is also published ). The feature was about notifying mentions, which involves that the text will be scanned for mentions and then notifications need to be produced. In addition to writing the functionality itself I wanted to add some unit tests to ensure it is not broken by future development. You can see the result here https://github.com/near/neardevhub-contract/blob/main/src/lib.rs#L487, but also check my conversation with ChatGPT https://chat.openai.com/share/ad8a4218-74c6-40f6-812f-691191f06160 where I saved a lot of time in just explaining the test code I needed, and got Rust code as a result, that also did compile and worked! Finally I want to share with you the coding of the GL Shader for my latest track on "WebAssembly Music". Shaders are not my main thing, but music is even cooler with some visuals, and so I wanted to have something done quickly that I also could present in a NEAR BOS widget. See the resulting widget here ( press play ): https://near.org/petersalomonsen.near/widget/much Now I had spent so much time on coding the music, that I just wanted a quick way to the visuals. I have already done another shader demo in the past, and I thought maybe I can just challenge ChatGPT to reuse that code, but produce something totally different. So the starting point was the demo you see here: https://psalomo.near.page/shaderdemo1 As you can see it is a Mandelbrot fractal that also reacts to the music. I wanted something that reacted to the music, but not a fractal. I didn't know really what I wanted, so I asked for a suggestion based on the fractal shader code. So actually I also asked for a bit of creativity here from ChatGPT. You can watch this video where I explain the process briefly: https://youtu.be/1vF56LmznmU And also read the full conversation with ChatGPT here: https://chat.openai.com/share/f1650c1b-17c8-4875-9210-39ac91d674a5 The music itself is also written in code. I find code as a very efficient way of describing music, compared to old-school sheet music, or graphical user interfaces of modern music software. And not only the notation on which instruments to be played at which note at what time, but also the instruments themselves. The sound of a string, flute, drums or guitar, or any other instrument can be expressed in code. It does not have to be recorded. And writing everything in code is exactly what I've been doing for the music here. Until now I have not been using AI for this, but I have written enough examples now to start training it also for creating the music. This is something I'm looking forward to explore even more, so stay tuned for updates on this! Thanks for reading!