You might find the results from Google Cloud's Vertex AI better than the general purpose Bard. They have a number of pre-trained models for coding tasks. You can chat in the console UI or use the API directly. They also offer a number of open source models (codey & llama), so you can easily try different models