The Design of Software is a Thing Apart - <AUTHOR> http://www.pathsensitive.com/2018/01/the-design-of-software-is-thing-apart.html <comment><USER2> > Those who speak of "self-documenting code" are missing something big: the > purpose of documentation is not just to describe how the system works today, > but also how it will work in the future and across many versions. And so > it's equally important what's not documented.

Documentation also (can) tell you _why_ the code is a certain way. The code itself can only answer "what" and "how" questions.

The simplest case to show this is a function with two possible implementations, one simple but buggy in a subtle way and one more complicated but correct. If you don't explain in documentation (e.g. comments) why you went the more complicated route, someone might come along and "simplify" things to incorrectness, and the _best_ case is they'll rediscover what you already knew in the first place, and fix their own mistake, wasting time in the process.

Some might claim unit tests will solve this, but I don't think that's true. All they can tell you is that something is wrong, they can't impart a solid understanding of _why_ it is wrong. They're just a fail-safe.

<comment><USER3> > Some might claim unit tests will solve this

Yes. Tests will solve this. Your point is perfect for tests.

If another experienced coder cannot comprehend from the tests why something is wrong, then improve the tests. Use any mix of literate programming, semantic names, domain driven design, test doubles, custom matchers, dependency injections, and the like.

If you can point to a specific example of your statement, i.e. a complex method that you feel can be explained in documentation yet not in tests, I'm happy to take a crack at writing the tests.

<comment> squeaky-clean Old and somewhat contrived example, but the first thing to pop into my head is the famous fast inverse square root function.

        float FastInvSqrt(float x) {
          float xhalf = 0.5f * x;
          int i = *(int*)&x;         // evil floating point bit level hacking
          i = 0x5f3759df - (i >> 1);  // what the fuck?
          x = *(float*)&i;
          x = x*(1.5f-(xhalf*x*x));
          return x;
        }

I can't think of a way to write a test that sufficiently explains "gets within a certain error margin of the correct answer yet is much much faster than the naive way."

The only way to test an expected input/output pair is to run the input through that function. If you test that, you're just testing that the function never changes. What if the magic number changed several times during development, do you recalculate all the tests?

You could create the tests to be within a certain tolerance of the number. Well how do you stop a programmer from replacing it with

        return 1.0/sqrt(x);

And then complaining when the game now runs at less than 1 frame per second?

Here's a commented version of the same function from betterexplained.com.

        float InvSqrt(float x){
            float xhalf = 0.5f * x;
            int i = *(int*)&x;            // store floating-point bits in integer
            i = 0x5f3759df - (i >> 1);    // initial guess for Newton's method
            x = *(float*)&i;              // convert new bits into float
            x = x*(1.5f - xhalf*x*x);     // One round of Newton's method
            return x;
        }

It's still very magic looking to me, but now I get vaguely that it's based on Newton's method and what each line is doing if I needed to modify them.

I actually just found this article [0] where someone is trying to find the original author of that function, and no one on the Quake 3 team can remember who wrote it, or why it was slightly different than other versions of the FastInvSqrt they had written.

> which actually is doing a floating point computation in integer - it took a > long time to figure out how and why this works, and I can't remember the > details anymore

This made me chuckle. The person eventually tracked down as closest to having written the original thing had to rederive how the function works the first time, and can't remember exactly how it works now.

I think the answer is both tests and documentation. Sometimes you do need both. Sometimes you don't, but the person after you will.

[0] [https://www.beyond3d.com/content/articles/8/](https://www.beyond3d.com/content/articles/8/)

<comment><USER4> Write a property based test, ie generate a bunch of random inputs, then assert that all of them are within some (loose) margin of error.

<comment> squeaky-clean This doesn't satisfy the time constraint though.

        return 1.0f / sqrt(x)

Passes a property based test but now your game doesn't actually run because it's much too slow of an operation on hardware at that time.

You can also test execution time too, but that's finicky and doesn't help explain how to fix it if you break that test (if there's no accompanying documentation).

<comment><USER5> But at this point all you're saying is "I can't think of a way of testing performance".

<comment><USER6> Performance can be tested in a unit test. You just need to measure the time needed to compute the function on a given set of numbers, then measure the time needed to compute 1.0f / sqrt(x) on the same set of numbers. The test succeed if your function is 10x faster. In future, the test may fail because sqrt has improved and this trick is no more needed.

</comment></comment></comment></comment></comment></comment></comment><comment><USER7> Peter Naur's "Programming as Theory Building" also addresses this topic of a "theory" which is built in tandem with a piece of software, in the minds of the programmers building it, without actually being a part of the software itself. Definitely worth a read: [http://pages.cs.wisc.edu/~remzi/Naur.pdf](http://pages.cs.wisc.edu/~remzi/Naur.pdf)

<comment><USER8> The biggest problem is when users of software, programmers of software, and the software code itself have 3 different incompatible theories of how it works.

Sometimes it gets worse still: you can have different theories according to (a) scientists doing basic research into physics or human perception/cognition, (b) computer science researchers inventing publishable papers/demos, (c) product managers or others making executive product decisions about what to implement, (d) low-level programmers doing the implementation, (e) user interface designers, (f) instructors and documentation authors, (h) marketers, (h) users of the software, and finally (i) the code itself.

Unless a critical proportion of the people in various stages of the process have a reasonable cross-disciplinary understanding and effective communication skills, models tend to diverge and software and its use go to shit.

<comment><USER9> This is why dogfooding is so important - you're updating the programmers' model to align with the users' model, reducing the total problem space (and thus the available avenues to get it wrong) by many degrees of freedom.

</comment></comment></comment><comment><USER10> I would love to see the pendulum swing back around to _good design_ again.

It matters more when designing libraries/frameworks than one-off apps.

Switching to a new framework/platform/language at the point the one you were on before finally matured enough that it was hard to ignore the need for good design doesn't actually help. you'll still be back eventually.

<comment><USER11> There have been articles over the last few years that have highlighted the dangers of idolizing and prioritizing innovation. I too hope for increased attention to craft and design of software in the future.

</comment></comment><comment><USER12> The OP doesn't seem to understand TDD:

"So you update the code, a test fails, and you think "'Oh. One of the details changed.'"

Some of the concerns they raise about writing tests are covered by Uncle Bob here: [http://blog.cleancoder.com/uncle- bob/2017/10/03/TestContrava...](http://blog.cleancoder.com/uncle- bob/2017/10/03/TestContravariance.html) and here: [http://blog.cleancoder.com/uncle- bob/2016/03/19/GivingUpOnTD...](http://blog.cleancoder.com/uncle- bob/2016/03/19/GivingUpOnTDD.html)

<comment><USER13> Good design is difficult. That's the easy to understand part. What is difficult for me to understand, why is this skill just ignored. There are lots of skills that are difficult, but people still persist on learning them. Not for software design. It-works-somehow-for-now seems to look good enough for the most. This also results in "OOD is difficult, FP will save us. Oh no, FP does not really save us, FRP for sure will". Sorry guys, you will need to break some eggs for omelette.

</comment></comment><comment><USER14> Seems to me there might be ways to program that convey more information. For example flow-based programming (FBP) seems like it might help and should help make the flow of the program explicit and obvious. That is, inherent to the code is a high level overview of what it does.

From my own limited experience it can make explaining a program to someone new almost trivial. You just use the various flows defined as almost visual guides to what is happening. I don't want to say FBP is a silver bullet, but I think it points to the idea that it is possible capture much more of the theory and design of the program in the code.

</comment><comment><USER15> We've increased our productivity by quite a lot over a five year period by ditching most testing on smaller applications.

Basically our philosophy is this: a small system like a booking system which gets designed with service-design, and developed by one guy won't really need to be altered much before it's end of life.

We document how it interfaces with our other systems, and the as-is + to-be parts of the business that it changes, but beyond that we basically build it to become obsolete.

The reason behind this was actually IoT. We've installed sensors in things like trash cans to tell us when they are full. Roads to tell us when they are freezing. Pressure wells to tell us where we have a leak (saves us millions each year btw). And stuff like that.

When we were doing this, our approach was "how do we maintain these things?". But the truth is, a municipal trash can has a shorter lifespan than the IoT censor, so we simply don't maintain them.

This got us thinking about our small scale software, which is typically web- apps, because we can't rightly install/manage 350 different programs on 7000 user PCs. Anyway, when we look at the lifespan of these, they don't last more than a few years before their tech and often their entire purpose is obsolete. They very often only serve a single or maybe two or three purposes, so if they fail it's blatantly obvious what went wrong.

So we've stopped worrying about things like automatic testing. It certainly makes sense on systems where "big" and "longevity" are things but it's also time consuming.

</comment><comment><USER16> _the information of a program's design is largely not present in its code_

And that's the problem. We need ways to make those higher level designs (~architecture) code.

<comment><USER17> This is the problem that I've run into trying to use formal methods.

I love them, I can express some things very concisely and even clearly. But there's no direct connection to the code and so keeping things synchronized (like keeping comments synchronized with code) is nigh impossible.

We need the details of these higher level models encoded in the language in a way that forces us to keep them synced. Type driven development seems like one possible route for this, and another is integrating the proof languages as is done with tools like Spark (for Ada).

This will reduce the speed of development, in some ways, but hopefully the improvement in reliability and the greater ability to communicate _purpose_ of code along with the code will also improve maintainability and offset the initial lost time.

And by keeping it optional (or parts of it optional) you can choose (has to be a concious choice) to take on the technical debt of not including the proofs or details in your code (like people who choose to leave out various testing methodologies today).

<comment><USER18> Gilad Bracha wandered off to work on progressively typed languages after he'd had enough of trying to fix Java's type system.

I think if it took something like JSdoc and have it more teeth you could do something like this in just about any of the dynamically typed languages.

<comment><USER16> Well, he also "wandered in" from doing optionally statically typed languages...see Strongtalk and Newspeak. :-)

</comment></comment></comment></comment><comment> Chiba-City This is a lovely article. Software is a possibly a) errant and b) misinterpreted operational semantics of some other semantic horizons of contractual or implicit expectations. Knuth's Literate Programming was onto something. We inhabit a world of word problems and even faulty realizations of rarer formal specifications. Claims concerning "phenomena in the world" drive maintenance and enhancement regimens.

<comment><USER18> Worse still, most of us walk around under the delusion that we know what we want while others can see it doesn't make us happy.

How do you get the product you want when you don't know what you want?

<comment><USER19> Just buy Apple. They know what you want.

<comment><USER20> You may be joking, but I think the way in which this is true explains Apple's success, even though they've generally released products that are less featureful and significantly more expensive than their competition.

</comment></comment></comment></comment><comment><USER21> 1 point by charlysl 21 minutes ago | edit | delete [-]

Wouldn't it be better to use data abstraction instead of abusing primitive types?

For instance dates are often abstracted as a Date type instead of directly manipulating a bare int or long, which can be used internally to encode a date.

So, age, which isn't an int conceptually (should age^3 be a legal operation on an age?), could be modelled with an Age type. This, on top of preventing nonsense operations, also allows automatic invariant checking (age > 0), and to encapsulate representation (for instance changing it from an int representing the current age to a date of birth).

</comment><comment><USER22> return x >= 'A';

Would be better than

return x >= ASCII_A;

surely. ASCII_A could be set incorrectly, or have a dumb type, and is more verbose anyway. By using the character directly, the code speaks its purpose.

<comment><USER23> > _ASCII_A could be set incorrectly, or have a dumb type, and is more verbose > anyway. By using the character directly, the code speaks its purpose._

I disagree. ASCII_A speaks it's purpose (we purposefully want an ASCII A stored here). And one can check the constant's definition, and immediately tell if it's correct. E.g.

      const ASCII_A = 'A' // correct

      const ASCII_A = 'E' // wrong

So:

      return x >= ASCII_A

tell us the intention of the code's author.

Whereas:

      return x >= 'A';

only tells us what the code does, which might nor might not be correct (and we have no way of knowing, without some other documentation).

So, by those two lines:

      const ASCII_A = 'E';
      (...)
      return x >= ASCII_A;

We know what the code is meant to do, AND that it does it wrongly (and thus, we know what to fix).

These line, on the other hand:

      return x >= 'A';

tells us nothing. Should it be 'A'? Should it be something else? We don't know.

<comment><USER24> return x >= "A"; // ascii A

Gets the whole message across in one line, as does using 65 with the comment.

<comment><USER22> (Ignoring the typo "A" != 'A')

return x >= 'A';

 _already and only means_ ascii A. Is there a C compiler anywhere where or likely in future where 'A' in C is NOT ascii A? The comment is redundant if correct, and could be wrong after an edit, so it has no value.

<comment><USER23> > _return x >= 'A'; already and only means ascii A._

See, here's where you are wrong.

      ASCII_A = "A"

      alphas = ["Α", "А", "Ꭺ", "ᗅ", "ꓮ", "A", "𐊠", "A", "𝐀", "𝖠", "𝙰", "𝚨", "𝝖"]

      for c in alphas:
          print c == ASCII_A

Output?

      False
      False
      False
      False
      False
      False
      False
      True
      False
      False
      False
      False
      False

Several of the numerous possible utf-8 alphas. Those are not A in different fonts -- they are different unicode characters that look like A. And depending on your font they could look absolutely the same as plain ascii a (of which only one towards the middle of the list is). And depending on your locale and keyboard language settings, one of them could be as easy to click as the regular english A in ASCII.

<comment><USER22> I deliberately used the character literal 'A' and not any of your UTF8 strings. I think you are mistaken to confuse a character with your strings. Is this wrong?

<comment><USER23> You can have a unicode character literal -- and depending on the language there's no distinction between character and string (at the type level), a character is just a string of length 1.

<comment><USER22> I was assuming C, where there is a difference.

int main() { printf( "%d %d\n", 'A', "A" ); return 0; }

produces: 65 197730221

since the value of string "A" is its base address.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER25> I wish websites wouldn't change the browsers default scrolling behavior

</comment><comment><USER26> I misread the title as "the design of software is a thing of the past". I welcome the actual title and content though.

</comment><comment><USER27> I lost interest after 'that is a fatal mistake'.

Fatal mistake? Really? An unrecoverable failure?

So, none of the software I've written in the last decade worked, despite all evidence to the contrary?

Right.</comment>


Ask HN: Can I make it in the Valley and live a well-rounded life? - <AUTHOR> This may seem like a strange question, but there may come a day where I have to decide whether or not to move from my quaint little tech hub of a city to The Valley (some opportunities have arisen, but I haven't yet accepted any). I enjoy software development. Got some good experience working at a vibrant startup. However, I am pretty skeptical about how well I would fit into (what I perceive to be) the Valley lifestyle. I like to spend my free time doing things like kayaking and rounding out my brain rather than hacking on side projects every evening. I enjoy a 40-50-hour work week and prefer a marathon to a sprint. Have I just fallen for a stereotypical representation of The Valley as a self-obsessed technology mecca filled with warrior-priests who live and breathe code 24/7, or is there more of a well-rounded atmosphere where I can still fit in without selling my soul to my career? <comment><USER2> I'm going to say something controversial, so take it with a grain of salt. I believe it depends significantly on the age/experience of the leaders (I'm 44 years old).

One thing that comes with experience is the realization that hours of startup work do not necessarily translate into results. At IndexTank I routinely averted multi-week efforts (saving lots of late night hacking) because I realized that their potential value to the company would have been marginal at best. It's true that there are times when a team needs to fix something ASAP, which may require 24-48 hours of near-constant work. However, this should not be the norm.

In the long run, having a team where everyone works insane hours leads to burnout, turnover, and monoculture (i.e. mostly twentysomethings without family commitments). A leadership team who can figure out that 500 hours of X is as valuable as 2000 hours of Y can yield the same results without unnecessary suffering.

<comment><USER3> I completely agree. I'm seeing an increasing amount of real evidence backing up skepticism over what I call the "cult of the 80 hour work week."

[http://dealbook.nytimes.com/2014/06/27/sleep-as-a- competitiv...](http://dealbook.nytimes.com/2014/06/27/sleep-as-a-competitive- advantage/?_php=true&_type=blogs&_r=0)

I think it's quantity vs. quality. There are times when a huge overtime crunch is needed or when something is "on fire" and has to be dealt with right now, but the data is showing that overwork, lack of sleep, and too much focus on only one thing results in a loss of higher-order mental capacities such as creativity and long-term thinking.

I've experienced this subjectively myself... doing the workaholic thing for more than month or two and literally being unable to remember what it was that I was really doing or why I was doing it. You basically degenerate into some kind of crank-out-the-next-thing automaton with no big picture thinking ability or vision.

I've also seen second hand what occurs when this happens to a company's leadership, and I think a lot of avoidable failure spirals originate this way. If you're not being successful you need to pivot, and that takes creativity and an ability to stand outside the box of what you're currently doing. Those mental abilities are the first to go in an overwork scenario.

Other negatives include depression, anxiety, and impulsive behavior. It was actually kind of scary. I had to give up the tech entrepreneur orbit for a while until I could re-center myself, and coming back to it now I consider it very important to avoid that trap.

Personally I think the cult of workaholism is more about machismo than real performance. There's this weird ego thing in a number of industries including tech where people brag about how many hours they work, how little they sleep, etc. It's stupid.

</comment></comment><comment><USER4> If you're a good engineer you can make it. These days there are so many wannabes trying to get into "startups" as a career move. They are encouraged and preyed upon by the bootcamps and the general anti-credentialist counter- culture that has come from Silicon Valley's roots. They are even founding companies and getting funding because there's so little places for capital to go these days everybody and their mother in the 1% is looking to become an angel investor since it seems perhaps a little less risky than rolling their dice with Goldman Sachs or whatever other shark wants to use them as a pawn at the top of the financial food chain.

But if you come out as a solid programmer with good technical sense and enough seasoning to figure out existing systems and work on them without introducing a maintenance nightmare down the line, that will be recognized and rewarded. If you are good at what you do and professional the only one who will look down their nose at you for working a solid 9-5 are fools and megalomaniacs—most of whom are destined to flame out spectacularly without ever having built anything of value.

</comment><comment><USER5> OF COURSE you can. but it's about choices. you must weed OUT the 60+ hr/week startups for the ones who work normal hours. this will eliminate some fun/great opportunities - BUT - it will NOT eliminate ALL great opportunities.

our startup's been a ~50hr/wk place for 2 years, built great product, and got acquired in January. we didn't make $19B, but we aren't complaining either.

from your priority set, which I personally agree with, you have plenty of options - but you'll have to be "on guard" for the manic places that think 70hrs is normal and the "only way" to be successful. pro tip - they are incorrect.

i do recommend coming up to SF over the peninsula though.... YMMV.

<comment><USER6> But, watch out! There is a constant exposure to these glorious tales of success and achievement and it will change anyone's mind and attitude. After sometime here, if you a have a little bit of ambition, you wouldn't mind these long working hours and you will also be trying hard to "make it" in the valley.

</comment></comment><comment><USER7> _> 'I enjoy a 40-50-hour work week and prefer a marathon to a sprint.'_

Is 40-50 hours a week the new casual? That's 9-12+ hours of work and/or adjacent things per weekday considering lunch and any sort of commute.

I've done everything from 40-70+ per week, for quarters at a time.

Personally, if I was being heavily recruited I'd be looking for 20-32 hours per week of consulting over a 40+ hour grind, preferably in a place without a high cost of living.

<comment><USER8> It has been my experience that Startups in the valley expect you to work for at least 10 hours per day, everyday.

For example last year I interviewed with a former YC company and they were saying that it's not uncommon for 90% of the team to still be in the office after 9:30pm.

Occasionally putting in long hours is a requirement of every job. I understand that, and in fact prefer to work late some times. But working past 9pm every night, never seeing your family, never doing anything with anyone outside of work? That's just absurd. Unfortunately that's the culture of the Valley.

<comment><USER9> Well, to put a finer point on it, the "culture of the Valley" sounds to me like poor management and disorganized development.

</comment></comment></comment><comment><USER10> I moved from the east coast to San Jose about 8 years ago. The adjustment for me was weird. I left a small town for the big city. I had to find things to do here that were easy for me back home.

What I discovered is that there are always places to hike, bike, walk, play basketball, social groups, tech circles you just need to find them.

I'm 37 (so 90 in Valley Years) and I share the same vision you described above. What worked for me was making sure I separated myself from my work. Make it appoint to get out and find the things I like to do and then dont make an excuse not to do them. Does that bug really need to be fixed tonight? Or can you fix it in the morning after some exercise, food, sleep and for me a clearer mind....

YMMV.

</comment><comment><USER11> At a later stage company (post A or B round) you will probably have a similar work-life balance than at your current gig. But if you are thinking about doing an early stage startup you should be prepared to "work" around the clock. Most of my friends working out here have to be available 24/7 and work well over 50hrs a week.

You will also most likely make more money outside of Silicon Valley by being able to save more of your take home pay.

</comment><comment><USER12> Everyone I know who works at Google has a well-rounded life.

Sure, they're nerds, so they enjoy "weird" stuff, but they are not workaholics.

Other companies in the Valley may be different. Other people may know workaholics at Google.

But my anecdotal evidence is that yes, people can make it in the Valley and live a well-rounded life.

</comment><comment><USER13> When I was younger and didn't had models of the world, my fist one was one of a workaholic - 10+ hours per day in the office; working weekdays. Everyone around me was following this model, so naturally, I thought the normal way is this. Thus was a financial audit company.

Then, I entered the other spectrum in a corporate structure company. Most of the people there didn't give much effort and just waited for the time to get to 5pm for then to leave home. The day was full with smoke breaks and coffee breaks.

When we (with friends) started a startup, 7 days a week was the norm. This quickly proved inefficient in the long term as people started resenting, not to mention long term thinking was missing and a lot of honest effort was a complete waste.

We're now into a normal work week model with the occasional up/down depending on the situation. But we got sufficient funding. Before we didn't and sometimes the pressure triggers a short-term mode where you want to grind as much as possible for the money-time-food you have available.

tl;dr - you are your own master and commander. You don't have to follow the "norm" but others may expect you to do so. In the end it's your choice.

@diego and @api summed up the benefits of a normal work time. Smart people value their rest. And, as you are probably aware - the best ideas usually come in the times when you are resting from work.

Free time has allowed me to get good at psychology, philosophy, sociology, marketing, critical thinking, martial arts, game design, have a decent fitness and endurance levels, social contacts with healthy people and so on resources, which I wound't have had of I was focusing only on work. Not to mention I would have probably go haywire.

Actually, without the knowledge of those fields, my overall suitability for business would be severely limited.

</comment><comment><USER14> There aren't many people with a lot of free time at small startups, especially in the early days. But more mature companies definitely let you find the right balance for you.

Though I've seen some people find a different balance: a couple years of intense work followed by lengthy sabbaticals to unwind.

</comment><comment><USER15> While there are exceptions, the majority of the valley is more the weekend biking, hiking, 40-50 hour a week with good work-life balance. There is a lot of stereotyping, which always has some grain of truth, but it is not the median.

</comment><comment><USER16> I'm going to guess that the answer depends a lot on the culture of the company; not every company in the valley is the same. I have a friend who's constantly talking about the 16 hour days she pulls at the office; in contrast, when my fiancee came out to visit for a few days my manager practically kicked me out of the office early so I could spend time with her.

</comment><comment><USER17> Don't believe everything you read. While there is definitely a valley culture, not every company is the same. For instance, we put a huge emphasis on _actual_ work/life balance. We've even posted proof: [https://www.runscope.com/jobs](https://www.runscope.com/jobs)

</comment><comment><USER18> I'd like to suggest thtat you can talk with the startup about the work hours first.It more accurate and objective.</comment>


The Best Magazine Articles of All Time - <AUTHOR> http://ace.mu.nu/archives/307970.php

<comment><AUTHOR> I find it interesting that nearly all the authors listed are primarily novelists.</comment>


CIA.vc service shutdown indefinetely - <AUTHOR> http://scanlime.org/2011/05/cia-vc-service-is-down-indefinitely/ The popular open source notification service has been surprisingly, and without warning shutdown. I know a lot of people who have come to rely on this server, I wonder if someone will pick up the project, or as the author is looking for, a new, modern service crops up. <comment><USER2> This is quite sad, I only started using this service quite recently.</comment>


Ask HN: Review QuoteSentinel, personalized stock price notifications - <AUTHOR> http://quotesentinel.com

<comment><USER2> I think it's a nice site, but I don't know why someone would pay for the feature.

\- Your motivating example is someone who wants to buy or sell a stock at a certain price threshold. Why wouldn't you just set a limit order or a stop- limit order? Both are available from virtually ever broker.

\- I don't see which exchanges you support. Is it just the NYSE and NASDAQ? Do you support European exchanges?

What would probably be helpful is if you created a way for me to specify some complex criteria about the time, price movement qualities, technical indicators, etc. For example, I could imagine being long MSFT at $25 and wanting an update if the price drops by more than $0.25 in less than 5 minutes and the DMI is less than 30. I believe some brokers actually offer this kind of algo trading already, though I'm not sure whether they also allow for only sending updates.

As a side note, if you offered an API of some sort and allowed me to specify a time (e.g., I want the closing price of the 9:30 bar) and you covered all major global markets/indices (I'm interested in HSI, DAX, FTSE, CAC, TOPIX, ASX), then I would probably be willing to pay $10 a month for that service if you had live prices. However, I imagine you would run into serious data licensing issues (if you're not already?).

<comment><AUTHOR> Tansey,

Thanks for the feedback. I will clarify that these are US equities.

The target market for now is somewhere around casual investors who invest themselves in the market generally, but less than professional customers that require exchange specificity.

I think the notion of complex filters is a good idea, but I am unlikely to get to it -- Including complex algo trading (or notifications based on those signals) becomes a monster project very quickly and suddenly trying to compete in the space of real Goliaths.

You hit the nail on the head though about "only sending updates". That's sort of exactly the service I needed a few months ago and couldn't find one I liked. Of course executions can be done with just stops and limits, but there have been times I've been filled after a news event and wished I had been there to insert the human decision making process between signal and trade.

</comment></comment><comment><AUTHOR> Clickable: <http://quotesentinel.com>

I'd prefer you look it through, but if you want to cut to the chase, log in using: username: email@example.com password: hn

or register for a free account: <https://quotesentinel.com/register/free>

Quote Sentinel lets users set prices of interest for US stocks, then sends SMS/email notification when that condition is met.

</comment><comment><USER3> As others have mentioned, you can already do this on Yahoo Finance for free. Notifo also allows you to set up free stock price alerts: <http://notifo.com/user/stockalerts>

It's certainly possible for you to do a better job than those services, but if you want me to pay, your site needs to explain exactly why you're better than them.

<comment><AUTHOR> Thanks Dirtae.

Correct me if I'm wrong, but my understanding is that it only serves iphone users (blackberry/android pending).

I suspect that iPhone (and generally smart phone) users will be less likely customers though, because its generally easier for them to check prices from their phone than for mobile users like me (no smart phone).

I certainly can't expect to be able to serve everyone who wants stock information. But I was right in my target market, so I'm crossing my fingers that there are others as well.

</comment></comment><comment><USER4> Something strange (my point of view), the pricing page listing is from high to low. imho this should be the reverse.

Also, you are not telling (I haven't found the info) if your source is a realtime provider, or not, (nor whom). I think this is very important..

Good luck with your service and congratulations for the launch.

</comment><comment><USER5> I've been looking for a realtime quote API that's good and affordable. What service are you using?

</comment><comment><USER6> It seems that HN is not the target audience for this. The folks here probably need much more sophisticated tools and likely build those tools themselves.

Who is this intended for?

</comment><comment><USER7> Very clean and polished site, well done.

It would be great to be able to see the full name of the stock, currency and last update time.

</comment><comment><USER8> yahoo finance already does this for free, as do many brokerages. what's your competitive advantage?

<comment><AUTHOR> Good question brosephius.

I was not/am not aware that yahoo finance and other brokerages do it for free. Didn't find it immediately with a quick Google search either, so I'd appreciate the link (though I found another site that is new to me and seems to provide similar service)

At the time I wrote it, I couldn't find other instances of this service online.

I could constantly poll stock prices on my phone to see if my price points had been reached, but what I wanted was to not have to pay attention and be notified when an event occurred.

<comment><USER9> You can setup Yahoo stock alerts from here:

<http://alerts.yahoo.com/st_watch_editalert.php>

But anyone that's going to take action on these types of alerts likely already has a brokerage account with more-advanced alerting capabilities.

<comment><AUTHOR> whoa, +1 uptown. i'm sort of bummed that I didn't know about that before. Seems like I should have found that.

1\. Have you used this (and did it work)? I just tried registering an alert and I never got the notification from yahoo, despite the fact that the alert condition was met. I was also able to set an alert to get notified when SPY fell to $500 (currently trading 108.70). I also got a 404 in the 3rd step of the phone registration process, but it somehow saved the number anyways.

2\. I got a 404 in step 3 when i registered my cell phone to receive alerts.

I guess I'm trying to figure out if this service is still operated at all by yahoo. Of course, it could be equally damning if yahoo decided that its not worth supporting and just nexted the product.

Regarding brokerages offering alert capabilities: I'd be interested in finding out more. I use Interactive Brokers personally and Quote Sentinel was originally actually a python script hooked up to the IB api.

Obviously trying to monetize a service that is being offered for free by many more established parties isn't the smartest idea... Can't really make excuses for why I didn't find that earlier though (functional or not).

<comment><USER9> I have no idea whether they maintain it or not, though it's linked to from every company's summary page within Yahoo! Finance right underneath the chart. E*Trade offers a similar feature, and I do use that one.

At the very least, I guess you've found that the Yahoo! product isn't the best ... so perhaps there's a market for your product. Something else you may be interested in is the Google Finance spreadsheet features.

[http://docs.google.com/support/bin/answer.py?hl=en&answe...](http://docs.google.com/support/bin/answer.py?hl=en&answer=54198)

Not sure whether there's a way you could add a hook to send an alert when certain prices are met, but their in-spreadsheet stock prices are pretty slick and very easy to use. Probably not something you could resell, but for personal use, it's a good tool.

</comment></comment></comment></comment></comment><comment><USER10> Umm, stop orders?

<comment><AUTHOR> I think you're hinting that the existence of stop orders make this unnecessary. For some people that may be true.

Quote Sentinel only notifies you -- at the time the first Quote Sentinel script was written, I couldn't find something that would send me a text message when my limit was about to be triggered.

Basically I personally had 2 main use cases:

1\. I want to go to lunch and I want to be notified if something is happening and I should come back to my desk.

2\. Markets are dynamic. Today I'd love to buy AAPL 10 bucks lower than it is, but if the market drops like a rock, it might not seem that great anymore. For big moves, I'd rather be notified so I can make a decision with the new information instead of my limit/stop getting filled based on what I thought was a good idea before.

Its definitely not an app for everyone, but it solved a specific need for me so I thought it'd be worth turning it into an app for others.

<comment><USER11> One thing I've always wanted is a view of the world that's beta-adjusted.

"Stock is up 7%, but down 1% if you factor in correlation to SPX"</comment></comment></comment>


What Grain Is Doing To Your Brain - <AUTHOR> http://www.forbes.com/sites/nextavenue/2013/11/14/what-grain-is-doing-to-your-brain/

<comment><USER2> My wife went gluten free and sugar free about 18months ago. That's led to losing 30 lbs, reduced incidence of numbness in the extremities (residual effect of west Nile) & heart murmurs. In addition she seems to be functioning at a higher cognitive level. She has suddenly taken a huge interest in reading and has written over 300,000 words of a series of novels. She is negative for celiac or any food allergies.

I go on and off gluten free and I'm starting to realize that while the effects are less profound for me, I do better without grain (we do eat a lot of oats).

The business of eating exclusively meat and dairy is due to ignorance. You should be eating large quantities of vegetables, particularly leafy greens. The hardest part of changing your diet is re-learning how to eat.

OTOH I find the historical perspective somewhat suspect. If you believe Jared Diamond, grain led to the rise of civilization. I think that it's incredibly difficult to understand life for the majority of humans. 100 years ago there were no antibiotics. 200 years ago there was no refrigeration. 300 years ago, the fastest way to move goods was by horse, which meant farming was naturally local. 500 years ago, corn and potatoes were unknown in the European diet. Humans have been around for about 2 million years. The best analogues are the abject poor in underdeveloped parts of the world, which makes the advice in "Born to Run" about "eating like a poor person" take on a new light.

<comment><USER3> Hey that's fantastic about your wife.

I was recently diagnosed with Narcolepsy. After the meds did not seem to help, I decided to experiment with my diet. Removing gluten was the key. I experienced what it was like to wake up refreshed for the first time in over a decade. My productivity has increased to a level where I get the same work done in 8 hours where before I'd push 12 hour days on average. The removal of Gluten has had a profound positive change.

Have you any references on gluten sensitivity that is isn't new age rubbish? I would like to know why gluten has caused brain fog and fatigue on such a detrimental level.

</comment></comment><comment><USER4> This article is bad, and while there are certainly reasons to think cutting wheat out of your diet could be helpful, it's certainly not a slam dunk case. The confidence level here is absurd, and some of the translation to laymen's speak is completely misleading.

> And yet Perlmutter argues that his recommendations are not radical at all. > In fact, he says, his suggested menu adheres more closely to the way mankind > has eaten for most of human history.

The human race has had an extremely varied diet based on geography, and even today doesn't really have a standard diet. (Sidenote: this is also the major flaw with labeling of diets like this as "paleo:" there was no "paleolithic" diet. Yes some populations ate about 50/50 meat, fruits and vegetables, but few of today's agriculture resembles that available even 20k years ago, so using that as justification is weak).

> Perlmutter says we need to return to the eating habits of early man, a diet > generally thought to be about 75% fat and 5% carbs.

He gets more specific here, but he gets even more wrong. There are some populations who had a diet of up to 95% carbs.

> "Perlmutter uses bits and pieces of the effects of diet on cognitive > outcomes — that obese people have a higher risk of cognitive impairment, for > example — to construct an ultimately misleading picture of what people > should eat for optimal cognitive and overall health," St. Catherine > University professor emerita Julie Miller Jones, Ph. D., told the website > FoodNavigator-USA.

This is the biggest issue with the article. Perlmutter (or at least the journo covering him) does not do a good job of untangling obesity's and caloric intake's effect and the effects of wheat specifically.

> Further research published in the New England Journal of Medicine in August > showed that people with even mildly elevated levels of blood sugar — too low > to register as a Type 2 diabetes risk — still had a significantly higher > risk of developing dementia.

Blood sugar does not necessarily come from ingesting sugar, it also comes from fat.

> "This low-fat idea that's been drummed into our heads and bellies," > Perlmutter says, "is completely off-base and deeply responsible for most of > our modern ills."

He's almost right here: the idea of low fat diets is stupid. We should focus much more on food quality and overall caloric intake.

> "People are getting to this place of understanding that their lifestyle > choices actually do matter a whole lot," he says, "as opposed to this notion > that you live your life come what may and hope for a pill."

Yes. Good.

> "The exact parts of the brain that allow people to become addicted to > narcotics are stimulated by gluten," Perlmutter points out.

Oh come one. Gluten and EVERY OTHER FOOD.

> "Nutrition matters," Perlmutter says. "The brain is more responsive to diet > and lifestyle than any other part of the body and until now it's been > virtually ignored. We load up on medications when our mood is off, we hope > for an Alzheimer's disease pill when we get older. I submit that we need to > take a step back and ask, 'Is this really how we want to treat ourselves?'"

Absolutely.

<comment><USER2> I mentioned it in another post, but we do have significant evidence that grains led to the rise of civilization, so I think that the "gluten is toxic" line is quite hyperbolic. However, the nutritional content of wheat is very low relative to the calories received.

<comment><USER5> Grains can support a large population even while causing dementia in later life. The two are not incompatible.

<comment><USER4> That's maybe true but doesn't mean anything. As far as I know there is no reason to suggest grains specifically cause dementia, and as I said the article doesn't do a good job showing that it is specifically grains and not the obesity itself which causes the issues.

<comment><USER5> Having not read the book, I imagine the argument is that grains are carbs and carbs cause obesity and dementia. Most Americans over consume refined grains [1] despite the government drastically reducing grains share of the food pyramid.

[1] [http://www.ers.usda.gov/publications/err-economic- research-r...](http://www.ers.usda.gov/publications/err-economic-research- report/err50.aspx#.Uoes1_u9LCQ)

<comment><USER4> Which does not point to grains causing dementia, being poison etc., it points to overeating being really bad for you. Possibly that has to do with carbs, probably not because your body ends up doing pretty similar things with an overabundance of fat or protein. The difference is these foods make you feel fuller, and so you are less likely to overeat them. But there is still little evidence that overeating one specific macronutrient is worse for you than another.

</comment></comment></comment></comment></comment></comment><comment><USER6> Anybody read this 'Ten Health Benefits of Fiber' thing? Who writes this stuff? I'm sure it's with good intentions, but the way it is written now doesn't sound convincing _at all_ : every single sentence except the one for picture 6, contains 'may' or 'can'. I feel this just doesn't cut it in a world where proper education about food is a must since so many are suffering from not eating healthy. Suppose I'm desperate for a new healthy diet and want to go for fibers (after all, the title says there are ten reasons why I should) and read this, I just might think 'well it just could be better, but it could as well not be, screw this'

<comment><USER7> Increasing fiber was originally used to reduce sex drive. [http://www.marksdailyapple.com/dietary-fiber-is-bad-for- sex-...](http://www.marksdailyapple.com/dietary-fiber-is-bad-for-sex-thats- the-only-claim-about-it-that-isnt-a-myth/)

</comment></comment><comment><USER8> > a diet rich in extra-virgin olive oil, grass-fed beef and wild fish provides > "life-sustaining fat that modern American diets are so desperate for."

So a diet completely unsustainable when considering a human population of 7 billion?

</comment><comment><USER9> Twaddle and pseudoscience.

People who cut out grains invariable also reduce their simple carb load and are surprised at how much better they feel.

<comment><USER5> Perhaps you didn't read the part of the article where carbs are ultimately blamed.

<comment><USER9> I did, also the part where gluten was ultimately blamed.

</comment></comment></comment><comment><USER10> There's decent evidence that avoiding grains like wheat is a good idea, but I don't think there's any reason to think sugars and simple starches are bad for you. The article insinuates orange juice is bad for you because it has sugar in it. So what? People in Cuba get something like a third of their calories from cane sugar and are quite healthy; healthier than Americans. Many healthy cultures have subsisted on milk, which is loaded with sugar.

Cutting out sugars and simple starches like rice is just a convenient way for fat people to lower calorie intake. If you're lean I've not seen any convincing arguments to avoid sugars.

Also, a lot of the paleo way of looking at diet as _the cause_ of diseases is I think way over done. Some folks will insist almost any disease can be traced to diet, but I think there's good evidence that yet to be isolated infections cause things like rheumatoid arthritis and MS and some other stuff. For example, skeletons show rheumatoid arthritis existed only in the New World and spread after contact to Europe and Asia. Another aspect is mutational load. People with weak immune systems or poorly tuned cell metabolism used to regularly die in childhood. Now these people survive to adulthood and eventually exhibit various degenerative diseases. They also pass their genes on, increasing prevalence in the population. Diet surely matters, but population increases in various middle age degenerative diseases probably has other factors totally independent from diet.

<comment><USER7> It's not the fact that you are eating sugar from an orange. It's the fact that most people drink a glass of orange juice that is made from 5-6 oranges. Would you eat 5-6 oranges in one sitting? no. So you are getting 5-6 times the sugar you would normally get eating the fruit whole. Secondly juicing something drastically increases it's glycemic index. Eating a lot of high glycemic foods leads to insulin resistance, which contributes to systemic inflamation. This leads to a number of conditions that affect the organs in your body, like your brain or your pancreas.

<comment><USER10> > you are getting 5-6 times the sugar you would normally get eating the fruit > whole

So what? If I'm hungry and need the calories provided by the sugar, what's the problem?

> Eating a lot of high glycemic foods leads to insulin resistance

Sugar has lower glycemic index than starch. And in any case I don't really buy the whole idea that eating carbs causes insulin resistance. Being fat causes insulin resistance. If you're not fat, sugar is fine.

<comment><USER7> Just because you don't "buy it" doesn't change the science.</comment></comment></comment></comment>


As Borders Closes Bookshops, Rival Barnes & Noble Survives - <AUTHOR> http://www.time.com/time/business/article/0,8599,2057760,00.html <comment><USER2> I was in a Borders on Sunday getting cheap NoSQL books on sale. The guy stocking the shelves, who's getting laid off, was on a rant about how the last 6 presidents of the company didn't know what they were doing and that's the reason they're going under.</comment>


Follow 3 startups through the SpringBoard Mobile accelerator - <AUTHOR> http://howtowriteabusinessplan.com/2012/09/startup-diary/

<comment><USER2> Love it, can't wait to see the progression!

</comment><comment><USER3> Awesome, thanks for this!

</comment><comment><USER4> really cool! we can learn as they learn I hope.

</comment><comment><USER5> Phenomenal!</comment>


The Brain on Trial - <AUTHOR> http://www.theatlantic.com/magazine/print/2011/07/the-brain-on-trial/8520/ <comment><USER2> From the article, referring to recidivism rates in sex crimes: "But among the strongest predictors of recidivism are prior sexual offenses and sexual interest in children. When you compare the predictive power of the actuarial approach with that of the parole boards and psychiatrists, there is no contest: numbers beat intuition."

One of the best changes in the administration of criminal justice in the United States during my lifetime has been use of standardized sentencing guidelines, pioneered in the state of Minnesota,

<http://www.msgc.state.mn.us/msgc5/guidelines.htm>

to reduce the variance among different judges in how convicted criminals are sentenced. By taking into account the severity of the most recent offense for which a defendant is convicted, along with the defendant's history of previous convictions, Minnesota can imprison many fewer criminals than most states-- diverting less dangerous criminals to community-based rehabilitation programs --and actually spend more per prisoner (for more humane imprisonment) while spending less per taxpayer on its prison system than most other states. The most dangerous criminals are kept away from potential victims, so that my neighborhood and most neighborhoods in Minnesota are perfectly safe for children to go out in alone. Youthful offenders who make one minor mistake are set straight and continue to be productive members of society. By contrast, the "three strikes and you're out" rule of California, promoted as a make-work program by the prison guard trade union, needlessly imprisons tens of thousands of California convicts in degrading conditions that result in more recidivism when convicts are eventually released, and endangers the solvency of the whole state government.

</comment><comment><USER3> "A leading neuroscientist describes how the foundations of our criminal- justice system are beginning to crumble"

Well, it's a blow to the foundations of revenge-based justice systems, like the US one.

In rehabilitation-based justice systems like the ones in Europe, this is not a problem. It's simply more tools to diagnose and rehabilitate prisoners.

<comment><USER4> Care to expand on the differences? I'm not sure if you have an insightful point here or if you're just making a glib anti-American remark.

<comment><USER3> It was a generalization, there are big differences between the various states in the US, and there are big differences between various countries in Europe, but generally, criminal punishments are less severe over here, and more severe in the US.

Some states in the US have the capital punishment, and some even allow the victims to witness the execution. "To ensure justice was done" is the official explanation, but in reality, it's to satisfy the victim's desire for revenge.

Over here, the victims of a crime are part of the process only as witnesses, and then they're out. There are no juries to sway with emotion, all sentence lengths are standardized by law, and "life in prison" means 20 years, max.

There is no public opinion that we should be "tougher on crime", no political parties are campaigning with the promise to increase sentence lengths or be harder on criminals, some want more resources and money to the police, but that's it.

There's a general awareness that prisons actually harden criminals, that the more time they spend with each other, the more likley they are to return to a life of crime when they get out. We try not to mix people serving a sentence for the first time, with people who are return criminals.

The primary purposes of prisons is of course to lock people up, to remove them from society, to ensure they can't move freely or do work or business, but there is a secondary explicit purpose, and that is to rehabilitate as effectively as possible, to give the prisoners as much help and support as possible, to make sure they don't commit crimes again.

It is very common over here that people who commit murder are sentenced to forced psychiatric rehabilitation instead of prison, and you do psychiatric evaluations of everyone accused of violent crimes, so there's an underlying general sentiment that criminals are sick, not evil.

Of course a lot of people mistrust former convicts, of course a lot of people think criminals deserve to be put away, but there's a lot less of those sentiments over here, compared to the US. Our prison population per capita here in Sweden is also 1/10th of the US average.

So, given all this, the news that a lot of criminal behaviour can be explained by brain malfunction isn't devastating at all. Quite the opposite, it means that you suddenly have more ways to rehabilitate criminals, if you can remove a tumor or fix a chemical inbalance, that's good! It means even less people in jail, and less violent crime.

But if the primary purpose of your justice system is to ensure the victims get their revenge, then it's not helpful, it's not good, because it will "rob" victims of their revenge.

<comment><USER4> The US had really, really bad crime in the 1980's and 1990's. In a lot of large American cities, infamously including New York, things like street muggings were literally a fact of life that nearly everyone had faced one time or another. I'm not aware that things ever got that bad in Europe; it's not fair to criticize our solution to a problem Europe hasn't even had.

Why were things so bad? We're not a culturally homogenous society, so we have lots of oppressed classes of people who are more likely to turn to crime. We have a history of high immigration and a history of puritanical, prohibitionist laws, which means organized crime from all over the world can easily gain a foothold here.

And, unlike Europe, large parts of America were basically frontier less than 150 years ago. The "wild west" wasn't as violent as you see in movies, but it wasn't a very nice place, either, and harsh measures were sometimes necessary. A lot of American sentiment on capital punishment dates from these times, and these circumstances which Europeans haven't been familiar with for centuries.

Pragmatically, the American justice system (capital punishment and long sentences included) does a very good job at containing criminals. We can be fairly certain that as long as someone is in prison, or dead, they are not going to go on and commit more crimes.

Frankly, the bulk of the problem in America has been urban gang violence. You can't fix that by rehabilitating individuals, because gang violence isn't an individual crime. Sure, brain malfunctions might explain individual criminals. They don't explain entire criminal subcultures. They can't all have brain damage, they just live in a culture where gangs are normal. Any human will do violent and terrible things to fit in with the culture that surrounds them.

As for the jury system, Americans consider jury trials to be just as fundamental to democracy as elections. Of course juries can be swayed by emotion--but if you only allow trained, expert judges to pass verdicts on a trial, by that same reasoning, shouldn't you only allow trained experts to choose your country's leaders? After all, voters can be swayed by emotion, too.

On another note, I'm curious as to how the justice systems you're talking about would handle criminals like Timothy McVeigh or Charles Manson. Don't you think that someone who kills children with truck bombs, or arranges a series of murders in order to incite a race war prophesied in Beatles lyrics, is too dangerous to be let go? A lot of experts believe that true psychopaths can't actually be rehabilitated--at best, they only learn how to fool therapists into believing they're healthy again. How is that handled?

<comment><USER3> Interesting perspective. Thanks!

(Sorry for not responding at length, but this is too far buried now)

</comment></comment></comment></comment></comment><comment><USER5> What struck me while reading this article, is thought that modern society will be seen as barbarian 100 years from now - it seems very likely to me that people will see imprisoning (of person with brain problems) as something cruel, similarly that we are disgusted by concept of cutting off thieves' hands. Also this implies that there are many behaviours in our society that will turn out immoral some years later, which is rather uncomfortable thought.

<comment><USER6> I've thought about this topic a lot lately. The issue with this is that in one way or another, all violent criminals have some sort of problem with their brain. They may not have a tumor or dementia, but something is wrong outside of their control. Should we punish them for that? And what is the alternative?

Well, I live in Norway, where the maximum sentence is 21 years. There are no life-sentences and certainly no death penalty. Even the top-security prisons are not too bad ( [http://www.time.com/time/magazine/article/0,9171,1986002,00....](http://www.time.com/time/magazine/article/0,9171,1986002,00.html) ). The focus is on rehabilitation instead of punishment, and it seems to work quite good. The inmates can get an education and participate in social activites.

Our crime rate is quite low and while that probably is a result of our welfare system, there are no indications that humane prisons negatively impact crime rates at all.

And the thing is that even our so-called "luxury prisons" ends up being cheaper than the American hellholes because we keep our inmates in for much shorter periods of time and focus on making them productive members of society instead of cage-animals.

<comment><USER7> _The issue with this is that in one way or another, all violent criminals have some sort of problem with their brain. They may not have a tumor or dementia, but something is wrong outside of their control._

You are saying that no healthy human being would ever commit a violent crime -- that nothing involving incentives or circumstances could prompt someone to make a decision to be violent? It seems to believe this you have to assume that in most eras most humans had some problem with their brain.

<comment><USER8> You are your brain so I kind of have problems seeing the distinction in the first place.

When a law says "Don't publish a copy of the copyrighted music you own." and you do publish a copy is there something wrong with your brain?

There certainly is if you believe that a healthy brain should not publish copyrighted music given the existing incentives in society.

Just think for a moment what would happen if we really were able and willing to change brains however we wanted to. Laws then become blueprints for changing brains which is kind of scary. Laws don't have to orient themselves on what might be considered healthy brain behavior (but who gets to define that?), they can say whatever they want. It's a pretty significant intrusion, but then again, so is locking someone up for a few decades.

I'm actually quite a fan of not ever punishing. I think the goal of criminal law should be to reduce crime while still allowing as much freedom as possible. Imprisonment (or, even worse, the death penalty) seems like a very blunt instrument for that purpose. Changing the brain, however, comes with its own issues. Does society get to decide who we are? I'm not sure about that.

</comment></comment></comment></comment><comment><USER9> This article is glib. It begins with a tragic anecdote that would soften anyone up - it certainly did me, no doubt triggering a brain reaction that caused me to read on. The author raises matters of great moral and social gravity. But what are his actual points?

1\. That the biology of brain function affects behavior. Well, duh. 2. That this has legal implications. Double duh. 3. That our present legal system is one-size-fits-all. No it isn't. It may in aggregate be crude and stupid, but not _that_ crude and stupid, as everybody knows (<http://en.wikipedia.org/wiki/Extenuating_circumstances>) and as the article itself shows (cf the Parks story). 4. That society's concepts of guilt change over time. 5. That scientific findings are relevant here. Who is arguing against any of this?

How about particular scientific findings with particular legal consequences? Well, "This research is just beginning"... "but if it works well, it will be a game changer." Today, "neuroimaging is a crude technology", but "within the coming decades" we "will be better able to say why people are predisposed to act the way they do". And that's it. The grandeur-to-substance ratio approaches that of strong AI.

Yes, the brain is important and people are not ideal atoms of free will. It does not follow that brain imaging has turned centuries of jurisprudence on their head.

<comment><USER10> "The future is already here, it's just not evenly distributed" is the Gibson quote that often gets applied to technology, but it applies as well to knowledge in general.

 _Who is arguing against any of this?_

Maybe not anyone at a certain level of academic discourse, but US society and law continue to argue against it: the average person would attempt to make an explicit argument, and laws on the whole reflect an implicit discipline-and- punish philosophy more than the rehab hypothesis.

There's a long way to go before this is democratically-actionable knowledge, and I think he does a good job of presenting some easily-digestible food for thought.

</comment></comment><comment><USER11> Nice article overall but the free will arguments towards the end were a little shaky. I also took issue with:

> No amount of threatening will chase away depression, but a little pill > called fluoxetine often does the trick.

Isn't therapy more effective than fluoxetine? Sugar pills certainly are.

<comment><USER12> Clinical depression has different causes. Even when it is neurochemical it could be an imbalance of dopamine or serotonin or norepinephrine or something else entirely. There's no one pill that works for everyone, or even most everyone.

</comment></comment><comment><USER13> "Imagine that you'd like to quit smoking cigarettes…"

This sentence alone is enough to tell me that this "game changing" technique of "prefrontal workouts" is misguided.

As a former smoker, I can tell you that there is definitely a mental rivalry going on in the head of someone who would like to quit cigarettes. However, I want to emphasize the "someone who would like to quit cigarettes" part because it makes an important distinction.

Smokers who have no desire to quit don't have the tug-of-war that the author speaks of. When I first started smoking I never once gave thought to quitting because, in my mind, I didn't have a problem. Only when I realized I was hooked and WANTED to quit did I start to have the mental rivalry he speaks of.

What does this have to do with criminals? The same rules apply. Let's rework that sentence a bit:

"Imagine that you'd like to quit crime…"

Huh???

How many criminals enter the penal system with such lofty goals? My guess would be not many.

I can see this being useful for someone who has already been reformed to some degree, because that person actually does possess a desire to change.

That being said, it still isn't THAT useful because, despite the fact that you may know which camp your thoughts fall into, you still need to deal with the day-to-day task of actualizing that knowledge.

As anyone who has ever tried to make a significant change can likely attest, knowledge is only half the battle- and the easiest half at that.

</comment><comment><USER14> Wow, this is the reason I read Hacker News day by day rather than the gibberish most of mass media produces.

</comment><comment><USER15> The not guilty verdict of Kenneth, the sleepwalk killer, bothers me. It doesn't seem likely to me that they jury was in any doubt whether he committed the crime. And, in that case, our legal system says you should find the defendant guilty. I guess the jury gave the not guilty verdict because they felt it would be wrong for the defendant to be punished for a crime he committed while sleepwalking. This suggests to me that there's insufficient separation in our legal system between whether someone committed a crime and what should be done about it. The assumption, you committed a crime therefore you should be punished, is deeply flawed and deserves serious reconsideration.

<comment><USER16> "[there's no doubt that] he committed the crime. And, in that case, our legal system says you should find the defendant guilty"

And what legal system is that? Grade 11 law class: both actus reas _and_ mens rea are fundamental (and equally important) elements of guilt.

<comment><USER17> For the others that didn't know what "actus reas" and "mens rea" mean:

actus rea: the actual guilty act

mens rea: the guilty mind. (knowing they did something wrong, I suppose?)

I used Wikipedia for the citation. A useful quote from the Actus reus article to help expound on what I think latch was saying: "The terms actus reus and mens rea developed in English Law, are derived from the principle stated by Edward Coke, namely, actus non facit reum nisi mens sit rea,[1] which means: "an act does not make a person guilty unless (their) mind is also guilty"; hence, the general test of guilt is one that requires proof of fault, culpability or blameworthiness both in behaviour and mind." (Actus Reus. Wikipedia. Entymology Section)

</comment></comment></comment><comment><USER18> Reminds me of an argument Plato (or was it Socrates?) made 2300 years ago. Essentially, he thought that all "unjust" people believe their actions to be "just" - they themselves thought they did the right thing.

As such, these unjust people should not be punished for their lack of knowledge, but instead educated or rehabilited, as their unjust actions were simply a result of not knowing what the "just" really is.

A modern metaphor for this might replace "knowledge of the just" with "biology that can resist impulse," or something similar. The problem, which was just as valid in Greece as it is now, is the question of "What is just?," or "Is a non-impulsive brain chemistry desirable?".

<comment><USER19> Hmm, do you really think most criminals believe themselves to be acting justly? I think they know full well that what they do is "wrong" but since they can get away with it, they figure why not?

<comment><USER18> Actually, now that you mention it, I believe Plato was (consciously or unconsciously, due to his aristocratic background) referring to the unjust in positions of power, maybe not so much criminals. As in, unjust men with long- term planning.

In that case, it is a convincing argument. Consider that most dictators and despots seem to think they are in the right (Ww2, etc.) Compare this to "normal" criminals, who seem to have poor impulse control (lack of long-term planning. )

Of course, that has nothing to do with the article. I've brought up an argument and then dismissed it just as quickly :)

<comment><USER20> I'm not sure I'd dismiss your argument so quickly. If one considers the "just" to be the best decision, given the circumstances, then most criminals are trying to be just. They may badly need money for their family. Or perhaps to feed a drug habit (In which case, as you said, perhaps they are ignorant of what really is just.) If they didn't think it was the best decision, for some good, why would they do it?

</comment></comment></comment></comment><comment><USER21> This just rehashes an old (and fallacious) argument under the guise of neuroscience. Bobert Blatchford tried to push the same view 100 years ago (see his article "Defense of the Bottom Dog"). He didn't convince many, though. There are some puzzles about the concept of "deserved punishment" (what do we say in cases of brain tumors?? omg!), but it isn't clear that we can reconceive of criminal justice on the model of putting someone in quarantine (where we don't blame them, but force them into a room for public safety; we also give them goodies to compensate for how we treat them..)

<comment><USER22> To the extent that our modern justice system is based on rehabilitation I think we're already pretty close to the model you seem to be saying is untenable. I only skimmed Blachford's article just now, but he seems to be saying that no criminal is responsible for his actions, which is very different from the tack taken by by this article, which distinguishes criminals who are responsible for their actions and those who aren't.

</comment></comment><comment><USER22> I thought this was an excellent article, and it brought to mind another excellent article on the same topic by from a more general perspective. [http://lesswrong.com/lw/2as/diseased_thinking_dissolving_que...](http://lesswrong.com/lw/2as/diseased_thinking_dissolving_questions_about/)</comment>


Not Every Drop of a Person's Blood Is the Same, a Study Says - <AUTHOR> http://www.nytimes.com/2016/02/23/health/not-every-drop-of-a-persons-blood-is-the-same-a-study-says.html <comment><USER2> Question from an outsider (of medicine and of medical research): Why is this study _new_? I mean I can understand why it is _news_ (for the mass media)...but isn't this something that would've have been tested long ago to a certain degree? At least to a degree in which, today, doctors are content that a venous draw is a statistically useful amount of blood to derive health results from? Wouldn't that have to based on some study that purported to find the minimum volume of blood needed to reliably represent someone's health?

Not only does it seem like a very fundamental question to have already asked...it doesn't even seem like a very difficult study to _do_. It's not substantially longitudinal over time -- for every subject, you take several pinpricks, and run the tests. Or logistically difficult to manage.

So I get why it's news, in terms of Theranos and what not...but this has to have been something that was studied many times over many decades. Or is the NYT misinterpreting/signifying the significance, i.e. the Rice scientists found a previously undetectable kind of difference, but which is, yes, technically shows that blood drops are different?

<comment><USER3> Microfluidics as a field is relatively new (last 10 years or so).

This study is at the "microtiter" scale, which is the scale that companies such as theranos are trying to take advantage of.

Microfluidics is largely an industrial field rather than academic.

>Not only does it seem like a very fundamental question to have already asked...it doesn't even seem like a very difficult study to do.

Yeah, well, that's the difference between Silicon Valley and academia.

SV doesn't want to hear about results that invalidate their business model.

<comment><USER4> > SV doesn't want to hear about results that invalidate their business model.

I promise you that academics not wanting to hear results that invalidate their models is the rule, not the exception.

<comment><USER5> otoh, academics _love_ hearing results that invalidate other people's models :)

</comment></comment></comment></comment><comment><USER6> In general this doesn't seem like huge surprise. Blood is reasonably homogeneous, but noise becomes an issue when you're looking for anything present in low concentration (signal close to the noise floor) or when small differences in concentration matter (signal superimposed on background noise causes the value change from expected to be close to the magnitude of the noise).

If noise is too high for a single drop, a venous draw is a much larger volume and theoretically equivalent to sampling many drops of blood—it's the physical equivalent to averaging samples to increase the SNR.

The authors note[1] that averaging may not be enough though, and that there may be an interesting difference inherent to fingerprick blood (possibly caused by their collection method):

"Our data also suggest that collecting and analyzing more fingerprick blood does not necessarily bring the measured value closer to those of the donor's venous blood (Figures 1D and 2D). For example, donor B's hemoglobin and WBC concentration were similar for venous blood and fingerprick in drop 1 but became less concordant with additional drops, while donor C's fingerprick measures came closer to the venous measures with additional drops. These data may represent true differences between fingerprick and venous blood, or they may be the result of errors in collection (such as leaving the tourniquet on for too long during a venous draw). Further research is needed to determine how common these patterns are."

1\. [http://ajcp.oxfordjournals.org/content/ajcpath/144/6/885.ful...](http://ajcp.oxfordjournals.org/content/ajcpath/144/6/885.full.pdf)

<comment><USER7> Considering that the body regulates its temperature by controlling blood flow to the extremities, maybe it's not surprising that venus blood in particular is not homogeneous. As the body cools blood flow to the hands is reduced. Venus blood is also impacted by movement, gravity, etc... Since there's no pulse in the veins, would it not make sense that the heavier constituents of the blood would remain as the lighter components "drain?"

I wonder if like how red blood cells would settle to the bottom in a test tube one might expect that there would be differing concentrations of blood constituents in venus blood in the extremities depending on the elevation, temperature, perfusion, etc... of the extremity?

</comment></comment><comment><USER8> As someone working in this field particularly on the product front and academic front - a major concern I have with this study is the lack of work done to establish what the clinical significance is in these variations. The methodology is well controlled enough to indicate that a statistically significant difference does indeed exist in the variations on the drop-to-drop level between venous and capillary samples, but what's missing is a detailed analysis of whether or not these differences would result in clinically different outcomes - from my work, the range of identifying an anemic, leukocyte spikes, etc. is large enough that the spikes in deviations in capillary samples ultimately become inconsequential. Furthermore dozens of studies [1,2,3 are just a few examples] in the past have found essentially the opposite outcome. A discussion is necessary - but suggesting that all drop based diagnostics will forever be inaccurate is both unbased and dangerous given the growing importance of this field. If anyone has specific questions feel free to drop me a line at ttandon[at]stanford[dot]edu

[1][http://www.hindawi.com/journals/isrn/2012/508649/](http://www.hindawi.com/journals/isrn/2012/508649/) [2][http://www.ncbi.nlm.nih.gov/pubmed/23294266](http://www.ncbi.nlm.nih.gov/pubmed/23294266) [3][http://journals.plos.org/plosone/article?id=10.1371/journal....](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0043702)

<comment><USER9> Perhaps that's not the goal of this study? I think there's benefit in knowing that there is a difference, even if it's just in the ability to get further, more targeted studied funded now that a fundamental question has been answered. Now, instead of answering both whether there's a difference, and whether it affects a specific aspect of blood testing, future studies can focus more on the second aspect of that. I imagine that makes funding quite a bit easier to get.

</comment></comment><comment><USER10> Well, that is the end of Theranos. They should just return what money is left to their investors at this point. This explains why they could never get the tech right...

<comment><USER11> I don't know too much detail about theranos, but is that really the case? The article says they needed to go to 6-9 drops, is that a dealbreaker for what they wanted to do?

<comment><USER12> Getting 6-9 drops of blood from a finger tip is not easy - you have to ask "Is it really a benefit over a venous draw if it's much more difficult?" At some point I think it makes it easier to instead just focus on super-fine needles, and the need to draw _less_ blood, from venous draws.

<comment><USER13> "Super-fine" cause mechanical haemolysis and will give inaccurate results for many routine blood tests

<comment><USER14> For anyone who isn't a doctor / biologist: "Mechanical hemolysis" means the needle is bursting red blood cells, leaking their cytoplasm into the blood plasma.

</comment></comment></comment></comment></comment><comment><USER15> this is basically the common sense for any one with some proper medical training. and it's why many clinical scientists and medical practitioners (read: peers) keep questioning about Theranos from the beginning.

</comment><comment><USER16> Something that's always perplexed me -- if we're talking about small amounts of blood, why finger-tips? This is such a sensitive area. Why not a prick on the elbow or the shoulder?

<comment><USER17> The skin is thin, easily accessed, and heals quickly.

<comment><USER18> I used to be a neuro tech, and I remember one patient coming in for a carpal tunnel test. She looked horrific - a gas heater had exploded and sprayed her a few years before, and all visible skin looked melted - she looked a bit like a skeletal-muscle model, as the melted skin had pooled in the divots between muscles. But what really struck me was that the only part of her skin that didn't look melted was the palms of her hands (and the inside of her fingers). They'd healed just fine, and the border between healthy palm and melted skin was like a knife edge.

</comment></comment></comment><comment><USER19> If it's scientifically proven that a drop of blood can't be accurate, what is the alternative to going into the vein? Maybe you wipe down the wrist with alcohol, then put on a cuff link apparatus that simultaneously takes 20 drops of blood.

<comment> semi-extrinsic It appears this depends a lot on what you are testing for. Fingerprick tests for CRP count (basic inflammation test) seem to already be standard practice in hospitals and health clinics. The test machine is the size of a toaster and gives the physician direct results in a minute or two.

Also, for blood glucose, which diabetics need to monitor closely, there is some buzz now around spectrographic (IR/UV) techniques, meaning you don't even have to puncture the skin. That would be huge. Diabetics actually complain more about fingerprick tests for glucose than about insulin injections, which sounds very counter-intuitive to non-diabetics.

What glucose and CRP have in common is that they are small. TFA talks about tests for white blood cells, platelets or HIV, which are much larger. If you compare white blood cells to glucose, they have three orders of magnitude larger radius, so _nine orders of magnitude_ larger volume.

That's like the difference in volume between a raindrop and a blue whale. No wonder different mechanisms may apply.

<comment><USER20> _Also, for blood glucose, which diabetics need to monitor closely, there is some buzz now around spectrographic (IR /UV) techniques, meaning you don't even have to puncture the skin. That would be huge._

It would be huge, yes. But it has been "five years away from being available" for about 25 years. Glucose has a much smaller signal than the Hb / HbO2 signal used for pulse oximetry.

 _Diabetics actually complain more about fingerprick tests for glucose than about insulin injections, which sounds very counter-intuitive to non- diabetics._

Most non-diabetics think that "injecting insulin" involves hitting a vein. That would be far more painful. Instead, we inject into subcutaneous tissue; and the needles we use are absolutely tiny. It's worth noting that it's very unusual to get any bleeding from an injection site.

</comment></comment></comment><comment><USER21> Finally! I wondered how people actually know that the genetic code is the same in every cell. How would you prove that? What if everyone is a chimera to some extent? We are just getting started understanding epigenetics.

<comment><USER22> It's not the same. Telomeric regions shrink over time. Viruses inject their own dna code into the host genomes. Minor damage piles up over the years.

<comment><USER23> Beyond even random changes and telomeres shrinking, VDJ recombination actively splices genes from B-cells and somatic hypermutation further modifies certain regions. Sampling two B-cells that share a common ancestor will likely have some genomic differences.

</comment></comment></comment><comment><USER24> For additional takes on this, there was some discussion of this result yesterday, based on a post of a direct link to the paper: [https://news.ycombinator.com/item?id=11159526](https://news.ycombinator.com/item?id=11159526)</comment>


Common shell script mistakes (2008) - <AUTHOR> http://www.pixelbeat.org/programming/shell_script_mistakes.html <comment><USER2> Shout out to Shellcheck ([http://www.shellcheck.net/](http://www.shellcheck.net/)), a linter for shell scripts

<comment><USER3> If you're on Sublime, this works like a charm!

[https://github.com/SublimeLinter/SublimeLinter- shellcheck](https://github.com/SublimeLinter/SublimeLinter-shellcheck)

<comment><USER4> If you're on Vim or Emacs you already (maybe) know you have integration with shellcheck

Emacs - [https://github.com/koalaman/shellcheck](https://github.com/koalaman/shellcheck)

Vim - part of syntactic - [https://github.com/scrooloose/syntastic/blob/master/syntax_c...](https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/sh/shellcheck.vim)

</comment></comment></comment><comment><USER5> The google shell style guide linked now lives here and is probably an even better starting point than this article:

[https://google.github.io/styleguide/shell.xml](https://google.github.io/styleguide/shell.xml)

<comment><USER6> The google shell style uses bash which is not portable, one of the main point of the OP article.

<comment><USER7> Bash is the default shell on the most popular server nix (Linux) and the most desktop nix (OS X, though it's always a slightly old version).

If you use OpenBSD and hate ports, then maybe ignore all the good things bash brings and write everything in Bourne shell. If not, then write bash. Just fire it up with '/usr/bin/env bash' to label it correctly.

<comment><USER8> > _Bash is the default shell_

Not for nigh on a decade, now.

* [https://wiki.ubuntu.com/DashAsBinSh](https://wiki.ubuntu.com/DashAsBinSh)

* [https://wiki.ubuntu.com/DashAsBinSh/Spec](https://wiki.ubuntu.com/DashAsBinSh/Spec)

* [https://lists.debian.org/debian-release/2007/07/msg00027.htm...](https://lists.debian.org/debian-release/2007/07/msg00027.html)

* [https://wiki.debian.org/DashAsBinSh](https://wiki.debian.org/DashAsBinSh)

<comment><USER7> Bourne shell being replaced as /bin/sh by dash doesn't change anything: Linux and OSX don't use /bin/sh as the default shell.

<comment><USER8> > _Linux and OSX don 't use /bin/sh as the default shell._

You didn't even read the first sentence of the first hyperlinked page.

<comment><USER9> I believe xe meant "default login shell". Also, "Bourne Again shell", while we're complaining about missing words :-)

<comment><USER8> Xe would have been a bit daft to mean that, given the headline topic as well as that the conversation so far has dealt in shell scripts and shell script interpreters, to which the choice of login shell is almost wholly irrelevant.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER10> So many edge cases. I prefer to just use perl if I am doing anything more complicated than making a wrapper for some other executable. Harder to screw up, easier to test, same expressiveness, better portability (works with all shells and with windows), plus you get regular expressions for free.

Python is a good alternative as well.

<comment><USER11> Perl is brutally under-rated as a scripting tool these days. I suppose it's passed into software orthodoxy by this point, the notion that perl is a uniformly horrific tool akin to nuclear waste.

<comment><USER12> I think that this is because people are finding Python equally well suited for such tasks and more modern. Perl (easy to) obscure syntax is not helping either.

<comment><USER13> If you're doing a really grungy, grotty text mangling task in a UNIX pipeline, suddenly all those crazy Perl features start making sense. The reason why Perl is arguably not the best choice for other tasks, such as creating large systems, is precisely that it's actually got many distinct advantages over Python for that sort of task. It's also really good for "I have a UNIX pipeline but this one chunk of it needs a database and this other chunk needs a JSON file and a few other things that shell just can't do".

For instance, for the first time in 15+ years, I recently had a reason to use Perl's half-deprecated, off-handedly-included form printing support, and, you know what? It's _really nice_ if that's what you want. Many dozens of lines of code replaced by what is basically a picture of what I want.

Python is a great language, but every once in a while "explicit is better than implicit", which is generally a philosophy I agree with wholeheartedly, results in a _lot_ more "explicit", in the form of "code I had to write", than you might be looking for. (Or, alternatively, you start writing Python that is a lot more implicit, which isn't exactly a huge victory for Python here.)

Nowadays I'd also suggest that if you find yourself having a lot of those tasks, you need to ask some questions about how you're storing your data. But pretty much everybody ends up with some of these somewhere; it's hard to eliminate them, and not really worth it (due to diminishing returns).

</comment></comment></comment></comment><comment><USER14> Great post. I disagree on using the concise form of the if statement, however.

      if [ "$var" = "find" ]; then
        echo "found"
      fi

Is far more readable than its equivalent

      [ "$var" = "find" ] && echo "found"

I understand the upside of readability. What does concision get me?

<comment><USER15> concision gets me less code to read. that's how i define "readability". but if forum commments are any indication, i know my preferences do not follow the norm.

most programmers seems to prefer verbosity.

however in my case verbosity slows me down.

<comment><USER16> By that logic you find minified javascript easier to read too.

<comment><USER17> This is not @pwd_mkdb's logic though, it's you who brought this to the extreme.

<comment><USER18> Not really. @pwd_mkdb said he defines readability as "less code to read".

If that's the only criterion, then the parent just followed the logic. Or let's put it another way, if the definition of readability can't survive taking it to the extreme, it is flawed.

<comment><USER19> > If that's the only criterion, then the parent just followed the logic.

wodenokoto offered up some _reductio ad absurdum_ and you are calling it logic.

It was not the only criterion. It was the only criterion that was explicit. There are implied criterion and most of us understand what pwd_mkdb means even if we don't necessarily agree with him.

<comment><USER18> > _It was the only criterion that was explicit._

Well, even in itself, it is wrong.

It's not just that other criteria apply too -- it's that it alone needs several caveats, as succinctness is quite orthogonal to readability (e.g. sometimes even needless boilerplate syntax that the compiler could infer by itself, make for better readability when present).

<comment><USER19> > Well, even in itself, it is wrong.

I am not in disagreement with you about whether it is wrong, I am in disagreement with you about _why_ it is wrong.

The counter argument was that Y is wrong and X is Y, therefore X is wrong. While this is a valid argument, it is not sound, because X is not Y.

> ... succinctness is quite orthogonal to readability ...

There is a relationship between succinctness and readability. The relationship is definitely not directly proportional as the pwd_mkdb's post could be read to imply, but to say there is no relationship between the two is flatly absurd.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER20> Bash is the love of my life! I have been working for years on this problem now (not full-time of course), gradually moving in the direction of finally being able to challenge this:

"Inappropriate use

shell is the main domain specific language designed to manipulate the UNIX abstractions for data and logic, i.e. files and processes. ... Correspondingly, please be wary of writing scripts that deviate from these abstractions, and have significant data manipulation in the shell process itself. While flexible, shell is not designed as a general purpose language and becomes unwieldly when ... "

Another person has actually solved the most important show stopper already: [http://ctypes.sh](http://ctypes.sh).

What now remains to be solved, are a few minor, additional details, and then simply writing a good manual of how to very successfully use bash as a general-purpose language.

My personal belief is that everything that you can do in other scripting languages, you can also do in Bash, only better.

<comment><USER21> Ok, I'll bite.

>> My personal belief is that everything that you can do in other scripting languages, you can also do in Bash, only better.

1) Native JSON, XML

2) Classes, namespacing, objects

3) Multiprocessing, multithreading

4) Performance

5) Package management

6) Portability

7) Documentation

8) Runtime debugging (!set -x)

I'm too tired to continue.

<comment><USER22> >3) Multiprocessing

IMO shell makes it very easy to work with multiple process (&). It's built in and natural.

>4) Performance

If you are carefull and know what you're doing, you can achive very good performance with the shell. Usually, better performance is achived processing less data, ie being inteligent. Rarely depends on the language (unless you care about cycle level performance, then yes :).

>6) Portability

I claim that it's way easier to depend on sh being on a (UNIX) system than $SCRIPTING_LANG.

>7) Documentation

?? You can mess up documentation in any language.

<comment><USER13> Shell makes it easy to spawn multiple processes. It makes it reasonably easy to read those processes' standard out or standard error, though it's not that much fun to try to do both at the same time while keeping them distinct. [1]

It pretty much doesn't do anything else that you might want to do with multiple processes, though, and it tends to encourage multiple processes to communicate via text which is a problematic limitation that one often finds oneself "working around".

Shell is really powerful, _but_ it hits a certain limit of what kind of tasks it can do and it hits that limit _hard_ , and that's why when one imagines orchestrating many processes on a machine to do some task, to say nothing of orchestrating many processes on many machines, you don't see solutions based on shell, and indeed the very idea is laughable. Shell is best used by making sure it stays firmly restricted to the domain it shines in and not so much as trying to dip a toe into the spaces where it is not.

[1]: Note "not much fun" != "can't". Shell is fundamentally written around the idea that a process has one stream STDOUT that may go to other processes, and one stream STDERR which is generally intended to go to the console (or other user output like a log) no matter how complicated the pipeline. While you _can_ get both streams and do things to them, you're starting to fight shell, which really wants to create pipelines with one "through" path with no branches out.

<comment><USER22> I think with the shell you have to adapt your abstractions to the "unix-way". For example, a queue to process will be a directory with N files, and each file can be processed in pararell by just something like "for f in dir/*; do process.sh "$f" & done;" but yeah ... it has limitations like everything.

</comment></comment></comment></comment></comment><comment><USER23> The big missing bashism in the list is the use of &> or >& to redirect both standard output and standard error.

In a POSIX conforming shell,

        &> word

is the same as

        & > word

since '&>' is not a distinct token; it puts the command in the background and redirects standard output.

The more commonly seen >& will bite you even in bash. What does this do?

        >& $FILENAME

Answer: in bash, it _depends on the spelling of the file name_.

Note that bash accepts both even in its so-called 'POSIX compatible' mode.

</comment><comment><USER24> > please be wary of writing scripts that deviate from these abstractions, and > have significant data manipulation in the shell process itself.

I appreciate he mentions this first. Shell scripting is excellent in its domain, just as SQL is great in its.

You would write an application in SQL and you shouldn't write one in shell.

</comment><comment><USER25> > Just test the string directly like [ "$var" ] && echo "var not empty"

Will this work if you've activated _set -u_ , fail on unset variables? Will the !-z variant do?

<comment><USER26> If `set -u` is enabled, the aforementioned test will fail on unset variables. To avoid this, you can "declare" `var` at the beginning of the script, e.g. `var=''`. Also instead of `[ ! -z "$var" ]` I prefer `[ -n "$var" ]`, which is the same as `[ "$var" ]` but more explicit.

</comment></comment><comment><USER27> _" Writing shell scripts leaves a lot of room to make mistakes, in ways that will cause your scripts to break on certain input, or (if some input is untrusted) open up security vulnerabilities. Here are some tips on how to make your shell scripts safer.

Don't"_ [0]

[0] MIT, writing safe shellscripts ~ [https://sipb.mit.edu/doc/safe- shell/](https://sipb.mit.edu/doc/safe-shell/)

</comment><comment><USER28> That temp file example is a vulnerable to symlink attacks.

</comment><comment><USER29> Is there a modern "JavaScript: The Good Parts" for bash? There are so many ways to do things and it's often hard to tell which is preferable.

<comment><USER30> Not sure if this is what you're looking for, but it's where I tend to go when writing something.

[http://mywiki.wooledge.org/BashGuide](http://mywiki.wooledge.org/BashGuide)

<comment><USER31> I'm a big fan of this guide. I wish every language had such a clear best practices list. See also [http://mywiki.wooledge.org/BashPitfalls](http://mywiki.wooledge.org/BashPitfalls)

</comment></comment></comment><comment><USER32> Written in 2008.

<comment><USER33> Shell hasn't changed much, if at all, since, has it?

<comment><USER15> nope. reminds me of comments where someone is purporting to be able to assess the quality of software based only on looking to see when the last changes to the source code were made.

<comment><USER34> I'm not saying that is a valid strategy, but man I see more bad old code than new code.</comment></comment></comment></comment>


What Silicon Valley Refuses to Learn from Steve Jobs - <AUTHOR> http://venturebeat.com/2014/07/13/what-silicon-valley-refuses-to-learn-from-steve-jobs/

<comment><AUTHOR> Technology is necessary but not sufficient for building great products and services. What the article didn't mention is people are looking for ways to simplify their lives and manage complexity. They desire simple tools allowing them to easily achieve those aims.</comment>