CherryBlossom

 

I don’t know what it is about haikus that makes them so neat. Maybe it’s because they’re made up of prime numbers (3 lines, 5 syllables, 7 syllables, 5 syllables, a total of 17 syllables), or maybe it’s because you have so much beauty, artistry and emotion neatly packaged in just three lines. Either way, I think they are pretty neat.

I think I first got the idea to write a language based on haikus around two weeks ago when I was reading about esoteric languages. I was going over the Shakespeare Programming Language (SPL) (which I first heard about from a slashdot post a few years ago) when I started thinking about variations on the same theme (that is, prose or poetry as program code). I then thought “What if a haiku could also be program code?”. Thus, the idea of CherryBlossom was conceived. Initially, I was stumped as to how I could transform a haiku into program code. The structure of a haiku is rather rigid, and I couldn’t think of an easy way to make a language (with variables, functions, and flow-control) because of that rigidity. In comparison, SPL is much more free-flowing since it’s prose. In haiku, you are limited to the number of syllables and lines. Then I thought, “What if the language was minimalistic?”. In that case, all I need to do is figure out a way to map words to a small instruction set! When talking about languages with small (although not too small) instruction sets, there is no better candidate than Brainfuck, which is a Turing-Complete language with only eight instructions. With that in mind, I finally had an idea about CherryBlossom‘s implementation.

Like I mentioned before, the idea behind CherryBlossom is pretty simple. Brainfuck instructions are mapped to words that convey the meaning or essence of the Brainfuck instruction. For example, the > instruction, which moves the pointer forward conveys an essence of moving forward, or up. Hence it makes sense to map it to words that convey a similar meaning. With that idea, I came up with the following mappings:

> (move pointer forward) above, ahead, atmosphere, bird, birds, flew, flies, flight, float, floated, floating, floats, fly, flew, flying, forward, front, heaven, heavenly, height, high, higher, hill, hillside, hilltop, mountain, mountainside, mountaintop, push, pushed, pushes, pushing, rise, rises, rising, sky, top, up, upward, upwards (words that convey a sense of forward or upward motion, flying, or height)
< (move pointer backward) back, backward, backwards, behind, below, dip, down, downwards, earth, fall, falling, falls, fell, ground, grounded, land, landed, landing, lands, low, lower, lowered, lowering, lowers, pull, rain, rained, rainfall, raining, rains, reverse, sink, sinking, sinks, snake, snow, snowed, snowfall, snowing, snows, valley, waterfall (words that convey a sense of backward or downard motion, falling, or depth)
+ (increment value at current memory location) alive, add, added, adding, adds, beautified, beautifies, beautiful, beautify, beautifying, beauty, butterfly, butterflies, big, bigger, bloom, bloomed, blooming, blooms, blossom, blossoming, blossoms, caress, caressed, caresses, caressing, cherry-blossom, cherry-blossoms, dawn, day, daybreak, days, dove, doves, dream, dreaming, dreams, dreamy, fat, fattening, fatty, field, fields, fire, flower, flowered, flowering, flowers, fragrance, fragrant, gain, gained, gains, get, gets, getting, good, grew, grow, growing, grows, had, happiness, happy, have, having, heal, healed, healing, heals, heat, heated, heats, hot, jasmine, learn, learning, learns, life, live, love, loved, lovely, loves, loving, lush, many, money, more, morning, new, own, owned, owning, owns, pleased, pleasing, pleasure, positive, pretty, rainbow, rainbows, remember, remembered, remembering, remembers, rose, roses, rosy, smile, smiled, smiles, smiling, spring, steam, steamed, steams, steamy, summer, sun, sunlight, sunlit, sunray, sunrays, sunshine, sweet, sweeten, sweetened, sweeter, sweetly, sweets, warm, warmth, wealth (words that convey a sense of gaining, beauty, increasing, or anything positive)
- (decrement value at current memory location) alone, autumn, anger, angry, bad, barren, break, broke, broken, cold, cool, chill, chilled, chills, chilly, cried, cry, crying, dark, darkening, darker, dead, death, desolate, desolation, depressed, depressing, desert, deserts, die, dies, dusk, dying, evening, evil, fear, fearful, few, fog, fogged, foggy, forget, forgetful, forgetting, forgot, forgotten, forsake, forsaken, freeze, freezing, freezes, froze, frozen, fright, frighten, frightened, frightening, gloom, gloomy, greed, greedy, ice, icy, less, lessen, lessened, lone, lonely, lonesome, lose, losing, loss, lost, melancholy, miss, missed, misses, missing, mist, mistake, mistaken, misted, mists, misty, moon, moonlight, moonlit, moonshine, nothing, night, nightfall, nightmare, old, pain, painful, poor, poverty, rage, remove, removes, removing, sad, sadness, scream, screamed, screams, screaming, shrank, shrink, shrinking, shrinks, shrunk, small, smaller, sorrow, sorrowful, tear, tearful, teary, thin, thins, thinned, thinning, ugliness, ugly, winter, wither, withering, withers, wound, wounded, wounds (words that convey a sense of loss, sadness, decreasing, or anything negative)
[ (jump forward past the matching ] if the value at the pointer is zero) if, why, when, where, how, who, what, inspect, puzzle, question, mull, riddle, decide, branch, branched, branches, branching, mulled, mulling, mulls, decides, deciding, decided, contemplate, contemplating, contemplation, contemplated, contemplates, think, thinking, thought, thinks, choose, chose, choosing, chooses, wonder, wondered, wondering, wonders (words that convey a sense of introspection or conditionality)
] (jump backward to the matching [ unless the value at the pointer is zero) return, home, reunite, returns, returned, returning, reunited, reunites, reuinting, acknowledge, acknowledges, acknowledged, acknowledging, acknowledgement, homecoming, retreat, retreating, retreats, retreated, restore, restoring, restored, restores, revisit, revisited, revisiting, revisits, rebound, rebounded, rebounding, rebounds, boomerang (words that convey a sense of returning)
. (print the ASCII character represented by the value at the pointer) answer, answered, answering, answers, art, artist, author, birdsong, book, brook, creek, display, displaying, displays, flow, flowing, flows, gave, give, giving, laugh, laughed, laughing, laughs, laughter, letter, melodious, melody, music, paint, painter, painting, paints, picture, poem, poet, present, respond, result, river, riverside, said, say, saying, says, show, showed, showing, shows, sang, sight, sing, singer, singing, sings, speak, speaker, speaking, speaks, spoke, stream, view, views, window, word, words, write, writer, writes, writing, wrote (words that convey a sense of speaking or saying)
, (input a value and store the ASCII character of that value at the pointer) absorb, absorbed, absorbing, absorbs, accepted, accepting, accepts, annex, annexed, annexes, annexing, ask, asked, asking, asks, attract, attracted, attracting, attracts, conquer, conquered, conquering, conquers, ditch, fill, filled, filling, fills, hear, hearing, hears, hole, in, indoor, indoors, inside, knew, know, knowing, knowledge, knows, learn, learned, learning, learns, lesson, lessons, question, questioned, questioning, questions, read, reader, reading, reads, receive, received, receives, receiving, suck, sucked, sucking, sucks, taken, takes, taking, taught, teach, teacher, teaching, took, vortex, whirlpool (words that convey a sense of questioning, learning or taking something in)
NOP (instructions that don’t do anything) about, all, and, am, an, at, a, any, are, because, be, by, came, can, come, could, did, do, does, every, everything, for, from, go, he, her, hers, here, him, his, in, i, is, it, man, me, mine, my, no, now, of, one, on, or, our, ours, she, should, some, such, that, them, then, the, their, theirs, there, they, this, to, to, us, was, went, were, will, with, woman, would, yes, you, your, yours (these are words that I added so that it would be easier to write haikus, since it’s hard to construct sentences or phrases without these words)

  10 Responses to “CherryBlossom”

  1. This really is amazing. Now I can express myself AND make beautiful code all in one. Great work.

  2. @TheMoonMaster
    Thanks! That was the idea ;) heh!

  3. Social comments and analytics for this post…

    This post was mentioned on Twitter by vi5in: @heisenthought @guusdk Here’s the actual project page with two samples and the interpreter (link is on last page)! http://bit.ly/bxB9Zt

  4. This is really cool!! BrainF**k was pretty much a disaster.

  5. @Tushar Dadlani
    Haha, thanks! Yeah I think that the intent with Brainfuck!

  6. Saw your shameless plug on SO :)

    This is so cool! I wish I had come up with something like this. I love it.

  7. @anon
    Thank you! :D It was definitely during some moments of boredom (and probably a little insanity) that I came up with this.

  8. Hey, this is really interesting! I’m kind of new to programming, and I really want to try this out. Could you just explain how Im supposed to set up and run the interpreter?

  9. @A
    You need to download Perl and install a few modules. If you’re on Ubuntu, Perl should already be installed. You can start up CPAN by typing “cpan” and then installing the following modules.

    GetOpt::Mixed
    Term::ReadKey
    Lingua::EN::Syllable

    For Windows, there are some other options. You can install Strawberry Perl and use cpan to install the above modules.

    You say that you’re new to programming; I would suggest not starting off with CherryBlossom. It is a Brainf*ck analog after all and Brainf*ck isn’t designed to be easy :)

  10. [...] also CherryBlossom. Written by Vivin Paliath, it maps the brainfuck instruction set to words that convey a similar [...]

Leave a Reply

All original content on these pages is fingerprinted and certified by Digiprove