Inspiration

We were inspired by the plethora of voice-enabled technology available today like Amazon Alexa, Google Home, Siri, and Cortana, as well as a love for esoteric languages. What started as a joke to make a voice-enabled programming language became the inspiration for a language with virtually no formal syntax, that could parse and produce compilable code from a wide variety of inputs.

What it does

Zencode is a web application that parses a string given to it by a user, and converts it into runnable python code. Currently, Zencode only supports simple loops and print statements, but we hope to expand the scope in the future. While far from finished, if you want to play with the application, run the alexa.py file (you will need python 3 and flask installed).

How I built it

I built the parser for the Zencode language almost exclusively in plain python 3. The general idea for how the parser works is that the language has a dictionary of words that correspond to various functions. The parser scans through the input string to identify tentative functions to be called, and based on the composition of these keywords and other values in the string, loops to create nested structures (like print statements nested in a loop) which eventually get converted into python code. The front-end web application was a simple Flask application.

Challenges I ran into

One of the largest challenges I ran into was organizing my thoughts and planning out how to build the parser. Given the nuances of natural language parsing, the lack of any dedicated library for NLP, and of course the time constraint, it was difficult to visualize how to effectively capture all of the possible permutations that a single line of psuedo-code could have. Additionally, while I was working on the parser, my partner Rohan had difficulty getting the Alexa component of our project to work, and we eventually had to pivot from a voice-activated platform to a text-based platform.

Accomplishments that I'm proud of

I'm proud that, however rudimentary, we were still able to get at least a prototype done in time at my first hackathon. And I posted my first project on Github!

What I learned

Although most of the development work I did was with python and familiar frameworks, I think I learned a lot just from the nature of the code I was writing: working with messy data sets like natural language, the biggest takeaway from Bitcamp for me would probably be that for real-world data like this, you'll have a lot of edge cases and exceptions to the general rule, and especially for code like mine that utilized recursive features, it's very important to carefully plan out how these exceptions are handled and how these functions interact with each other before you start diving in.

What's next for Zencode

We would like to expand the functionality of the language and provide a wider variety of capabilities, including variables, basic arithmetic, conditional statements, and hopefully the capability to interact with external data sets. Furthermore, one of the weaknesses of a language like Zencode is that it creates a much higher level of ambiguity than it's more formal siblings with well-defined syntax. We hope to mitigate this by enhancing the debugger to evaluate more possible interpretations of a user's code, and interact with the user through prompts to clarify these points of ambiguity. Finally, we hope to integrate our language with voice-enabled hardware like Alexa and Google Home.

Share this project:

Updates