Quantcast
Channel: Hacker News 50
Viewing all 9433 articles
Browse latest View live

Top Science Longreads of 2013 – Phenomena: Not Exactly Rocket Science

$
0
0

Comments:" Top Science Longreads of 2013 – Phenomena: Not Exactly Rocket Science "

URL:http://phenomena.nationalgeographic.com/2013/12/23/top-science-longreads-of-2013/


I’m really optimistic about the future for long, deep, rich science reporting. There are more places that a publishing it, more ways of finding it, and a seemingly huge cadre of people who are writing it well. So without further ado, here’s a list of my top pieces of the year. It has blossomed to 15 from last year’s 12 because I was gripped by indecision and they’re all so good. In no particular order:

1)       Bones of Contention, by Paige Williams for the New Yorker. The curious case of USA v. One Tyrannosaurus Bataar Skeleton frames this exquisitely crafted tale about a Florida man’s trade in Mongolian dinosaurs, and the amazing world of fossils, auctions, and private collectors.

“He sold sloth claws, elephant jaws, wolf molars, dinosaur ribs—a wide range of anatomical fragments that went, mostly, for between ten and fifty dollars. Increasingly, Florida Fossils got into triple digits, especially when Prokopi started selling dinosaur parts. In the fall of 2011, he sold two Mongolian oviraptor nests for more than three hundred and fifty dollars each, a tyrannosaurus ileum for five hundred and sixty-one dollars, a tyrannosaurus tooth for three hundred and twenty-five dollars, and a tyrannosaurus tail vertebra for four hundred and ten dollars.”

2)       Imagining the Post-Antibiotics Future, by Maryn McKenna for Medium. The post-antibiotic world is much worse than you might imagine, and this sweeping piece takes us through the implications for medicine, agriculture & more.

““Many treatments require suppressing the immune system, to help destroy cancer or to keep a transplanted organ viable. That suppression makes people unusually vulnerable to infection. Antibiotics reduce the threat; without them, chemotherapy or radiation treatment would be as dangerous as the cancers they seek to cure… Similarly with transplantation. And severe burns are hugely susceptible to infection. Burn units would have a very, very difficult task keeping people alive.””

3)       Uprooted, by Virginia Hughes for Matter. An incredible story about how DNA testing is changing the way people look at their genealogy, and revealing that some people aren’t who they thought they were. (And a special shout-out to Hughes’ piece on Romanian orphans—it was very hard to choose between these.)

“Searching your genetic ancestry can certainly be fun: You can trace the migration patterns of 10,000-year-old ancestors, or discover whether a distant relative ruled a continent or rode on the Mayflower. But the technology can just as easily unearth more private acts—infidelities, sperm donations, adoptions—of more recent generations, including previously unknown behaviors of your grandparents, parents, and even spouses. Family secrets have never been so vulnerable.”

4)       The Social Life of Genes, by David Dobbs for Pacific Standard. A stunning piece about how our day-to-day lives quickly influence how our genes are deployed, and how cells are machines “for turning experience into biology”.

“Half were European honeybees, Apis mellifera ligustica, the sweet-tempered kind most beekeepers raise. The other half were ligustica’s genetically close cousins, Apis mellifera scutellata, the African strain better known as killer bees. Though the two subspecies are nearly indistinguishable, the latter defend territory far more aggressively. Kick a European honeybee hive and perhaps a hundred bees will attack you. Kick a killer bee hive and you may suffer a thousand stings or more. Two thousand will kill you.”

5)       A Race to Save the Orange by Altering Its DNA, by Amy Harmon for the New York Times. A nuanced and insightful piece that brings fresh light, and a lot of humanity, to the contentious issue of genetically modified crops.

“His quest to save the orange offers a close look at the daunting process of genetically modifying one well-loved organism — on a deadline… Only in recent months has he begun to face the full magnitude of the gap between what science can achieve and what society might accept.”

6)       The Short Happy Life of a Serengeti Lion, by David Quammen. Put yourself in a lion’s head with this rollicking tale of C-Boy, the Killers, and the brutal Serengeti.

“She sat in a Land Rover, 30 feet away, while three other males ganged up on C-Boy and tried to kill him. His struggle to survive against those daunting odds, dramatic in itself, reflected a larger truth about the Serengeti lion: Continual risk of death, even more than the ability to cause it, is what shapes the social behavior of this ferocious but ever jeopardized animal.”

7)       A Life-Or-Death Situation, by Robin Marantz Henig, for the New York Times. A moving and compassionate piece about end-of-life care.

“Suffering, suicide, euthanasia, a dignified death — these were subjects she had thought and written about for years, and now, suddenly, they turned unbearably personal. Alongside her physically ravaged husband, she would watch lofty ideas be trumped by reality — and would discover just how messy, raw and muddled the end of life can be.”

8)       Drive-Thru Astronomy, by Lee Billings for Aeon. Billings goes on a roadtrip through a scale model of the Solar System that spans the United States, and it’s a fantastic ride.

“McCartney half-jokingly asked if Pluto was still there. Its box is mounted at eye level, and the building is open to all comers, all day. McCartney said he had a half dozen ceramic dwarf planet replacements squirrelled away in a desk drawer for when the planet goes missing. I assured him that Pluto was in place. ‘Great. Call me when you’re at Uranus and I’ll meet you at Saturn,’ McCartney said, before hanging up abruptly.”

9)       The Case of the Missing Ancestor, by Jamie Shreeve for National Geographic. In 2011, we discovered a new group of ancient humans by sequencing DNA form a tiny bone chip. This amazing piece, which reads like a thriller, tells the story.

“Krause himself recalls that Friday as “scientifically the most exciting day of my life.” The tiny chip of a finger bone, it seemed, was not from a modern human at all. But it wasn’t from a Neanderthal either. It belonged to a new kind of human being, never before seen.”

10)   Omens, by Ross Andersen for Aeon. A beautiful essay on extinctions and the end of humans, suffused with gorgeous poetry.

“It’s a sad story from the dinosaurs’ perspective, but there is symmetry to it, for they too rose to power on the back of a mass extinction. One hundred and fifty million years before the asteroid struck, a supervolcanic surge killed off the large crurotarsans, a group that outcompeted the dinosaurs for aeons. Mass extinctions serve as guillotines and kingmakers both.”

11)   The Boy Whose Brain Could Unlock Autism, by Maia Szalavitz for Matter. This stunning piece looks at a neuroscientist’s quest to understand his autistic son, and the new “intense world” hypothesis of autism.

“Imagine being born into a world of bewildering, inescapable sensory overload, like a visitor from a much darker, calmer, quieter planet. Your mother’s eyes: a strobe light. Your father’s voice: a growling jackhammer. That cute little onesie everyone thinks is so soft? Sandpaper with diamond grit. And what about all that cooing and affection? A barrage of chaotic, indecipherable input, a cacophony of raw, unfilterable data.”

12)   Beyond recognition: the incredible story of a face transplant, by Katie Drummond for Verge. This thoughtful piece explores the science and ethics behind a mind-blowing new technology, and the hope it provides for victims of unbelievable tragedy.

“He said to me, ‘Isn’t this an amazing result?’” Dubernard recalls of the patchwork of skin grafts used to remodel Woods’ face. “And I told him, ‘Yes, this is good. But you know what? A face transplant would be better.’”

13)  Cows might fly, by Veronique Greenwood for Aeon. What begins with some quirky trivia about Swiss airlifted cows slowly reveals itself as a meditation on our environmental future in a world that’s running out of land. Relentless entertaining and fascinating.

From time to time, a hiker through the Swiss Alps might witness a startling sight. First, the sound of a helicopter reverberates off the valley walls. Then the chopper appears, a long cable hanging from its belly. When the burden at the end of the cable heaves into view, it is not a rescued mountaineer, en route to the hospital. Nor is it a pot of cement or a pallet of planks, on the way to a high-mountain building project. It is a single cow, hanging gently from a harness, her dark eyes alert, her hooves high above the ground.

14)   Bad Blood, by Will Storrfor Matter. This chronicle of the life and death of Russian dissident Alexander Litvinenko, and the poison that killed him, has won awards, and rightly so.

“As [uranium] throws out these chunks — cannonballs containing two protons and two neutrons, a combination known as an alpha particle — it cascades down the periodic table, transforming itself into a different element each time. Just before its arrival at lead-206, it becomes a substance called polonium-210. And it is at this point that the elements of science become the elements of murder.”

15)   The Spy Who Loved Frogs, by Brendan Borrell for Nature. A gripping piece about a young scientist must follow the jungle path of a herpetologist who led a secret double life.

“Before leaving for the Philippines as an undergraduate in 1992, Rafe Brown scoured his supervisor’s bookshelf to learn as much as he could about the creatures he might encounter. He flipped through a photocopy of a 1922 monograph by the prolific herpetologist Edward Taylor, and became mesmerized by a particular lizard, Ptychozoon intermedium, the Philippine parachute gecko. With marbled skin, webs between its toes and aerodynamic flaps along its body that allow it to glide down from the treetops, it was just about the strangest animal that Brown had ever seen.“

And finally…

Here are three of my own longreads from this year.

  • Ant Farm (Aeon), about how ants are killing Ghana’s coffee supply, how plant diseases could bring the world to its knees, and why we’re woefully unprepared to stop them.
  • The Power of Swarms (Wired), about the surprising, amazing science of herds, shoals, flocks, tumours, brains, and other collectives.
  • Dynasty (Nature), about Bob Paine: a man who changed science not just through his own work, but by inspiring a legacy of other scientists.

The Economist’s country of the year: Earth’s got talent | The Economist

$
0
0

Comments:"The Economist’s country of the year: Earth’s got talent | The Economist"

URL:http://www.economist.com/news/leaders/21591872-resilient-ireland-booming-south-sudan-tumultuous-turkey-our-country-year-earths-got


HUMAN life isn’t all bad, but it sometimes feels that way. Good news is no news: the headlines mostly tell of strife and bail-outs, failure and folly.

Yet, like every year, 2013 has witnessed glory as well as calamity. When the time comes for year-end accountings, both the accomplishments and the cock-ups tend to be judged the offspring of lone egomaniacs or saints, rather than the joint efforts that characterise most human endeavour. To redress the balance from the individual to the collective, and from gloom to cheer, The Economist has decided, for the first time, to nominate a country of the year.

But how to choose it? Readers might expect our materialistic outlook to point us to simple measures of economic performance, but they can be misleading. Focusing on GDP growth would lead us to opt for South Sudan, which will probably notch up a stonking 30% increase in 2013—more the consequence of a 55% drop the previous year, caused by the closure of its only oil pipeline as a result of its divorce from Sudan, than a reason for optimism about a troubled land. Or we might choose a nation that has endured economic trials and lived to tell the tale. Ireland has come through its bail-out and cuts with exemplary fortitude and calm; Estonia has the lowest level of debt in the European Union. But we worry that this econometric method would confirm the worst caricatures of us as flint-hearted number-crunchers; and not every triumph shows up in a country’s balance of payments.

Another problem is whether to evaluate governments or their people. In some cases their merits are inversely proportional: consider Ukraine, with its thuggish president, Viktor Yanukovych, and its plucky citizens, freezing for democracy in the streets of Kiev, even though nine years ago they went to the trouble of having a revolution to keep the same man out of office. Or remember Turkey, where tens of thousands protested against the creeping autocracy and Islamism of Recep Tayyip Erdogan, the prime minister-cum-sultan. Alas, neither movement has yet been all that successful.

Definitional questions creep in, too. One possible candidate, Somaliland, has kept both piracy and Islamic extremism at bay, yet on most reckonings it is not a country at all, rather a renegade province of Somalia—which has struggled to contain either. As well as countries yet to be, we might celebrate one that could soon disintegrate: the United Kingdom, which hasn’t fared too badly, all things considered, since coming into being in 1707, but could fracture in 2014 should the Scots be foolhardy enough to vote for secession.

And the winner is

When other publications conduct this sort of exercise, but for individuals, they generally reward impact rather than virtue. Thus they end up nominating the likes of Vladimir Putin, Ayatollah Khomeini or, in 1938, Adolf Hitler. Adapting that realpolitikal rationale, we might choose Bashar Assad’s Syria, from which millions of benighted refugees have now been scattered to freezing camps across the Levant. If we were swayed by influence per head of population, we might plump for the Senkaku (or Diaoyu) islands, the clutch of barren rocks in the East China Sea that have periodically threatened to incite a third world war—though that might imply their independence, leading both China and Japan to invade us. Alternatively, applying the Hippocratic principle to statecraft, we might suggest a country from which no reports of harm or excitement have emanated. Kiribati seems to have had a quiet year.

But the accomplishments that most deserve commendation, we think, are path-breaking reforms that do not merely improve a single nation but, if emulated, might benefit the world. Gay marriage is one such border-crossing policy, which has increased the global sum of human happiness at no financial cost. Several countries have implemented it in 2013—including Uruguay, which also, uniquely, passed a law to legalise and regulate the production, sale and consumption of cannabis. This is a change so obviously sensible, squeezing out the crooks and allowing the authorities to concentrate on graver crimes, that no other country has made it. If others followed suit, and other narcotics were included, the damage such drugs wreak on the world would be drastically reduced.

Better yet, the man at the top, President José Mujica, is admirably self-effacing. With unusual frankness for a politician, he referred to the new law as an experiment. He lives in a humble cottage, drives himself to work in a Volkswagen Beetle and flies economy class. Modest yet bold, liberal and fun-loving, Uruguay is our country of the year. ¡Felicitaciones!

Putting people first Ethnographic research: Facebook is basically dead and buried with UK teenagers

Dell UltraSharp 24 Ultra HD Monitor - UP2414Q

Emacs users are like Terry Pratchett’s Igors

$
0
0

Comments:"Emacs users are like Terry Pratchett’s Igors"

URL:http://chrisdone.com/posts/emacs-users-are-like-igor


By Chris Done

Within the constraints of the Emacs environment, there are no limits. Emacs is built upon this principle; the Lisp principle. Make some small kernel of features. A substrate. Take care to make this substrate programmable, and then build the system upon it. Let users worry about future features. Some 359,000 lines of C code comprise its kernel, and 1,637,000 lines of Emacs Lisp take the rest of it.

Similarly, the nature of The Lisp Curse is that what can be written to express any given problem is so arbitrary and free, that you are spoiled for choice, and every programmer re-invents solutions to the same problems, uncaring about sharing a common language with the world outside. The core problem is that Lisp makes programmers selfish. Giving programmers so much flexibility is inviting the alienation of other programmers; Lispers think: how can I express this problem best, for me?

That phenomenon is not a problem for Emacs. Work environments are a very personal thing. They exist to serve only one person: you. Me-me-me is a winning attitude when dealing with your environment. Maybe in the real world, out there, where you have to share programs with other people, where other people will see or even use your efforts, you have to care or take consideration about other people. Not in your environment. Not in your Emacs. It is your virtual home for at least nine hours of the day, every day.

My road to Emacs love developed slowly. I first came to it due to Common Lisp. I knew enough Lisp to get by, copy-pasting example snippets, configuring just enough to edit my environment. It felt a little bit barebones compared to the IDEs I’d used before it. Little did I know the world of functionality and configuration waiting beneath my feet.

Eventually I started patching some things here and there, writing my own hooks, little things like that. I used Emacs for a long time, just becoming proficient as a user with the keybindings and window management, before I ever wrote any Elisp. It hadn’t occured to me that writing any Elisp would ever be of interest to me. I would often shaft my .emacs configuration, and everything would break, and I wouldn’t quite know why.

Finally, I wrote my first mode. I think it was a mode for ASP. It wasn’t very good, and I didn’t fully understand everything that was going on. But it gave me some key insights. This thing isn’t just an editor, it’s really an environment all the way down. I can configure everything about this mode. And the mode consists of a bunch of functions and variables. It’s all code.

After that, it was really a sky-rocket of productivity. Eventually I would write Elisp casually in between programming on work projects. I would notice that a way of working was repetitive, or that Emacs behaved in a way I just didn’t quite like, or I simply thought of a nice thing that I could add. I’d happily spend anywhere from 30 seconds to half an hour writing some functionality to extend my editing facilities.

And it was extended for good. That amazed me, and still does. My problems are only problems for as long as I don’t notice them. Once I do, I write some Elisp to solve it, and then it’s never a problem again. In typical editors and IDEs, I simply wouldn’t even think of fixing such things, never mind actually putting my work to one side for a minute, solving them, and then going back to work again.

I’ve now written a lot of Elisp to support my development, especially with respect to Haskell. Many times, for many months at a time, over the years, I’ve been working on an experimental feature, or feature set, mode, what-have-you, and it’s been very spotty. Mostly working, but breaking a lot, interrupting my work, but with me persevering, pushing through, until that work becomes stable and quite robust through sheer usage and battle testing.

When working recently it occured to me that a lot of the functionality I depend on presently in Emacs for work is built upon my own work. I use the session/interactive-mode work for interacting with Cabal and GHCi, I use structured-haskell-mode in conjunction with that, and then atop that I use god-mode, my own Emacs input method. At one time or another in the past they have all been unusable, or flaky as hell. SHM still has a few growing pains, but is basically there.

This really reminds me of Terry Pratchett’s Igor clan. I discovered this amiable race in The Fifth Elephant. Igors are a people inspired from the typical hunchbacked Igor archetype, but in Discworld, they are also self-modifiers. Their bodies consist of mixed and matched and patched and swapped body parts among other members of their clan, of scars and self-adjustements. They are infinitely self-improving, self-experimenting. They might end up with a botched job and have to hobble around for a few days, but in the end it’s always fixable.

And they lisp.

© 2013-12-25 Chris Done <chrisdone@gmail.com>

Tools | Intel® Developer Zone

$
0
0

Comments:"Tools | Intel® Developer Zone"

URL:http://software.intel.com/en-us/html5/tools











The Intel® XDK

Intel® XDK, a no cost, integrated and front-to-back HTML5 app development environment for true cross-platform apps for multiple app stores, and form factor devices. Features in the first release included:

  • Editor, Device Emulator and Debugger
  • App for On-device Testing
  • Javascript UI library optimized for mobile
  • APIs for game developers with accelerated canvas
  • Prototype GUI quick-start wizard
  • Installs on Microsoft Windows*, Apple OS X*, runs in Google Chrome*
  • Intel cloud-based build system for most app stores
  • No need to download Native Platform SDKs
  • Tool to convert iOS* apps to HTML5


Cordova Friendly

In addition to support for the popular Apache Cordova* API, the Intel® XDK provides an extended API (the intel.xdk API) that includes features that are not currently available in the Cordova open source project. The Intel XDK includes:

  • Facebook* login API
  • Android* multi-touch
  • OAuth support
  • Enhanced audio
  • Accelerated canvas


Here’s what’s updated...

NEW App Framework UI jQuery plugin

  • Removes conflicts with App Framework
  • Enables jQuery to be used with App Framework UI
  • No need to port plugins or legacy code
Try the plugin


Read what other users are saying or provide feedback by visiting our forums. Topics include the following:

  • Intel® HTML5 Development Announcements
  • Getting Started
  • App Framework
  • App Game Interface
  • ... and more
Visit the HTML5 Forums

Write Your App

See how easy it is to create an attractive and responsive app using the Intel® XDK. The tool has a variety of different development paths to start your project.

Watch Now

Emulate, Debug and Test

Intel XDK makes it easy for developers to check the look and feel of their apps with on-screen emulation on a wide variety of devices. The App Tester allows you to test on a physical device.

Learn How


Build for App Stores

We've compiled everything you need. Free packaging service for HTML5 apps and Apache Cordova* apps, for Android*, Microsoft Windows*, Apple iOS*, Facebook*, Amazon Kindle*, and other App Stores.

Watch Now

Intel® XDK NEW Resources

Tutorials, resources, videos and documentation for previous releases of the XDK:






The 7 Habits of Highly Overrated People | DaedTech

$
0
0

Comments:"The 7 Habits of Highly Overrated People | DaedTech"

URL:http://www.daedtech.com/the-7-habits-of-highly-overrated-people


I remember having a discussion with a more tenured coworker, with the subject being the impending departure of another coworker. I said, “man, it’s going to be rough when he leaves, considering how much he’s done for us over the last several years.” The person I was talking to replied in a way that perplexed me. He said, “when you think about it, though, he really hasn’t done anything.” Ridiculous. I immediately objected and started my defense:

Well, in the last release, he worked on… that is, I think he was part of the team that did… or maybe it was… well, whatever, bad example. I know in the release before that, he was instrumental in… uh… that thing with the speed improvement stuff, I think. Wait, no, that was Bill. He did the… maybe that was two releases ago, when he… Holy crap, you’re right. He doesn’t do anything!

How did this happen? Meaning, how did I get this so wrong? Am I just an idiot? It could be, except that fails as an explanation for this particular case because the next day` I talked to someone who said, “boy, we’re sure going to miss him.” It seemed I was not alone in just assuming that this guy had been an instrumental cog in the work of the group when he had really, well, not been.

In the time that has passed since that incident, I’ve paid attention to people in groups and collaborating on projects. I’ve had occasion to do this as a team member and a team lead, as a boss and a line employee, as a consultant and as a team member collaborating with consultants, and just about everything else you can think of. And what I’ve observed is that this phenomenon is not a function of the people who have been fooled but the person doing the fooling. When you look at people who wind up being highly overrated, they share certain common habits.

If you too want to be highly overrated, read on. Being overrated can mean that you’re mediocre but people think that you’re great, or it can mean that you’re completely incompetent but nestle in somewhere and go unnoticed, doing, as Peter Gibbons in Office Space puts it, “just enough not to get fired.” The common facet is that there’s a sizable deficit between your actual value and your perceived value — you appear useful while actually being relatively useless. Here’s how.

1. “Overcommunicate”

I’m putting this term in quotes because it was common enough at one place I worked to earn a spot on a corporate BS Bingo card, but I’ve never heard it anywhere else. I don’t know exactly what people there meant by it, and for all I know, neither do they, so I’m going to reappropriate it here. If you want to seem productive without doing anything useful, then a great way to do so is to make lots of phone calls, send lots of emails, create lots of memos, etc.

A lot of people mistake activity for productivity, and you can capitalize on that. If you send one or two emails a day, summarizing what’s going on with a project in excruciating detail, people will start to think of you as that vaguely annoying person who has his fingers on the pulse all of the time. This is an even better strategy if you make the rounds, calling and talking to people to get status updates as to what they’re doing before sending an email.

Now, I know what you’re thinking — that might actually be productive. And, well, it might be, nominally so. But do you notice that you’ve got a very tangible plan of action here and there’s been no mention of what the project actually involves? A great way to appear useful without being useful is engage heavily in an activity completely orthogonal to the actual goal.

2. Be Bossy and Critical

Being an “overcommunicator” is a good start, but you can really drive your phantom value home by ordering people around and being hypercritical. If your daily (or hourly) status report is well received, just go ahead and start dropping instructions in for the team members. “We’re getting a little off schedule with our reporting, so Jim, it’d be great if you could coordinate with Barbara on some checks for report generation.” Having your finger on the pulse is one thing, but creating the pulse is a lot better. Now, you might wind up getting called out on this if you’re in no position of actual authority, but I bet you’d be surprised how infrequently this happens. Most people are conflict avoiders and reconcilers and you can use that to your advantage.

But if you do get called out (or even if you don’t), just get hypercritical. “Oh my God, Jim and Barbara, what is up with the reports! Am I going to have to take this on myself?!” Don’t worry about doing the actual work yourself — that’s not part of the plan. You’re just making it clear that you’re displeased and using a bit of shaming to get other people to do things. This shuts up people inclined to call you out on bossiness because they’re going to become sidetracked by getting defensive and demonstrating that they are, in fact, perfectly capable of doing the reports.

3. Shamelessly Self Promote

If a deluge of communication and orders and criticisms aren’t enough to convince people how instrumental you are, it never hurts just to tell them straight out. This is sort of like “fake it till you make it” but without the intention of getting to the part where you “make it.” Whenever you send out one of your frequent email digests, walk around and tell people what hard work it is putting together the digests and saying things like, “I’d rather be home with my family than staying until 10 PM putting those emails together, but you know how it is — we’ve all got to sacrifice.” Don’t worry, the 10:00 part is just a helpful ‘embellishment’ — you don’t actually need to do things to take credit for them (more on that later).

Similarly, if you are ever subject to any criticisms, just launch a blitzkrieg of things that you’ve done at your opponent and suggest that everyone can agree how awesome those things are. List every digest email you’ve sent over the last month, and mention the time you sent each one. By the fifth or sixth email, your critic will just give up out of sheer exasperation and agree that your performance has been impeccable.

4. Distract with Arguments about Minutiae

If you’re having trouble making the mental leap to finding good things about your performance to mention, you can always completely derail the discussion. If someone mentions that you haven’t checked in code in the last month, just point out that in the source control system you’re using, technically, “check in” is not the preferred verbiage. Rather, you “promote code.” The distinction may not seem important, but the importance is subtle. It really goes to the deeper philosophy of programming or, as some might call it, “the art of software engineering.” Now, when you’ve been doing this as long as I have, you’ll understand that code promotions… ha! You no longer have any idea what we were talking about!

This technique is not only effective for deflecting criticism but also for putting the brakes on policy changes that you don’t like and your peers getting credit for their accomplishments. Sure, Susan might have gotten a big feature in ahead of schedule, but a lot of her code is using a set of classes that some have argued should be deprecated, which means that it might not be as future-proof as it could. Oh, and you’ve run some time trials and feel like you could definitely shave a few nanoseconds off of the code that executes between the database read and the export to a flat file.

5. Time It So You Look Good (Or Everyone Else Looks Bad)

If you ever wind up in the unfortunate position of having to write some code, you can generally get out of it fairly easily. The most tried and true way is for the project to be delayed or abandoned, and you can do your part to make that happen while making it appear to be someone else’s fault. One great way to do that is to create a huge communication gap that appears to be everyone’s fault but yours.

Here’s what I mean. Let’s say that you’re working with Bill and Bill goes home every night at 6:00 PM. At 6:01, send Bill an email saying that you’re all set to get to work, but you just need the class stub from him to get started. Sucker. Now 15 hours are going to pass where he’s the bottleneck before he gets in at 9:00 the next morning and responds. If you’re lucky and you’ve buried him in digest emails, you might even get an extra hour or two.

If Bill wises to your game and stays a few extra minutes, start sending those emails at like 10:00 PM from home. After all, what’s it to you? It takes just as little effort not to work at 6:00 as it does at 10:00. Now, you’ve given up a few hours of response time, but you’re still sitting pretty at 11 hours or so, and you can now show people that you work pretty much around the clock and that if you’re going to be saddled with an idiot like Bill that waits 12 hours to get you critical information, you pretty much have to work around the clock.

6. Plan Excuses Ahead of Time

This is best explained with an example. Many years ago, I worked as lead on a project with an offshore consultant who was the Rembrandt of pre-planned excuses. This person’s job title was some variant of “Software Engineer” but I’m not sure I ever witnessed software or engineering even attempted. One morning I came in and messaged him to see if he’d made progress overnight on a task I’d set him to work on. He responded by asking if I’d seen his email from last night. I hadn’t, so I checked. It said, “the clock is wrong, and I can’t proceed — please advise.”

After a bit of back and forth, I came to realize that he was referring to the clock in the taskbar on his desktop. I asked him how this could possibly be relevant and what he told me was that he wasn’t sure how the clock being off might affect the long-running upload that was part of the task, and that since he wasn’t familiar with Slackware Linux, he didn’t know how to adjust the clock. I kid you not. A “software engineer” couldn’t figure out how to change the time on his computer and thought that this time being wrong would adversely affect an upload that in no way depended on any kind of timestamp or notion of time. That was his story, and he was sticking with it.

And it is actually perfect. It’s exasperating but unassailable. After all, he was a “complete expert in Windows and several different distributions of Linux,” but Slackware was something he hadn’t been trained in, so how could he possibly be expected to complete this impossible task without me giving him instructions? And, going back to number five, where had I been all night, anyway? Sleeping? Pff.

7. Take Credit in Non-Disprovable Ways

The flip side of pre-creating explanations for non-productivity so that you can sit back in a metaphorical hammock and be protected from accusations of laziness is to take credit inappropriately, but in ways that aren’t technically wrong. A good example of this might be to make sure to check in a few lines of code to a project that appears as though it will be successful so that your name automatically winds up on the roster of people at the release lunch. Once you’re at that lunch, no one can take that credit away from you.

But that’s a little on the nose and not overly subtle. After all, anyone looking can see that you added three lines of white space, and objective metrics are not your friends. Do subjective things. Offer a bunch of unsolicited advice to people and then later point out that you offered “leadership and mentoring.” When asked later at a post mortem (or deposition) whether you were a leader on the project, people will remember those moments and say, grudgingly and with annoyance, “yeah, I guess you could say that.” And, that’s all you’re after. If you’re making sure to self-promote as described in section three, all you really need here is a few people that won’t outright say that you’re lying when asked about your claims.

Is This Really For You?

Let me tell you something. If you’re thinking of doing these things, don’t. If you’re currently doing them, stop. I’m not saying this because you’ll be insufferable (though you will be) and I want to defend humanity from this sort of thing. I’m offering this as advice. Seriously. These things are a whole lot more transparent than the people who do them think they are, and acting like this is a guaranteed way to have a moment in life where you wonder why you’ve bounced around so much, having so much trouble with the people you work with.

A study I read once of the nature of generosity said that appearing generous conferred an evolutionary advantage. Apparently generous people were more likely to be the recipients of help during lean times. It also turned out that the best way to appear generous was actually to be generous since false displays of generosity were usually discovered and resulted in ostracism and a substantially worse outcome than even simply being miserly. It’s the same thing in the workplace with effort and competence. If you don’t like your work or find it overwhelming, then consider doing something else or finding an environment that’s more your speed rather than being manipulative or playing games. You and everyone around you will be better off in the end.

Sourcing


Haskell for all: Equational reasoning

$
0
0

Comments:"Haskell for all: Equational reasoning"

URL:http://www.haskellforall.com/2013/12/equational-reasoning.html


You may have heard that Haskell is "great for equational reasoning", but perhaps you didn't know precisely what that meant. This post will walk through an intermediate example of equational reasoning to show how you can interpret Haskell code by hand by applying substitutions as if your code were a mathematical expression. This process of interpreting code by substituting equals-for-equals is known as equational reasoning.


Equality

In Haskell, when you see a single equals sign it means that the left-hand and right-hand side are substitutable for each other both ways. For example, if you see:

x = 5

That means that wherever you see an x in your program, you can substitute it with a 5, and, vice versa, anywhere you see a 5 in your program you can substitute it with an x. Substitutions like these preserve the behavior of your program.

In fact, you can "run" your program just by repeatedly applying these substitutions until your program is just one giant main. To illustrate this, we will begin with the following program, which should print the number 1 three times:

import Control.Monad
main = replicateM_ 3 (print 1)

replicateM_ is a function that repeats an action a specified number of times. Its type when specialized to IO is:

replicateM_ :: Int -> IO () -> IO ()

The first argument is an Int specifying how many times to repeat the action and the second argument is the action we wish to repeat. In the above example, we specify that we wish to repeat the print 1 action three times.

But what if you don't believe me? What if you wanted to prove to yourself that it repeated the action three times? How would you prove that?


Use the source!

You can locate the source to Haskell functions using one of three tricks:

  • Use Hoogle, which can also search for functions by type signature

  • Use Hayoo!, which is like hoogle, but searches a larger package database and is more strict about matches

  • Use Google and search for "hackage <function>". This also works well for searching for packages.

Using either of those three tricks we would locate replicateM_here and then we can click the Source link to the right of it to view its definition, which I reproduce here:

replicateM_ n x = sequence_ (replicate n x)

The equals sign means that any time we see something of the form replicateM_ n x, we can substitute it with sequence_ (replicate n x), for any choice of n or x. For example, if we choose the following values for n and x:

n = 3
x = print 1

... then we obtain the following more specific equation:

replicateM_ 3 (print 1) = sequence_ (replicate 3 (print 1))

We will use this equation to replace our program's replicateM_ command with an equal program built from sequence and replicate:

main = sequence_ (replicate 3 (print 1))

The equation tells us that this substitution is safe and preserves the original behavior of our program.

Now, in order to simplify this further we must consult the definition of both replicate and sequence_. When in doubt which one to pick, always pick the outermost function because Haskell is lazy and evaluates everything from outside to in.

In this case, our outermost function is sequence_, defined here:

-- | Combine a list of actions into a single action
sequence_ :: [IO ()] -> IO () -- I've simplified the type
sequence_ ms = foldr (>>) (return ()) ms

We will substitute this into our main, noting that ms is replicate 3 (print 1) for the purpose of this substitution:

main = foldr (>>) (return ()) (replicate 3 (print 1))

Now foldr is our outermost function, so we'll consult the definition of foldr:

-- | 'foldr k z' replaces all `(:)`s with `k`
-- and replaces `[]` with `z`
foldr :: (a -> b -> b) -> b -> [a] -> b
foldr k z [] = z
foldr k z (x:xs) = k x (foldr k z xs)

Here we see two equations. Both equations work both ways, but we don't really know which equation to apply unless we know whether or not the third argument to foldr is an empty list or not. We must evaluate the call to replicate to see whether it will pass us an empty list or a non-empty list, so we consult the definition of replicate:

-- | Create a list containing `x` repeated `n` times
replicate :: Int -> a -> [a]
replicate n x = take n (repeat x)
-- Apply the substitution, using these values:
-- n = 3
-- x = print 1
main = foldr (>>) (return ()) (take 3 (repeat (print 1)))

Boy, this rabbit hole keeps getting deeper and deeper! However, we must persevere. Let's now consult the definition of take:

-- | Take the first `n` elements from a list
take :: Int -> [a] -> [a]
take n _ | n <= 0 = []
take _ [] = []
take n (x:xs) = x : take (n-1) xs

Here we see three equations. The first one has a predicate, saying that the equality is only valid if n is less than or equal to 0. In our case n is 3, so we skip that equation. However, we cannot distinguish which of the latter two equations to use unless we know whether repeat (print 1) produces an empty list or not, so we must consult the definition of repeat:

-- | `repeat x` creates an infinite list of `x`s
repeat :: a -> [a]
repeat x = x:repeat x -- Simplified from the real definition
-- Apply the substitution, using these values:
-- x = print 1
main = foldr (>>) (return ()) (take 3 (print 1:repeat (print 1)))

The buck stops here! Although repeat is infinitely recursive, we don't have to fully evaluate it. We can just evaluate it once and lazily defer the recursive call, since all we need to know for now is that the list has at least one value. This now provides us with enough information to select the third equation for take that requires a non-empty list as its argument:

take n (x:xs) = x : take (n-1) xs
-- Apply the substitution, using these values:
-- n = 3
-- x = print 1
-- xs = repeat (print 1)
main = foldr (>>) (return ()) (print 1:take 2 (repeat (print 1)))

Now we know for sure that foldr's third argument is a non-empty list, so we can select the second equation for foldr:

foldr k z (x:xs) = k x (foldr k z xs)
-- Apply the substitution, using these values:
-- k = (>>)
-- z = return ()
-- x = print 1
-- xs = take 2 (repeat (print 1))
main =
 (>>) (print 1)
 (foldr (>>) (return ()) (take 2 (repeat (print 1))))
-- Note: "(>>) x y" is the same thing as "x >> y"
main = print 1 >> foldr (>>)
 (return ())
 (take 2 (repeat (print 1)))
-- Note: "x >> y" is the same thing as "do { x; y }
main = do
 print 1
 foldr (>>) (return ()) (take 2 (repeat (print 1)))

Now our Haskell runtime knows enough information to realize that it needs to print a single 1. The language is smart and will execute the first print statement before further evaluating the call to foldr.

We can repeat this process two more times, cycling through evaluating repeat, take, and foldr, which emit two additional print commands:

-- Evaluate `repeat`
main = do
 print 1
 foldr (>>) (return ()) (take 2 (print 1:repeat (print 1)))
-- Evaluate `take`
main = do
 print 1
 foldr (>>) (return ()) (print 1:take 1 (repeat (print 1)))
-- Evaluate `foldr`
main = do
 print 1
 print 1
 foldr (>>) (return ()) (take 1 (repeat (print 1)))
-- Evaluate `repeat`
main = do
 print 1
 print 1
 foldr (>>) (return ()) (take 1 (print 1:repeat (print 1)))
-- Evaluate `take`
main = do
 print 1
 print 1
 foldr (>>) (return ()) (print 1:take 0 (repeat (print 1)))
-- Evaluate `foldr`
main = do
 print 1
 print 1
 print 1
 foldr (>>) (return ()) (take 0 (repeat (print 1)))

Now something different will happen. Let's revisit our definition of take:

take n _ | n <= 0 = []
take _ [] = []
take n (x:xs) = x : take (n-1) xs

This time the first equation matches, because n is now equal to 0. However, we also know the third equation will match because repeat will emit a new element. Whenever more than one equation matches Haskell takes the first one by default, so we use the first equation to substitute the call to take with an empty list:

main = do
 print 1
 print 1
 print 1
 foldr (>>) (return ()) []

This then triggers the first equation for foldr:

foldr k z [] = z
-- Therefore:
main = do
 print 1
 print 1
 print 1
 return ()

There it is! We've fully expanded out our use of replicateM_ to prove that it prints the number 1 three times. For reasons I won't go into, we can also remove the final return () and finish with:

main = do
 print 1
 print 1
 print 1

Equational reasoning - Part 1

Notice how Haskell has a very straightforward way to interpret all code: substitution. If you can substitute equals-for-equals then you can interpret a Haskell program on pen and paper. Substitution is the engine of application state.

Equally cool: we never needed to understand the language runtime to know what our code did. The Haskell language has a very limited role: ensure that substitution is valid and otherwise get out of our way.

Unlike imperative languages, there are no extra language statements such as for or break that we need to understand in order to interpret our code. Our printing "loop" that repeated three times was just a bunch of ordinary Haskell code. This is a common theme in Haskell: "language features" are usually ordinary libraries.

Also, had we tried the same pen-and-paper approach to interpreting an imperative language we would have had to keep track of temporary values somewhere in the margins while evaluating our program. In Haskell, all the "state" of our program resides within the expression we are evaluating, and in our case the "state" was the integer argument to take that we threaded through our subsitutions. Haskell code requires less context to understand than imperative code because Haskell expressions are self-contained.

We didn't need to be told to keep track of state. We just kept mindlessly applying substitution and perhaps realized after the fact that what we were doing was equivalent to a state machine. Indeed, state is implemented within the language just like everything else.


Proof reduction

Proving the behavior of our code was really tedious, and we're really interested in proving more generally reusable properties rather than deducing the behavior of specific, disposable programs. However, we spent a lot of effort to prove our last equation, so we want to pick our battles wisely and only spend time proving equations that we can reuse heavily.

So I will propose that we should only really bother to prove the following four equations in order to cover most common uses of replicateM_:

-- replicateM_ "distributes" over addition
replicateM_ 0 x = return ()
replicateM_ (m + n) x = replicateM_ m x >> replicateM_ n x
-- replicateM_ "distributes" over multiplication
replicateM_ 1 = id
replicateM_ (m * n) = replicateM_ m . replicateM_ n

The last two equations are written in a "point-free style" to emphasize that replicateM_ distributes in a different way over multiplication. If you expand those two equations out to a "point-ful style" you get:

replicateM_ (m * n) x = replicateM_ m (replicateM_ n x)
replicateM 1 x = x

If we could prove these equations, then we could much more easily deduce how replicateM_ behaves for our example program, because we could transform our code more rapidly like this:

replicateM_ 3 (print 1)
-- 3 = 1 + 1 + 1
= replicateM_ (1 + 1 + 1) (print 1)
-- replicateM_ distributes over addition
= do replicateM_ 1 (print 1)
 replicateM_ 1 (print 1)
 replicateM_ 1 (print 1)
-- replicateM_ 1 x = x
= do print 1
 print 1
 print 1

These four master equations are still very tedious to prove all in one go, but we can break this complex task into smaller bite-sized tasks. As a bonus, this divide-and-conquer approach will also produce several other useful and highly reusable equations along the way.

Let's begin by revisiting the definition of replicateM_:

replicateM_ n x = sequence_ (replicate n x)

Like many Haskell functions, replicateM_ is built from two smaller composable pieces: sequence_ and replicate. So perhaps we can also build our proofs from smaller and composable proofs about the individual behaviors of sequence_ and replicate.

Indeed, replicate possesses a set of properties that are remarkably similar to replicateM_:

-- replicate distributes over addition
replicate 0 x = []
replicate (m + n) x = replicate m x ++ replicate n x
-- replicate distributes over multiplication
replicate 1 = return
replicate (m * n) = replicate m <=< replicate n

Again, the last two equations can be expanded to a "point-ful" form:

-- `return x` is `[x]` for lists
replicate 1 x = [x]
-- `(<=<)` is like a point-free `concatMap` for lists
replicate (m * n) x = concatMap (replicate m) (replicate n x)

These four replicate equations are easier to prove than the corresponding replicateM_ equations. If we can somehow prove these simpler equations, then all we have to do is then prove that sequence_ lifts all of the replicate proofs into the equivalent replicateM_ proofs:

-- sequence_ lifts list concatenation to sequencing
sequence_ [] = return ()
sequence_ (xs ++ ys) = sequence_ xs >> sequence_ ys
-- (sequence_ .) lifts list functions to ordinary functions
sequence_ . return = id
sequence_ . (f <=< g) = (sequence_ . f) . (sequence_ . g)
-- Point-ful version of last two equations:
sequence_ [x] = x
sequence_ (concatMap f (g x)) = sequence_ (f (sequence_ (g x)))

It might not be obvious at first, but the above four equations for sequence_ suffice to transform the replicate proofs into the analogous replicateM_ proofs. For example, this is how we would prove the first replicateM_ equation in terms of the first replicate equation and the first sequence equation:

replicateM_ 0 x
-- Definition of `replicateM_`
= sequence_ (replicate 0 x)
-- replicate 0 x = []
= sequence_ []
-- sequence_ [] = return ()
= return ()

That was simple. It is only slightly more tricky to prove the second equation:

replicateM_ (m + n) x
-- Definition of `replicateM_`
= sequence_ (replicate (m + n) x)
-- replicate (m + n) x = replicate m x ++ replicate n x
= sequence_ (replicate m x ++ replicate n x)
-- sequence (xs ++ ys) = sequence xs >> sequence ys
= sequence_ (replicate m x) >> sequence_ (replicate n x)
-- Definition of `replicateM_`, in reverse!
= replicateM_ m x >> replicateM_ n x

Notice how the last step of the proof involves using the original replicateM_ equation, but instead substituting from right-to-left!

-- +-- We can substitute this way --+
-- | |
-- ^ v
replicateM_ n x = sequence_ (replicate n x)
-- ^ v
-- | |
-- +--------- Or this way! ---------+

This is a nice example of the utility of bidirectional substitution. We can replace the body of a function with the equivalent function call.

The third replicateM_ equation is also simple to prove in terms of the third replicate and sequence_ equations. I will use the point-ful forms of all these equations for simplicity:

replicateM_ 1 x
-- Definition of `replicateM_`
= sequence_ (replicate 1 x)
-- replicate 1 x = [x]
= sequence_ [x]
-- sequence_ [x] = x
= x

The fourth property is surprisingly short, too:

replicateM_ (m * n) x
-- Definition of `replicateM_`
= sequence_ (replicate (m * n) x)
-- replicate (m * n) x = concatMap (replicate m) (replicate n x)
= sequence_ (concatMap (replicate m) (replicate n x))
-- sequence_ (concatMap f (g x)) = sequence_ (f (sequence_ (g x)))
= sequence_ (replicate m (sequence_ (replicate n x)))
-- Definition of `replicateM_`, in reverse
= replicateM_ m (replicateM_ n x)

Equational reasoning - Part 2

We reduced our proofs of the replicateM_ properties to smaller proofs for replicate and sequence properties. The overhead of this proof reduction is tiny and we can gain the benefit of reusing proofs for replicate and sequence.

As programmers we try to reuse code when we program and the way we promote code reuse is to divide programs into smaller composable pieces that are more reusable. Likewise, we try to reuse proofs when we equationally reason about code and the way we encourage proof reuse is to divide larger proofs into smaller proofs using proof reduction. In the above example we reduced the four equations for replicateM_ into four equations for replicate and four equations for sequence_. These smaller equations are equally useful in their own right and they can be reused by other people as sub-proofs for their own proofs.

However, proof reuse also faces the same challenges as code reuse. When we break up code into smaller pieces sometimes we take things too far and create components we like to think are reusable but really aren't. Similarly, when we reduce proofs sometimes we pick sub-proofs that are worthless and only add more overhead to the entire proof process. How can we sift out the gold from the garbage?

I find that the most reusable proofs are functor laws of some sort. In fact, every single proof from the previous section was a functor law in disguise. To learn more about functor laws and how they arise everywhere you can read another post of mine about the functor design pattern.


Proof techniques

This section will walk through the complete proofs for the replicate equations to provide several worked examples and to also illustrate several useful proof tricks.

I deliberately write these proofs to be reasonably detailed and to skip as few steps as possible. In practice, though, proofs become much easier the more you equationally reason about code because you get better at taking larger steps.

Let's revisit the equations we wish to prove for replicate, in point-ful form:

replicate 0 x = []
replicate (m + n) x = replicate m x ++ replicate n x
replicate 1 x = [x]
replicate (m * n) x = concatMap (replicate m) (replicate n x)

... where concatMap is defined as:

concatMap :: [a] -> (a -> [b]) -> [b]
concatMap f = foldr ((++) . f) []

Now we must use the same equational reasoning skills we developed in the first section to prove all four of these equations.

The first equation is simple:

replicate 0 x
-- Definition of `replicate`
= take 0 (repeat x)
-- Definition of `take`
= []
-- Proof complete

The second equation is trickier:

replicate (m + n) x
-- Definition of `take`
= take (m + n) (repeat x)

We can't proceed further unless we know whether or not m + n is greater than 0. For simplicity we'll assume that m and n are non-negative.

We then do something analogous to "case analysis" on m, pretending it is like a Peano number. That means that m is either 0 or positive (i.e. greater than 0). We'll first prove our equation for the case where m equals 0:

-- Assume: m = 0
= take (0 + n) (repeat x)
-- 0 + n = n
= take n (repeat x)
-- Definition of `(++)`, in reverse
= [] ++ take n (repeat x)
-- Definition of `take`, in reverse
= take 0 (repeat x) ++ take n (repeat x)
-- m = 0
= take m (repeat x) ++ take n (repeat x)
-- Definition of `replicate`, in reverse
= replicate m x ++ replicate n x
-- Proof complete for m = 0

Then there is the second case, where m is positive, meaning that we can represent m as 1 plus some other non-negative number m':

-- Assume: m = 1 + m'
= take (1 + m' + n) (repeat x)
-- Definition of `repeat`
= take (1 + m' + n) (x:repeat x)
-- Definition of `take`
= x:take (m' + n) (repeat x)
-- Definition of `replicate` in reverse
= x:replicate (m' + n) x

Now we can use induction to reuse the original premise since m' is strictly smaller than m. Since we are assuming that m is non-negative this logical recursion is well-founded and guaranteed to eventually bottom out at the base case where m equals 0:

-- Induction: reuse the premise
= x:(replicate m' x ++ replicate n x)
-- Definition of `(++)`, in reverse
= (x:replicate m' x) ++ replicate n x
-- Definition of `replicate`
= (x:take m' (repeat x)) ++ replicate n x
-- Definition of `take`, in reverse
= take (1 + m') (repeat x) ++ replicate n x
-- Definition of `replicate`, in reverse
= replicate (1 + m') x ++ replicate n x
-- m = 1 + m', in reverse
= replicate m x ++ replicate n x
-- Proof complete for m = 1 + m'

This completes the proof for both cases so the proof is "total", meaning that we covered all possibilities. Actually, that's a lie because really rigorous Haskell proofs must account for the possibility of non-termination (a.k.a. "bottom"). However, I usually consider proofs that don't account for non-termination to be good enough for most practical purposes.

The third replicate law is very straightforward to prove:

replicate 1 x
-- Definition of `replicate`
= take 1 (repeat x)
-- Definition of `repeat`
= take 1 (x:repeat x)
-- Definition of `take`
= x:take 0 (repeat x)
-- Definition of `take`
= x:[]
-- [x] is syntactic sugar for `x:[]`
= [x]

The fourth equation for replicate also requires us to split our proof into two branches. Either n is zero or greater than zero. First we consider the case where n is zero:

replicate (m * n) x
-- Assume: n = 0
= replicate 0 x
-- replicate 0 x = []
= []
-- Definition of `foldr`, in reverse
= foldr ((++) . replicate m) [] []
-- Definition of `concatMap`, in reverse
= concatMap (replicate m) []
-- replicate 0 x = [], in reverse
= concatMap (replicate m) (replicate 0 x)
-- n = 0, in reverse
= concatMap (replicate m) (replicate n x)
-- Proof complete for n = 0

Then we consider the case where n is greater than zero:

replicate (m * n) x
-- Assume: n = 1 + n'
= replicate (m * (1 + n')) x
-- m * (1 + n') = m + m * n'
= replicate (m + m * n') x
-- replicate distributes over addition
= replicate m x ++ replicate (m * n') x
-- replicate (m * n) x = concatMap (replicate m) (replicate n x)
= replicate m x ++ concatMap (replicate m) (replicate n' x)
-- Definition of `concatMap`
= replicate m x ++ foldr ((++) . replicate m) [] (replicate n' x)
-- Definition of `foldr`, in reverse
= foldr ((++) . replicate m)) [] (x:replicate n' x)
-- Definition of `concatMap`, in reverse
= concatMap (replicate m) (x:replicate n' x)
-- Definition of `replicate`
= concatMap (replicate m) (x:take n' (repeat x))
-- Definition of `take`, in reverse
= concatMap (replicate m) (take (1 + n') (x:repeat x))
-- n = 1 + n', in reverse
= concatMap (replicate m) (take n (x:repeat x))
-- Definition of `repeat`, in reverse
= concatMap (replicate m) (take n (repeat x))
-- Definition of `replicate`, in reverse
= concatMap (replicate m) (replicate n x)
-- Proof complete for n = 1 + n'

Hopefully these proofs give an idea for the amount of effort involved to prove properties of moderate complexity. I omitted the final part of proving the sequence_ equations in the interest of space, but they make for a great exercise.


Equational Reasoning - Part 3

Reasoning about Haskell differs from reasoning about code in other languages. Traditionally, reasoning about code would require:

  • building a formal model of a program's algorithm,
  • reasoning about the behavior of the formal model using its axioms, and
  • proving that the program matches the model.

In a purely functional language like Haskell you formally reason about your code within the language itself. There is no need for a separate formal model because the code is already written as a bunch of formal equations. This is what people mean when they say that Haskell has strong ties to mathematics, because you can reason about Haskell code the same way you reason about mathematical equations.

This is why Haskell syntax for function definitions deviates from mainstream languages. All function definitions are just equalities, which is why Haskell is great for equational reasoning.

This post illustrated how equational reasoning in Haskell can scale to larger complexity through the use of proof reduction. A future post of mine will walk through a second tool for reducing proof complexity: type classes inspired by mathematics that come with associated type class laws.

Da Vinci's String Organ Must Be Heard To Be Believed : Deceptive Cadence : NPR

$
0
0

Comments:"Da Vinci's String Organ Must Be Heard To Be Believed : Deceptive Cadence : NPR"

URL:http://www.npr.org/blogs/deceptivecadence/2013/12/01/247543086/da-vinci-s-string-organ-must-be-heard-to-be-believed


hide captionPianist Slawomir Zubrzycki presents the "viola organista" on Oct. 18 in Krakow, Poland. Zubrzycki spent almost four years building the instrument, which is based on a late 15th-century design by Leonardo da Vinci.

Tomasz Wiech/AFP/Getty Images

Pianist Slawomir Zubrzycki presents the "viola organista" on Oct. 18 in Krakow, Poland. Zubrzycki spent almost four years building the instrument, which is based on a late 15th-century design by Leonardo da Vinci.

Tomasz Wiech/AFP/Getty Images

The man who painted the Mona Lisa, and was the first to sketch out the helicopter and the submarine, also dabbled in music. So here's the question: What musical instrument did Leonardo da Vinci design?

There isn't an easy answer. His 15th-century sketches indicate something between a harpsichord and a cello, where spinning wheels of horsehair run along the strings. He named it the "viola organista."

Leonardo never did build the instrument. Others tried, with varied results. Now, after four years, Polish pianist Slawomir Zubrzycki has managed to bring the curious instrument to life. Last month he unveiled the organista, revealing its unique sounds to an enthusiastic audience in Krakow, Poland.

"The drawing by Leonardo da Vinci that is the basis for this instrument," Zubrzycki recently told the AFP news agency, "is not a technical drawing. It does not contain all the necessary information. But it is more than enough to understand the concept of this instrument."

Bijou CSS Framework

BlogMask

$
0
0

Comments:"BlogMask"

URL:https://blogmask.herokuapp.com/posts/Mzg=/keyboards-ux-and-fuck


For those who didn't read the title, the following post contains profanity:

When Apple's iPhone came out in 2007, the auto-correct keyboard was a new typing experience for most people.  The software was ahead of its time in many ways, but also primitive in others.  It was understandable, then, that the keyboard would never suggest profanity.  Type "fuck", and the keyboard would suggest "duck".  It was always the safe bet to suggest something more appropriate, rather than accidentally insert something offensive into a user's text message.   Early iPhone users joked about the auto-correct mishaps, but it wasn't really a big issue.

In 2013, many people own their third, fourth, or even fifth post-iPhone smartphone.  Every half-decent touchscreen smartphone since 2007 has a touchscreen with an auto-correcting or predictive keyboard; the exception has become the rule.  But even today, I can't type "fuck", "shit", "asshole" or any adult language without the phone acting like I'm making up words.  My phone thinks I couldn't possibly want to say those things, how crass!  I'm not a clumsy smartphone newbie, I'm an adult and sometimes I want to say fuck.  It's about time that I had the option to turn on a full dictionary, even if it's just an opt-in setting for savvy users.  Even SwiftKey, the keyboard that claims to learn from the way I write, seems to magically look the other way every time I utter profanity.  The UX of Android and OS X has been optimized to the tiniest detail, but somehow this has been constantly overlooked.  So if you're out there reading this and you have any hand in making a mobile keyboard: let me curse already.  It's about fucking time.

jawb/JSVM · GitHub

Dogewallet hacked!

Untitled

$
0
0

Comments:"Untitled"

URL:http://www.scribd.com/vacuum?url=http://rbidocs.rbi.org.in/rdocs/PressRelease/PDFs/IEPR1261VC1213.pdf


 

 

पेस 

 

पकशनी 

 

PRESS RELEASE

 

संचार 

 

विभाग 

,

 

दय 

 

कयालय 

,

एस 

.

बी 

.

एस 

.

मरा

,

म    ुबई 

-

400001

  _____________________________________________________________________________________________________________________

DEPARTMENT OF COMMUNICATION

,

 

Central Office, S.B.S.Marg, Mumbai-400001

 

फोन 

/Phone:

91 22

 

2266 0502

 

स 

/Fax:

91 22

 

22660358

भारतीय 

 

रजिव

 

ब     ैक 

 

RESERVE BANK OF INDIA

 

वेबसइट 

 :

www.rbi.org.in/hindi Website : www.rbi.org.in

इ 

-

मेल 

 

email

:

December 24, 2013

RBI cautions users of Virtual Currencies against Risks

The Reserve Bank of India has today cautioned the users, holders and traders of Virtual currencies (VCs), including Bitcoins, about the potential financial, operational, legal, customer protection and security related risks that they are exposing themselves to. The Reserve Bank has mentioned that it has been looking at the

developments relating to certain electronic records claimed to be “Decentralised Digital Currency” or “Virtual Currency” (VCs), such as, Bitcoins, litecoins, bbqcoins,

dogecoins etc., their usage or trading in the country and the various media reports in this regard. The creation, trading or usage of VCs including Bitcoins, as a medium for payment are not authorised by any central bank or monetary authority. No regulatory approvals, registration or authorisation is stated to have been obtained by the entities concerned for carrying on such activities. As such, they may pose several risks to their users, including the following:

 

VCs being in digital form are stored in digital/electronic media that are called electronic wallets. Therefore, they are prone to losses arising out of hacking, loss of password, compromise of access credentials, malware attack etc. Since they are not created by or traded through any authorised central registry or agency, the loss of the e-wallet could result in the permanent loss of the VCs held in them.

 

Payments by VCs, such as Bitcoins, take place on a peer-to-peer basis without an authorised central agency which regulates such payments. As such, there is no established framework for recourse to customer problems / disputes / charge backs etc.

 

There is no underlying or backing of any asset for VCs. As such, their value seems to be a matter of speculation. Huge volatility in the value of VCs has been noticed in the recent past. Thus, the users are exposed to potential losses on account of such volatility in value.

 

It is reported that VCs, such as Bitcoins, are being traded on exchange platforms set up in various jurisdictions whose legal status is also unclear. Hence, the traders of VCs on such platforms are exposed to legal as well as financial risks.

 

There have been several media reports of the usage of VCs, including Bitcoins, for illicit and illegal activities in several jurisdictions. The absence of information of counterparties in such peer-to-peer anonymous/ pseudonymous systems could subject the users to unintentional breaches of anti-money laundering and combating the financing of terrorism (AML/CFT) laws.


Why I stopped using Spring » Thinking Inside a Bigger Box

$
0
0

Comments:"Why I stopped using Spring » Thinking Inside a Bigger Box"

URL:http://johannesbrodwall.com/2013/12/09/why-i-stopped-using-spring/


My post on DZone about Humble Architects sparked somewhat of a controversy, especially around my disparaging comments regarding Spring and Dependency Injection Frameworks. In this post, I expand on why I stopped using Spring.

I was one of the earliest adopter of Spring in Norway. We developed a large system where we eventually had to start thinking about things like different mechanisms for reuse of XML configuration. Eventually, this evolved into the @Autowire and component-scan which took away the problem with huge configuration files, but in return reduced the ability to reason about the whole source code – instead isolating developers in a very small island in the application.

The applications tended to blossom in complexity as either the culture, the tool, the documentation or something else made developers build unnecessary layer upon unnecessary layer.

Later, I tried to build applications without a Dependency Injection framework, but taking with me the lessons about when to use “new”, when to have a setter or a constructor argument and which types were good to use as dependencies and which created coupling to infrastructure.

So I found that some of the instincts that the DI container had given me made me improve the design, but at the same time, I found that when I removed the container, the solution became smaller (which is good!), easier to navigate and understand and easier to test.

This leaves me with a dilemma. I found that the cost of using the container is very high – it creates a force towards increasing complexity and size and reduced coherence. But at the same time, it taught me some good design skills as well.

In the end, creating a coherent, small system is to me of much higher value than to create one that is decoupled just for the sake of decoupling. Coherence and decoupling are opposing forces and I side with coherence.

At the same time, I found that the culture around dependency injection has a very strong preference for reuse. But reuse does introduce coupling. If module A reuses module B, module A and B are coupled. A change in B might affect A for better (a bug fix) or worse (an introduced bug). If the savings from the reuse are high, this is a trade-off worth making. If the savings are low – it is not.

So reuse and decoupling are opposing forces. I find myself siding with decoupling.

When there is a conflict, I value coherence over decoupling and decoupling over reuse. The culture where Spring is in use seems to have opposite values.


Why I stopped using Spring by Johannes Brodwall, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 3.0 Unported License.

Unenumerated: Bit gold

$
0
0

Comments:"Unenumerated: Bit gold"

URL:http://unenumerated.blogspot.co.uk/2005/12/bit-gold.html


A long time ago I hit upon the idea of bit gold. The problem, in a nutshell, is that our money currently depends on trust in a third party for its value. As many inflationary and hyperinflationary episodes during the 20th century demonstrated, this is not an ideal state of affairs. Similarly, private bank note issue, while it had various advantages as well as disadvantages, similarly depended on a trusted third party.

Precious metals and collectibles have an unforgeable scarcity due to the costliness of their creation. This once provided money the value of which was largely independent of any trusted third party. Precious metals have problems, however. It's too costly to assay metals repeatedly for common transactions. Thus a trusted third party (usually associated with a tax collector who accepted the coins as payment) was invoked to stamp a standard amount of the metal into a coin. Transporting large values of metal can be a rather insecure affair, as the British found when transporting gold across a U-boat infested Atlantic to Canada during World War I to support their gold standard. What's worse, you can't pay online with metal.

Thus, it would be very nice if there were a protocol whereby unforgeably costly bits could be created online with minimal dependence on trusted third parties, and then securely stored, transferred, and assayed with similar minimal trust. Bit gold.

My proposal for bit gold is based on computing a string of bits from a string of challenge bits, using functions called variously "client puzzle function," "proof of work function," or "secure benchmark function.". The resulting string of bits is the proof of work. Where a one-way function is prohibitively difficult to compute backwards, a secure benchmark function ideally comes with a specific cost, measured in compute cycles, to compute backwards.

Here are the main steps of the bit gold system that I envision:

(1) A public string of bits, the "challenge string," is created (see step 5).

(2) Alice on her computer generates the proof of work string from the challenge bits using a benchmark function.

(3) The proof of work is securely timestamped. This should work in a distributed fashion, with several different timestamp services so that no particular timestamp service need be substantially relied on.

(4) Alice adds the challenge string and the timestamped proof of work string to a distributed property title registryfor bit gold. Here, too, no single server is substantially relied on to properly operate the registry.

(5) The last-created string of bit gold provides the challenge bits for the next-created string.

(6) To verify that Alice is the owner of a particular string of bit gold, Bob checks the unforgeable chain of title in the bit gold title registry.

(7) To assay the value of a string of bit gold, Bob checks and verifies the challenge bits, the proof of work string, and the timestamp.

Note that Alice's control over her bit gold does not depend on her sole possession of the bits, but rather on her lead position in the unforgeable chain of title (chain of digital signatures) in the title registry.

All of this can be automated by software. The main limits to the security of the scheme are how well trust can be distributed in steps (3) and (4), and the problem of machine architecture which will be discussed below.

Hal Finney has implemented a variant of bit gold called RPOW (Reusable Proofs of Work). This relies on publishing the computer code for the "mint," which runs on a remote tamper-evident computer. The purchaser of of bit gold can then use remote attestation, which Finney calls the transparent server technique, to verify that a particular number of cycles were actually performed.

The main problem with all these schemes is that proof of work schemes depend on computer architecture, not just an abstract mathematics based on an abstract "compute cycle." (I wrote about this obscurely several years ago.) Thus, it might be possible to be a very low cost producer (by several orders of magnitude) and swamp the market with bit gold. However, since bit gold is timestamped, the time created as well as the mathematical difficulty of the work can be automatically proven. From this, it can usually be inferred what the cost of producing during that time period was.

Unlike fungible atoms of gold, but as with collector's items, a large supply during a given time period will drive down the value of those particular items. In this respect "bit gold" acts more like collector's items than like gold. However, the match between this ex post market and the auction determining the initial value might create a very substantial profit for the "bit gold miner" who invents and deploys an optimized computer architecture.

Thus, bit gold will not be fungible based on a simple function of, for example, the length of the string. Instead, to create fungible units dealers will have to combine different-valued pieces of bit gold into larger units of approximately equal value. This is analogous to what many commodity dealers do today to make commodity markets possible. Trust is still distributed because the estimated values of such bundles can be independently verified by many other parties in a largely or entirely automated fashion.

In summary, all money mankind has ever used has been insecure in one way or another. This insecurity has been manifested in a wide variety of ways, from counterfeiting to theft, but the most pernicious of which has probably been inflation. Bit gold may provide us with a money of unprecedented security from these dangers. The potential for initially hidden supply gluts due to hidden innovations in machine architecture is a potential flaw in bit gold, or at least an imperfection which the initial auctions and ex post exchanges of bit gold will have to address.

Google Destroys Rap Genius’ Search Rankings As Punishment For SEO Spam, But Resolution In Progress | TechCrunch

$
0
0

Comments:"Google Destroys Rap Genius’ Search Rankings As Punishment For SEO Spam, But Resolution In Progress | TechCrunch"

URL:http://techcrunch.com/2013/12/25/google-rap-genius/


Google hit back hard today after it learned lyrics site Rap Genius had been using dubious SEO tricks to attain top spots in search results. Now RapGenius.com doesn’t appear on the first page of results for a search of “Rap Genius,” and popular queries like “Jay-Z Holy Grail Lyrics” don’t bring up the startup like they used to. [Update: But the two companies are working on a resolution.]

Founded in 2009, Rap Genius is a lyrics and text annotation site. It lets users provide their own explanations for song lyrics, religious texts, legal documents, images, and more that other users see when they hover over snippets of text hosted on the site. The startup lept into the limelight when it received a massive $15 million investment led by Andreessen Horowitz in late 2012.

Known for their foul mouths and outrageous behavior, the Rap Genius founders had been riding high over the last year as their site climbed to prominent and lucrative slots in Google search results. For a sense of how ridiculous these guys are, check out our onstage talk at TechCrunch Disrupt NY where founder Mahbod Moghadam apologizes for telling Mark Zuckerberg to “suck his d*ck”.

Rap Genius Announces News Genius at Disrupt NY

But earlier this week, Rap Genius invited bloggers to join its “Rap Genius Blog Affiliate” program. John Marbach, the founder of email filtering startup Glider, emailed in asking for details, and Rap Genius offerered to tweet links to his blog in exchange for him placing a series of links to Rap Genius’ Justin Bieber lyrics on his blog. The links were designed to trick Google into giving Rap Genius better result rankings on searches for lyrics to songs from Bieber’s new album — sure to be popular searches this season.

Marbach then revealed Rap Genius’ unscrupulous tactics by publishing the email it sent him in a widely read blog post, prompting Google’s webspam czar Matt Cutts to announce on Hacker News, ”We’re investigating this now.” Rap Genius apologized in an open letter to Google, asking for the entire lyrics site category to be examined, implying shady SEO tactics were common amongst its competitors.

That apology doesn’t seem to have gotten it very far, as Google this morning practically swept Rap Genius out of its search results. Previously, Rap Genius was appearing at the top or close to the top of search results for queries of popular rap songs and the word “lyrics,” for example “Kanye West Flashing Lights Lyrics.” It would even sometimes appear high in simple searches for artist and song names.

Now, you won’t find Rap Genius for that query until the fifth page of results, likely further than anyone would look. For evidence of how serious the punshment is, adding “Rap Genius” to the end of that query actually makes Rap Genius appear even deeper down the results on the sixth page.

And just to make sure it was clear, Google banished RapGenius.com to the bottom of the sixth page of results of searches for “Rap Genius.”

Becoming practically unsearchable could be a huge hit to Rap Genius’ business, which depends on Google search referral traffic. Without that traffic, it will be much harder to grow its user base, collect new annotations, and potentially monetize with ads down the road.

Whether Google’s reaction was too tough is a matter of opinion. Gaming search results with spammy SEO tactics is certainly deplorable, but wiping Rap Genius off of top result pages for queries that include its own name is pretty harsh. Whether the startup deserves it or should get a lighter punishment depends on your perspective regarding the sanctity of Google search results. We’re awaiting a response from the Rap Genius founders, and have been promised a statement shortly.

Update: Rap Genius’ founders have provided this statement, indicating they’re working with Google on being returned to better search result rankings:

“We are working with Google right now to resolve this. They’ve been really great, helping us identify changes we need to make, even on Christmas. We’re working on it as fast as we can, and expect to be back on Google very soon. It sucks to be off Google for us and for the thousands of our community members who have worked so hard to create what’s often the best search result. We hope everyone who reads this will take a little time out from their Christmas and head to Rap Genius and sign up so you can contribute your knowledge on your favorite subjects – becoming a member of our community makes the site way more fun. Merry Christmas”

Looks like Rap Genius and Google might come to some compromise where Google restores at least some of the startup’s search result ranking juice in exchange for it cleaning up its act. However, at least some of the decreased visibility is likely to stick around for a long time, impeding Rap Genius’ business. We’ll have more details on the outcome of the talks as soon as possible and we are awaiting a response from Google.

For more on the never-ending insanity and adventures of Rap Genius, check out:

Disrupt On-Stage Video: Rap Genius’ Co-Founder Apologizes To Zuck (Then Says They’ll Be Bigger Than Facebook)

Video Interview: Ben Horowitz And The Founders Explain Why A16Z Put $15M Into Rap Genius

Rap Genius Is Getting Into Breaking News Analysis With News Genius

Rap Genius Reveals One Of Its Business Models Will Be ‘Enterprise Genius’ Collaborative Tool

As New Services Track Habits, the E-Books Are Reading You - NYTimes.com

$
0
0

Comments:"As New Services Track Habits, the E-Books Are Reading You - NYTimes.com"

URL:http://www.nytimes.com/2013/12/25/technology/as-new-services-track-habits-the-e-books-are-reading-you.html?hp&_r=0


Peter DaSilva for The New York Times

Scribd engineers, above, at work in San Francisco.

SAN FRANCISCO — Before the Internet, books were written — and published — blindly, hopefully. Sometimes they sold, usually they did not, but no one had a clue what readers did when they opened them up. Did they skip or skim? Slow down or speed up when the end was in sight? Linger over the sex scenes?

News from the technology industry, including start-ups, the Internet, enterprise and gadgets.
On Twitter: @nytimesbits.

Justin Bolle for The New York Times

Quinn Loftis, a writer of romances, interacts with readers on Facebook, Pinterest, Twitter, Goodreads, YouTube, Flickr and her website.

A wave of start-ups is using technology to answer these questions — and help writers give readers more of what they want. The companies get reading data from subscribers who, for a flat monthly fee, buy access to an array of titles, which they can read on a variety of devices. The idea is to do for books what Netflix did for movies and Spotify for music.

“Self-published writers are going to eat this up,” said Mark Coker, the chief executive of Smashwords, a large independent publisher. “Many seem to value their books more than their kids. They want anything that might help them reach more readers.”

Last week, Smashwords made a deal to put 225,000 books on Scribd, a digital library here that unveiled a reading subscription service in October. Many of Smashwords’ books are already on Oyster, a New York-based subscription start-up that also began in the fall.

The move to exploit reading data is one aspect of how consumer analytics is making its way into every corner of the culture. Amazon and Barnes & Noble already collect vast amounts of information from their e-readers but keep it proprietary. Now the start-ups — which also include Entitle, a North Carolina-based company — are hoping to profit by telling all.

“We’re going to be pretty open about sharing this data so people can use it to publish better books,” said Trip Adler, Scribd’s chief executive.

Quinn Loftis, a writer of young adult paranormal romances who lives in western Arkansas, interacts extensively with her fans on Facebook, Pinterest, Twitter, Goodreads, YouTube, Flickr and her own website. These efforts at community, most of which did not exist a decade ago, have already given the 33-year-old a six-figure annual income. But having actual data about how her books are being read would take her market research to the ultimate level.

“What writer would pass up the opportunity to peer into the reader’s mind?” she asked.

Scribd is just beginning to analyze the data from its subscribers. Some general insights: The longer a mystery novel is, the more likely readers are to jump to the end to see who done it. People are more likely to finish biographies than business titles, but a chapter of a yoga book is all they need. They speed through romances faster than religious titles, and erotica fastest of all.

At Oyster, a top book is “What Women Want,” promoted as a work that “brings you inside a woman’s head so you can learn how to blow her mind.” Everyone who starts it finishes it. On the other hand, Arthur M. Schlesinger Jr.’s “The Cycles of American History” blows no minds: fewer than 1 percent of the readers who start it get to the end.

Oyster data shows that readers are 25 percent more likely to finish books that are broken up into shorter chapters. That is an inevitable consequence of people reading in short sessions during the day on an iPhone.

A few writers might be repelled by too much knowledge. But others would be fascinated, as long as they retained control.

“Would we provide this data to an author? Absolutely,” said Chantal Restivo-Alessi, chief digital officer for HarperCollins Publishers. “But it is up to him how to write the book. The creative process is a mysterious process.”

The services say they will make the data anonymous so readers will not be identified. The privacy policies however are broad. “You are consenting to the collection, transfer, manipulation, storage, disclosure and other uses of your information,” Oyster tells new customers.

Before writers will broadly be able to use any data, the services must become viable by making deals with publishers to supply the books. Publishers, however, are suspicious of yet another disruption to their business. HarperCollins has signed up with Oyster and Scribd, but Penguin Random House and Simon & Schuster have thus far stayed away.

Some agents, too, are wary.

“It’s hard to tell authors that it’s worth starting a new relationship with any of these new services,” said Ted Weinstein, an agent in San Francisco. “It is literally an unsustainable business model.”

Here is how Scribd and Oyster work: Readers pay about $10 a month for a library of about 100,000 books from traditional presses. They can read as many books as they want.

“We love big readers,” said Eric Stromberg, Oyster’s chief executive. But Oyster, whose management includes two ex-Google engineers, cannot afford too many of them.

Article 31

Viewing all 9433 articles
Browse latest View live