scribbledecobble
scribbledecobble.blogspot.com
Pages
Home
Contents
A
…
K
Fame!
README
https://www.compilejava.net/
See also
Code
/*..:....1....:....2....:....3....:....4....:....5....:....6....:....7 * * Everything that needs to be said has already been said. * But since no one was listening, everything must be said * again. * * - ANDRÉ PAUL * *** * * The Art of Computer Programming (1973, 1968) * by Donald Ervin Knuth * Volume 1: Fundamental Algorithms * Preface, p. v * * The process of preparing programs for a digital computer is * especially attractive, not only because it can be economically * and scientifically rewarding, but also because it can be an * aesthetic experience, much like composing poetry or music. * *** * * Donald Knuth. "Literate Programming (1984)" in * Literate Programming. CSLI, 1992, pg. 99. * * I believe that the time is ripe for significantly better * documentation of programs, and that we can best achieve this * by considering programs to be works of literature. Hence, my * title: "Literate Programming." * * www.literateprogramming.com * accessed on 19 Aug 2017 * *** * * How to Write Doc Comments for the Javadoc Tool * www.oracle.com/technetwork/articles/java/index-137868.html * *** * * The Art of Computer Programming (1973, 1968) * by Donald Ervin Knuth * Volume 1: Fundamental Algorithms * 1.2.2 Numbers, Powers, and Logarithms, p. 22 * * One might expect that in computer work BINARY LOGARITHMS * (to the base 2) might be more useful, since binary arithmetic * is often used in computers. Actually, we will see that binary * logarithms are very useful, but not only for that reason; * the reason is primarily that a computer algorithm often makes * two-way branches. * *** * * The Road Not Taken * by Robert Frost * * Two roads diverged in a yellow wood, * And sorry I could not travel both * And be one traveler, long I stood * And looked down one as far as I could * To where it bent in the undergrowth; * * Then took the other, as just as fair, * And having perhaps the better claim, * Because it was grassy and wanted wear; * Though as for that the passing there * Had worn them really about the same, * * And both that morning equally lay * In leaves no step had trodden black. * Oh, I kept the first for another day! * Yet knowing how way leads on to way, * I doubted if I should ever come back. * * I shall be telling this with a sigh * Somewhere ages and ages hence: * Two roads diverged in a wood, and I - * I took the one less traveled by, * And that has made all the difference. * *..:....1....:....2....:....3....:....4....:....5....:....6....:....7 */ import java.util.*; public class YellowWood { public static void main(String[] baggage) { final int moreTraveledRoad = 1; final int lessTraveledRoad = 2; Decision destiny; if (baggage == null || baggage.length == 0) { destiny = Roads.pick(moreTraveledRoad); } else { destiny = Roads.pick(lessTraveledRoad); } Life.embrace(destiny, baggage); } } public class BlueSky { public static void main(String[] args) { if (args != null && args.length > 0) { Roads.pick(2).take(args); } else { Roads.pick(1).take(args); } } } interface Decision { void take(String[] lumps); } class Life { public static void embrace(Decision risk, String[] boxOfChocolates) { risk.take(boxOfChocolates); } } class Roads { public static Decision pick(int n) { return n == 1 ? new FirstCut() : new Risk(); } } class FirstCut implements Decision { public void take(String[] args) { System.out.println("Hello, World."); } } class Risk implements Decision { public void take(String[] args) { double oddsAgainst = 0.99; if (Math.random() > oddsAgainst) { DreamJob.score(args); } else { System.out.println("FAIL"); oddsAgainst = 1 - Math.pow(oddsAgainst, 2); this.take(args); } } } class DreamJob { public static void score(String[] args) { HitShow hitShow = Hollywood.produceHit(args); hitShow.performHeadliner(); if (hitShow.audience.size() > 0) { hitShow.performEncore(); } } } /* THE UNDERGROWTH */ class Hollywood { public static HitShow produceHit(String[] args) { IntPrecipResult result = BaseNToIntPrecipitator.precipitate(args, 2); List
acts = result.precipitation; List
audience = result.residue; return new HitShow(acts, audience); } } class IntPrecipResult { public ArrayList
precipitation; public ArrayList
filtrate; public ArrayList
residue; public IntPrecipResult() { this.precipitation = new ArrayList
(); this.filtrate = new ArrayList
(); this.residue = new ArrayList
(); } } class BaseNToIntPrecipitator { public static IntPrecipResult precipitate(String[] mixture, int baseN) { IntPrecipResult result = new IntPrecipResult(); for (String s : mixture) { try { int i = Integer.parseInt(s, baseN); result.precipitation.add(i); result.filtrate.add(s); } catch (NumberFormatException e) { result.residue.add(s); } } return result; } } class HitShow { private final FamousCast cast = new FamousCast(); private final List
actsToPerform; public final List
audience; public HitShow(List
acts, List
names) { this.actsToPerform = acts; this.audience = names; } public void performHeadliner() { FamousMusical.enact(this.actsToPerform, this.cast); } public void performEncore() { System.out.println("Encore\n"); System.out.println("So long."); System.out.println("Farewell."); System.out.println("Auf wiedersehen."); System.out.println("Good night."); for (String name : this.audience) { System.out.println("Adios, " + name + "."); } System.out.println("Thanks for all the fish!"); } } class FamousCast { public final Planet world; public final Soc leadActor; public final Soc leadActress; public final Soc[] maleSupportingActors; public final Soc[] femaleSupportingActors; public final ArrayList
guys; public final ArrayList
gals; public FamousCast() { final Soc simon = new CopyCat().christen("Moonan"), simone = new CopyCat().christen("Telecchi"), tom = new BoisterousBruiser("Howdy").christen("Tom"), dick = new Soc("Hi").christen("Dick"), harry = new Soc().christen("Harry"), tamsin = new BoisterousBruiser("Hey").christen("Tamsin"), rikki = new Soc("Hello there").christen("Rikki"), harriet = new Soc().christen("Harriet"); final Soc[] males = { tom, dick, harry }; final Soc[] females = { tamsin, rikki, harriet }; leadActor = simon; leadActress = simone; maleSupportingActors = males; femaleSupportingActors = females; guys = new ArrayList
(Arrays.asList(males)); gals = new ArrayList
(Arrays.asList(females)); guys.add(0, leadActor); gals.add(0, leadActress); world = new Planet("World").christen("3rd Rock"); } } class FamousMusical { private final static Actor god = new Actor("Morgan Freeman", "YHWH"); public static void enact(List
acts, FamousCast cast) { doPrologue(); for (int act : acts) { switch(act) { case 1: doEntracte("\nSummer 2017\n"); doAct1(cast.leadActor, cast.leadActress, cast.world); break; case 2: doEntracte("\nSummer 2018\n"); doAct2(cast.maleSupportingActors, cast.world); break; case 3: doEntracte("\nSummer 2019\n"); doAct3(cast.femaleSupportingActors, cast.world); break; case 4: doEntracte("\nSummer 2020\n"); doAct4(cast.guys, cast.gals, cast.world); break; } } doEpilogue(); } private static void doPrologue() { String lyrics = "I'm gonna live forever.\n" + "I'm gonna learn how to fly."; doAct0(god, "Fame!"); sing(lyrics + '\n'); doAct0(god, "Hi."); } private static void doEpilogue() { final int durationMs = 1; String lyrics1 = "I'm gonna make it to heaven.\n" + "Light up the sky like a flame."; String lyrics2 = "I'm gonna live forever.\n" + "Baby, remember my name..."; sing(lyrics1 + '\n'); doAct0(god, "Fame!"); sing(lyrics2); singRemember(-1); } private static void doAct0(Actor omniscientNarrator, String soliloquy) { omniscientNarrator.printLine(soliloquy); } private static void doAct1(Soc adam, Soc eve, Planet world) { announceAct(1, "Freshman Year"); adam.greet(world); eve.greet(world); } private static void doAct2(Soc[] ourGang, Planet earth) { announceAct(2, "Sophomore Year"); for (Soc member : ourGang) { for (Soc otherMember : ourGang) { if (member != otherMember) { member.greet(otherMember); } } } earth.rumble(); } private static void doAct3(Soc[] ourGang, Planet rock) { announceAct(3, "Junior Year"); for (int i = 0; i < ourGang.length; i++) { Soc member = ourGang[i]; for (int j = i + 1; j < ourGang.length; j++) { Soc otherMember = ourGang[j]; if (member != otherMember) { member.greet(otherMember); otherMember.greet(member); } } } rock.roll(); } private static void doAct4(List
guys, List
gals, Planet world) { announceAct(4, "Senior Year"); for (Soc romeo : guys) { for (Soc juliet : gals) { romeo.greet(juliet); juliet.greet(romeo); } } world.clap(); } private static void doEntracte(String incidentalMusic) { System.out.println(incidentalMusic); } private static void announceAct(int n, String title) { String heading = "Act " + n + " - " + title + '\n'; System.out.println(heading); } private static void sing(String lyrics) { System.out.println('\n' + lyrics); } private static void singRemember(int ms) { if (ms >= 0) { // to do } else { singRemember(); } } private static void singRemember() { for (int times = 0; times < 6; times++) { sing(" Remember,"); } sing(" Remember.\n"); } } // https://en.wikipedia.org/wiki/Hail_fellow_well_met // https://en.wikipedia.org/wiki/Event_(computing) interface WellMetListener { public String giveName(); public void noteSalutation(String word); public void notePunctuation(char mark); } class Actor { private final String name; private String alias; public Actor(String realName, String stageName) { name = realName; setStageName(stageName); } public Actor(String realName) { this(realName, "A. Actor"); } public Actor() { this("anonymous"); } public String getRealName() { return name; } public String getStageName() { return alias; } public Actor setStageName(String stageName) { alias = stageName; return this; } public void print(String utterence) { System.out.print(utterence); } public void printLine(String utterence) { String line = this.getStageName() + ": " + utterence; System.out.println(line); } } class Planet extends Actor implements WellMetListener { private final String[] wakeWords = { // p. 3 "Bababadalgharaghtakamminarronnkonnbronntonnerronnt" + "uonnthunntrovarrhounawnskawntoohoohoordenenthurnuk", // p. 90 "Bladyughfoulmoecklenburgwhurawhorascortastrumpapor" + "nanennykocksapastippatappatupperstrippuckputtanach", // p. 44 "klikkaklakkaklaskaklopatzklatschabattacreppycrotty" + "graddaghsemmihsammihnouithappluddyappladdypkonpkot" }; public Planet(String name, String moniker) { super(name, moniker); } public Planet(String name) { this(name, "A. Rock"); } public void rumble() { this.printLine(wakeWords[0] + "!"); } public void roll() { this.printLine(wakeWords[1] + ", eh?"); } public void clap() { this.printLine("(" + wakeWords[2] + "!)"); } public Planet christen(String nickName) { this.setStageName(nickName); return this; } public String giveName() { return this.getRealName(); } public void noteSalutation(String word) { } public void notePunctuation(char mark) { } } class Soc extends Actor implements WellMetListener { private String salutation; private char punctuation; public Soc(String phrase, char punctuationMark) { this.setStageName("A. Soc"); this.setSalutation(phrase); this.punctuation = punctuationMark; } public Soc(String phrase) { this(phrase, '.'); } public Soc() { this("Hello"); } public void setSalutation(String word) { this.salutation = word; } public void setPunctuation(char mark) { this.punctuation = mark; } public void greet(WellMetListener listener) { final String who = listener.giveName(); final String greeting = this.salutation + ", " + who; this.printLine(greeting + this.punctuation); listener.noteSalutation(this.salutation); listener.notePunctuation(this.punctuation); } public Soc christen(String fakeName) { this.setStageName(fakeName); return this; } public String giveName() { return this.getStageName(); } public void noteSalutation(String word) { } public void notePunctuation(char mark) { } } // http://tvtropes.org/pmwiki/pmwiki.php/Main/BoisterousBruiser class BoisterousBruiser extends Soc { public BoisterousBruiser(String phrase) { super(phrase, '!'); } public BoisterousBruiser() { this("Hi"); } } // https://en.wikipedia.org/wiki/Copycat_(software) class CopyCat extends Soc { public CopyCat() { super(); } public void noteSalutation(String word) { this.setSalutation(word); } public void notePunctuation(char mark) { this.setPunctuation(mark); } } /*..:....1....:....2....:....3....:....4....:....5....:....6....:....7 * * André Gide * * Born: in Paris, France November 22, 1869 * Died: February 19, 1951 * * André Paul Guillaume Gide was a French author and winner of * the Nobel Prize in literature in 1947. Gide's career ranged * from its beginnings in the symbolist movement, to the advent * of anticolonialism between the two World Wars. * * Known for his fiction as well as his autobiographical works, * Gide exposes to public view the conflict and eventual * reconciliation between the two sides of his personality, split * apart by a straight-laced education and a narrow social * moralism. Gide's work can be seen as an investigation of * freedom and empowerment in the face of moralistic and puritan * constraints, and gravitates around his continuous effort to * achieve intellectual honesty. His self-exploratory texts * reflect his search of how to be fully oneself, even to the * point of owning one's sexual nature, without at the same time * betraying one's values. His political activity is informed by * the same ethos, as suggested by his repudiation of communism * after his 1936 voyage to the USSR. * * www.goodreads.com/author/show/7617.Andr_Gide * accessed on 18 Aug 2017 * *** * * Symbolism (arts) > Effect * * Among English-speaking artists, the closest counterpart to * symbolism was aestheticism. The pre-Raphaelites were * contemporaries of the earlier symbolists, and have much in * common with them. Symbolism had a significant influence on * modernism, (Remy de Gourmont considered the Imagists were its * descendants) and its traces can also be detected in the work * of many modernist poets, including T. S. Eliot, Wallace * Stevens, Conrad Aiken, Hart Crane, and W. B. Yeats in the * anglophone tradition and Rubén Darío in Hispanic literature. * The early poems of Guillaume Apollinaire have strong * affinities with symbolism. * * Edmund Wilson's 1931 study Axel's Castle focuses on the * continuity with symbolism and several important writers of the * early twentieth century, with a particular emphasis on Yeats, * Eliot, Paul Valéry, Marcel Proust, James Joyce, and Gertrude * Stein. Wilson concluded that the symbolists represented a * dreaming retreat into * * things that are dying–the whole belle-lettristic tradition * of Renaissance culture perhaps, compelled to specialize more * and more, more and more driven in on itself, as * industrialism and democratic education have come to press it * closer and closer. * * en.wikipedia.org/wiki/Symbolism_(arts) * accessed on 18 Aug 2017 * *** * * From: Interview with Donald Knuth * By Donald E. Knuth and Andrew Binstock * Apr 25, 2008 * * Andrew: One of the few projects of yours that hasn’t been * embraced by a widespread community is literate programming. * What are your thoughts about why literate programming didn’t * catch on? And is there anything you’d have done differently * in retrospect regarding literate programming? * * Donald: Literate programming is a very personal thing. I * think it’s terrific, but that might well be because I’m a * very strange person. It has tens of thousands of fans, but * not millions. * * In my experience, software created with literate programming * has turned out to be significantly better than software * developed in more traditional ways. Yet ordinary software is * usually okay—I’d give it a grade of C (or maybe C++), but not * F; hence, the traditional methods stay with us. Since they’re * understood by a vast community of programmers, most people * have no big incentive to change, just as I’m not motivated to * learn Esperanto even though it might be preferable to English * and German and French and Russian (if everybody switched). * * Jon Bentley probably hit the nail on the head when he once was * asked why literate programming hasn’t taken the whole world by * storm. He observed that a small percentage of the world’s * population is good at programming, and a small percentage is * good at writing; apparently I am asking everybody to be in * both subsets. * * Yet to me, literate programming is certainly the most important * thing that came out of the TeX project. Not only has it enabled * me to write and maintain programs faster and more reliably than * ever before, and been one of my greatest sources of joy since * the 1980s—it has actually been indispensable at times. Some of * my major programs, such as the MMIX meta-simulator, could not * have been written with any other methodology that I’ve ever * heard of. The complexity was simply too daunting for my * limited brain to handle; without literate programming, the * whole enterprise would have flopped miserably. * * If people do discover nice ways to use the newfangled * multithreaded machines, I would expect the discovery to come * from people who routinely use literate programming. Literate * programming is what you need to rise above the ordinary level * of achievement. But I don’t believe in forcing ideas on * anybody. If literate programming isn’t your style, please * forget it and do what you like. If nobody likes it but me, * let it die. * * On a positive note, I’ve been pleased to discover that the * conventions of CWEB are already standard equipment within * preinstalled software such as Makefiles, when I get * off-the-shelf Linux these days. * * www.informit.com/articles/article.aspx?p=1193856 * accessed on 19 Aug 2017 * *..:....1....:....2....:....3....:....4....:....5....:....6....:....7 */
Newer Post
Older Post
Home