Jan 23

Punctuality

Category: Interpreted Glyphs

This is a statement of personal intention rather than advice to readers who probably won’t have occasion to apply my observation.

C derived languages tend to assign with a single =, as in grade school: x = 3. Algol derived languages (Pascal) instead make assignment more explicit by using x := 3. They share the same symbol for testing equality ==. “If x equals 3 [...]” is written if x == 3. This is widely reputed as a source of unintended program behavior in C’s descendants. While a pascal compiler will complain when encountering if x = 3 – it matches neither assignment nor an equality check, a C-type compiler will quietly always evaluate that expression is true. In essence, the assignment succeeded, so the following code will always execute. Worse, it also changes the value of x in cases where it wasn’t already 3. If this typo were in a sorting algorithm, the final list would be all threes. Beginners are warned to keep aware of this type of bug.

So, I warmly received the advice to switch the order of the conditional expression. If 3 equals x becomes if 3 == x. And, mistyped is if 3 = x. But, the suggester noted, that assignment will not just fail inflexibly, most compilers will reject the syntax and halt. 3 can not be reassigned to some arbitrary value (most C derived compilers, Ruby/Ioites). So, went the line of reasoning, always assign in the least dangerous order and reap the benefit of always correcting this simple mistake.

While that sounds nice in theory, as a practice, it serves best as a special case rather than a general rule. Trying to rotate the expression has no meaning when I am comparing variables, ie if x == y. Further, by making a habit of rotating the conditional, I found myself trying to rotate inequality checks. x < 3 :: 3 > x Doing so demands that I make sure to rotate the inequality symbol with the expression, something the compiler will not check. Perhaps, this is an element of adjusting to a new habit. Eventually, I will internalize the special case and drop the temptation to apply it as a rule.

Except, I am less productive now for no benefit. Juggling expressions in a manner against my habit costs me more effort than I should for aspects of a program thought resolved in design. In planning a program I may write “if grandparent_node is black and uncle_node is red, left rotate.” But, I sit to implement it and must somewhat ignore the natural way of speaking ” if black is grandparent ” against a possible side effect. Really, rather than ‘optimize’ equality conditionals against unintentional assignment – and hence breaking Flow over snitty details of order – checking the number of all equal signs following an IF keyword is much simpler. Just before compilation is the best time to think about compilation and runtime errors since that is what I expect to do anyway.

My experience suggests I return to writing if x == 3 and keep thoughts of errors to postproduction or make a note of a potential problem in a side comment.

No comments

Jan 9

Are his lips moving?

Category: I am that I am

[My patron is shamelessly revealing posts he hid during an apparently silent 2011. I'm in no competition, but that must be met with some response. Unfortunately, the following is depressing. Warning over.]

My mother commented to her husband, Rick, that she can’t trust anything that the candidates say because they usually promise things that they can’t accomplish. In my gratitude at hearing someone else utter what I consider a basic truth, I rushed to provide what I didn’t, until then, realize is the importance of their doing so. If you, as a citizen, really believed that your invoked opinion (vote) had zero correlation with your intended effect, it would likely remove a great deal of meaning from the activity.

My mother uttered the correlary I so wanted to hear about their false promised, “because what they promise is Congress’ responsibility.” I can rest a platform on zero tax increases, a federal health care mandate, and so on, but realizing those plans requires the buy in of at least three hundred members of Congress. Mind, the president has lots of political capital at the outset (John Quincy aside) as indicated by winning. That means his suggestions are more heeded that that of a grassroot petition for some new law to submit to congress. But, ultimately, not only are the senator & assemblymen’s incentives not pointed at him’er (well someday I’ll have to say him or her), they are as complex as those of real people. Imagine.

But, in the rush of recognition, I latched onto a structuralist answer. Thank goodness they promise us no taxes and more jobs. (By the way, did you hear about the budget cut to the DoDefense’s budget? Guess which department is the biggest employer. Tough, tough choices for people who have already seized the low hanging fruit.) How could a candidate get anybody’s attention if sh’he said, “I promise to be in dozens of meetings each month to styme unhelpful amendments to bills that I will only ever read cliffs’ notes of.” Or perhaps a presidential runner who assures the Iowa caucus that sh’he will keep out of the public eye until the trending opinion is just about certain.

Mind, I’m not being facetious about Obama or any other official with those examples because I just made them up now. I am pretty sure that they conform to what federal political life may require, but that is outside the realm of my experience. The point is the same, as a voter, I want to hear that the President I elect will be the benevolent dictator on my side, ignoring criticism to accomplish the Things That I Think Need Doing. If Romney doesn’t promise me something to attract my attention, why should I give him the time of day?

Realistically, to make the optimal choice for a representative, rather than a satisficing choice from the available alternatives would involve a candidate undertaking a terribly complex simulation lasting months. It needs to have him’er interact with his’er peers in both branches of government. Actually, at the time I resorted to my standby objection to ‘researching’ the candidates’ opinions. One of the most visible uses of explicit presidential power, besides DoD announcements, is choosing Federal positions: cabinet members and Justices (federal are obviously more abundant than Supreme). The allotment of those positions will strongly influence the bureaucratic environment during his’er term. But, suppose each candidate puts forward a potential cabinet list. While revealing and meaningful to people in his social circle, it doesn’t mean anything to me. Those people may be even harder to ferret information about than the figurehead. Plus, ten candidates (per party) means one hundred people to judge for disparate roles interacting with thousands of others. No thanks.

The trick is that we citizens are offered a small API, one selection for five federal positions with a couple of options each. From there I have to hope that such judgment helps steer the ship of state in a sensible direction. The ship of state, as already described, is a dense web of relationships with vague goals. Perhaps some HR departments in technology related businesses have invested in software to find the perfect fit for their extant teams? I know well enough the danger of trusting such a filter, whether it has been made or not.

This isn’t really a plea for any kind of political reconception on your part. It serves as requiem to my political idealism. I can not invest enough time to thoroughly investigate the fitness of any single candidate, much less several of the same party, to effect change within a crowd of five hundred others. Frankly, if I want to pursue that, I would become a cultural agent and attempt to move the hearts of citizens outside my district and state to assume the same kinds of priorities that I do and hence elect representatives amenable to that style of thought. Anything less is on the asymptote of diminished returns and I may as well use hair color as a correlate for fitness for all the explanatory power that listening to speeches will accomplish.

Or, maybe I have typed “change” too much in this last hour. With budgetary suicide watch in both my state and nation, change is something I would hope the next crop can effect. I can always adopt a rictus smile and say, “I’ve not heard of a nation going bankrupt in my lifetime.” Except for Ireland. And maybe Greece. And Iceland. But those are small countries, with [ not the point ]. Look, if I’m not hoping for ‘change’ then what do I care? And that was why I shushed my mother. Let’s all shoo Lovecraft’s specter into the other room. Important bureaucratic changes have been made in my grandmother’s lifetime (even if she wasn’t here to experience them). If americans hadn’t voted for FDRoosevelt’s three terms, Something Else would have happened. Without Bush Jr & Obama, Something Else would be our present state.

[There was a hole here, decrying the directionless stumble you've just finished reading. There's just this now.] I guess I am wrong. I haven’t decided whether voting is worthwhile or not. BUT, those who are untroubled enough to cope with/ignore these aspects to civil life make the collective decisions. About our representatives. And who are they? More people with more confidence than I.

No comments

Jun 7

NomNom da plum

Category: Interpreted Glyphs

Six months ago, I crowed that I had created my most significant program to date, a specialized file renamer. Specialized because it is hard coded to correct files from DeviantArt, as indicated by the presence of “_by_” in the filename. I am grateful for my younger self’s automation of the tedious task of changing underscores to spaces and switching the artist’s name and picture title. What I didn’t appreciate was my surrender on the point of multiple underscores.

 

Specifically, I just turned every underscore into a space. It turns out, deviantart’s servers pretty much hate every non-alphanumeric character because anything else becomes an underscore. Worse, some characters, like the apostrophe are saved as an escape character which deforms into two underscores, which may result in three spaces in a row. Some artists‘ submissions have been particularly trying.

 

While there is more to say, it is late and I have more to do yet. Here is the (procedural) source code. Here is the executable itself.

 

Warnings

The program uses window’s api, so don’t bother downloading if you use Mac or linux (but I guess linux types learned proper regex scripting for vim already). If the title has “_by_” in the filename when it isn’t dividing an artist and title (or two other values you want to exchange), it will garble it. That is the only flag I chose, so be aware of the non-psychic nature of this program. If your filename raises that flag and has a file extension (.exe .gif) not equal to three letters, it will treat it to a procrustean turn down service. Failing those edge cases, it will work spectacularly.

No comments

May 27

Edutainmental Programming

I’ll write this before my interest dissipates. I completed the physics lab assignment early and headed to the library to leaf through Pomona’s (relatively) unlimited possibilities. A book about children and software for them came to hand as I noted the proportional representation in the computer languages section. Its chapter about youth programming intrigued enough to half-skim, half-read it, given the time before I had to return home.

 

Roughly two weeks ago, a friend, in the Java class that just ended, described his ambitious idea for a game. While an involved design challenge, it isn’t really my style. We spoke at length about it on Monday. While I value his friendship, I don’t feel attached to the project. Nevertheless, it further whetted my appetite for a new programming goal.

 

The study group that he and I belonged to entertained the idea of a collaborative package we could all work on, without hashing out any suggestions. Soon after, the group fractured because of schedule incompatibility and accreting members whose availability was even further at odds.

 

I would have suggested the boring – textbook inspired – option of a machine simulation, just to get us started. That way we would have clear responsibilities that we could rely on as we matched our stride. With trust built on that base, we could then tackle a more difficult task.

 

While a vending machine (and its customers/stockers) is the least offensive simulation, I would have backed a low level electronics emulator. The evolution of the robotics class I concurrently attended beyond basic electronics to controlling a boe-bot largely inspired that inclination. We could directly collaborate on the electricity class that the parts would inherit from, so we all understood it intimately. And then, go off and make a capacitor or resistor on our own, share them and unite all to make some basic circuit like a light switch or a ‘keypad entry’ system.

 

However, I had entertained a similar plan before then. At the close of the computer organization class last semester, I wished that the virtual machine we demonstrated certain concepts on embodied a computer more holistically. The Pep8 computer has two modes: an assembly running cpu and a microcode executing cpu.

 

Like the facebook user wishing for privacy from Facebook’s real clients, I longed for a simulator that would showcase many more levels. (ie something unworkable) Like an internet map, it ‘would’ zoom to the electric behavior of the wires within the logic gates that scale up to multiplexers and the ALU. These condense when looking at the microcode layer, and so on.

 

Of course, no one should expect to see such a program for some time because it flies in the face of one of the central concepts of the course: electrical computers of nontrivial potential are largely only possible because they are made of many layers that rely on an abstraction of the lower levels. For example, the operating system handles memory allocation in RAM and on the hard disk. While atari programmers performed every trick to eke out every advantage from their eight kilobytes, modern (desktop, not mobile) programmers somewhat get to assume infinite space and instant recall from memory.

 

The further problem to a total virtual machine comes from the disconnect between the software layer and hardware. The extrapolation from logic gates to a bank of RAM is mostly straightforward (spoiler, it relys on different principles), but there is a real transition between its expected behavior in electric terms and showing different ways for the operating system to allocate on it. I guess the solution might be like an internet map program using a layer to show the roads of an area and an overlay of the current traffic.

 

Which was background as I read the 1998 chapter/essay, “Making Programming Easier for Children,” in The Design of Children’s Technology. David Smith and Allen Cypher compared hypercard and Cocoa as tools for learning programming concepts. (After Apple hired Jobs, one of the restructuring decisions involved using the Cocoa trademark for a new framework and renaming the kid’s environment Stagecast Creator.)

 

They introduced the topic with a criticism of SimCity as an urban planning demonstration. While a player may zone out a city, sh’he has no control over the basic variables of the pollution output of roads. The game can’t simulate the difference between a hybrid only city and the two-stroke pit that is Marijipoor. Teaching pre-collegates requires a transparent engine so they can make a new game while altering its behavior to suit themselves.

 

The authors compared the transparency of a similar simulation included in both Hypercard and Cocoa: a train and track set. The hypercard version gravely disappointed the authors because of the sharp divide between its ‘gameplay’ that allowed a user to lay tracks but not include more than one locomotive so they could crash. They reproduced the available code that the locomotive uses to move forward to exhibit the steep chasm between its inflexibly simple interface and the game engine. As it was a language perched between C and pbasic, the syntax was a little ugly. Further, the majority of the code consisted of environment validation that obfuscated the real work going on. Ostentibly, the authors complained that there was no place to include a second locomotive; but, really, they reprinted it to demonstrate the difficulty a beginner would face in looking for a simple addition and the frailty if sh’he should change even a little of the code. The misdirection annoyed me because it was akin to looking in the pantry and complaining about missing coats when the real goal was to show me a disorganized pantry. In the end, Hypercard’s real sin was exposing complexity well beyond their target audience’s ability & offering them it as a toy.

 

Cocoa, on the other hand, uses a ‘visual’ programming language. To the authors’ delight, it even anticipated desires to crash locomotives together. Seriously though, the environment garnered their praise because it presented the concepts at a more appropriate level, and showed the more complex description in a sidebar before execution. I admit that I had to skim this section because of an impending departure. Still, they made their point clear, distinguishing data types and validating input are irrelevant to a person on day 1, especially when competing for the attention of a young adolescent. Better to let his’er first real language demand textual rigor and introduce general logical procedures now. I guess Pascal’s creators had that design goal when they made a toy language that isn’t suitable for advanced tasks. (Spoken only having seen that judgment and read some simple pascal programs without ever writing any.)

 

Which provoked internal discussion about what a children’s programming tool might consist of. Ideally, it would be like the computer simulation above: utilizing multiple layers of abstraction to support some game creation environment. That way, someone could place tiles to make a box pushing game, or whatever. That runs with a set of procedures built in the same way that the authors suggested Cocoa used to, perhaps for the AI? The next level involves modding the tileset, like Quake or Cortex Command let you do. Both those elements may be interpreted by an intermediate game engine that embodies a little bit more complexity for the youngster ready to tackle that layer. Finally, the real game engine/virtual machine is written in a commercial programming language since the student would presumably be ready.

 

While successive interpretive layers guarantee slow performance, the greatest problem I envision is described in Drawing on the Right Side of the Brain. Betty Edwards described a fulcrum point around middle school when boys and girls, who were priorly satisfied with their drawing ability, feel anxiety about their limitations. They can see people, but realizing that internal vision demands focusing on studying faces or hands past our lightning, yet sparse, recognition faculties. A number of people complained that inviting community content for Little Big Planet would flood the system with a bunch of boring levels. The problem isn’t that we aren’t imaginative, but that our execution falls far short of our ambition. (Plus, priming the pump plays a factor: my level will likely resemble one that I just finished playing.) Drawing savants, autistic or not, embody a potential in all of us, that unfortunately takes hours to realize for the ungodly.

 

That is a high bar for a game creation engine. Not only does it need to be transparent at all levels (conflicts with business practice so open source only), it needs to be powerful enough at each level that a player can make meaningful products without throwing them against a fifty page manual. That may be Alice’s selling point in the sense that the 3D environment removes a layer of cutsie-ness, but cuts out the next layer unless you are well versed with matrix transforms and their use in raytracing. Further, the SimCity and train crashing elements of the essay indirectly highlighted limitation as a tool. Sure, making a Cortex Command gun that rapes enemies and the terrain is fun for a few minutes, but quickly bores because it saps the challenge from the game. A good game designer must avoid putting such broken elements within a player’s grasp, for the player’s own good. But if a programming tool didn’t let me ruin the game, what good would it be? Conflict of interest.

 

Creating a package of programs that put me in the ballpark would be cool but take a while. In the meantime, I must quickly decide how to use this short vacation between quarters. The semester at SAC and SCC ended last week, hence the anachronistic ‘Monday’ in the second sentence at the beginning, and the Pomona quarter continues for another two weeks before resuming the week after for summer session. This gives me a solid month to, perhaps, learn a new programming language. I have a copy of Seven Languages in Seven Weeks, which sounds a little rushed. I would probably tackle Ruby and Haskell since the latter is a functional language and a great many people are blogging about Ruby. Lisp is another alternative since it represents the other archetypal programming paradigm. Or, I could push my C++/Java knowledge into deeper waters. The latter is particularly important since the Data Structures courses are taught using Java rather than C++. No need to rehash what I posted last time. Still, I think I can derive what I need rather easily and will test my intuition with a program I’ve been nagging myself to make since I learned about linked lists: a daily planner.

No comments

May 25

VM 0.1

Writing half a post about a transparent game engine to help beginners learn to program, in response to an old chapter on the subject, was the final straw to push me to implement a super basic computer simulator. Under the hood, it is ugly because it uses decimals rather than hex, immediate rather than indirect addressing, and still has some instruction bugs. Nevertheless, I’ll claim victories where I create them. This suite works with the severely constrained instruction set I decided upon. The program I included in ‘machine code’ counts up to a sentinel value and then crashes (to demonstrate a core dump).
In the future, I will put more safety in the loader and math operations. As mentioned, better addressing will free up some currently inconsistent logic. The biggest change will involve switching to hex and thence, to real bit comparison. In the farther future, I will use this as a theory testbed. Pushing it to a finer hardware simulation involves having the alu manipulate and compare those hex bits directly. A major change may involve simulating the microcode layer so that the only messages passed between the components are the clock and blind bits emitted by the cpu’s control section.
Running advance software represents the other direction. Machine code is not worth touching again, which demands a rudimentary compiler so I can use the equivalent of assembly/pbasic to program in. Of course, the only thing worth wasting time programming in assembly for this simulator is an operating system that can run several programs at once and fill the ram nicely. That would about wrap up the revival of my experience in Computer Architecture, albiet via tool construction.
So, for those of you with a java compiler and jvm, here are the class and source files, rar’ed.
By the way, it turns out that the Pomona data structures classes are taught in Java rather than C++, like at Santiago. The minor solace is that they don’t progress as far as trees, heaps or graphs. The correlary is that they have more practice than I with lists, stacks and queues. That isn’t too bad since I did utilize a queue (and abandoned a stack) in a java set/get class templater. Oh, I didn’t tell you about that? Well, here it is too.

No comments

Apr 15

IDE n’t know what to do

Category: Interpreted Glyphs

The Java professor has, from the beginning, encouraged us to build our programs in notepad and test them through the console. I know that netbeans and eclipse exist. I even futzed with the netbeans in the computer lab for an hour. Yet, this has been a novel experience for me since my school’s MSDN lisence has gifted me an elegant Visual Studio (henceforth VS).
Of course, Notepad++ had much better functionality over plain notepad with highlighting, block collapsing, macros, and imitative indentation. What neither text editor, plus the compiler, can give me is a glance at the local variables at runtime. As I progress, utilizing data structures taught concurrently in C++, this handicap presents more insistently. Putting in status outputs manually bores quickly. I may break down & research which IDE offers the fuctionality I want.
In writing this post, I noticed that Notepad++ has a file comparer. That could be useful. I idly consider the merits of version control, but VS requires I set up a team foundation server. That seems like overkill for my needs, but oh well. My peers should have access to VS as well, but it seems that some of the professors don’t set up accounts for their students.
Uploading my files to sourceforge, git, or some other source code repository would likely offer the lineage I seek. However, I don’t think that the toys I’m creating warrant a page since most everyone makes them at this stage in their education. Cortex Command’s mod community wasn’t really friendly to newbies since they overtly discouraged mods that didn’t prove new ground, meaning learning Lua since most of the obvious changes had been made in the earlier years of Cortex Command’s release. Granted, I doubt such is the case on sourceforge, but I can’t help view a potential submission from my projection of the ‘community.’

1 comment

Mar 21

Not caring

I have long considered that Utilitarians need a catalog of their own. They form their life schedule on the unfolding calculus of efficient effort, such that each effort benefits the maximum persons with minimum negative externalities for a reasonably long time-frame, et ctera et cetera. But, I need to invest a disproportionate amount of time researching the various charitable organizations for inadvertent waste and every disease to gauge its quantifiable suffering. Most utilitarians shouldn’t repeat this study redundantly ad nauseum (except perhaps as a Rite of Passage).
Better to have an NGO, with auditors, handle most of that so I, utilitarian with profit to dispose of, can send my money to [unicef], content in the knowledge that it will go to the most ethically effacious cause, organization, utile creation. Spoken thus, the catalog becomes obsolete as soon as the first one hits the street. When [unicef] gets its first hundred thousand, it automatically hits diminishing returns (perhaps only temporarily) that push it from spot 1 to 2 or further. Solution: a website run by said NGO that responds – in real time – to donations such that the top spot isn’t flooded to the paucity of the next top ten.
And that quieted that idea in me. Oh, perhaps some group could overcome the great difficulties and achieve such a status as The utilitarian arbitrage. Thankfully, I am no utilitarian and am at peace with the inequality of the world; obviously, because I benefit from it.
Time passes. I discern my preference for computer science. And throughout the field/industry, there is a reliance on abstraction to create managable complexity. No one would design a modern pc one resistor at a time. Better to organize them into logic gates, use the gates to create adders, join those into an ALU, and translate the design into a chemical fabrication plan once done. Abstraction is at the heart of ‘general’ scientific practice. I investigate native herbal remedy A by isolating the effect of single proteins it creates (abstracting the complex solution in each bite of the leaf). Then I bid a representative group to ingest it under controlled circumstances to abstract out only its physiological effect.
However, the introductions to abstraction’s value in the computer books I have read seem to prefer the example of driving a car. Namely, you wouldn’t want to need to know that the coefficient of friction of your rubber tires on various other materials (asphalt, mud, piles of zombies) every time you wanted to drive. That fails because we do need to know it, albiet intuitively. In mud, I take out a 2×4 so my tires don’t spin out.
The two came together as I watched the end of the 1978 miniseries Connections (which is badass, by the way). James Burke traces/narrates out the convoluted histories behind primary technologies: plastic that was petrol plus dye chemistry, that came from quinine research, which utilized ammonia which came from experiments with coal tar and gases, and so on backwards from the most innocuous developments hundreds of years ago. The last episode, on the other hand, had some review but mainly looked at how the viewers could view technological progress in light of what they had learnt.
For example, we could say ‘only research these subjects and nothing else,’ try to return to a low-tech society (albiet with insupportably many people), stop all research to concentrate on lifting all humans to our standard of living, or let things continue as they are. But, Burke notes, you are then – as before – caught in the grip of changes that will only buffet you by their symptoms. Further, could you possibly find time to research the consequences of say a local nuclear power plant or whatever. (Despite current controversy, this is his example and I’ll stick with it.) Sure, you may have an emotive reaction, but will you look at the projected cost and revenues bundle? Verify that study against the economic performance of the most recently built reactors or older ones over their entire lifetime?
Of course not, and he acknowledges this. That last episode was a bit of a disappointment – not because I disagree – but because he fully qualified the opinions and options explored and there were no clear solutions. All had their cost and he admitted that openly. Of course, here we survive thirty years later, not quite as dire as feared, but that is hindsight and tangential to my purpose.
In listening to him give his ultimate conclusion, that our most important ability is that to ask questions of the experts, for that is how they came to their position. And that gelled with a class of articles I generally ignore on google’s feedery. Namely, blog posts that describe or call for (government) transparency. “They can’t just offer us the data, it needs basic english explanations.” And that pulled it all together: environmentalists and the utilitarians who subsume them want to live without abstractions.
Consider the campaigns for no sweatshops or against conflict diamonds, or calculating a company’s carbon footprint, or comparing local, organic, and geneered agriculture. The (vocal) liberals want you to, effectively, use the utilitarian catalog. No starbucks because they don’t buy their coffee beans at US rates or whatever. If we had the catalog such decisions would be easy. I shop from [x], buy soy, not beef, from [y] for dinner which I cook on an electric stove, but not during peak energy use hours and so on. But, I, Nicholas, don’t know what x or y are and finding out involves a lot of work.
This constitutes one reason a number of people don’t take negative climate change seriously. Or, more accurately, why they object about the effacy of radically changing a huge number of subsidized, optimized behaviors. It’s not just hard, it involves front loading an inordinate amount of information before I can even assess how spartan I have to live for the sins of my culture. Sure, I could listen to this hippy, but who is he and how do I know he’s even done all the homework rather than just look at Haiti, Japan, and cleft lips before saying ‘enough.’
Once you start down this path though, you can’t say enough or you’ve opened yourself to the same dangers you’ve tried to mitigate. Fine, Bill Gates cures malaria by killing the mosquitos with lasers, except, there are no roads or water treatment so the kids still die of dysentary. Congratulations, Pyrrhus.
Further, finding out Everything will be hard because so many of our behaviors are subsidized. I attended a community college for a while that charged twenty six dollars per unit. Private, unsubsidized colleges cost as much as a nice sedan, annually. Further, this belies anyone’s expectation that companies ought conform to their ‘social ideal.’ Some complain that newspapers reprint pap and give only cursory analysis. They aren’t performing on their mandate: to provide unexpurgated knowlege about the deep issues of our world rather than stalking celebrities. Of course, that would only be the case if media literacy’s cheerleaders were newspapers’ primary customers. Instead, they, like Facebook, are in the business of attracting potential customers for advertisers who work for various businesses.
Consider this factor in media’s reduced audience, we grow up with all our media subsidized. Radio plays free music. TV is on 24/7 plus holidays. Local libraries ensure I can read just about any book for free. That commercials (and your parents’ bills) support the former two is irrelevant. They are just a distraction, easily ignored or silenced. Just keep Serenity for another season! Ratings are nice, but supporting your favorite show means buying old spice, a new lexus, or whoever is interrupting that delicate suspension of disbelief so rudely.
None of this constitutes a rejection of less abstraction in our dealings. Knowing that printer cartriges have internal expiration mechanisms to prevent clogging can alter my behavior. In that case, I may be a bit more profligate with what I print, to at least get a slightly better return on my investment. That’s nice, but to begin to approach the level of totalizing knowledge the greens or utilitarians demand is an expensive proposition. Consider mutual fund staff who collectively research the great majority of American companies for predictive cues. Analysts earn, on average, 60,000 dollars annually. Could an NGO assembling the catalog about the business practices of every corporation on the planet offer that? How much would a subscription to the catalog end up costing?
Could I hope to identify the best practices with as accurate detail on my free time? I largely disagree. For example, I wanted to find a book about the various trade routes utilized during the Renaissance. Sure, historical atlases offer a page or two on the subject. Historians’ analyses of various locales for selected years may present it, but are hard to find outside of university libraries (meaning expensive).
Martin Ford identified a social cost to transparency in the polarization of the political process. All anecdotes about the constitution’s creation begin with the shuttering of the windows during the hot Pennsylvanian summer so the delegates could hash out their political future. Given current scrutiny, the meeting would have been immediately hounded for its subversion of the ostensible purpose, to update the Articles of Confederation. And, rather than find a series of compromises between fifty five delegates, an explosion of lobbyists tut and glare with every word.
Ford explains this and many more harrowing and apt analyses in his book Lights in the Tunnel (free as pdf). Therein he analyzes the potential for automation to eliminate the majority of every job globally. Yes, even knowledge workers and service professionals. Remember Watson’s performance on Jeopardy? That sort of advanced search AI could one day identify all the legal precedents for your class action lawsuit, a task performed by teams of new law graduates.
Thankfully, he also identifies some mitigatory policies to stave off an economic collapse from automating out everyone’s customer base. Before seeing Watson’s performance, I’d have fobbed off his somewhat socialist alternative. (Tax capital intensive companies, like Hulu or Paramount Farms, for the workers they automate away for a direct redistribution to sustain consumption.) He rightly identifies companies that increase their profit in this manner do so by using the rest of the economy’s businesses to subsidize their demand. It is a queer experience to find myself nodding, because of the likely alternative, at conclusions my younger self would have revialed as counter-productive to business and human dignity. Time makes fools of us all down a two-way street.

No comments

Mar 19

Wasting cycles

The Java class I am currently attending is no challenge at all. The professor’s encroaching external problems worsen this as we are behind by three sessions. You wouldn’t know it though to look at his midterm. Which is a quibble because, as he clearly proved when we went over the answers, everything he asked about was in the chapters he asked us to read (albiet in the graphics sections). So despite his lowest common denominator lectures, it was my fault for letting that inure me to his expectation of a close reading. And so I’ll catch up this vacation week and surpass. Mark Twain had some relevant advice for just such an occasion.

The consequence to his nominally low expectations (reflected in the homework assigned) is tremendous boredom. To wit, chapter six deals with methods in Java. So, rather than assign something totally new, he requires we perform a huge number (100 each) of mutations to objects of a cone, sphere, and rectanglular prism. File streams are in chapter 17, so I’m guessing we are ‘supposed to’ print all these to the screen. That will quickly overwhelm the console’s height. Nevertheless, I finished the homework in the hour before the next class should have started (his third absence; not the due date either which is after break).

The form is trivial, for loops of varying depth alter each dimension by one, and output the volume. Looking at that rewritten code inspired my current self-assignment: accomplish all three with a single recursive function. There are better projects, in the book even, but this has seized me for the moment, so I’ll not resist. As there is no rush, I’ll come upon it slowly and feel like publishing the results here, in pseudocode.

To be clear of where all these are going, I plan to use a spartan object for all three geometric shapes to simplify the recursive functions. The alternative involves big switches that are aware of which solid class they are using as well as which element to change. I may sketch it out later, but it is tangential to my purpose of carving out a single recursive function to handle all three types of shapes.

public class Solid
{
. . . private int xDim, yDim, zDim;
. . . int shapeType;
. . . public Solid( int shapeWanted )
. . . {
. . . // I would really use an enum but I'm abstracting that out
. . . . . . shapeType = shapeWanted; // ie sphere 1 dim, cone 2 dim, or rect 3 dim
. . . }
. . . public setX; setY; setZ; setShapeType;
. . . public double getVolume( )
. . . {
. . . . . . switch ( shapeType )
. . . . . . case 1:
. . . . . . . . . return 4/3*pi*xDim^3 // xDim represents radius
. . . . . . case 2:
. . . . . . . . . return 1/3*pi*xDim^2*yDim; // xdim : radius :: yDim : height
. . . . . . case 3:
. . . . . . . . . return xDim*yDim*zDim;
. . . }
}

A recursive function to handle a single dimensioned object (sphere) is easy enough. I wrote it just to practice in anticipation of the more complex versions & as a reference.

public void generateVolumes( fileOut, sphere, xBig, xSmall )
{
. . . // or maybe I should instantiate the fileOut & solid in here?
. . . prepElements( xBig, xSmall );
. . . int xCounter = xBig;
. . . recurseSphere( fileOut, sphere, xBig, xSmall, xCounter );
}
private void prepElements( big, small )
{
. . . if big < small
. . . {
. . . . . . int swap = big
. . . . . . big = small
. . . . . . small = swap
. . . } // arithmetic solutions available for the space conscious
}

The format of those two won’t change except that I will check how many times to call prep elements and send in the x, then y, and z if applicable. That feels like an encroachment of the original structure, but I shouldn’t give up the checks since the parameter list for the final form may be pretty big and prone to entry errors.

public void recurseSphere( fileOut, sphere, xSmall, xCounter )
{
. . . if xCounter < xSmall
. . . . . . return
. . . solid.setX( xcounter )
. . . fileOut.println( xcounter, sphere.volume( ) );
. . . xCounter--;
. . . recurseSphere( fileOut, sphere, xBig, xSmall, xCounter );
}

Simple enough, but for the stack abuse, it might as well have been an iterative loop. One method of accomplishing the task would involve three separate recursive functions of that form that may or may not call on one another. I will do that a bit later as I pushed on when I sketched these out on paper. The next thing I wrote was a recursive function for the cone that lacks the capacity to revert to a single dimension. Nevertheless, seeing the structure informs the later versions that will.

recurseCone( solid, fileout, xSmall, xBig, xCounter, ySmall, yCounter )
{
. . . if yCounter < ySmall
. . . . . . return;
. . . else
. . . {
. . . . . . if xCounter < xSmall
. . . . . . {
. . . . . . . . . xcounter = xbig; // which is why I passed it in here and not above
. . . . . . . . . yCounter--;
. . . . . . . . . if yCounter >= ySmall
. . . . . . . . . {
. . . . . . . . . . . . solid.setY( yCounter );
. . . . . . . . . . . . recurseCone( solid, fileout, xSmall, xBig, xCounter, ySmall, yCounter );
. . . . . . . . . }
. . . . . . }
. . . . . . else
. . . . . . {
. . . . . . . . . solid.setX( xCounter );
. . . . . . . . . fileOut.println( xcounter, sphere.volume( ) );
. . . . . . . . . xCounter--;
. . . . . . . . . recurseCone( solid, fileout, xSmall, xBig, xCounter, ySmall, yCounter );
. . . . . . }
. . . }
}

Obviously, with a bit more checking, I could make a version that would accomplish the work of the three for loops that a rectangular prism requires. It would, nevertheless, lack the ability to restrict itself to solely working on a sphere or cone. Which isn’t quite true; I could make yBig & ySmall = 1 so it would only do one iteration. That feels somewhat like a copout but jives with my intuition about useless parameters in either case. Namely, unless I make different versions that take different numbers of parameters (returning to the original, redundant form) I will have to load in dummy values. At least, in this case, they are useful to a degree.

At this point, I had two options: design chained recursive functions like the former, or a single recursive function to handle all three. I chose chained recursives as it was easier. This involved updating generateVolumes:

public void generateVolumes( fileOut, shape, shapeType, x,y,zBig, x,y,zSmall )
{ // not in main so the function call is cleaner
. . . switch ( shapeType )
. . . {
. . . case 1
. . . . . . prepElements( xBig, xSmall );
. . . . . . int xCounter = xBig;
. . . . . . recurse1Dimension( fileOut, sphere, xSmall, xCounter );
. . . case 2
. . . . . . prepElements( x,yBig, x,ySmall );
. . . . . . int x,yCounter = x,yBig;
. . . . . . recurse2Dimensions( fileOut, sphere, xBig, x,ySmall, x,yCounter );
. . . case 3
. . . . . . // the same
. . . }
}
public void recurse2Dimensions( fileOut, sphere, xBig, x,ySmall, x,yCounter )
{
. . . if yCounter < ySmall
. . . . . . return;
. . . solid.setY( yCounter );
. . . xCounter = xBig;
. . . recurse1Dimension( fileOut, sphere, xSmall, xCounter );
. . . yCounter--;
. . . recurse2Dimensions( fileOut, sphere, xBig, x,ySmall, x,yCounter )
}

Recurse1Dimension is the same as recurseSphere above. Recurse3Dimensions would be almost the same as recurse2 so I won’t print it here. But, I looked at this and at recurseCone above. I was close to my stated goal. At the time, I hadn’t realized that using 1 for the unused parameters permitted the use of the recurseCone structure. Unlike generateVolumes above, they would be necessary lest the recursion end early. I could use a single function with three nested for loops – again specifying one iteration for the unused dimensions – but it would be no better.

Chained recursive functions appealed through their elegance. They do only the work they are supposed to & only spam the stack when they need to, namely for three dimensions, but only on the third dimension’s recursion. Mind, even with one hundred iterations, I wouldn’t be in danger of stack overflow. I have seen people push a recursive Fibonacci summation so high that it took the school desktops five realtime minutes to complete. (I forgot how big the parameter involved was; maybe 50 terms?)

At this point, I shall quickly turn these into syntactically correct Java and test them out. I’m missing the file printing class, but I’ll utilize the sample code from the website. Then I could email my results to two fellows in the class I studied with before the midterm as confirmation. Likely, neither has begun even though the task (with iterative loops) is so trivial. Perhaps the results could encourage them to start. Bragging rights constitute the second reason I chose this challenge. Had this code been a bit more obfuscated, I might have sent them the source, secure that they would not turn in what they would not have produced. Recursion is not a tool any of us keep close at hand.

No comments

Mar 5

Post, one month obsolete

Zynga has suckered me in yet again. I quit Vampire Wars when I had achieved all I set out to: get to the end of normal content. Technically, I hadn’t since, like Mafia Wars, Zynga hopes players will grind the same tired jobs through three levels of mastery. Perhaps they’ve added new areas, but I already play the much more complex – hence novel – Mafia Wars with a larger stable of aquaintances. One element of that complexity convinced me to try another zynga offering, Cafe World.
When Mafia Wars finally enabled the last item (animals) building device, Zynga created a promotion to encourage play for Cafe World and Frontierville. Completing a plant and harvest type task in either would net a consumable that any of the four item building devices could use to make a defense heavy, but stat boosting item. This forced a reassessment. Before the promotion, the menu of items involved staid, inflation-sensitive fare. For any of the four to produce a stat modifying item required nagging fellow players (or money or inhuman patience) for hundreds of consumables and then collecting enough normal and rare parts to build one. Golden-rulewise, I just stockpile the parts and nag slowly. The promotion, on the other hand, let me build one from each for just the cost of a short grind and wait.
Frontierville’s task involved removing a tree. They take a few days to grow and I left the game with a dense border of them. Here, I kept to strict business because it still sucks in every other fashion. Every quest involves some nagging for consumables plus a clickstorm. Cafe World (henceforth CW), on the other hand, involves the least clicking of any zynga game. The whole sits on a razor’s edge in that regard. Consider the promotion’s task: cook five cheesecakes (they mature in 12 hours).
I thought this easy money: I set them to cook before I go to bed & wake up to free skill points. Of course, a new player begins with three ovens & must level five times before the fifth drops. Better yet, the game is literally unplayable until one of your aquaintances (or someone on CW’s forum) befriends you through Cafe World. I had the marvelous luck that someone had sent be an invite that sat long ignored. Typical entry more likely involves scanning the list of your friends who played CW at some point and sending a plea. When someone agrees, sh’he can act as your waiter. Your avatar is only capable of cooking and putting dishes on a counter. Waiters, with more enabled during leveling, take the food to the customers’ tables. So, no friend, no service.
But that’s a momentary stumble on an arduous marathon, or so my computer tells me. Whenever I play for more than two minutes, Norton Antivirus informs me that Chrome is asking for all my cores. My laptop in Costa Mesa informs me via the kick in fan speed. This is because Zynga chose to have CW render a bunch of moving avatars in 3D. The basic set up is the same as Youville’s job: choose time delay and rewards, click to ‘add ingredients,’ return, harvest, and clean. 2D avatars would have been just fine. Instead, blocky tikes walk all about, serving, finding seats, gesturing at the ovens, or eating. Eating is a five second process of gesturing while the plate of food takes battle damage. And all the while, icons ping the server to update how much buzz or dough each fool gave me. In all it is the poster child of abusing Adobe’s vector engine.
These movements likely make up for the austerity of my own. I am level thirty two and I only have eleven stoves that need four actions each in a cycle. Eleven, in contrast with Farmville’s initial 144 farm plots and Frontierville’s initial 400(I think). Even Mafia Wars requires (offers) fifty or so hotspots to the new player, and I’ve been at this a month. Obviously, if I choose short return times – since they offer the best return in every measure if applied often enough – this number can skyrocket. But, that was also possible in Farmville or Frontierville to a degree. A ‘degree’ because those had daily action ceilings. Except for two ‘higher return’ devices (coffee machine & bar), there is no limit. A player can probably burn up his’er cpu with these gluttons scurrying around 24-7. (Which is almost possible without too much zoning out since the shortest maturity is three minutes.)
This wouldn’t accomplish much though, since CW is solipsist, as are Frontierville & Farmville. Your avatar’s prison must entertain you by itself or fail. Sure, you can visit aquaintance’s cells and leave a coin, but real work is done in the same box & it’s your job to spruce it up. Which is hard since anything more than cement and aged furniture is fantastically expensive. The cheapest table is 400c; cheap because we are certain to buy many over time. However, the cheapest door is 10,000c and less useful items (tapestries plants) that take up space only increase on that.
I felt particularly crowded by any size restarant as I wanted to feng shui my way into an optimal layout. Each customer has two timers, one to sit & one to be served. Should either expire without satisfaction, sh’he leaves. (CW isn’t quite solipsist: all your customers have your facebook friend’s names & avatars if sh’he has used CW.) After learning that each avatar eats alone, I saw the opportunity to code up a tool to generate the optimal layout with arbitrary sizes & numbers of ovens.
Normal experimentation rather than redundant simulation provided the answer: counters in the center, bounded by a ring of inward facing tables. This minimized the distances for the waiters and let me put the ovens at the corners of the room. Still later, I put them only on the lower walls despite some lost seating. Prepping a dish to cook generates progress bars & such which block any ovens one square north in either direction. This wouldn’t be a problem if your cook avatar weren’t afflicted with ADD such that it will grow bored after a few seconds & peel off its completed task to uselessly gesture in front of any other oven. With the ovens at opposite corners of the room, I often felt like tearing my hair out. (That’s a pic of mine.)
And so it continued for the duration of the promotion. Unlike for Frontierville, I found myself participating in CW specific tasks that didn’t earn me MW loot. Ostentibly this began so I could have five ovens to bake the five cakes, then ten ovens. But in the middle, there was a period of wanting to boost CW specific stats (buzz) or even make different, suboptimal dishes just for variety. (Just like Farmville, some fool made the initial three dishes in the top 5 most efficient. The other two drop around level 50.) The game was comfortingly easy, but without the sometime distraction of quests would have grown insufferably boring. Which is exactly what happened when Zynga silently cancelled the promotion.
I frantically searched the forums & found a ten page thread of alternate kvetching about the unheralded end and gloats that many would delete their CW accounts. (A dumb plan as zynga will inevitably hold another promotion that requires being at least level five, setting those fools back.) I tried baking a few more dishes out of nostalgia & let them rot because I don’t need CW. MW is more than enough wasted effort in strategy & gifting rosters. This demise is also why, despite writing the majority of this post (up to the ‘solipsist’ paragraph) exactly one month ago, I didn’t publish it.
In the meantime, MW has been a distraction. Surpassing my fears of exhaustion, zynga has kept a steady stream of overlapping events since before the year began. Some are missions (little quests mostly centered on nagging & fighting enough people); some gifting events. It is helpful because the alternative is to grind out enough money for all the required equipment in the youngest city and then grind for strong items for a while. I’ve done both before & those are dispassionate times. The loot grind will be particularly long now because, for some months, one of the free gifts has been 2 ‘hired guns’ with a daily limit of 10 received. Hired guns count toward the maximum gang size rather than requiring a facebook aquaintance to join your mafia. Earlier this week, I hit the cap: 500.
But so have many, many others. And so I idly wonder about what Mafia Wars looks like to new players. I recall that much slowly unlocks over the first fifteen levels and the cities in increments of thirty after that. Should a total newbie post in the forum sh’he could have a hundred friends in a shot since zynga rewards most highly for inducting or sustaining the lowest levels past the committment threshold. However, when fights start to offer opponents of double their level, a new player who didn’t look for a full rolodex will be met with a wall of opponents with gangs of several hundred, courtesy of the hired guns.

No comments

Feb 5

Yak shaving

Kinesis has totally won me over. I will use both keyboards until they wear out and then buy still more from them. My first was the Maxim version that swings outward from the center and can elevate as well. For my new computer, I bought the freestyle version which consists of two halves joined by a one foot cord. This is the way I need all my subsequent keyboards. My arms are totally at rest and using cheap keyboards is a nuisance I am amazed we collectively endure. (Lotto fantasy: $1000.)
Of course, the price is the general barrier to stronger penetration (laptop flexibility too). I have bought each used, which – like any other second hand good – isn’t actually sustaining the company whose product I value. Except, if my purchase funds the original purchaser’s next keyboard from them (I paid 3/4 of the retail price so I wouldn’t be surprised). Also, switching between these two is a bit jarring. The maxis’ tighter form isn’t the concern. Kinesis changed the layout of the extra keys between the two. The Maxis has enough space on the side to put the page up down and delete keys in a nice cluster. (The number pad is accessed with a function button and the keys centering on I.) The Freestyle, on the other hand, has a laptop style by arranging them in a row and putting the delete key at the very top. This would be a grave mark had they not put a small one on the left. This is in a cluster featuring more useful buttons like copy and paste.
Nevertheless, this idea is so good, I looked into crafting one of my own. It seems like it should be simple enough. My new computer came with a cheap keyboard I could carefully cut. The membrane that keyboard aficianados complain about should submit to a sharp knife. Unfortunately, I have seen video evidence corroborating my fear: the circuit board spans the whole surface. Granted, the board is printed on plastic sheets that can be cut more easily than a stiff printed circuit board. I knew I would have to solder and secure a bunch of wires, so I guess my disappointment is unwarranted. Oh well; I’ve put it on my someday/maybe list.
That comes from a cool book I’ve had my kindle read to me recently called Getting Things Done, by David Allen. I’ve made lists of goals and stuff before but I end up putting Everything on it: do homework for classes aBc, type blog posts, scan photo albums, consider a desklamp, practice juggling or tying knots, and youtube latin music education. (I know how to dance salsa, but can’t readily distinguish it from cumbias or merengue unless someone tells me.)
Allen suggests sorting all our obligations onto lists or focused stacks to dissuade ourselves from maintaining the list in our short term memory. Better to keep desires classified by contextual ability to accomplish the next step. For example, learning more about latin music goes into my someday/maybe pile with a bunch of other high flying ideas I can review in, say three months time to reevaluate my interest. At that point, I can promote them to a project or discard the idea entirely.
A project, in Allen’s estimation, is anything that requires more than two actions to accomplish (like scanning, but also the desklamp), niether of which takes less than two minutes. That is the lower threshhold for deferring an action. The project gets its own resource folder and a sheet with its name in a stack of project names. If they are few enough, a written list can work but most of us have a hundred or more hopeful outcomes by his estimation so it wouldn’t work out too well. Further, He suggests reviewing the lot on a weekly basis.
In the meantime, his devotee has a list – by context: while driving, at computer, on the internet, making calls – of the next concrete action to take for each project. In the case of consider a desklamp, that could be pricing one on the internet or measuring my desk’s thickness and calling my father about the measurements of the one in Costa Mesa that I’m not using. My call list has the number of the person I want to call as well as notes needed for the conversation so I can take care of them in one fell swoop. The point is to have a solid list of these so that when I’m done with one project’s action, I don’t need to review all the projects in play and then derive its next action and derive again before comparing the two or four I happen to remember (wondering if I forgot something more important).
I can’t tell you how amazing it is in practice because I’ve only implimented a rudimentary form of it and know there are things I haven’t sorted by his classification system. Still, it is nice to have this list of concrete actions to choose from or feel guilty about rather than an amorphous cloud that can’t stand against the time sink in front of me that won’t mean anything ten minutes afterward.
No comments

Next Page »