Bing AI can write code in my custom programming language and its blowing my mind

I’ve been working on a programming language project for quite a while. Its been challenging and fun as my on-again-off-again side project for probably 10+ years.

Needless to say this programming language isn’t known by many people and it is fairly original while borrowing from a few other similarly obscure language projects.

The language is a parser generator language, a programming language programming language if you will. Its intent is to make it easier for people to create DSLs and the accompanying tools. You can check it out at

So I figured it would be an interesting opportunity to see how good the new Big AI actually is by asking it to do something cognitively difficult for a human and which there is little to no literature available online for it to have been heavily trained in prior to my request.

So I asked it to “write a program in the Uffda language that parses Morse Code?”

It gave me a little guff saying that Uffda is actually a scandanavian expression, which is closer to what I expected it to do. But then it went on to say that its actually a TypeScript library for a parser generator and offered “If you want, I can write a program in TypeScript that uses the Uffda library to define a parser for Morse Code.😊”

It then gave me the option to press a button to “Yes, please write the program.”

And so I did… And the results kind of astonished me. It actually wrote what appears to be a viable parser and beyond that it took advantage of a few concepts which really suprised me:

  • The TypeScript code was correct (unsprisingly)
  • The Uffda code inside the string inside TypeScript is correct (a language inside a language!)
  • Its using Direct Left Recursion which is a pretty complex concept
  • It added completely accurate and relevant code comments
  • It actually included an example of running the code, as well as the expected output in a code comment, which implies that it simulated running the program of a language… even if it isn’t actually capable of doing that giving the impression it did is still pretty amazing.

The Code

// Import the Uffda library
import { dsl, uffda } from "";

// Define a parser for Morse Code using Uffda syntax
export const Morse = await uffda()`
  // A dot is represented by a single dot character
  Dot = ({ kind = 'Token', value = '.' } -> '.');
  // A dash is represented by a single dash character
  Dash = ({ kind = 'Token', value = '-' } -> '-');
  // A letter is composed of one or more dots and dashes
    = (l:Letter Dot r:Letter -> l + '.' + r) // Concatenate dots and dashes
    | (l:Letter Dash r:Letter -> l + '-' + r)
    | Dot // A single dot is also a letter
    | Dash // A single dash is also a letter
  // A word is composed of one or more letters separated by spaces
    = (l:Word { kind = 'Token', value = ' ' } r:Letter -> l + ' ' + r) // Concatenate letters with spaces
    | Letter // A single letter is also a word
  // A sentence is composed of one or more words separated by slashes
    = (l:Sentence { kind = 'Token', value = '/' } r:Word -> l + '/' + r) // Concatenate words with slashes
    | Word // A single word is also a sentence

    > Sentence; // The main parser expects a sentence as input


// Create a DSL function that parses Morse Code using the defined parser
export const morse = dsl(import.meta.url, Morse);

// Parse some Morse Code and print the result
const { value } = morse`.... . .-.. .-.. --- / .-- --- .-. .-.. -..`;
console.log(value); // Prints ".... . .-.. .-.. --- / .-- --- .-. .-.. -."

Now as I’m expanding this I can see it actually got the code a little bit wrong. The last line of the parser is the Main rule which should actually be…

Main = ${Basic} > Sentence;

So I told it that it made a mistake and forgot to import the Basic pattern and pipe it into the Sentence pattern. I asked it to correct and reprint the program…

It emitted the same program again but this time it actually included the missing Basic pattern import.

However it did completely omit the Main rule as well. So I gave it another hint and asked it to try again.

And so this time it printed it out but still not fully correct (> instead of =).

Also, somewhat astonishing here is that the code comment is saying “The main parser expects a sentence as input after applying the Basic pattern”, which is correct despite me calling it a “rule” in the previous comment (A rule is a kind of a pattern in this language).

Moving on I asked it to print out each letter as Ascii instead of printing out the input dot’s and dashes. Here it made a pretty big mistake by adding a switch statement which isn’t even valid syntax in uffda.

So I then gave it a hint about pattern matching and the correct syntax and it had pretty amazing results.

It sort of broke down around the Letter O and stopped printing spaces between the patterns, the Z pattern completely stopped using Dot and Dash patterns and just printed out literal dots and dashes. But honestly I’m still pretty impressed with the results.

Asking it to fix the O through Z patterns by adding spaces seems to not be working. Asking it to use Dot and Dash pattern references instead of verbatim . and – characters seems to have exacerbated the problem. So at this point I think we hit the edge of its capabilities.

That being said I’m highly impressed. For it to be able to write a language within a language is pretty surprising, especially for a language that it couldn’t possibly have had much training data on.

Being able to talk to it naturally and have it build context is a really nice way to work with a search engine. Being able to simply correct it and have it seem to grow its understanding of the programming lanaguage as we went felt really natural. I honestly have given many code reviews that felt pretty similar to this conversation I had with the AI and that went less well too.

I do feel like I hit a limit to its capabilities but its very impressive nonetheless. I hope someday I will be able to essentially give the AI more and more constraints in a natural way and have it fully write the code needed to make it work.

Open Source is Software Feudalism

I’m a big fan of open source. One of the things I have enjoyed since my departure from Microsoft is being more involved in the open source community. I have been contributing changes to projects that I am using as well as trying to make more of my code open source. Of course I’ve been relying on Github heavily as most people do, and have been enjoying it quite a bit.

One problem I’ve been noticing as a member of the Open Source community is that while Open Source projects claim to be open and free they do still have owners and controls which can limit participation.

I was discussing this with my good friend Leo and he called Open Source “Feudalism with infinite land”. Because an open source project stakes a claim in the land of software-needs and then controls it tyrannically. It’s easy to see a lot of parallels where this analogy makes sense. Such as the fact that projects have owners who have power over its community of users. Popular projects are like duchies, you are able to claim “land” in popular package managers such as npm. Once you’ve branded your project and claimed the names you effectively control that territory forever.

To take the analogy a little further the GPL license itself is a little bit like the Catholicism of this feudal system, with Linus Torvalds as its Pope. It’s the one true religion that all believers should conform to, even though most of us are secretly MIT heathens in our day to day lives. Furthermore, like the vow of chastity which is used to consolidate the inheritance of priests’ wealth, the viral nature of the GPL license is designed to ensure that more IP is slowly inherited over time by church of Open Source.

Now I don’t want to slam Open Source too much but it would be really nice to see it turn in a more truly free and open direction, away from tyranny and more towards anarchy. But what would this even look like?

For starters I think there should be a feature for any open project in Github to allow the community to control the owners of the project. Meaning, for a given project there should be a voting mechanism, which periodically allows the community to add or remove people from the set of project owners.

Similarly there should be a mechanism for individual Pull Requests where the community could vote on said PR to influence its acceptance.

Furthermore, a culture where people are happy to transfer ownership and view it as a healthy way to vitalize projects and limit power consolidation is necessary.

Additionally, I would like to see a feature where a project can, in a structured way, declare what kind of contributions they are seeking. From owners, to developers, to design work, to specific features and bugs. There should then be a master list where anybody could go and see this list of work sought and after a period of time automatically join into a project they find interesting.

Projects that go stagnant would have ownership roles automatically go up onto the board. Ownership roles that have more applicants than are available would have community based voting before the role is granted.

Most of these ideas are just things I came up with this morning (with the help of Leo of course). So I’m not saying they’re perfect or even well thought out. However I think the general principal is sound, which is that there is a problem of tyranny currently in Open Source and I would like to see it move into an even more open, anarchistic direction.

Atheist Voices of Minnesota

I recently contributed a chapter to what I think is a very remarkable anthology of short stories written by fellow Minnesota Atheists. It was a very nice experience to finally be able to write about the unusual path I have taken to both arrive in Minnesota and become and atheist. My contribution was a fairly personal story, partly about my time in a religious cult but also how it felt to loose my faith and the thought process that lead me to the conclusion that there is no God. It felt good to share it publicly and I hope you enjoy it.  The goal of the book was to provide positive and inspirational stories from regular people to show everyone that Atheists are just people too and to help provide some insight into what makes us tick. And maybe you are an atheist too? If so, with this book you may find a community of like minded people waiting for you.

The book is now officially published and available in print or ebook from various book stores. Please head over to the website for more details:

Image Cover

A message to my Senator, Al Franken


I voted for you in your last election and have been very happy with your service overall. You’re a great source of reason and intelligence in the Senate and I’m glad to have you here in Minnesota.

However, it’s come to my attention that you have chosen to support PIPA. I believe that this is a very unpopular position for you to take, and for good reason. I would strongly urge you to reconsider your position in this matter. Internet freedom and freedom of expression in general is an important issue to me; in fact I might say it is one of the most important issues to me. The reason it is so important is that I believe that all other evils stem from untruth and censorship. Freedom of expression is the most general way to combat evil and without it we are lost. This completely open, global, communication system we have created is truly the most incredible wonder human kind has ever created. And the potential for evil that PIPA is attempting to prevent is only matched by a potential for good which will be equivalently stifled. Please do not support anything that will diminish this amazing creation. The internet is still young, and full of zest. People do evil things, it’s true, but that fact is dramatically outweighed by the goodness we do as well.

What’s needed is not for the movie industry to get overly general legislation so they can continue to stagnate but for them to embrace this brave new world and finally innovate. They’re still stuck on over priced mega-plexes, DVD’s and obsolete Cable TV  while the rest of us are pining for verbose streaming options, ownership of the things we purchase and the removal of entrenched middle men. Please read this article for opinions I agree with:

We cannot allow a single industry to hinder free expression of everyone simply because they have a powerful lobby in Washington. Combatting piracy with legislation is a losing battle, it’s bad for consumers and it’s bad for the art we all want to protect.

Take a stand. Force them to change, not the internet. A free and open internet will make this world a better place and that is the most important thing to remember. From there all other things will unfold.

Thank you, I know you’ll do the right thing.


Justin Chase