Erlang Scheduler Details and Why They Matter - hamidreza-s https://hamidreza-s.github.io/erlang/scheduling/real-time/preemptive/migration/2016/02/09/erlang-scheduler-details.html <comment><AUTHOR> I am enjoying the steam that both Erlang and Elixir are gaining here on Hacker News. They're both interesting, well designed languages built atop a rock solid VM with some great abstractions for concurrency.

I'm hoping that this trend continues because out of all the noise of new languages and frameworks I feel like Erlang/Elixir are very deserving of becoming the new way forward for developing anything that runs on a network.

<comment><USER2> Absolutely this. I've enjoyed JavaScript the past few years. (Dare I admit that). And the only light I see is something like Elixir that has a fundamentally superior foundation for scale and concurrency. I'm intrigued and am hoping elixir / erlang / Phoenix keep growing.

</comment></comment><comment><USER3> The Erlang scheduler is very interesting. I attempted to reimplement it in JavaScript with some success. It works like the first version of the scheduler but I could see web workers being used to make it more like the current version. [https://github.com/bryanjos/processes](https://github.com/bryanjos/processes)

</comment><comment><USER4> Is there a resurgence of interest in Erlang because of Elixir? Or has the Actor model really taken a hold of developers because of it's direct and easy to understand model of concurrency?

<comment><USER5> The short version:

* 'event driven' things like Node.js got popular because they use fewer resources to serve the same amount of data (generally). But for a lot of people, JS is not really their idea of a good time. Erlang (and Go) fill this niche pretty well.

* Elixir finally made Erlang more palatable to more people. Jose has done a superb job with it, because it's not just a nicer syntax, there is a bunch of nice stuff he's built into it. It doesn't hurt that as a former(?) member of the Rails core team, he has a deep understanding of web programming and its requirements.

* It is solid, solid tech. There's lots of new development happening on top of, say, Elixir, like Phoenix, but the underlying system is pretty hardened.

</comment></comment><comment><USER6> Lots of Erlang articles making it to the front page... I like.

</comment><comment><USER7>
        in case of high level platforms, languages or libraries
        it can be claimed that Erlang virtual machine is almost
        unique because JVM threads depend on operating system
        schedulers, CAF which is a C++ actor library uses
        cooperative scheduling, Golang is not fully preemptive
        and it also applies to Python's Twisted, Ruby's Event
        Machine and Nodejs.

Most languages/runtimes that are taking concurrency seriously do so using libraries or frameworks (eg Akka on the JVM) that look a lot like Erlang's under the hood. Erlang is not quite as unique as it was, but obviously baking it into the language is v useful.

<comment><USER8> Akka is not preemptive. That's the problem with the library solutions, it's still a squarish peg in a round hole.

<comment><USER9> to be fair, the original article is fundamentally incorrect and Erlang is not truly preemptive either. It uses a reduction-counting based cooperative multitasking system which yields at function calls, but a badly programmed NIF can still ruin your day if you don't put it on a dirty scheduler.

<comment><USER5> There are N ways that badly coded C code loaded into a Unix process can send things to hell in a handbasket. "All bets are off" as they say.

<comment><USER9> In this case just taking more than a millisecond can cause scheduler collapse. So it's a pretty easy mistake to make.

<comment> hamidreza-s Although writing C code for NIFs is not a regular task for Erlang developers, it must be done with extreme care because not only a long-running NIF could degrade the responsiveness of the VM, but also when it crashes the whole VM will crash.

However when there is no other options except writing a NIF, there are ways to protect yourself:

1\. Your NIF should return less than a millisecond.

2\. If the item 1 is not possible, split it into shorter NIF calls.

3\. If item 1 and 2 are not possible so you have a dirty NIF. It is a NIF that cannot be split and cannot execute in a millisecond or less. There is an _experimental_ feature in Erlang virtual machine which is called "dirty scheduler". When it is enabled some other schedulers are ready to execute the dirty NIFs, so they won't interfere with the normal operation of schedulers.

4\. If item 1 and 2 are not possible and you don't want to use dirty schedulers, the +sfwi emulator flag is available to force normal schedulers to wake up again from the collapse situation.

These items are some solutions to remain in normal scheduling state even in case of writing the native functions in C (NIF), but what the article says is about just Erlang code which is run by schedulers and are preempted with no trouble as soon as they reach the reduction limit.

</comment></comment></comment></comment></comment></comment><comment><USER10> To my knowledge, Erlang uses a cooperative scheduler. The process itself counts downs its reductions and yields when it is time. The programmer can call erlang:yield() to do this before time if he wants. Calling something like receive will also yield. I guess it comes down to definitions, but since Erlang is said to have only soft real-time (as opposed to hard real-time) properties, this makes more sense. The schedulers doesn't give any guarantees as to when a process gets to run and the scheduler never really preempts a process. Again, to my knowledge.

Great article though!

<comment><USER11> I was also confused by this phrasing. The only thing I could think of was that from the programmer's perspective, it's not cooperative (you don't have to call yield), but that's also true of threads.

I see people down thread repeating this claim. Can anyone explain how the scheduler is preemptive?

<comment><USER12> You are absolutely correct, the schedulers never preempt a process in the classical sense, but from an Erlang code perspective, the system behaves as if it would be preemptive. The schedulers are actually running a byte code interpreter and the interpreter will switch processes once a certain number of reductions is reached (or the code yields). This breaks down when running native code in the form of NIFs - it is entirely possible to block a scheduler indefinitely while running native code.

</comment></comment></comment><comment><USER13> I've been into Erlang for about 5 years now and once I found it, I never looked back. They really nailed it and many competitive technologies like Go don't have a preemptive scheduler yet. I wish Elixir had a Pythonic syntax, but I'm all for anything BEAM gaining steam and have enjoyed using Elixir.

I personally feel that if someone made a Pythonic version of Elixir, say "Hydra", it would take over the world. If anyone starts such a project, look me up!

<comment><USER14> I second that. Elixir is great, but I was not a Ruby programmer, and prefer other syntax. I've tried LFE, and I love Lisp, but it has not gained traction. Perhaps I'll look into Luerl. Both LFE and Luerl were created by Robert Virding one of the original workers on Erlang with Joe Armstrong. I just might go with straight Erlang. I don't think the syntax is that bad.

</comment></comment><comment><USER15> FYI racket and gambit VM use preemtive green thread, but they have nothing to do with SMP.</comment>


Ask HN: How can one speed up development on solo programming projects? - <AUTHOR> <comment><USER2> I think keep patient is more important than speed

</comment><comment><USER3> Outsource some/all of it to freelancers on Upwork so they can make progress while you sleep, work a day job, etc.

</comment><comment><USER4> Choose tools you already know and familiar with.</comment>


Across the West powerful firms are becoming even more powerful - <AUTHOR> https://www.economist.com/special-report/2018/11/15/across-the-west-powerful-firms-are-becoming-even-more-powerful <comment><USER3> This is also a national security risk. A nation state interested in war will have an easier time shutting down a small handful of things simultaneously to quickly cripple our economy.

For example:

\- Shutting down only Visa and Mastercard would disable the vast majority of credit cards.

\- Disabling debit cards or withdrawing funds from JP, BofA, Wells Fargo, and Citi would disable the majority of banking clients in the US.

\- About 40% of US air travel could be stopped by hacking American and Southwest.

We've already seen similar large scale attacks on large companies:

\- In the 90s and early 2000s, Microsoft's weak security allowed worms to cripple Microsoft Office and Windows.

\- 100 million JP Morgan accounts were compromised by 3 people in 2015.

<comment><USER4> I'm not disagreeing with you, but the military side of me can't help but see how all of those things would be beneficial for our government as well. Stopping US air travel in an emergency. Stopping electronic transactions in a financial emergency. Etc etc etc.

I think a lot of government types would see many potential benefits in the way things are set up now. Even most regular people would have to, grudgingly, admit that, if it were necessary, this system could deliver the government unprecedented amounts of control. I mean, for good or for bad.

But yeah, there's likely a double edged sword there. No question.

<comment><USER5> The US government already has a legitimate way to stop air travel. And the government already has significant persuasive power; if the Secretary of the Treasury asked all the banks to stop electronic transactions for a legitimate reason, I'm sure they'd comply.

So what you're talking about is neither a legal government power or something where people would trust the government and follow along. You're looking for a way for the people in power to seize further power illegally when they think it appropriate. There's no "for good" there; that's just authoritarians undermining the rule of law.

<comment><USER6> > _if the Secretary of the Treasury asked all the banks to stop electronic > transactions for a legitimate reason, I 'm sure they'd comply_

"Franklin Delano Roosevelt proclaimed a Bank Holiday...that shut down the banking system" in 1933 [1]. This is an old power pre-dating our current hyper-centralised banking system.

[1] [https://www.newyorkfed.org/research/epr/09v15n1/0907silb.htm...](https://www.newyorkfed.org/research/epr/09v15n1/0907silb.html)

</comment></comment></comment></comment><comment><USER7> We need significant, international corporate reform well beyond just tax policy, or Western liberal democracy will be lost as corporate 'citizens' completely dominate the human ones.

<comment><USER4> Good luck getting everyone to cooperate.

Think about it, how much did different cities cooperated when trying to get Amazon's HQ2?

That said, you could at least _narrow_ the problem by getting just the US, the EU, and China to cooperate. (But even that strikes me as a Sisyphean task. But what do I know?)

<comment><USER8> It would be rational for cities and states to lobby for the federal government to introduce legislation which makes the kind of tax breaks that corporations are angling for illegal.

Note: it is rational for them to _simultaneously_ compete for corporate investment by offering individual tax breaks _and_ lobby for such tax breaks to be made illegal at the federal level. This is rather hard to explain to many even otherwise intelligent people, but it's one of the most important lessons that game theory has to offer.

The EU was acting somewhat in this direction when it forced Ireland to collect taxes from corporations.

<comment><USER9> I don't think it's hard to explain: it's the cities' equivalent to cartelization. It's no wonder why two competing firms would like to prevent each other from lowering prices, and they often lobby for laws to do that. The mechanism here is the same.

<comment><USER10> > I don't think it's hard to explain: it's the cities' equivalent to > cartelization. It's no wonder why two competing firms would like to prevent > each other from lowering prices, and they often lobby for laws to do that. > The mechanism here is the same.

A city or a state isn't a "firm." It's not seeking the private profit of its owners: it's seeking the welfare of its citizens, which is part of seeking the welfare of all the citizens of a nation. When it comes to government, "cartelization" isn't a bad thing, because it keeps private interests from exploiting public divisions to harm the common good for private gain.

Cartels prevent "races to the bottom," but some of those are actually good for society (e.g. the race to the lowest price per unit of product-value). Other races to the bottom are bad for society (e.g. lowest standard of living per worker), and government cohesion can help prevent them by resisting the private interests that benefit.

<comment><USER9> I don't disagree with any of that; just saying the mechanism is the same.

</comment></comment></comment></comment></comment></comment><comment><USER11> > "The firms involved in the journey made profits of $151bn and had a median > return on capital of 29% last year. An equally weighted basket of their > shares—call it the monopoly money portfolio—beat global stockmarkets by 484% > over the past decade. Collectively, 17% of the companies' shares are owned > by just three investment mega-managers, BlackRock, Vanguard and State > Street."

If these were a nation-state they would rank in the Top 10, yes? Top 20 at the least?

With money comes power. With power the drive to maintain that power.

Where there is anti-West sentiment, these outfits should be very concerned. As should the rest of us, as it is the rest of who will fight their battles / wars, if history repeats itself.

</comment><comment><USER12> Relatedly in NY Times: "Be Afraid of Economic 'Bigness.' Be Very Afraid. In the 1930s it contributed to the rise of fascism." [https://www.nytimes.com/2018/11/10/opinion/sunday/fascism- ec...](https://www.nytimes.com/2018/11/10/opinion/sunday/fascism-economy- monopoly.html)

<comment><USER13> Fascinating, thanks. No idea why the negative reception.

Previously:

[https://news.ycombinator.com/item?id=18429409](https://news.ycombinator.com/item?id=18429409)

</comment></comment><comment><USER14> I always see this as fundamentally a matter of weakening of democracy. In my personal view, democracy is the principle that each person must have a say in decisions that affect them. In other words, any given power must be shared among the people that it affects.

Now as more and more "power" goes into the hands of corporations, less and less power is in the hands of the (supposedly "democratic") governments, which themselves are imperfect democracies. And make no mistake: corporations control, and have power over, _vast_ and chunks of our lives. Crucially, that power is fundamentally held in a nondemocratic way: not subject to any scrutiny or control by the part of the people that it affects. For me, this is one of the most critical flaws of capitalism, the fact that _privately held power_ and _democracy_ are fundamentally incompatible, and that the more power corporations hold, the less democratic is our control over our lives: the less free we are.

<comment><USER15> The Dig podcast just posted a fascinating discussion of the roots of neoliberalism talking about the binding of nations in favor of nameless market structures. There is a discussion of Hayek seeing a ideal of people making independent decisions, but essentially bound by market constraints in a way that makes the system operate smoothly. I don't think there was the anticipation of the rollup of large corporate entities in this kind of vision - at least not to the scale that they start pulling on the fabric of the system leading to instability.

[https://www.blubrry.com/thedig/39413662/a-history-of- neolibe...](https://www.blubrry.com/thedig/39413662/a-history-of- neoliberalism-with-quinn-slobodian/)

</comment></comment><comment><USER16> Note this is the intro piece to a series of articles in an Economist "Special Report" which they do from time to time on various topics. They talk about tech more specifically in the "The tech antitrust paradox". However, while this not just a simple attack piece at all, and the Economist to its credit tries to consider various defenses and complexities as well, I think they miss a couple of really big ones by failing to really get down to some of the fundamental foundations tech is built on.

The first issue is simple: fantastically enormous capital expenditures. The basic story here is simple and repeated, the early and medium stages of a new industry's development inevitably harvest all the low hanging fruit in terms of pure physics and math. There is no path dependency yet either. But as it matures the cost of incremental gains begins increasing non-linearly. In tech we see this most particularly in semiconductor fabrication, where the costs of the cutting edge processes that have powered everything we do have been on a J-curve for each new node. An article by by SemiEng "Big Trouble At 3nm" [1] earlier this year had a good graph from IBS show the trend in design costs alone. In terms of the fab themselves IBS estimated "3nm will cost $4 billion to $5 billion in process development, and the fab cost for 40,000 wafers per month will be $15 billion to $20 billion", and it wouldn't be surprising if that was _optimistic_. "7nm" (TSMC, ~Intel 10nm) has been hard and multi- billion expensive also.

Economically the only way to make this work is by trying to amortize towards the thankfully very low raw material cost through enormous volume, and players must be able to front fantastic sums with very long time horizons. How does this square with tons of tiny firms? Vertical integration could be gone after so it's a pure foundry model, but that still leaves just a couple of foundries in control there. That's chips alone though, lots of other areas of electronics have the property of low resource cost combined with utterly enormous capex requirements, such as state of the art displays. Improvements in energy storage also require plants like the Gigafactory. The results are super, super important in my opinion, it's absolutely in our overall interest to keep pushing forward computation (not just silicon but whatever else becomes possible like optical computing), to reduce the price and improve the performance of energy storage technology, better human/system interfaces (retinal scanning displays next perhaps?), more reliable better memory, and on and on. We're far from "done" here. Yet this naturally takes not just long time scale dirt moving but also R&D, inevitably including some blue-sky.

And blue-sky R&D in the context of tech brings us right back to government vs corps too. In principle one way to try to allow smaller firms again would be to offload a lot of this back onto government instead, which by definition has a long time horizon and shouldn't be as worried about individual short term ROI or any single area vs the long term health of the state as a whole. It can make the results of research available to all. But government R&D has not been keeping up there. Monopolies can act in effect as a pseudo-government in many ways financially, and in fact a lot of the scary parts of them can also potentially give them an escape from typical quarter-to-quarter thinking. Some of the key foundations of our current tech trace right back to places like Bell Labs and Xerox PARC, R&D outfits that performed long term research which their parents often didn't even profit from, but were themselves backed in part by the massive economic power of their parent corps.

And no discussion of this would be complete without getting back to one area the government directly plays in monopolies: intellectual property. Maximalism there long since got out of control. The Economist piece doesn't give this the right level of attention IMO, particular wrt tech where rather then merely having (overlong _incorrectly implemented_ ) copyright and trademark, there are "software patents" and "business method patents" that don't just cover an implementation but basic mathematics and fundamental ideas themselves. This is a big practical part of the "moats" they talk about in their conclusion, and the difficulty small firms have in competing because that would depend on interoperability.

The capex part is just really hard, and I didn't even touch on things like the space exploration SpaceX (and hopefully Blue Origin soon) has started to revolutionize after decades of doldrums. It's one thing to talk grandly about "splitting up the bad guys" and such, but asking the public to pony up tens of billions to take their place might be different (if it can't be disguised another way, like military spending maybe). And that's even assuming it'd work and government could do the job there, which it might not. R&D is more promising and the open research initiatives gaining steam now are an important part of that, but also unfortunately doesn't seem a slam dunk or very safe from politicians looking for easy things to cut and attack. "What is this even any good for anyway huh?" etc.

IP is promising if only because it's purely within the power of government itself in principle, it's a creation of government in the first place anyway. Making copyright function with software like it does all previous media (source escrow for non-open/available), reducing its term to levels that reflect how modern electronic distribution has reduced costs and increased audiences along with desired churn, eliminating software and business method patents entirely, carving out far more powerful interoperability exceptions, requirements that at the least technical protection measures cannot be stacked with legal protections (or must be very term limited), would all go a long way towards increasing dynamism there. So would legal changes to cut down the EULA tape, and _not_ just for buyers either. Producers should also be fully protected from liability by default without any contract, and contracts reserved for sufficient sophisticated entities in bespoke arrangements that wish to affirmatively bargain standard rights.

It'd be good if popular anger here could be channeled towards some real positive changes, but I do fear that between lack of public or political understanding and powerful entrenched interests it will instead be channeled unproductively at best or into a real baby-and-bathwater situation at worst. To some extent big corps have even perversely taken a role defending some of our interests from governments in a way individuals cannot, would we be able to oppose intelligence agencies efforts to backdoor crypto as well as Apple for example? Of course conversely big companies have often been directly complicit and key to government authoritarian impulses and intel gathering too. It's really hard to figure out where to start, though I think IP at least is a relatively easy pickings place.

\----

1: [https://semiengineering.com/big-trouble- at-3nm/](https://semiengineering.com/big-trouble-at-3nm/)

<comment><USER17> Or as my boss likes to say, it takes a lot to grow a redwood tree and after you are done you can't turn it into a blue whale. So you just sit there making sure no one cuts it down.

</comment></comment><comment><USER18> Replacing one supergiant with a small cartel of giants doesn't make a major difference in the balance of power.

What's needed is actual decentralization, where consensus occurs without a trusted third party.

</comment><comment><USER19> In other news, green grass gets greener, at least in Michigan

</comment><comment><USER20> I feel that we should at least mention decentralized technologies in this discussion.

Please consider how systems like cryptocurrency, smart contracts, types of content-oriented networking, etc. may enable open platforms that can be an alternative to the monopoly companies'.

<comment><USER21> Don't stop there, there is a push for Decentralized Planned Economies. ( [https://www.wikiwand.com/en/Decentralized_planning_(economic...](https://www.wikiwand.com/en/Decentralized_planning_\(economics\)) )

<comment><USER22> That's just an empty page, you probably meant [https://en.wikipedia.org/wiki/Decentralized_planning_%28econ...](https://en.wikipedia.org/wiki/Decentralized_planning_%28economics%29)

</comment></comment></comment><comment><USER23> The problem with the free market is really _language_. Humans tend to converge to a small number of words for everything. It's Google for search, iPhone for phones, and Coke for cola. If we solve this language problem, then we can hope to solve the problems caused by monopolistic behavior.

<comment><USER24> It's an intriguing idea that language might cause humans to be biased towards exploiting knowledge about common brands rather than exploring new ones. Do we derive utility from having a thinner "tail" on our (shared societal) vocabulary?

Unfortunately, the distinction between "brand" and "corporation" makes this point, while interesting, somewhat moot. Consider that the Koch brothers have been able to consolidate brands ranging from TIME to Sports Illustrated, from Brawny towels to Dixie cups. In a world where users desire a "long tail" of brands, corporations continue to consolidate but simply invest in a wider variety of brand names and marketing for them. There's still synergy to be gained from a consolidated entity operating all of those brands. And so we're right back where we started.

<comment><USER10> > In a world where users desire a "long tail" of brands, corporations continue > to consolidate but simply invest in a wider variety of brand names and > marketing for them. There's still synergy to be gained from a consolidated > entity operating all of those brands. And so we're right back where we > started.

Exactly. An example: Whirlpool owns many major appliance brands (e.g. Maytag and Amana). They can afford to make ever crappier products, because they know when a customer is unsatisfied, they'll more than likely buy another Whirlpool under a different brand name.

[https://recraigslist.com/2015/10/they-used-to- last-50-years/](https://recraigslist.com/2015/10/they-used-to-last-50-years/)

</comment></comment></comment><comment><USER25> So the rich are getting richer and the powerful more powerful. Unfettered capitalism is working as it's supposed to be. What else is new?

</comment><comment><USER26> > "Competition is for losers," writes Peter Thiel, an American venture > capitalist, in his book, "Zero to One". Monopoly is the goal, he says.

Wow!

<comment><USER27> It's specifically in reference to tech firms. He postulates that competition causes human suffering since people work harder and harder for diminishing rewards as things get increasingly competitive. On the other side, monopolies are established because they invented some novel technology that other people couldn't easily reproduce, or did something so much better than the competition that everyone chooses to use them. Thus, he says monopolies are responsible for making society richer. Moreover, he says they reduce human suffering because 1. the great societal value produced by the monopoly, 2. the workers at the firms don't need to work as hard since they don't have competition, and 3. they can spend more on r&d, thus adding even more value to society.

The statement is surprising on its face, but he plays a good devil's advocate. There are plenty of holes to poke in his arguments, so have at it.

<comment><USER10> > There are plenty of holes to poke in his arguments, so have at it.

1\. You're not going to truly release the social value of a monopoly unless you socialize it, either through social control or regulation. Without that, the monopoly will mainly serve to benefit its owners.

2\. Monopoly R&D expenditure will likely be less than the excess profit captured by the monopoly's owners, and mainly motivated by potential regulation. IIRC, the main raison d'être for Bell Labs to exist as it did was to convince regulators to not break up AT&T. Without that threat it would have likely been more focused on AT&T's profit motive and less on generalized scientific advancement.

3\. Monopolies (socialized or otherwise) will more likely end in stagnation.

<comment><USER27> > 1\. You're not going to truly release the social value of a monopoly unless > you socialize it, either through social control or regulation.

I somewhat disagree. There are some monopolies which become more valuable to society the larger they are due to network effects. One example is Google maps. I suspect the more people use maps, the more accurate their live traffic data will be, which gives every other user more accurate information. Marketplaces are another example of network effects benefitting users - <USER2> more buyers and sellers in one marketplace, the easier it becomes for them to find one another.

> 2\. IIRC, the main raison d'être for Bell Labs to exist as it did was to > convince regulators to not break up AT&T

Interesting, I was going to use Bell Labs as an argument in favor of monopolies producing r&d. It seems like they invented everything!</comment></comment></comment></comment>


Some thoughts about setting up a basic frond-end build process - <AUTHOR> https://ministryofdev.wordpress.com/2016/11/05/creating-a-resilient-front-end-build-process/ <comment><AUTHOR> My first attempt to write down some thoughts. Please let me know what you think!</comment>


Arizona: Racketeering Suit Filed Against Speed Cameras  - <AUTHOR> http://www.thenewspaper.com/news/32/3290.asp

<comment><USER2> If I drive with a mask on does that protect me from photo enforced intersection tickets?

<comment><USER3> What's the precedent on masks in public these days? Surely it would fall under some form of protection from terrorists?</comment></comment>


Ghostdown - Markdown editor from Ghost - <AUTHOR> https://github.com/timsayshey/Ghost-Markdown-Editor

<comment><USER2> This looks awesome. Markdown is just about simple enough to bridge the divide between people like me, who left to their own devices, would probably use LaTeX for most things, and others who mostly skew toward word. This kind of editor definitely reduces friction for people in the latter group.

One thing I'd love to see (and maybe it already does this) is support for Pandoc's Markdown extensions. Org-tbl is nice, as are the supports for bibtex refs. There's a handful of other niceties that pandoc has added.</comment>


If you wrote a program to find the meaning of life, what language would you use? - <AUTHOR>

<comment><USER2> Perl. You can find anything with regexp.

</comment><comment><USER3> At risk of downvotes, Java.

</comment><comment><USER4> Python and NLTK :)

</comment><comment><USER5> Javascript !

</comment><comment><USER6> DNA

</comment><comment><USER7> Lisp.</comment>


Ask HN: What Vim plugins would you pay for? - <AUTHOR>

I just realized that I don't know of a single plugin/addon/modification to vim that you can purchase.  This is somewhat suprising, and made me wonder, what would a vim plugin do that would make you willing to pay for it?<p>Also, if you've paid for a vim plugin/addon/modification, what was it?  Was it worth it? <comment><USER2> i'd pay for a single unified plugin that manages a project, incorporating automatic ctags (i.e., i don't have to run tags manually - it should automatically update the tags list with any open file), a file browser (like nerdtree), buffer management (like fuzzybuffer).. there are all these parts available i'd like something that is guaranteed to work consistently, look good, and be easy to install with one vimball</comment>


100 Days Without the App Store - <AUTHOR> http://mjtsai.com/blog/2017/01/12/100-days-without-the-app-store/ <comment><AUTHOR> Original URL: [https://blog.kapeli.com/100-days-without-the-app- store](https://blog.kapeli.com/100-days-without-the-app-store)</comment>


Econometricians, Financial Markets and Uncertainty: An Anthropological View - <AUTHOR> http://fixingtheeconomists.wordpress.com/2014/08/21/econometricians-financial-markets-and-uncertainty-an-anthropological-view/

<comment><USER2> Whenever I see arguments like,

" _It is clear that Zaka the Malagasy thinks David the American's questions to be absolutely bizarre. It simply does not make any sense to him. Despite being educated he does not even think to ascribe to chance a numerical estimate._ "

I start getting the suspicion that I'm being played. Do Malagasies not gamble? He goes on with,

" _But when Graeber asks what the chance of the bus turning up is or whether the cops will notice that he is parked illegally, these estimates are not objective. They are entirely mystical._ "

Those estimates are not mystical. They're not backed up by good data and they're not really objective, but "mystical" is absolutely the wrong word. The probability of a bus arriving in the next five minutes can certainly be quantified, as a single number.

On the other hand, it is also true that much of "econometrics", economics based on numbers rather than the even-worse grand theories of the universe, are _not_ backed by the solid grounding that bus arrivals are. Things like GDP (or GNP; I can't remember the current term) or Black–Scholes do not have any real evidence of existence and are certainly "mystical".

I see imagine the "performativity" aspect is going to be a hoot, too.

<comment><USER3> > I start getting the suspicion that I'm being played. Do Malagasies not > gamble?

They may gamble, but who says they do so _well_? How well do Westerners indulging in gambler's fallacy or gambler's ruin understand it? And remember Blaise Pascal's invention of probability is ascribed to a dispute between experienced gamblers (Chevalier de Méré).

</comment></comment><comment><USER4> The anthropology of economics and the economics of anthropology are equally hilarious.

<comment><USER5> Yes, it was amusing to read in Graeber's _Debt: The First 5000 Years_ about economics' founding myth of barter. And "the fact that many of Adam Smith's most famous arguments appear to have been cribbed from the works of free- market theorists from medieval Persia (a story which, incidentally, has interesting implications for understanding the current appeal of political Islam)."

Econ is indeed the dismal pseudoscience...

</comment></comment><comment><USER6> Somehow, David Graeber on anything economic, is likely worth about as much as his description of Apple's founding.

[http://www.businessweek.com/finance/occupy-wall- street/archi...](http://www.businessweek.com/finance/occupy-wall- street/archives/2011/11/david_graebers_odd_history_of_silicon_valley.html)</comment>


I incorporate randomness into my blog's stylesheet - <AUTHOR> https://blog.canh.am/how-i-incorporate-randomness-into-my-blogs-stylesheet/ <comment><AUTHOR> I'm interested to hear about other projects that are using a similar concept. Post below if you know of any...</comment>


Microsoft to stop producing Windows versions - <AUTHOR> http://www.bbc.co.uk/news/technology-32658340 <comment><USER2> Numbering the versions turned out to be problematic. That's why Windows 10 is not Windows 9.

[http://www.businessinsider.com/windows-10-not- windows-9-2014...](http://www.businessinsider.com/windows-10-not- windows-9-2014-10)

</comment><comment><USER3> Microsoft is again on Apple's footsteps.. OS X.. :)</comment>


Indian College suspends students for eating in class: Orders enquiry   - <AUTHOR> http://imgur.com/tAnKTkF

<comment> indian-here Good. Certain level of decorum needs to be maintained in class. Love the freedom of doing things you like, but when you get in class, you respect others in the class.

Note: This is not some elementary class hungry students, when you are in Engineering, its expected you have attained some maturity to manage your time.

<comment><AUTHOR> Respect for others in class is shown by not disturbing or interrupting the class. While the decision to follow the class or not lies with the individual. Seems they were just on their of and not in any way disrupting the class for others. To force students to pay attention in class is a stupid idea because learning is a voluntary process.

Further making it into such a huge issue actually reflects on the immaturity of people involved.</comment></comment>


Learning Racket #2: Macros, Macros and a Bit of Modules - <AUTHOR> http://artyom.me/learning-racket-2

<comment><USER2> Just nitpicking. The first example that uses define-syntax-rule can also be fixed with "...". He uses the "..." later in syntax-parse, but they are available in define-syntax-rule too. With syntax-parse is easier to construct advanced macros, but I like to use define-syntax-rule for small throwaway macros.

      #lang racket

      (define-syntax-rule (def id body ...) (define id body ...))

      (def (vector-swap! vec i j)
        (def t (vector-ref vec i))
        (vector-set! vec i (vector-ref vec j))
        (vector-set! vec j t))

      (let ([v (vector 'a 'b 'c)])
        (vector-swap! v 0 1)
        v)  ;==> (vector 'b 'a 'c)

<comment><USER3> Thanks for telling! (I've written a bit of a response here: [http://artyom.me/learning-racket-2#gus_massa-from- hn](http://artyom.me/learning-racket-2#gus_massa-from-hn) .)

</comment></comment><comment><USER4>
        I'm afraid that with the level of flexibility Racket allows, I'll never get to writing an actual program

Great series

</comment><comment><USER5> While I know hn discourages "mee too!"-posts, let me just say that I find these series really interesting. I'm such a lazy programmer, I just love having someone else muck about with stuff like this macro-madness and then tell me about it, saving me from having to start up racket at all :-)

In short: Keep at it! It's greatly appreciated.

<comment><USER6> HN discourages substanceless comments, but this one is just fine.</comment></comment>


Ask HN: Do you need Karma to upvote? - <AUTHOR>

My friend posted an article to HN and asked me to upvote it.  I did, but my upvote never counted.  Several other people upvoted also, but their votes didn't count either.  I didn't find anything in HN Faq or other places on internet about requiring you to have Karma to upvote.
How much Karma do you need for your vote to count?
Also it is a bit confusing to have "upvote" button available if upvoting is not enabled for you.  Would be nice to have it disabled or show an alert that you haven't met a certain requirement to be able to upvote. <comment><USER2> No, you dont need karma to upvote. However, people often do things like get friends to upvote their content. Therefore, there are algorithms in place to detect this. When the algorithm detects that this has happened, it revokes the upvote.

<comment><AUTHOR> How can algorithm detect if someone is my friend?</comment></comment>


Redis 2.6.0 Released - <AUTHOR> http://redis.io/download#2.6.0

<comment><USER2> Joy to all! This means that the Lua scripting is now available in a stable release!

Want to use Redis as a very fast bloom filter server? A couple of short Lua scripts can make it happen. Want to do some operation which would require a lot of round-trips to Redis? Turn it into a Lua script and get rid of those network round-trips. Once you get used to having this capability, it starts to feel indespensible, an essential feature that Redis would be incomplete without.

Oh, and I guess there are a bunch of other improvements in 2.6 -- reduced memory usage, more convenient command-line options for redis-server, some handy new commands, and a lot more -- but really, the Lua scripting is so good that it outshines everything else.

<comment><USER3> That sounded like fun, so:

Bloom filters in redis: <https://gist.github.com/3936629>

Turns out it's kinda hard to get a decent hashing algorithm working in redis- lua-land, but I'm sure an implementation of murmurhash wouldn't be so hard if one had a few hours.

EDIT: It's worth mentioning, too, that we've been using a collection of lua scripts to manage inventory reservations at Shopify since March, and the tech has worked very well for us.

<comment><USER2> I was thinking that you could have the client pass in a couple of hash values, and then use linear combinations of them to get a bunch of independent-enough hashes. This is mathematically fine, and hash functions are a dime a dozen when you're not in redis-lua-land. Paper justifying this technique:

[http://www.eecs.harvard.edu/~michaelm/postscripts/tr-02-05.p...](http://www.eecs.harvard.edu/~michaelm/postscripts/tr-02-05.pdf)

</comment></comment></comment><comment><USER4> My (pretty exhaustive) notes from RedisConf today, in five parts:

<https://gist.github.com/3932768>

<https://gist.github.com/3933451>

<https://gist.github.com/3934073>

<https://gist.github.com/3935007>

<https://gist.github.com/3935671>

<comment><USER5> Would you mind putting them into a single gist or git repo or would you mind if I do?

<comment><USER6> One file: <http://pastebin.com/tASCpVMH>

</comment></comment></comment><comment><USER5> Congratulations to antirez and all the other commiters! It's been a long awaited release and there are still a lot of good things to come!

</comment><comment><USER7> Related -> <http://antirez.com/news/21>

</comment><comment><USER8> Can one simply upgrade from 2.4 -> 2.6? No data migration involved?

Side topic: It's pretty cool that you guys have dedicated pages for administration. <http://redis.io/topics/admin>

<comment><USER9> Read the release notes. There's an entire section about migration from 2.4 to 2.6.

Short answer: You can simply upgrade.

</comment></comment><comment><USER10> I can't tell, does 2.6 include Sentinel / failover support?

<comment><USER7> Both Redis 2.6 and latest 2.4 patch release are ready to be monitored by Sentinel as targets of the monitoring.

Redis 2.6 includes an experimental implementation of Sentinel considered in beta stage, that will be upgraded with every new release of 2.8.

The development of Redis Sentinel continues in the unstable branch in the meantime. Basically at some point when Sentinel will be declared stable, 2.6 will ship with a stable version of Sentinel, however 2.8 may implement additional support for Sentinel features that may not be available for 2.6.</comment></comment>


Strava Drops a Popular Feature and Drives Users Away - <AUTHOR> https://www.forbes.com/sites/kevinmurnane/2019/10/22/strava-drops-a-popular-feature-and-drives-users-away/ <comment><AUTHOR> This sort of decision confounds me. Without being a fly on the wall at Strava HQ it's impossible to know why they would do such a thing (any press releases taken at face value).

This change won't affect most serious users, but it is still a core part of their offering. Sadly it seems that each update just makes the UI less useful and more "share-y".

But without a good alternative, I'll be sticking with Strava for the indefinite future. Hopefully they get back on track and start fixing the long list of bugs that are meaningful to their super-users.</comment>


Two new particles detected by LHC - <AUTHOR> http://www.newscientist.com/article/dn26345-two-new-strange-and-charming-particles-appear-at-lhc.html#

<comment><USER2> So, with my meagre understanding, is this emerging evidence of some form of supersymmetry?</comment>


Ask HN: How did Ross William Ulbricht get caught? - <AUTHOR>

<comment><USER2> At least someone intelligent is asking if "parallel construction" was used: [http://blog.erratasec.com/2013/10/silk-road-caught-by- nsa.ht...](http://blog.erratasec.com/2013/10/silk-road-caught-by-nsa.html)

</comment><comment><AUTHOR> Best description found so far: [http://www.bbc.co.uk/news/technology-24371894](http://www.bbc.co.uk/news/technology-24371894)</comment>


The Meme as Meme (2015) - <AUTHOR> http://nautil.us/issue/23/dominoes/the-meme-as-meme-rp <comment> Tech-Noir > Richard Dawkins, the famous evolutionary biologist who coined the word > "meme" in his classic 1976 book, The Selfish Gene, seemed bent on disowning > the Internet variety, calling it a "hijacking" of the original term.

I'd hardly call the video where he calls it "hijacking" showing him "bent on disowning the Internet variety":

[https://youtu.be/GFn-ixX9edg?t=4m8s](https://youtu.be/GFn-ixX9edg?t=4m8s)

Nor his attitude to the word being "reappropriated by the internet"[1]:

        The meaning is not that far away from the original.
        It's anything that goes viral.

        In the original introduction to the word meme in the
        last chapter of The Selfish Gene, I did actually use
        the metaphor of a virus.

        So when anybody talks about something going viral on
        the internet, that is exactly what a meme is and it
        looks as though the word has been appropriated for a
        subset of that.

[1] [https://www.wired.co.uk/article/richard-dawkins- memes](https://www.wired.co.uk/article/richard-dawkins-memes)

<comment><USER2> I'm thinking of meme as a broader category than that, more of a trope.

Disclaimer: I'm not trying to hickack the term, but I think writing "disclaimer:" especially on HN is a meme, but not virulent.

<comment><USER3> There are loads of HN memes. "strawman" "true scotsman" "this is why we can't have nice things" etc.

</comment></comment></comment><comment><USER4> Discussion of memes is always a little surreal for me, because I can never be quite sure what someone else means when they say the word. Probably because I encountered Dawkins' idea of a meme as a replicating unit of thought before "Internet Memes" existed. I start off assuming that others are using the term with my internal definition (i.e. correctly) but then encounter clues that they mean the internet-spread picture formats. However, there is rarely enough context to be certain which meaning is being used.

It makes me wonder how we communicate at all when no two people ever quite speak the same language. It also makes me a grammar nazi as I become aware of how important a uniform shared language is :)

<comment><USER5> I think you're doing yourself a disservice by defaulting to assuming "meme" means the biological definition. The "correct" definition of a word is however most people use it, not whatever internal definition you yourself have in your mind, nor whatever the dictionary happens to say.

<comment><USER6> It's not that simple. Sometimes people use a word in one or several ways, while expecting other people to use it in one or several different ways. And it hardly ever makes sense to count all people equally: you're probably more interested in how the people you personally communicate with use or understand a word than with how millions of people in a different country might use or understand the word. And lots of people speak several varieties of a language, or have different registers for different social situations. It can all get very complex, but a thorough lexicographer will attempt to understand and describe that complexity, rather than claim they can solve it all with some kind of majority vote. The concept of "correctness" exists in the heads of many speakers and is part of the linguistic reality that should be understood and described along with everything else.

</comment></comment></comment><comment><USER7> I don't see memes as infecting our minds so much as giving voice to something that is already there that doesn't come up in conversation. The Nike and Sweatshop meme wouldn't be funny if people didn't already know that Nike had faced charges of using sweatshops. We all have a friend who seems to have terrible luck, so when formalized as "Bad Luck Brian" it becomes a vehicle for finding humor in this.

<comment><USER8> "I don't see memes as infecting our minds " See also: Tide pods.

<comment><USER9> I like to combine Tide Pods with Ugandan Knuckles:

"Tide Pods are de way."

</comment></comment></comment><comment><USER10> Dawkins' issue with basically natural vs. artificial selection of memes seems unnecessary as far as 'killing' the meme. There's interesting information there regardless of origin and methods of evolution - a shared lexicon is important (tangentially, in part that's what memes - Internet and otherwise - signify), when discussing memes I do try to distinguish via image memes that are passed on the Internet, classical memes, copypasta, etc.

It's really interesting research, and I don't think it's dead. Me and others built Danqex (formerly Nasdanq) partially to analyze trends and gather information to figure out the lifecycle of an Internet meme. I still also hold out hope that more formal research will continue in this area, whether academic or commercial.

</comment><comment><USER11> An interesting tanget: when reading this _Nautil.us_ article, they have an "Also in the Web" section where they recommend related articles, but they recommended I read the self-same article. Seems like they need to add an extra line of code to prevent this.</comment>


Show HN: Learning to code, my first CRUD web app - <AUTHOR> http://www.opusnota.com <comment><AUTHOR> Hacker News: you publish your first learning project web app that allows to post comments and the first comments posted are a rant and two tries of hacking the app:

\- _" A haven for ridiculous clickbait sites like this one"_

\- _" <script>alert('hello')</script>"_

\- _" SQL injection'; delete from posts;"_

<comment><USER2> Hacker News: you publish your first learning project web app and helpful people validate its security \o/ .. :P

<comment><AUTHOR> : ) Ok, I will go with this take on it!

<comment><USER3> I was going to say the same thing. If they had succeeded you would have gotten some valuable feedback

</comment></comment></comment></comment><comment><USER4> Why not talk a little about what tools/languages you used, tutorials you read, videos you watched, etc.

<comment><AUTHOR> I touched on it at the site's "about". But basically is made using NodeJS+ExpressJS+MySQL hosted at Heroku that I learned at www.freecodecamp.com and trysparkschool.com.

Videos don't work for me, so these two courses are a great fit.

<comment><USER5> Hey I'm Shane, the creator of [http://trysparkschool.com](http://trysparkschool.com).

I really like your site and I'm glad the course helped you get it built. Keep up the good work!

<comment><AUTHOR> Congrats again for your work! I enjoyed it a lot! I commented on the course and also sent an email to say so! :)

What do you plan next?

You can see that the app resists the basics injection attacks (i remembered that lesson when the comments started! lol).

<comment><USER5> Thanks for the comments and email! I'll be responding to your email in a few minutes.

I'm going to make another course, but not sure what it's going to be over yet. I'll be asking people that completed the Twitter clone course what they are interested in, but I'm leaning towards building a full web app (user, payments, etc).

Haha I saw some people tried to do injection attacks. That's pretty great. We have you covered though :)

<comment><AUTHOR> My vote goes for user management + deploy to the real world.

</comment></comment></comment></comment></comment></comment><comment><USER6> Curious about the story behind learning to code.

<comment><AUTHOR> A late career change. I used to work with NGOs, with fundraising. Then with startup, with marketing and growth, once a founder.

I decided to become a professional software developer mostly for two reasons: i) I really enjoy coding - the few times in my life I dedicated myself to learning and creating small things with software I always had a very good feeling and ii) it is a more defined, employable career than my current very heterodox, weird, mixed bag CV experiences of social sector + startup founder + generalist digital marketing.

<comment><USER6> I can relate to your motivation based similar experiences.</comment></comment></comment>


Developing Effective Bioinformatics Programming Skills (2009) - <AUTHOR> http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1000589

<comment><USER2> There's also the recent (2014) " _Online Computational Biology Curriculum_ " paper that might be interesting:

[http://journals.plos.org/ploscompbiol/article?id=10.1371/jou...](http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003662)

</comment><comment><USER3> Oreilly has an excellent bioinfo data skills book: [http://shop.oreilly.com/product/mobile/0636920030157.do](http://shop.oreilly.com/product/mobile/0636920030157.do)</comment>


Type 2 diabetes cure, extreme diet - <AUTHOR> http://www.latimes.com/health/boostershots/la-heb-diabetes-extreme-diet-06252011,0,7790769.story <comment><USER2> To be clear, onset of type2 diabetes is tied in with weight and health.

My wife (who studied dietetics/food & nutrition) while at university volunteered for a pre-diabetes program whose sole purpose was to stress to people who were at high risk for developing type2 diabetes that they could stave off the effects of the disease by eating more healthily, and explaining how they could accomplish it.

The vastly important thing to stress here is that a reduction of the level of fat is the important part, _not_ starving themselves. Presumably other forms of weight loss (as a means to better overall health) would have the same sorts of effects.

Starving one's self should not be taken as the first step that people should reach for, and even if people were to do so, they should make absolutely sure that they're still getting proper nutrition so that they are losing weight safely.

tl;dr: it's unhealthy to be morbidly obese. Your health improves if you stop being morbidly obese. That can include the effects of type 2 diabetes.

</comment><comment><USER3> I did my surgical internship at a hospital with a substantial bariatrics service. Yes. Starvation will cure type 2 diabetes. Overnight. Roux-en-Y patients often have normal blood sugars by the time they're out of the OR. We would watch them for 48 hours and their blood sugar didn't go back up. When they came in for follow-up, still down. It works. Like a champ.

I would like to reply to more comments here, but it's past midnight and my battery is dying. Maybe more tomorrow.

But, yeah, in general, type 2 diabetes is almost universally a consequence of over-eating.

<comment><USER4> I came here to say the same thing. While on my bariatric surgery rotation, the attending surgeons all said much what you said above with regards to normalizing blood sugars. One of them felt that the majority of her patients normalized their blood sugars _pre-op_ thanks to their preoperative fast...

</comment></comment><comment><USER5> The original paper: <http://www.diabetologia-journal.org/Lim.pdf>

> After the baseline measurements, individuals with type 2 diabetes started > the diet, which consisted of a liquid diet formula (46.4% carbohydrate, > 32.5% protein and 20.1% fat; vitamins, minerals and trace elements; 2.1 > MJ/day [510 kcal/day]; Optifast; Nestlé Nutrition, Croydon, UK). This was > supplemented with three portions of non-starchy vegetables such that total > energy intake was about 2.5 MJ (600 kcal)/day. Participants were provided > with sugges- tions of vegetable recipes to enhance compliance by varying > daily eating. They were also encouraged to drink at least 2 l of water or > other energy-free beverages each day, and asked to maintain their habitual > level of physical activity. Ongoing support and encouragement was provided > by means of regular telephone contact. At the end of the 8 week intervention > participants returned to normal eating but were provided with information > about portion size and healthy eating.

</comment><comment><USER6> I suspect the word cure is used capriciously here. Remission would probably be a better term. I know this study made a splash on Drudge the other day, but the response over on diabetesforums.com was much more measured:

[http://www.diabetesforums.com/forum/scientific- studies/60390...](http://www.diabetesforums.com/forum/scientific- studies/60390-interesting-study-reversing-type.html)

<comment><USER7> Right, well the whole point to a "cure" is to not have to make lifestyle adjustments. Anyone who's looking to be rid of their diabetes without having to adjust their lifestyle is going to be disappointed by this research and it's conclusions. In fact, I imagine that some sufferers will be outright livid once they realize the full implications of the research results.

Basically, we're getting more conclusive research showing that type 2 diabetes (runs in my family) is a lifestyle disease. In other words: if you are diagnosed with type 2, it's your own fault.

Specifically, insulin resistance is caused by higher-than-normal levels of fat in the liver and pancreas. Belly fat doesn't matter much. Arm fat doesn't matter much. It's the fat in your organs that's gumming up the works. People are more or less prone to developing fatty organs, so diabetes rates vary between genetic/family backgrounds.

To me, this is all fantastic news. I imagine that many of us are prepared to make a few comfort sacrifices in order to avoid these types of diseases. There is still a very persistent mindset, though, that all body issues (even obesity) are caused by external factors and that the sufferers are just helpless victims. I wouldn't expect that anyone trapped in the "my type 2 is out of my control, but the cure is just around the corner" mindset is going to be welcoming of the crash diet research.

</comment></comment><comment><USER8> So much argument here with extreme positions and blanket absolute statements, I am a little surprised.

What you eat is inextricably linked to your body's proper functioning and, yes, risk for a variety of diseases.

Thinking just about calories is meaningless. A single calorie of glucose / fructose / fat / alcohol / gasoline are simply not at all the same. Even the same ingredients (those useless nutritional composition labels) affect the body totally differently depending on how they are structured.

1 gram of pureed corn for instance will burn very differently from 1 gram of steamed corn kernels, versus that same 1 gram, popped.

It is a massive failure of education that people are surprised to hear that eating poorly leads to increased risk of disease.

Arguing that diet has no effect on disease is like suggesting that you could just live on glucose, a multivitamin, and water. Try that for a week and your body will be in full-on war against you. Actually, please don't.

</comment><comment><USER9> The benefits from fasting and/or eliminating sugar and starches from your diet comports with Robert Lustig's research on sugar toxicity (<http://news.ycombinator.com/item?id=2472019>).

</comment><comment><USER10> It would be interesting to see if a fat- and protein-sparing fast (i.e. Atkins diet) would work as well. Apparently it's much easier to eat a semi-starvation diet by eliminating nearly all carbohydrates than by simply cutting back calories in general.

<comment><USER11> Good point. Reversing type 2 diabetes comes when insulin sensitivity is gained back. For this to happen I believe a low carb diet should be enough, not a caloric restriction, but merely the elimination of foods that spike blood sugar. Would like to see clinical results of a strict Atkins / Paleo type diet for this group.

<comment><USER12> Did you actually read the article? The hypothesis has nothing to do with insulin itself, and everything to do with reducing fat deposits in the pancreas.

<comment><USER13> As the article says, that was just a hypothesis. There's no mention of tracking insulin levels, only blood sugar. And what's more, type diabetes is described in the article as resistance to insulin.

I can think of at least one further hypothesis, which is that cutting out indigestible sugars, per Lustig, frees up the liver from the task of metabolizing fructose/sucrose etc., to respond correctly to insulin, allowing blood sugar to be regulated.

</comment></comment></comment></comment><comment><USER14> There's a longer and less journalistic article about the same study here: [http://www.nhs.uk/news/2011/06June/Pages/type-2-diabetes- and...](http://www.nhs.uk/news/2011/06June/Pages/type-2-diabetes-and-low- calorie-diets.aspx)

I wonder it it supports/is related to this line of reasoning: [http://www.nytimes.com/2011/04/17/magazine/mag-17Sugar-t.htm...](http://www.nytimes.com/2011/04/17/magazine/mag-17Sugar-t.html)

</comment><comment><USER15> There is a significant cultural difference in the matter of treating diseases between West and East.

In the West people first use a drug (rather tons of them), then, if no progress was made, a medical assistance, then, changes in behavior as an inevitable consequence and a restricted diet as a last resort.

In the East (Tibet, for example) people _at fist_ use shifting to an appropriate diet _and_ behavioral changes, then, medical assistance and a drug (which is in most cases a placebo) as a last resort.

The differences between these two almost opposite approaches could be easily seen in the life expectation statistics between poor (common) people in Tibet/China/Mongolia/Japan and, say, Russia (where they use vodka, in many cases along with antibiotics, as the first aid) or US where the medicare is the way to make money, not to heal people, could be easily found in the net. ^_^

<comment><USER16> I wonder if that is a direct result of a more profit driven system in the west? There's no profit in good exercise and diet...

<comment><USER17> Tell that to gyms..

</comment></comment></comment><comment><USER18> Is it a cure or reversal? According to WebMD, it's not possible to cure completely. Honestly I am confused between the two definitions.

<http://diabetes.webmd.com/features/reversing-type-2-diabetes>

<comment><USER19> It's a reversal. Cure implies that a disease cannot, under most circumstances, come back due to the treatment regimen (whether that be diet, drugs, radiation, etc...). The reason it's a reversal and not a cure is that if a patient were to "stop treatment," which in this case means revert to a diet far above daily caloric needs, it is likely insulin resistance will return.

</comment></comment><comment><USER20> Or you could eat natural healthy food with exception of flour and sugar products (and reduction in lentils and dairy) instead of starving yourself: <http://www.marksdailyapple.com/diabetes/>

</comment><comment><USER21> Watch Food Matters on Netflix. A good diet can help cure many diseases.

<comment><USER22> Not to discredit (haven't had a chance to watch yet), but is there scientific evidence behind this?

<comment><USER23> Most people tend to discredit diet therapy because it's "not mainstream" or against the norm.

Of course you don't see nearly as many "studies" on diet therapy as you do a typical medicine or pill, most scientists and doctors that practice alternative therapy are considered heretics (cooks, crazy people, etc) and banished from the "mainstream" portion of the medical world (the one with all the cash flow).

Look up Dr. Max Gerson and all of the amazing things he's done with the use of a simple diet therapy consisting mainly of juices and fruits and vegetables. I would highly recommend his biography - [http://www.amazon.com/Dr-Max-Gerson- Healing-Hopeless/dp/0976...](http://www.amazon.com/Dr-Max-Gerson-Healing- Hopeless/dp/0976018616/ref=sr_1_6?ie=UTF8&qid=1309140433&sr=8-6)

It's a fascinating read and really challenges you to think against the mainstream medical world.

<comment><USER24> for the grandparent poster, the relevant studies on Gerson [http://www.cancer.gov/cancertopics/pdq/cam/gerson/patient/pa...](http://www.cancer.gov/cancertopics/pdq/cam/gerson/patient/page2)

</comment></comment></comment></comment><comment><USER25> Lifestyle change

\</comment><comment></comment><comment>-----

 _" Research has shown that people with severe coronary heart disease are able to halt disease progression or reverse it without drugs or surgery by making comprehensive lifestyle changes such as managing stress through yoga and meditation, switching to a low-fat vegetarian diet, stopping smoking, exercising moderately, and finding social support.<http://www.pmri.org/publications/1761.pdf>

• The June 2008 Proceedings of the National Academy of Sciences published a prostate cancer study demonstrating that lifestyle change can affect gene expression. The researchers found that improved nutrition, stress management, walking, and psychosocial support changed the expression of over 500 genes in men with early-stage prostate cancer. <http://www.pnas.org/content/105/24/8369>

• A long-term randomized controlled trial of patients with coronary heart disease showed that Transcendental Meditation practice was associated with a 47 percent reduction in mortality, nonfatal myocardial infarction, and stroke compared with controls during a five-year follow-up <http://220.127.116.11/TM_and_mortality.pdf> "_

[http://www.theatlantic.com/life/archive/2011/06/first-do- no-...](http://www.theatlantic.com/life/archive/2011/06/first-do-no- harm/240538/)

\</comment><comment></comment><comment></comment><comment></comment><comment>

Change or Die ( BY: ALAN DEUTSCHMAN )

Tags: Careers, Work/Life, work life balance, personal growth

<http://www.fastcompany.com/node/52717/print>

 _"What if you were given that choice? For real. What if it weren't just the hyperbolic rhetoric that conflates corporate performance with life and death? Not the overblown exhortations of a rabid boss, or a slick motivational speaker, or a self-dramatizing CEO. We're talking actual life or death now. Your own life or death. What if a well-informed, trusted authority figure said you had to make difficult and enduring changes in the way you think and act? If you didn't, your time would end soon -- a lot sooner than it had to. Could you change when change really mattered? When it mattered most?

Yes, you say?

Try again.

Yes?

You're probably deluding yourself.

You wouldn't change.

... "_

</comment><comment><USER26> I don't know if it's true, but I heard a story about a man who was cured from cancer by eating very healthy.

To me it's no surprise the body likes healthy food to maintain the ability to cure from a lot of things.

(edit: I think T. Colin Campbell is related <http://en.wikipedia.org/wiki/T._Colin_Campbell>)

</comment><comment><USER23> Diet can be used as a form of cure for nearly every disease that exist. So why not use it more often? Oh right, there is no money to be made...

<comment><USER24> This is a tin-foil-hat conspiracy theory reaction.

Define "use it more often". Doctors recommend diet and exercise all the time. It's the first thing to recommend to patients. It's simply very hard for people to accomplish it, and the vast majority of people either can't or won't lose weight.

<comment><USER27> "It's the first thing to recommend to patients."

I'm 42, I've been involved with two major medical systems for 30+ years, both in Canada and the United States (Kaiser) - for one reason or another, I've been to a doctor maybe a dozen times. For about 15-20 years I was either on the cusp of obesity, was always overweight - and certainly was never in the slightest bit of good physical shape.

In that 30+ years, I solemnly swear no medical official has ever made any recommendations about diet and/or exercise, with one exception of a emergency room intake doctor giving me some guidance on drinking more water after I was checked in for dehydration and the second time, when I contacted Kaiser Intake (half dead from a case of pneumonia ) - and they recommended I drink tea with a bit of honey. Sum total of diet advice.

In general, the medical system is much more interested in "Fix it when it's broken" then they are "Prevent it from breaking in the first place."

And they really tend to reach towards surgery/and drugs any time there is a problem. Some are offended when you suggest that perhaps an affliction might be diet recommended.

It's not a tin-foil-hat theory reaction. The American Journal of Clinical Nutrition has any number of peer reviewed observational studies on what happens to indigenous populations when they encountered western (refined) diets.

Taubes has an endless number of references in "Good Calories, Bad Calories" for those who are even moderately interested in how unbelievably important diet turns out to be when it comes to modern health.

But, where's the money in getting people to lead a healthy lifestyle?

People will need to figure this stuff out for themselves, it certainly won't be marketed to them the way HFCS laden beverages will be.

<comment><USER24> _"I'm 42, I've been involved with two major medical systems for 30+ years, both in Canada and the United States (Kaiser) - for one reason or another, I've been to a doctor maybe a dozen times. For about 15-20 years I was either on the cusp of obesity, was always overweight - and certainly was never in the slightest bit of good physical shape. In that 30+ years, I solemnly swear no medical official has ever made any recommendations about diet and/or exercise"_

I'm 36, I was a physician for 8 years (no longer practicing). I recommended diet and exercise to many many patients for general prevention and certainly for anyone with type 2 diabetes. And this was considered standard of care. I was not the exception.</comment></comment></comment></comment>


Understanding Bash (2018) - <AUTHOR> https://www.linuxjournal.com/content/understanding-bash-elements-programming <comment><USER2> I love bash and I know I'm not alone.

Sure, it's syntax is based on ideas from the 1960s[0] and it has a weird core library of functions[1]. Certainly writing code that is a blend of logic and managing other programs takes some getting used to. However, it is very well documented[2] and I've had great success with it over the past 20 years.

If one takes the time to get to know it, it is actually easy and fun to write scripts that are robust and easy to maintain.

I'd venture to say that bash is the putty in the little gaps of the internet. It is the fitting that glues programs to the various systems on which they run.

0\. [https://en.wikipedia.org/wiki/ALGOL](https://en.wikipedia.org/wiki/ALGOL)

1\. [https://en.wikipedia.org/wiki/POSIX](https://en.wikipedia.org/wiki/POSIX)

2\. [https://www.gnu.org/software/bash/manual/](https://www.gnu.org/software/bash/manual/)

edit: formatting

<comment><USER3> It's also extremely fast.

<comment><USER4> Sure, until you need to do something advanced like have a function return a string and use it in the caller.

Test case:

      #!/bin/bash

      fun()
      {
        echo "result"
      }

      RES=$(fun)
      echo $RES

Snippet from system call trace (via "strace bash ./test.sh"):

      pipe([3, 4])                            = 0
      rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
      rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
      rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
      lseek(255, -10, SEEK_CUR)               = 51
      clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fccbed72a10) = 3870
      rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
      rt_sigaction(SIGCHLD, {0x446240, [], SA_RESTORER|SA_RESTART, 0x7fccbe3b0ff0}, {0x446240, [], SA_RESTORER|SA_RESTART, 0x7fccbe3b0ff0}, 8) = 0
      close(4)                                = 0
      read(3, "result\n", 128)                = 7
      read(3, "", 128)                        = 0

In other words, this requires a pipe to be created a child process to be spawned, and its output to be read from that pipe.

In any reasonable scripting language, and even some unreasonable ones, this is all done in one address space. How about, oh, Awk:

      function fun() { return "result" }

One of the most common mantras for effective shell programming is "avoid writing loops; orchestrate external utilities".

<comment><USER5> The way one typically accomplishes this in bash is the following since the $() construct spawns a subshell.

        #!/bin/bash

        fun() {
            res="result"
        }

        fun && echo "$res"

The same strace snippet.

        openat(AT_FDCWD, "./test.sh", O_RDONLY) = 3
        stat("./test.sh", {st_mode=S_IFREG|0755, st_size=53, ...}) = 0
        ioctl(3, TCGETS, 0x7ffd65c6d890)        = -1 ENOTTY (Inappropriate ioctl for device)
        lseek(3, 0, SEEK_CUR)                   = 0
        read(3, "#!/bin/bash\n\nfun() {\n  res=\"resu"..., 80) = 53
        lseek(3, 0, SEEK_SET)                   = 0
        prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=512*1024}) = 0
        fcntl(255, F_GETFD)                     = -1 EBADF (Bad file descriptor)
        dup2(3, 255)                            = 255
        close(3)                                = 0
        fcntl(255, F_SETFD, FD_CLOEXEC)         = 0
        fcntl(255, F_GETFL)                     = 0x8000 (flags O_RDONLY|O_LARGEFILE)
        fstat(255, {st_mode=S_IFREG|0755, st_size=53, ...}) = 0
        lseek(255, 0, SEEK_CUR)                 = 0
        read(255, "#!/bin/bash\n\nfun() {\n  res=\"resu"..., 53) = 53
        fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x2), ...}) = 0
        write(1, "result\n", 7result
        )                 = 7
        read(255, "", 53)                       = 0
        rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
        rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
        exit_group(0)                           = ?

If you want use the old magics to return values like the built-ins then it's a little uglier but a lot cleaner.

        #!/bin/bash

        fun() {
          eval $1=\""result"\"
        }

        fun res && echo $res

<comment><USER4> Assignment to hard-coded global variable is not a return mechanism, and generally a nonstarter. It's not a viable approach for generally returning strings out shell functions everywhere in a codebase as a matter of habit.

Use of eval: still slow, because the shell eval re-processes input from the character level and up. eval should be generally avoided as much as possible in shell programming. Careless use of eval can introduce security holes (piece of untrusted datum gets evaled as an expression). You really need to have your black belt in "shell escaping karate".

Producing output and capturing with command substitution is the primary idiom for getting text out of a shell function. It has no visible side effect. The rebinding of standard output is scoped to the process substitution (and is confined to the child process, in fact), and the creation of the temporary process and pipe, expensive as they might be, are invisible to the program semantics.

> _The way one typically accomplishes this in bash_

In summary, what you propose here is not only vanishingly atypical, but also bad coding practice.

<comment><USER5> > In summary, what you propose here is not only vanishingly atypical, but also > bad coding practice.

What I'm describing has been SOP in bash for twenty years. You can program in a more modern style and replace some uses of eval with ${!indirect_references}, declare, and associative arrays but eval is still in wide use today. Search through /etc for eval with grep and you'll return plenty of results in the wild.

For example the eval in my previous post could be rewritten as the following

        declare -g "$1"="result"

but this form, although safer, is the less common usage.

Assigning to global variables or passing in a variable name to get the return value is just how bash works. See $MAPFILE $OPTIND $OPTARG for examples of the former and read as an example of the latter.

<comment><USER6> That [declare -g] is bad too, because it means you can't use it to set a local variable (see my sibling comment about dynamic scoping), which is surprising and confusing to the caller.

While I agree with the parent that the whole thing is disgusting, I also recognize that it's a valid optimization technique, and it's sometimes necessary. So, if you do go down that route, I'd encourage you to do it as

        printf -v "$1" '%s' "$result"

</comment></comment></comment></comment></comment></comment></comment><comment><USER7> > [ ] is a command—basically another way to call the built-in test command.

Literally, '/usr/bin/[', which takes as an argument a final ']', but actually a different binary than '/usr/bin/test'. And is different from the bash builtin. Crazy shit.

      vagrant@vagrant:~$ [ --version
      -bash: [: missing `]'
      vagrant@vagrant:~$ /usr/bin/[ --version
      [ (GNU coreutils) 8.28
      Copyright (C) 2017 Free Software Foundation, Inc.
      License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.

      Written by Kevin Braunsdorf and Matthew Bradburn.

<comment><USER8> I think it's cute.

</comment></comment><comment><USER9> This seems like a very basic introduction to bash, which is fine, but I was hoping for something called "Understanding Bash" to help with some of the understanding about why it behaves so weirdly at times.

For me, the biggest problem when writing bash is when I need to do something just a little more complex than what is there, but there is no good way to do it. An example that usually trips me up is this: [https://mywiki.wooledge.org/BashFAQ/050](https://mywiki.wooledge.org/BashFAQ/050).

FWIW, the above link is probably the most useful thing I have found that actually helps me understand bash.

<comment><USER10> I've been writing a (hopefully one day) POSIX compatible shell using a parser generator library. Having to try and fit sh into a parser framework makes you make some choices, and it's a great way to find these weird things. For example, I was surprised at first to learn that `{ ls }` isn't a valid program. Or:

        FOO=1 echo $FOO
        # vs
        FOO=1; echo $FOO
        # vs
        FOO=1 printenv FOO

</comment></comment><comment><USER11> > Note that the exit value of true is 0, and the exit value of false is 1. > This is somewhat counterintuitive, and it's the exact opposite of most > programming languages.

"Happy families are all alike; every unhappy family is unhappy in its own way."

[https://en.wikipedia.org/wiki/Anna_Karenina_principle](https://en.wikipedia.org/wiki/Anna_Karenina_principle)

<comment><USER12> The article is wrong though. For error codes, 0 being a success value is the CONVENTION. A non-zero code is an error. This isn't about "programming languages."

<comment><USER13> The problem is that for bash `true` is a function (or builtin) that returns 0, while for C (and thus most languages) any non-zero value (typically 1 for the builtins) is true. In c99 and later with stdbool.h, `true` is almost always defined as `#define true 1`.

</comment></comment></comment><comment><USER14> It is far simpler to just learn the POSIX shell first - much shorter man page. The the Bash stuff is then just a few additions if you ever need them (other shells are available).

<comment><USER15> Notably, such a concept as a function having a local variable is beyond POSIX shell.

<comment><USER14> "Variables may be declared to be local to a function by using a 'local' command."

<comment><USER15> Here's the spec. Where is it? [https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html)

<comment><USER14> It is in both ash and dash, the shells I mentioned. Your attempt at point scoring is irrelevant but expected.

ash & dash are about 100kB executables (POSIX plus a tiny number of non- interactive improvments like 'local'), bash is 1100kB. Every shell and subshell.

<comment><USER15> My point is that POSIX shell purity is masochism. Understanding how it's the core and other shells build on top of it is certainly valuable, but it's not inherently particularly good to use.

<comment><USER14> Maybe we are at cross purposes. My default shell is bash, but my default "sh" is dash. This is as it should be (and is default in Debian & Ubuntu I think).

If you are talking about interactive use, of course bash is the one to use, but for writing shell scripts, it is a 10X interactivity overhead" over dash.

<comment><USER15> IMO it's a big win for scripts to at least be able to use Arrays in that otherwise "stringly-typed" world.

<comment><USER16> As a POSIX shell masochist myself, Arrays are the single biggest missing feature. POSIX shells actually do have one array: $@. Having more would make my life so much easier.

The amount of gyrations I go through to account for the lack of arrays is easily 1000x worse than accounting for not having local variables.

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER7> I've been using bash for nearly two decades, and I just found out that Bash is apparently the only shell whose built-in _echo_ uses the _-e_ option. I thought others used this too, but it seems every other shell's _echo_ just implicitly interpolates escaped characters. POSIX actually says anything following '\' is undefined behavior. Apparently _printf_ is the only portable way to interpolate escaped characters in output.

Here's a bunch of very useful tips like that: [https://www.etalabs.net/sh_tricks.html](https://www.etalabs.net/sh_tricks.html)

<comment><USER8> That resource is lovely, thank you.

</comment></comment><comment><USER17> > Second, in principle, there's nothing to enforce that a UNIX shell must have > echo as a built-in, and therefore, it's important to have the external > utility /bin/echo as a fallback.

I read here [https://en.wikipedia.org/wiki/POSIX#Overview](https://en.wikipedia.org/wiki/POSIX#Overview) that echo has been standardized for POSIX, can you elaborate further ?

</comment><comment><USER17> Amazing article, I like to understand the why behind things like that. Kudos to you.

</comment><comment><USER18> This is a really good article and worth the read.</comment>