Package: vernac
Vernac: programming (in) language 📖Vernac is a tool for writing software in "vernacular"—plain language.Vernac isn't for turning English into code; it's for turning English intoprograms:$catfizzbuzz.vnprint all the numbers between 1 and 100print 'fizz' instead of the number if it’s divisible by 3print 'buzz' if it’s divisible by 5$vernacfizzbuzz.vn-ofizzbuzz$./fizzbuzz|head-n512fizz4buzzCautionBe careful: Vernac is anunstableand somewhat whimsicalexperiment.You shouldn't use it in production. You might, however, find it more useful than you expect.MotivationTo state the obvious: Vernac just does some LLM prompting and generates code under the hood.Its value is in bundling together known prompts and annoying packaging steps so you can go from English to an executable program in one step.The dream is that you check theEnglishinto git, not the code.Every modern programmer already uses ChatGPT to generate code, then copies the code into their own source file. That’s a bit like writing your application in assembly and occasionally pasting in output from your compiler. Stay in the highest-level language you have for as long as you can! Today, in the GPT era, our highest-level language is English.UsagePrerequisitesPython 3.10+OpenAI API key with GPT-4Installpip install vernacor (recommended →)pipx install vernacRunexport OPENAI_API_KEY=<key>vernac <source_in> -o <executable_out>The executable bundles its dependenciesexceptfor a Python interpreter.ExamplesHitting an API:emojiChatGPT may remembersomestale information about an API, but often it's best to paste in relevant details:-fetch all emoji from https://emojihub.yurace.pro/api/all-if a keyword is given as command line arg, pick the emoji with the most similar name-otherwise pick a random emoji-convert its unicode code point into a character and print that# referencesthe emojihub API returns data like this:```{'name': 'minidisc', 'category': 'objects', 'group': 'objects', 'htmlCode': ['&#128189;'], 'unicode': ['U+1F4BD']}```Writing tests:fizzbuzz-with-testsDescribe test cases and Vernac will run them during compilation:accept N as a command line arg
print all the numbers between 1 and N
print 'fizz' instead of the number if it’s divisible by 3
print 'buzz' if it’s divisible by 5# testsdo the right thing with N=20Splitting code into modules:todoVernac can accept multiple input files. It will compile each one separately, guessing which are modules and which is the main program.todo-storage.vn# storage moduletodo list entries have-number-description-status (done, not done)

todo list entries are stored in`~/.todo`as a json list of objectstodo-tui.vn# terminal-based todo listtodo list entries have-number-description-status (done, not done)## usage-running the program shows a list of all todo list entries ordered by number-one entry is selected at a time-up/down arrow keys change the selection-pressing d toggles the status of the selected entry-pressing the del key removes the selected entry-pressing c pops creates a new entry-pressing s saves to the file-pressing q saves and quits-running with`--help`prints instructions and exits immediately*Note: Ensure that any HTML strings are properly formatted, i.e., all tags are correctly opened and closed.*## creating a new entry-to create a new entry, present a dialog to the user-it should have one text field to provide the description-pressing esc should close the dialog without creating an entry-new entries are selected automatically after they are createdRelated workhttps://github.com/PrefectHQ/marvinhttps://github.com/jina-ai/gptdeployFAQsWhat prevents my programs from behaving differently every time I recompile?Nothing.What about non-English languages?They are likely to work, but less likely than English.This is a joke, right?Is it? You tell me. :)