The Stack Monoid - <AUTHOR> https://raphlinus.github.io/gpu/2020/09/05/stack-monoid.html <comment><USER2> This language of matching brackets is also called the Dyck language and its syntactic monoid is the bicyclic semigroup, which is an interesting example of an inverse semigroup. Edward Kmett gave a talk on programming with these sorts of algebraic structures that some might find illuminating: [https://www.youtube.com/watch?v=HGi5AxmQUwU](https://www.youtube.com/watch?v=HGi5AxmQUwU)

Inverse semigroups are used in the geometry of interaction to give a parallelizable interpretation of lambda calculus. I don't have a great introductory reference. Here's some people who have implemented a system based on the theory: [https://www.cambridge.org/core/journals/mathematical- structu...](https://www.cambridge.org/core/journals/mathematical-structures- in-computer-science/article/abstract-machines-optimal-reduction-and- streams/60F590DA98EAC48CC6E7AADB46235B8C)

Sorry for the citation dump, I'm short on time and I thought they would be interesting to those who found this submission interesting.

References

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

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

<comment><AUTHOR> The Dyck language I was already aware of; I linked it in the previous post in the series. But the bicyclic semigroup was new to me. Yes, the bones of it are very similar to my "stack monoid;" if you erase the actual element values of the stack contents and just count the lengths, it's clearly the same thing. No doubt there's some theory that justifies adding the elements back in as well.

I'll have to check out the Kmett talk - from the description it sounds very interesting.

<comment><USER3> Although I didn't know it by that name, I have seen the bicyclic semigroup in competitive programming many times before (usually any problem involving intervals/brackets and segment trees).

For example in this problem [https://codeforces.com/contest/1285/problem/E](https://codeforces.com/contest/1285/problem/E), one solution is to parse and count the number of top-level parentheses after small modifications. For example the original string might be "(()())()". Then "(()())" is 1, "(())()" is 2, "()()()" is 3.

This is solved with the following monoid to make incremental reparsing fast:

        neutral = Node(0, 0, 0)

        def combine(x, y):
            # Each node tracks numClose, numCount, numOpen:
            # e.g., )))) (...)(...)(...) ((((((
            if x.open == y.close == 0:
                ret = x.close, x.count + y.count, y.open
            elif x.open == y.close:
                ret = x.close, x.count + 1 + y.count, y.open
            elif x.open > y.close:
                ret = x.close, x.count, x.open - y.close + y.open
            elif x.open < y.close:
                ret = x.close + y.close - x.open, y.count, y.open
            return Node(*ret)

Reference solution: [https://codeforces.com/contest/1285/submission/92169958](https://codeforces.com/contest/1285/submission/92169958)

Monoid cached trees are extremely popular in competitive programming, but never by that name. It's always referred to as a "segment tree" without using any mathematical terminology more advanced than "associativity".

Due to its popularity, all kinds of crazy monoid states have already been explored (though you need to squint a bit to see them due to the terminology mismatch): [https://codeforces.com/blog/entry/15890](https://codeforces.com/blog/entry/15890). I've never seen stack used though. You almost always want to compress the state as much as possible and the problems I've seen only needed stack depth (aka the bicyclic semigroup), not contents. Requiring O(N) to merge also highly limits its use cases.

Anyway, not sure how relevant this is to you since the use of monoids in data structures and for parallelism is slightly different (binary merges all the way down versus stopping at some chunk size).

</comment></comment></comment><comment><USER3> > Automatically generating monoids such as the stack monoid from their > corresponding simple sequential programs seems like an extremely promising > area for research.

I was interested in this problem a while back and the papers I remembered being useful were:

"Automatic Inversion Generates Divide-and-Conquer Parallel Programs": [https://core.ac.uk/download/pdf/192663016.pdf](https://core.ac.uk/download/pdf/192663016.pdf)

which is based on "The Third Homomorphism Theorem": [http://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/th...](http://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/thirdht.ps.gz)

The motivating example is whether you can generate a mergesort (where the monoid is combine two sorted lists) given an implementation of an insertion sort (where the sequential program is inserting one element by one into a sorted list).

I remember being disappointed by the answer after reading these papers but in the citation graph there are a bunch of relatively recent program synthesis papers. Maybe there's something better now.

<comment><AUTHOR> Thanks for the reference, it's definitely relevant. I took a pass over the paper somewhere between skimming and reading, and, while it's definitely in the ballpark of deriving parallel programs from sequential, it's also pretty clear their source language can't express the stack monoid problem because it lacks a "cons" operation; basically it seems to be for various fancy reduction problems where it consumes a sequence and spits out a scalar. On a quick read, I have no idea whether that's a fundamental limitation or something that could be extended.

I think examples like generating mergesort from insertion sort are maybe trying to be too clever. I mostly just want something that lets you slice up the problem into chunks, process each chunk in parallel, then combine them back in ways that don't kill performance on modern GPU hardware.

</comment></comment><comment><USER4> In the conclusion, raph writes:

> I am even more convinced than before that efficient parsing is possible on > GPU.

IMO, the place to start looking for GPU-friendly parsing algorithms is Valiant's algorithm, which is asymptotically the fastest known general CFG parsing algorithm, and is implemented in terms of Boolean matrix multiplication.

The intuition is that bottom-up parsing is basically a transitive closure computation, which is basically the same as solving systems of linear equations over a Boolean ring, which can be sped up using Strassen's algorithm.

A bit of Googling suggests that people have looked at optimising Boolean matrix multiplication on GPUs, but I have no idea what the state of the art here is.

<comment><USER5> Didn't SIGFPE's blog cover this years ago?

Bonus clip: [https://www.youtube.com/watch?v=j4YNPhllDXU](https://www.youtube.com/watch?v=j4YNPhllDXU)

</comment></comment><comment><AUTHOR> A note: I just updated the post with a bunch of related work that people have sent me since I published the first draft. It also includes a bit more intuition behind the monoid.

</comment><comment><USER6> How do you get started with learning GPU programming? I mean that in a pedagogical way, like what is the best educational way forward. Build stupid stuff in shader toys?

<comment><AUTHOR> It's a good question, and it's been suggested I write a GPU compute 101. I did do a talk at Jane Street earlier in the year called "A taste of GPU compute" which has some relevant resources (a Google search on that term will give you a number of links).

I think there are probably a number of on-ramps. One easy way to get started is shadertoy, which if nothing else should give familiarity with GLSL syntax and intuition for performance in the simplest case: each "thread" computes something (a pixel value) independently of the others. You'll quickly run into limitations though, as it can't really do any of the more advanced compute stuff. I think as WebGPU becomes real, an analogous tool that unlocks compute kernels (aka compute shaders) could be very powerful for pedagogy.

I think most people that do compute on GPU use CUDA, as it's the only really practical toolchain for it. That has a large number of high quality open source libraries, which tend to be well-documented and have good research papers behind them. You can start by using these libraries, then digging deeper to see how they're implemented.

As I've been going on about, I believe this space is ripe for major growth in the next decade or so. As a rough guide, if you can make your algorithm fit the GPU compute model nicely, you'll get about 10x the compute per dollar, which is effectively the same as compute per watt. Why leave such performance on the table? The answer is that programming GPUs is just too hard. In certain areas, including machine learning, an investment of research has partially fixed that problem. But in others there is fruit at medium height, ripe for the picking. And in some other areas, you'll need a tall ladder, of which I believe a solid understanding of monoids is but one rung.

<comment><USER6> Thanks, it was your work that kindled my interest in programming the GPU. The fact that most vector graphics are done by CPU libraries made me resize it's still a very underdeveloped area. The hard thing about it is also what makes it interesting, it's not just a different programming language but a different architecture with other runtime characteristics. Sort of the closest you can get to owning a quantum computer. Anyway I'll learn some math and cuda, and buy the book if you find the time :)

</comment></comment></comment><comment><USER7> About the stack/monoid structure, there was a nice talk by Conal Elliott recently describing how it can be used to implement a compiler [0]. He also mentions parallel computations at some point.

[0] [https://www.youtube.com/watch?v=wvQbpS6wBa0](https://www.youtube.com/watch?v=wvQbpS6wBa0)

<comment><USER8> I may be extrapolating too much but I think Steele team workig on Fortress was also doing monoid like thinking to parallelize heavy. He made a talk on how to delinearize problems into partially solved subproblems to be reconciled later.

<comment><USER9> Is this the talk?: [https://youtu.be/EZD3Scuv02g?t=2192](https://youtu.be/EZD3Scuv02g?t=2192)

<comment><USER8> hmm related but not the one I had in mind

[https://www.infoq.com/presentations/Thinking-Parallel- Progra...](https://www.infoq.com/presentations/Thinking-Parallel-Programming/)

ps: you can see they were using mathematical structures (ring, monoids) in your video anyway

<comment><USER9> Thanks, the talk you linked goes into more detail.

</comment></comment></comment></comment></comment><comment><USER10> What is a monoid? I googled to no avail. Lots of articles, but none tell what the heck it actually is.

<comment><USER11> So a bunch of people are giving you good _definitions_. Here's an article that does FizzBuzz with monoids. I think this is the first thing I saw that actually cemented them into my mind. Probably because it takes a problem-to- solution teaching method. (Unfortunately looks like the original page is dead.)

[https://web.archive.org/web/20200325013049/http://dave.fayr....](https://web.archive.org/web/20200325013049/http://dave.fayr.am/posts/2012-10-4-finding- fizzbuzz.html)

<comment><USER12> I just notice a common pattern in a lot of these answers

* First, give a definition

* then some basic examples to clarify the concept

* then some advanced usage to demonstrate the advantages.

I tend to do it myself, maybe because a math concept has a clear definition and math courses do it too. However, it scares away a lot of people, including myself when I'm on the receiving end.

</comment></comment></comment><comment><USER13> Raph, I think some of the order-independent transparency folks (Bavoil, Wyman, Lefohn, Salvi, etc.) have had to do this bounded k-stack plus overflow thing. Might be a good "hmm, how did they do it" for comparison.

<comment><AUTHOR> Good call, that rings a bell and I'll look into it. A bounded k-stack with overflow seems like a really good fit for the capabilities provided by GPU.

<comment><USER13> Hmm. In the end, maybe transparency is a bad example, because people immediately jumped to approximating it instead. Wyman's review paper though is a good read regardless:

[http://cwyman.org/papers/hpg16_oitContinuum.pdf](http://cwyman.org/papers/hpg16_oitContinuum.pdf)

The GPU / accelerator BVH traversals are perhaps more applicable (e.g., [https://www.embree.org/papers/2019-HPG- ShortStack.pdf](https://www.embree.org/papers/2019-HPG-ShortStack.pdf)) but they also have a different "I can restart my computation" property that say JSON parsing wouldn't have (though maybe if you're willing to do a lot of restarts once you parse the inner portions and push them onto a heap...).

Anyway, cool problem!

<comment><AUTHOR> The bell it rang for me was [1], which has come up in discussions with Patrick Walton about maintaining a sort order for coarse rasterization in 2D vector rendering. Taking another look at that, it seems like they propose _both_ bounded k-stacks and linked lists as solutions for recording all the fragments to be combined for transparency blending, but not the hybrid of the two. I wouldn't be surprised if that's been considered.

The problem is slightly different, though, because the major focus for transparency is concurrent writing from potentially many different shaders, while in the stack case each thread can build its data structure without any concurrency or need for atomics; once an aggregate is built, it is "published" (see my prefix sum blog for details on that) and treated as immutable.

These kinds of concurrent approaches do become important for later stages in the JSON parsing process, like building hashmaps for keys in a dictionary. I'm pretty sure the whole problem is tractable and have thoughts how to solve it, but deliberately kept the scope of this blog post limited, as I figured it was challenging enough. But it's very cool to reach people who appreciate the ideas, and if you find anything else that's relevant, I'd love to hear from you.

[1]: [https://on- demand.gputechconf.com/gtc/2014/presentations/S43...](https://on- demand.gputechconf.com/gtc/2014/presentations/S4385-order-independent- transparency-opengl.pdf)

</comment></comment></comment></comment><comment><USER14> My first thought when seeing this stack problem was that it might be possible to use the techniques presented in "Internally Deterministic Parallel Algorithms Can Be Fast"[1]. The idea is that the algorithm runs on the prefix of the input in two steps: In the first step it will figure out which items can be processed in parallel (e.g. those that don't depend on any earlier input) and in the second step it will actually calculate it. Both steps are done in parallel. There's also a slide deck[2] which explains it quite well.

I'm not quite sure how it would work on this problem, but it might be interesting to look into.

[1]: [https://www.cs.cmu.edu/~guyb/papers/BFGS12.pdf](https://www.cs.cmu.edu/~guyb/papers/BFGS12.pdf)

[2]: [http://www.cs.cmu.edu/~blelloch/papers/spaapodc17.pdf](http://www.cs.cmu.edu/~blelloch/papers/spaapodc17.pdf)

</comment><comment><USER15> The elements of this monoid kind of look like type signatures for Forth words. I was already playing with the idea of a sort of concurrent forth-like where each word sort of gets its own stack context. I'm really interested in neat models that provide partial evaluation, so I will be giving this some thought.

</comment><comment><USER16> I had this crazy idea a while back using Ray tracing APIs to piggy back a database. Testing for a row could be done shooting in parallel rays to a structure mapped to the data.

</comment><comment><USER8> best thread of the year</comment>


Much Win with Node.js for Client-Side Unit Testing - <AUTHOR> https://github.com/attachmentsme/pollio/blob/master/blog.md

<comment><AUTHOR> This is a neat, light-weight, approach we're using to unit-testing our Chrome extension at Attachments.me.</comment>


The and-httpd server has a $2,000 "security guarantee" - <AUTHOR> http://www.and.org/and-httpd/#security-guarantee

<comment><USER2> This sort of thing is not new. I think the first one was qmail: <http://cr.yp.to/qmail/guarantee.html> followed shortly by djbdns: <http://cr.yp.to/djbdns/guarantee.html> (which was awarded in 2009: <http://article.gmane.org/gmane.network.djbdns/13864>)

Dovecot also has a similar guarantee: <http://dovecot.org/security.html>

As does Mozilla: <http://www.mozilla.org/security/bug-bounty.html>

Even Facebook is in on the game: <http://www.facebook.com/whitehat/bounty/>

Bug bountying in general of course started with Donald Knuth: <http://en.wikipedia.org/wiki/Knuth_reward_check> and has recently become moderately popular as a strategy for increasing open-source code quality: [http://www.daemonology.net/blog/2011-09-05-lessons- learned-f...](http://www.daemonology.net/blog/2011-09-05-lessons-learned-from- bountying-bugs.html)

<comment><USER3> And Chromium: [http://www.chromium.org/Home/chromium- security/vulnerability...](http://www.chromium.org/Home/chromium- security/vulnerability-rewards-program)

</comment></comment><comment><AUTHOR> Here is the latest source for anyone with too much time on their hands: <http://www.and.org/and-httpd/0.99.11/>

Last update from changelog is 2006-09-10

<comment><USER4> Files missing.

</comment></comment><comment><USER5> How did this get to the front page when the last update to the source was 6 years ago?

<comment><USER6> +1

</comment></comment><comment><USER7> I wanted to give it a try, had to look for the source (found it on sourceforge) tried to ./configure it requires a Vstr from the same website now need to look for the source ...

It's not like they want you to try it :D

</comment><comment><USER8> That isn't a guarantee it's a bounty. A guarantee would pay out to all affected customers. Affected probably would mean compromised by an attacker.

</comment><comment><USER9> That page was last modified in 2006. It must have held up well against attacks or he would be broke by now!

<comment><USER10> "The $2,000 is only available to the first person who provides a working attack"

</comment></comment><comment><USER11> I would look to find the last time the code was worked on, but there isn't even a code repository listed.

</comment><comment><USER12> Similar to the bounty Dovecot <http://dovecot.org/security.html> has.</comment>


Security concerns with minified JavaScript code - <AUTHOR> https://lists.debian.org/debian-devel/2015/08/msg00427.html <comment><USER2> Javascript minification seems like a classic case of premature optimization. I'm not a front-end developer so maybe I'm missing something, but wouldn't simple, transparent gzip compression via your webserver — one line in a config file — get you something like ~90% of the benefits of minification, for free?

I'm sure there are some additional gains to be made from knowing the syntactical structure of the language you're minifying, since no generic compression scheme can know that. But that seems really marginal — and, as the article in question shows, opens up potential security vulns.

<comment><USER3> It depends on why you're minifying, but there are good reasons to do so. I'd bet, as in guess/speculate without evidence, that the #1 reason people do it is for code obfuscation. Front end JavaScript delivers source code to your users and competitors alike, that can be scary when you're working hard on something you think people will like & copy.

Most here are talking about uglify which does very superficial minimization, but Google's closure compiler is in the mix too, and that provides static type checking, nested variable flattening, dead code removal, inlining optimizations, and more. These things are substantial, not marginal, especially the static type checking. It's closer to C++ compilation than it is to gzip.

Gzip can be used (and usually is) either way, and generally still has some benefit even on minified code. But no, gzip can't replace or provide the majority benefit of a minification pass, they're two mostly independent things done for mostly different reasons.

<comment><USER4> I don't know if you could hide it from competition - it can be unminified ex with: [http://jsbeautifier.org/](http://jsbeautifier.org/) I have tried this before and it worked.

<comment><USER5> it depends on how you minify.

if you use Closure Compiler in Advanced mode it will rename and rescope pretty much everything except native methods and strings (making lots of globals cause it assumes you're compiling all page's code at once), it will eliminate unused code even from third party libs like jquery and do all sorts of stuff that make the beautified code very expensive to understand, follow and reverse and even then you may end up with only half a library that does only one specific task and the rest of the code would be missing.

you have to do a bit of JSDoc annotations in some places to fix some breakages and restructure the code a tiny bit to get it to rename absolutely everything but the results are excellent.

<comment><USER6> So, run [http://www.jsnice.org/](http://www.jsnice.org/) over it?

<comment><USER7> You can also just click the {} icon in Chromes debugger.

All you will get is a lot of function a with arguments z d and f calling eq on z and passing it d, then returning the qln value of the result.

Slightly more readable, yes, but still like debugging assembler.

<comment><USER6> It actually provides meaningful names, here is more about it: [https://news.ycombinator.com/item?id=7836092](https://news.ycombinator.com/item?id=7836092)

</comment></comment></comment></comment></comment></comment></comment><comment><USER8> Looks like Debian is mostly on top of it:

        > To me the problem suggests that it is important from a security and
        > accountability perspective to 1) include the human-readable source
        > code of JavaScript in Debian packages, and 2) to compile the
        > human-readable source code into a minified code (if required) during
        > package builds, using a JS-minifier that is included in Debian.
        > Thoughts?

        This is anyway mandatory in Debian.

[https://lists.debian.org/debian- devel/2015/08/msg00478.html](https://lists.debian.org/debian- devel/2015/08/msg00478.html)

<comment><USER9> > Looks like Debian is mostly on top of it

I wonder... I'm assuming their concern surrounds stuff that is installed on- disk with the package manager. Is there any benefit _at all_ to JS minification when the file:// protocol is in use? Marginal (if at all) improvements to parse time? Anything else? Or is "everyone doing it?"

<comment><USER10> V8 uses a function's length in characters, _including comments_, to make optimization decisions. By removing comments and shortening var identifiers internal to a function, I can imagine a number of functions dropping under that 600-char threshold. Would be great to measure.

<comment><USER11> that seems like a terrible way to measure things. why not go by the number of some form of nodes after parsing? Parsing has to happen before optimization anyway.

<comment><USER12> Agreed, this is awful. Presumably it means that _adding comments can slow your code down_ , which I would otherwise have thought a completely laughable suggestion.

<comment><USER13> The problem with JIT compiled languages is compilation time is as critical as the performance of the compiled code. Using string length happens to be quicker than producing ASTs. So while it is a dirty hack, it generally offers greater performance more often than not.

</comment></comment></comment></comment></comment></comment><comment><USER14> It's hard to see how shipping minified JavaScript in the source packages passed muster with Debian in the first place. If it's not the human-readable source that's in the preferred form for modifications, it's not really the source at all.

</comment><comment><USER15> I like how strict Fedora Packaging Policy is regarding this ([https://fedoraproject.org/wiki/Packaging:JavaScript](https://fedoraproject.org/wiki/Packaging:JavaScript)).

"If a JavaScript library typically is shipped as minified or compiled code, it must be compiled or minified as part of the RPM build process. Shipping pre- minified or pre-compiled code is unacceptable in Fedora."

<comment><USER16> They say that but this is not always the case. See for example Roundcube. They just shipped minified JS as shipped by upstream. In Debian, pre-minification JS files are shipped and minified during the build process.

[http://pkgs.fedoraproject.org/cgit/roundcubemail.git/tree/ro...](http://pkgs.fedoraproject.org/cgit/roundcubemail.git/tree/roundcubemail.spec)

</comment></comment><comment><USER17> One of the messages in the thread links to this debian wiki article that lays out all the arguments against minification.

[https://wiki.debian.org/onlyjob/no- minification](https://wiki.debian.org/onlyjob/no-minification)

One argument that really drives it home -- GZIP compression without minification is faster and better, and from my own experience takes exactly two lines of nginx config to set up.

Is there really any benefit of using minification besides code obfuscation?

<comment><USER18> Define "faster." GZIP creates a smaller file size, but the benefit of minification is faster parsing by the Javascript engine -- GZIP does nothing to help with this.

<comment><USER19> Maybe not always. Minifiers optimize for space. So they might turn "false" into "!1". Not sure that executes faster.

<comment><USER20> So yeah they optimize for space but they also optimize for execution. For example the closure minifier literally puts everything on one line, without semicolons (where possible) and uses commas which forces the JavaScript engine to execute it as a single statement which can be faster.

That's just a minor point but it can help with speed. Is it enough of an optimization that it's worth it though? I'm not sure; I haven't seen much in the way of benchmarks in this area.

</comment></comment></comment></comment><comment><USER21> All of the interesting content is in the link provided in the list[1], and otherwise this is just a post about how debian should handle the security issues presented there.

This might be a good candidate for having the link updated.

[1]: [https://zyan.scripts.mit.edu/blog/backdooring- js/](https://zyan.scripts.mit.edu/blog/backdooring-js/)

<comment><USER22> This link has already been posted: [https://news.ycombinator.com/item?id=10107833](https://news.ycombinator.com/item?id=10107833)

<comment><USER23> (As of right now, 202 points and 34 comments)

</comment></comment></comment><comment><USER24> The moral of the story, it seems, is to beware any tool that modifies or writes your code for you, even something as seemingly harmless as a JS minifier.

<comment><USER25> Wouldn't that include compilers, too?

<comment><USER26> ...and that's why the Debian community is driving reproducible builds: [https://reproducible.debian.net/reproducible.html](https://reproducible.debian.net/reproducible.html)

<comment><USER27> Reproducible builds do not solve the problem of a compiler bug being used to introduce a backdoor during the translation from source code to binary.

<comment><USER6> Yes, they do – you take a C compiler (written in ASM) that is just good enough to compile TCC, now you prove that the source of TCC and GCC is right, you compile TCC with your simple compiler, then compile GCC with TCC, and you have a compiler which is guaranteed to be free of such backdoors.

Now, you compile your code with this compiler, and if your own build reproducibly has the same results as this verified compiler, you're safe.

<comment><USER28> That defends you from a different type of attack. That can't fix bugs in your compiler or minifier. See [https://zyan.scripts.mit.edu/blog/backdooring- js/](https://zyan.scripts.mit.edu/blog/backdooring-js/)

<comment><USER6> Your attack only applies if my minifier is wrong.

My solution even protects me from attacks where the source of the minifier is safe, and only the minified minifier contains the bug.

</comment></comment></comment></comment></comment></comment></comment><comment><USER3> The whole point of the back-dooring js blog post was that you can create "deniable" bugs that are hard if not impossible to see by inspecting the unminified source, and can't prove intention. They already have great reasons to require source, so it's ironic this would be the catalyst to start, no?

</comment><comment><USER29> Conceptually, this is a reasonable line to draw in the sand. Minified Javascript should be thought of as equivalent to assembly language or Java bytecode[1], and if the policy is to not ship compiled binaries without source available, minified JS should fall into that category.

[1] [https://www.destroyallsoftware.com/talks/the-birth-and- death...](https://www.destroyallsoftware.com/talks/the-birth-and-death-of- javascript) is funny, but the honest truth is that it's likely the future of web technologies, as Javascript is so deeply entrenched in the fiber of the web standards and the practical implementation of the browsers.

</comment><comment><USER30> Is the AST structure preserved when minifying? If only identifier names and whitespace changed, then it seems like one could verify that the minified matches the original.

<comment><USER31> Not always, most do tricks like `!0` for `true` and `a && b` instead of `if (a) b`.

<comment><USER32> IMHO that's going into optimiser territory, and perhaps the reason why these minifier bugs exist - the minifier writers need to be _very_ sure of the semantics of the language before attempting to rewrite code to have the same behaviour, and JS/ECMAscript semantics are not trivial especially w.r.t the (highly) dynamic type system as the example shows. Even renaming things is not as trivial as it seems because the names can themselves be dynamic, e.g. a.somefield vs a['s' \+ 'ome' \+ 'field'].

(I'm not a JS developer so I might've missed a few other things, but minifying JS is definitely a much harder problem than doing it with something like C.)

<comment><USER33> just one nitpick on your comment - minifiers do not replace property names, only variable names in JS

<comment><USER34> Closure Compiler does rewrite property names in advanced mode.

<comment><USER35> UglifyJS also rewrites property names if you tell it to. It's conservative so it only replaces the names you explicitly tell it to rename. Recently it gained the ability to let you give a regex, so if you have a convention of always prefixing private rename-safe properties with an underscore, you can now have those renamed.

</comment></comment></comment></comment></comment></comment><comment><USER36> This thread on V8 inlining was buried at the bottom of the blog post linked in this thread, but it was super valuable and is changing the way I write functions in Node this morning: [https://news.ycombinator.com/item?id=10108672](https://news.ycombinator.com/item?id=10108672)

</comment><comment><USER37> Did anyone else get a kick out of seeing these two in a row on the homepage?

Closure compiler parses JavaScript code, removes dead code, _minimizes what 's left_

Security concerns with _minified_ JavaScript code

One of those moments where I pause to wonder if I should even read further haha.

</comment><comment><USER38> The quoted link discusses backdooring js by writing legit code that turns malicious through minifier bugs.

The only way to be sure is not minifying the source.

<comment><USER39> Or by using a trusted minifier on the source code yourself, as mentioned in the link.

<comment><USER38> How do you tell your trusted minifier has no exploitable bugs?

<comment><USER40> Exploitable by what?

<comment><USER41> Anyone who has ever pushed a patch to the project that you're running through the minifier.

<comment><USER40> What would be the point of exploiting the minifier? The purpose is to get the code to the Debian users, how does exploiting the minifier help with that? If you can put an exploit is the program's source, you just want it to be minified as-is so that it'll run on the end user machines.

<comment><USER41> Read the linked article: [https://zyan.scripts.mit.edu/blog/backdooring- js/](https://zyan.scripts.mit.edu/blog/backdooring-js/)

It has the answer to your question. Namely, you can write bugs that are exploitable _that aren 't present in the original source_, that _only_ appear in the minified output. Which means that a) it is a whole lot harder for someone to find (especially if it's something that is "obviously" correct), and b) it's plausibly deniable.

</comment></comment></comment></comment></comment></comment></comment><comment><USER42> This is why LibreJS is an important project.

[https://www.gnu.org/software/librejs/](https://www.gnu.org/software/librejs/)

It won't help towards minification bugs or backdooring, but it's a step in the right direction.</comment>


What is Your C Development Environment like? - <AUTHOR>

Let me explain my problem:
Say I want to start looking at the source of a C project. First thing I do is highlight all the .c/.h files in the folder (ctrl + click and so on..), right click, select "open all with GVim". The script opens all .c and .h files in GVim in separate tabs each. After that, I resize the GVim window to leave some space for a terminal to run make/gcc/gdb/git etc. At this point, I'm ready to look at some code.
Browsing through code is not easy mainly because of the tabs. In this project that I'm looking at, there are 10+ files and I know that's not even a lot. I have to keep hitting 'gt' or 'gT' if I want to go to a certain .c or .h file and it's a nightmare if you have 10+ tabs open.
So, HN what is your environment or workflow like when coding in C? Any tips on how I can make my environment better?
Here's my environment right now:
Laptop 15.6" screen Ubuntu 10.04 GVim (NerdTree, Taglist, ctags) Terminal for (gcc, gdb, make, git)
GVim and Terminal are side by side. <comment><USER2> I usually have a konsole open ready to run make; and two kwrite windows open, side by side. Sometimes also a konqueror window open to the directory containing the source code I'm working on at the time.

As lukesandberg points out, there's no reason to have 10+ files open at once. Work on one thing at once and only open up files when you're working on them or need to check something (e.g., "what order did I put the parameters to that function").

</comment><comment><USER3> I usually use vim+screen+make(gdb, gcc...). Plus a really hairy .screenrc that does some magic to put running command lines in the status line (so i can see which screen has vim foo.c running). But the key is to not have 10+ files open at once. You're using vim so opening and closing vim instances is no big deal. I usually only have two or three source files open at a time that way i know exactly where each one is. This limits my screen tabs to only 4-5 which is pretty manageable.

</comment><comment><USER4> I don't do much C myself but I use Vim all the time so maybe I can give you a few useful hints:

\- learn to open files from Vim with :e and tab completion

\- learn to use buffers effectively, the :b command with tab completion is particularly useful to switch between buffers

\- CRTL-0 / CTRL-I to go back and forth between cursor positions

\- for C/C++, a.vim is a plugin that allows you to switch quickly between header and implementation

\- learn to use make from Vim with :make, it will take you to the first compilation error and open a quickfix window that you can use to go to other errors (can be configured to compile other languages than C/C++)

\- try ack, a better grep, very useful to search source code, there's a Vim plugin to integrate it

\- if you have a lot of files and directories in your project, try the Command-T plugin

\- for git, the Fugitive plugin can also be helpful (screencasts at <http://vimcasts.org/>)

</comment><comment><USER5> This is exactly why I find using an IDE (MSCV / XCode) so attractive when working in C or C++, I'm sure others would agree too. It makes you lazy (ignorant?) about makefiles and the build process unfortunately, but increases productivity for me when I can easily view the whole project in terms of files OR classes/code constructs.

I'm also a fan of TextWrangler on the Mac for its basic file sidebar for quickly switching, but its still a bit tougher on big projects, having only a "flat" view of your files.

</comment><comment><USER6> A random guess at the _real_ problem: you have not found a way to efficiently navigate multi-file projects, and thus end up opening tons of tabs. I was going to recommend ctags, but apparently you've already found it (you know about the extremely useful Ctrl-], Ctrl-t?); I've heard people recommend cscope (although I wouldn't run it on untrusted source code), and I'm sure there are other options. If this is indeed the real issue, try to fix that first.

</comment><comment><USER7> I use Emacs with all of the ido stuff. Even with dozens of buffers open, I can just hit C-x b and then a couple of characters in the name of the buffer I want. I don't even have to use consecutive character; 'fb' would work to match 'foobar.txt'.

You can have a shell in an Emacs buffer, but I could never really get used to that. Instead, I use Tilda to have a Quake-style console that I can show or hide as I need.

</comment><comment><USER8> snavigator+vim</comment>


Ask HN: Is this a feasible business idea? - <AUTHOR>

A couple weeks ago I had an idea for a new service, but I'm not sure it's something others would find useful or if it would be accepted as an authority.
Basically, what I'm thinking is a service where people could do things like store notes, pictures, recordings, etc. and each item would be stored in such a way so that it could not be later altered (was thinking MySQL archive tables).
For example, the idea came to mind when my wife moved out a few weeks ago. Every time we have a conversation I feel like I need to document it, e.g. "Just spoke with X and stated that abc" and have that stored on a server of a non-biased company somewhere so that if the situation gets to the point of legal counsel being brought in I could put together a sort of log or journal of what's been said and when.
If this was something that could be useful, I could build out mobile apps that could take recordings and submit those or even automatically forward text messages from selected individuals. I would, of course, want something like triple redundancy on the databases to ensure nothing is lost.
But, like I said earlier, I'm not sure such a service would be helpful to others or if lawyers/courts would even consider the information worthwhile or admissible.
What say ye, all wise HN community? :) <comment><USER2> If such a thing existed, it would have helped this guy: <http://huff.to/kKIGDa>

The important part is in the grey box. The guy went to a notary public and legalized a statement that he could later use in court.

You could take your idea further and actually charge users to have their submission automatically notarized, after they prove their real life identity, of course (there's already a startup that offers to certify users' identities, anyone remember the name?).

<comment><AUTHOR> You're right, it's situations like that which brought up this idea. Some way to reliably document a statement or idea and the date just seems like a useful service.

The notarization would be a bit difficult since each state has their own rules and laws. Additionally, I think they all have a residency requirements, at least the two states I've been a notary in did.

</comment></comment><comment><USER3> You can use

\- private tumblr blog

\- catch.com

\- evernote

\- google docs

\- emacs org-mode + dropbox

etc.

If you record everything on audio tape or talk only using phone and record it. Or you use gtalk only then legal bodies might take it seriously. But no one is going to take notes written by you seriously.

Is it legal to record phone conversation without other persons consent? I don't k now.

<comment><AUTHOR> But can't the time and dates can be changed those.

As for recording phone calls, the laws vary from state to state. The states I have experience with only require one person on the conversation to be aware that it's being recorded.

</comment></comment><comment><USER4> I know my parents would have paid quite a bit for something like that when they were still raising kids. They talked about it every time there was a disagreement about who said what.

</comment><comment><USER5> The key part is allowing both parties to sign the content as accurate and then lock it down. Without both parties signing I suspect it would carry little weight legally.

<comment><AUTHOR> That's an interesting idea that I hadn't considered. Thanks.</comment></comment>


Starbucks vs. Dunkin': How Capitalism Gives the Illusion of Choice - <AUTHOR> https://www.theguardian.com/commentisfree/2019/jul/29/starbucks-v-dunkin-how-capitalism-gives-us-the-illusion-of-choice <comment><USER2> >Calling a friend for after-work plans? That will be with an iPhone, most likely (55% market share): or perhaps a Samsung (25%).

Does the iPhone really have 55% market share? I don't believe that for a minute.

<comment><USER3> This article is US specific. The iPhone has a higher market share in the US than just about anywhere else.

[https://deviceatlas.com/blog/android-v-ios-market- share#us](https://deviceatlas.com/blog/android-v-ios-market-share#us)

</comment></comment><comment><USER4> Pretty hard to believe that Instagram has a 2% social network market share. Having looked at the source material for that particular chart, it dates from Nov. 2017, not 2019 as stated in the article. It seems poorly researched and overblown. How many car companies/coffee chains/social networks _should_ there be? I don't see how anyone could answer that question from a logical perspective.

</comment><comment><USER5> I don't understand the point of emphasizing corporations over brands. There are many toothpastes available to me in any supermarket. They vary by brand, and about five attributes (whitening, enamel protection, etc.) How would things really be different if those brands were offered by more or fewer corporations?

I generally prefer Starbucks over Dunkin' Donuts, but both offer a wide variety of options.

<comment><USER6> I don't understand why, as a consumer, you'd care about brands.

Corporations often differ in some fundamental ways. Since 2017, 100% of Dunkin Donuts locations are franchises[1]. This puts a Dunkin Donuts location somewhere between a local business and a multinational corporation in my mind --when there are no local coffee shops available, I'll choose Dunkin Donuts over Starbucks, because I'd rather support small business owners who are more directly responsible to their customers.

[1] [https://en.wikipedia.org/wiki/Dunkin%27_Donuts#United_States](https://en.wikipedia.org/wiki/Dunkin%27_Donuts#United_States)

</comment></comment><comment><USER7> it is irrelevant what companies offer the products. There is still choice of product because of capitalism.

Socialist economies reduce the total product offering as well as innovation.

In a capitalist grocery store we have a choice of 10 types of apples. In a communist grocery store there might not be apples.</comment>


Against Economics - <AUTHOR> https://www.nybooks.com/articles/2019/12/05/against-economics/ <comment><USER3> > Printing money does not cause inflation.

Ah, but it does. It creates _asset inflation_. This may be the worst kind of all possible inflation because it makes people believe they are wealthier than they are. When the inflation can no longer be sustained, large numbers will soon find out they are far poorer than they once thought. That's the stuff of revolutions and Dark Times.

Asset inflation takes root through policies that distribute money, not to the poor (Great Society), but to the rich (Deregulation and Quantitative Easing). The rich have no use for the money being given out and so drive up asset prices with it.

From this perspective, it's easier to see how a multi-thousand word essay on new economics fails to mention negative interest rates once.

<comment><USER4> This is the big flaw in how inflation is measured. Assets (eg. for pension savings) and especially housing costs are for some reason not included in the Consumer Pricing Index despite them being a huge expense from person's monthly paycheck.

One can argue the reasons why. Is of the same problem with KPIs in general thay we only measure things which are easy to measure and omit the difficult but often much more important things to measure?

Or is it a conspiracy plot in which the governments realized that the only way to repay those ever increasing government debts is by inflating them away. Ie. borrowing at 1% akin to CPI reported inflation instead of at 8% which is what the actual inflation might be.

<comment><USER5> Putting on my academic Econ hat for a moment: There's probably a stronger argument for including housing costs like rent into CPI than asset value like home values. Assets like homes are supposed to be illiquid and relatively constant over time. Ie little change in the underlying fundamentals of the item or changes that can be accounted for in an uncomplicated way. When such stable in underlying value but relatively illiquid assets like homes trade their realized prices are supposed to reflect little more than inflation. So maybe their price changes make more sense on the exogenous side of the equation than the endogenous?

Is this argument still valid? It seems like it would be since it still seems moving in and out of a mortgage is a longer (by months) process than moving in or out of a lease.

<comment><USER5> Replying to myself to avoid an edit as this is a new topic.

I'm wondering increasingly lately if oil hasn't replaced gold and fiat as the underlying backer value of currency. We had a problem in Econ to contrast and compare fiat currency to gold backed currency. Fiat is supposed to not be tied to a scarce resource and thus central banks have the ability to influence market growth through currency growth. Gold or resource backed currency can only grow at the rate new stock is removed from the ground. Of course, oil complicates there concept as oil is irreversibly consumed when it's burned. The value of it still greatly affects market growth potentials though.

<comment><USER6> The difference with oil is that not everybody exports it. With the gold standard, every sovereign nation worth the name attempted to create a gold- backed sovereign currency, and so was essentially "exporting gold" in some sense (the sense in which you can take their currency outside the country and spend it.)

But not all countries are oil exporters, or oil "holders"; and even those who are, are not exporters to the same order-of-magnitude. This creates very clear market effects where e.g. the value of the Canadian dollar at any time is essentially the value of the US dollar divided by the quantity of US oil exports.

This would be like different gold-backed sovereign nations declaring a different, floating "ratio" of their fiat currency's value to their level of gold deposits, such that changes in the price of gold would throw exchange rates around (and some nations having no gold at all, and thus having an exchange rate that measures only how much of some _other_ country's gold their fiat currency could buy you!)

</comment></comment></comment></comment></comment><comment><USER7> The article takes things a bit too far with the political angle. Just because economists may or may not be particularly accurate at predicting recessions doesn't mean that "economics" doesn't deserve its place in the neo-liberal order.

NPR did a podcast a few years ago on six policies it's ideologically diverse panel of economists all agreed on: [https://www.npr.org/sections/money/2012/07/19/157047211/six-...](https://www.npr.org/sections/money/2012/07/19/157047211/six- policies-economists-love-and-politicians-hate)

They are:

1&2) get rid of tax deductions for mortgage interest and healthcare

3) eliminate corporate taxes

4) replace payroll and income taxes with consumption taxes

5) impose carbon taxes

6) Legalize marijuana

Perhaps unsurprisingly, Europe, Canada, and Australia have all been moving in the above direction (at least slowly) over the past 30 years, marking a period of return to growth after decades of economic doldrums where they were uncompetitive with the USA.

There is even less disagreement when it gets into microeconomics. Everyone agrees that markets produce efficient prices so long as you account for externalities. So for example, an EPI study polled economists about the $15 minimum wage (who identified as Democrats 3:1 as compared with Republicans): [https://www.johnlocke.org/update/what-do-economists-think- ab...](https://www.johnlocke.org/update/what-do-economists-think- about-a-15-hr-minimum-wage). 75% thought it would negatively affect employment, and 84% agreed it would hurt youth employment.

Similarly, few economists support rent controls: [https://www.economist.com/leaders/2019/09/19/rent-control- wi...](https://www.economist.com/leaders/2019/09/19/rent-control-will-make- housing-shortages-worse)

Indeed, the consensus on government price controls is so deep that, with the exception of isolated things like rent control and the minimum wage, where people don't perceive it as price regulation, even liberals don't really call for price regulation. That is remarkable, because price regulation was a feature of life until the 1970s. Airline tickets, freight trucking, phone bills--all were priced not based on markets, but based on bureaucrats picking numbers.

<comment><USER8> >4) replace payroll and income taxes with consumption taxes

how can this be implemented in a fashion that's non-regressive? income taxes in most countries are progressive, and consumption taxes are regressive.

<comment><USER9> Progressiveness is a function of both taxes and benefits. A consumption tax scheme can be made more progressive by paying benefits in a more progressive manner.

For example, Exampleville institutes a consumption tax of 15%. Such a tax is regressive because consumption is usually a smaller proportion of a wealthy person's income than a poor person's income. To counteract this, Exampleville pays a monthly cash grant to all citizens and adjusts the payment level so that the cash grant is larger for the poor and smaller (or non-existent) for the wealthy.

See [https://tax.purpleplans.org](https://tax.purpleplans.org) for an example of a real proposal that mimics this scheme.

<comment><USER10> But this assumes that the revenue from the consumption tax will 1) be the same as for the income tax, and 2) hit wealthy people enough that the lower benefit payout will balance it.

I don't really see how these can be true given that, as you state, wealthy people spend a smaller portion ( _a lot_ smaller) of their income than do poor people.

To toss out some numbers, let's say the wealthy person makes $1M per year at a 35% effective income tax rate and the poor person makes $50K per year at an effective 10% income tax rate. Let's further suppose the wealthy person spends half their after-tax income, and the poor person spends all of it. Total tax revenue in this case would be $355K under the income scheme, but if we switch to a consumption tax, the tax revenue drops to $55,500. There's no amount of benefit allocation you can do to make up the difference. On top of that, the tax burden for the wealthy person (after offsetting for the benefit allocation) is still massively lower than under the income scheme, even if they get $0 in benefits. You'd have to raise the consumption tax ridiculously high (33% !) to get close, which will effectively discourage expenditures and encourage savings, pretty much destroying the US consumption-based economy.

I just can't see a realistic scenario where this setup isn't regressive or generally a bad idea. If you want to keep a progressive system but also eliminate income tax, we need to consider a wealth tax.

<comment><USER11> > You'd have to raise the consumption tax ridiculously high (33% !)

I don't think 33% is ridiculously high. VAT is 25% in Norway, Sweden, and Denmark, 27% in Hungary; and their economies are doing well.

<comment><USER12> Interestingly, the Nordics also have super-high income taxes. I wonder what the VAT there would have to be to abolish income taxes. 50%? 60%?

<comment><USER13> Just checked the Danish national budget. Danish VAT brought in (or was estimated to bring in) 212 billion DKK in 2018. In comparison, tax levied on personal income brought in 562 billion.

</comment></comment></comment></comment></comment></comment></comment><comment><USER14> Oh great, another non-economist getting famous for criticizing economics from a position of comprehensive ignorance. Modern economics has more than enough critics WITHIN the economics field. People who wouldn't say something as stupid as "Economists still teach their students that the _primary role of government_ ... is to guarantee price stability!". Seriously, this has NEVER been remotely close to true. When you say something like that, you effectively lose the section of the audience that knows the something about economics, and are instead rousing the ignorant rabble. The field of Economics has problems (such as an over-reliance on mathematical models), but instead of any of THAT being discussed we have the argument centering around some fantasy-world view of economics and economists!

<comment><USER15> You're taking the least charitable interpretation of that sentence, reading it as "all" or "most" economist teaching government's primary role is price stability. That is apparently false (I'll take your word for it).

In a more charitable reading, he's reacting to one or a few instances where it is taught but shouldn't. That could be accurate, if contextually misleading and possibly myopic.

Discounting his argument based on factual errors is fine, but given that you only bring one counterpoint to the table, "another non-economist getting famous for criticizing economics from a position of comprehensive ignorance" sounds like an argument from authority.

<comment><USER16> I don't see how anything in the text permits that charitable reading. Even the inventor of monetarism itself, Milton Friedman, thought that the government could prevent recessions -- he just thought that the best way to do that was to target the money supply, so you get price stability and no recessions all at once. The whole point of his and Schwartz _The Monetary History of the United States_ is that drops in the money supply are linked to recessions.

</comment></comment></comment><comment><USER17> Does anyone have a good, non-biased resource explaining why keynesians cannot explain stagflation, and what Milton Friedman did during this era to solve that problem and thereby launch us into the modern neo-liberal moment?

Whenever I search for this, I have a tendency to find articles that already assume the reader has read on the topic numerous times (like this one), or they they only address the topic in the most watered-down and overtly partisan manner.

From reading between the lines on the first few pages of google results, it seems like Keynesian thought in the 1970s hadn't evolved far enough to recognize that inflation could have multiple driving factors and could impact different parts of the economy disproportionately. My limited understanding too is that this was resolved theoretically and with obvious and clear explanation in the years afterward (now referred to as neo-keynesian), but by then Milton Friedman had been lionized as the new economic "truth" and the universe moved on in his direction.

<comment><USER18> Inflation was fixed when the Federal Reserve (led by Volker) increased interest rates to over 17%, causing the early 80's recession. [1] We've had other problems since then, but not inflation, so it increased confidence that the the Fed knows what it's doing.

But I don't know what Friedman had to do with this or how it affected theory.

[1] [https://en.wikipedia.org/wiki/Early_1980s_recession_in_the_U...](https://en.wikipedia.org/wiki/Early_1980s_recession_in_the_United_States)

<comment><USER19> This is an unsatisfying view of things, for me, because it seems like low inflation and interest rates are a global phenomenon.

As a pessimist, it seems to me that assuming there are resilient homeostatic mechanisms preventing inflation, then they must be obscure, given that politicians have not been able to screw them up for quite some time. And that means that when they do break for whatever reason, markets may not be aware for an indefinite amount of time. Like, for instance, lately people have been worrying about the US President trying to bully the Fed. It's hard to tell if he's had any effect, if he was right in his opinion, and whether he has found or will find any new lever to influence them.

I don't really think it makes sense to regard the Fed as an entity that still entails the Volcker era, and I'm doubtful that markets really have faith in it that way. I'm inclined to think more along the lines that often markets just go along assuming nothing has changed until there is a shock or crisis that shows they have. Like Wile E. Coyote running off a cliff.

<comment><USER16> According to current thinking, the homeostatic mechanism is inflation expectations. People currently have "anchored" inflation expectations in that expect any inflation to remain stable in the long run. If inflation expectations become unanchored (like in the 70s), then it requires larger and larger inflation to stimulate the economy.

</comment></comment></comment></comment><comment><USER4> After years of unsatisfactory personal research of various schools od economics I had to come to conclusion they are all flawed because they completely omit the important parts which govern our economy.

For example having all economical models based around people exchanging goods and not focusing on why money actually disappears from economy in form of monopolies and money parked in real estate. It always has to be poured back into economy in form of money stimuli like QE, yet people are blind to the fact that it yet again gets eaten up by ever bigger monopolies and more expensive real estate. A simple network model of money circulating in economy would show that these sinks are where the money keeps disappearing.

Yet no economic school has its primary focus set on these money eating sinks. The closest school is actually the once mighty, now close to extinct Georgist school, in which they at least explain the business cycle of booms and busts as housing cycle, where housing bust is not some random consequence of a business going bonkers, but housing (actually land speculation) being the major cause of these cycles.

If you think about it 100% of population (except for hobos) are involved in real estate market and paying close to 50% of paycheck on housing in some form. Yet all economics focus on stock and bond markets and exchange of random little items even though these are dwarfed by the housing markets.

I don't think it is a conspiracy, but laziness. People like to research things which are easy to research, but not things which are difficult but important.

<comment><USER16> There's an entire field of real estate economics. There are professors and conferences and everything.

You won't find your theory about money sinks, because it's a theory unique to you. It may be the greatest breakthrough in the history of economics, but it's not a theory that currently anyone else believes in. I personally am skeptical.

</comment></comment><comment><USER20> > To this day, economics continues to be taught not as a story of > arguments—not, like any other social science, as a welter of often warring > theoretical perspectives—but rather as something more like physics, the > gradual realization of universal, unimpeachable mathematical truths.

This has always been my main frustration with economics. As a field, it certainly has value and usefulness, just like sociology, anthropology, or any of the 'softer' sciences. However, it eschews the tradition of teaching a variety of views and perspectives for the rigid orthodoxy of classical physics or chemistry, without the clean experimental results to back it up.

Microeconomics and econometrics take a much more concrete and practical view and well-describe localized economic phenomenon, but macroeconomics is a bastardized combination of sociology and capitalist political theory mashed into an unfalsifiable 'science' and taught as such.

<comment><USER21> As someone who studied economics, I've always found the history of the subject itself to be more illuminating than much of the content of it. Both due to the content having this not-rigorous quality to it and because a lot of macroeconomics seems to be politics in disguise.

You're right about micro though.

<comment><USER22> > a lot of macroeconomics seems to be politics in disguise.

It used to be called political economy. But macroeconomics went off on a math- trip in the 20th century that rivals string theory in its practical applications.

<comment><USER16> The opposite is true. Before the mathematics, everyone in macroeconomics was hopelessly confused. The mathematics makes the claims people are making much clearer. People still argue about what Marx meant in _Capital_. Nobody argues what Kydland and Prescott meant in "Aggregate Fluctations and Time to Build" (an early mathy path on macroeconomics), because it's all right there in the math.

</comment></comment></comment></comment><comment><USER23> "...government borrowing didn't divert funds from the private sector; it created entirely new money..."

The general answer to this is that public spending crowds out private spending as both are bidding for the same goods and services.

Not sure if that's a good explanation, but the article doesn't seem to address that conventional wisdom.

</comment><comment><USER24> > We now live in a different economic universe than we did before the crash

I think "this time is different" thinking is dangerous. Yes, maybe the world is different now, but it's only been 10 years since the big crash, not so long.

Expecting the world to keep being the same as it is now is just as dangerous as thinking it will always be as it was for the last 50 years.

</comment><comment><USER5> """ The one thing it never seemed to occur to anyone to do was to get a job at a bank, and find out what actually happens when someone asks to borrow money. In 2014 a German economist named Richard Werner did exactly that, and discovered that, in fact, loan officers do not check their existing funds, reserves, or anything else. They simply create money out of thin air, or, as he preferred to put it, "fairy dust.""""

Let me stop you there. Economists aren't trying to create the exact theory that market participants implement. That would almost certainly be short sighted to the point of uselessness. (How often in your life have you woken up with Plan A and wound up doing B - where B is very different from A?) Instead, they're looking for a theory that agrees in the outcome and may be applied usefully to describe what's going on in resource allocation. This probably flies in the face of a technology focused era in which surveillance of the masses at the nearly perfectly micro/individual level is a prime factor in market valuation. Some of the largest corporations today have access to data no economist ever dared dream to consider.

That actually makes me think modern surveillance companies (google, Apple, amazon, etc) could really make market models from the individual to market level in aggregate.

Versus the topics at discussion here - which are macroeconomic. Macro is often hurt by a lack of data since there are only so many years of data of the goings ons of nations in a global context - with probably not enough variation to make conclusions.

</comment><comment><USER25> I would write this author off, this is a rant and nothing more. "We now live in a different economic universe than we did before the crash. Falling unemployment no longer drives up wages..." Wages are certainly going up in places with low unemployment, its just not distributed as evenly as it was in prior history.

<comment><USER26> For context, David Graeber is an anarchist anthropologist who has written extensively about economics. His two best-known works on the subject:

\- [https://www.amazon.com/Debt- First-5-000-Years/dp/1612191290/](https://www.amazon.com/Debt- First-5-000-Years/dp/1612191290/)

\- [https://www.amazon.com/Bullshit-Jobs-Theory-David- Graeber/dp...](https://www.amazon.com/Bullshit-Jobs-Theory-David- Graeber/dp/150114331X)

His views are surely influenced by his a-priori politics, but I've found his ideas thought-provoking to say the least.

<comment><USER16> Graeber is also the person who wrote this sentence:

"Apple Computers is a famous example: it was founded by (mostly Republican) computer engineers who broke from IBM in Silicon Valley in the 1980s, forming little democratic circles of twenty to forty people with their laptops in each other's garages..."

</comment></comment></comment><comment><USER27> > Central banks like the Bank of England create money as well, but monetarists > are entirely wrong to insist that their proper function is to control the > money supply. In fact, central banks do not in any sense control the money > supply; their main function is to set the interest rate—to determine how > much private banks can charge for the money they create. Almost all public > debate on these subjects is therefore based on false premises.

This seems to be a weird oversight on the part of the author. Even if we accept the heterodox view of money creation as espoused by this article (which I do, for what it's worth), the central bank still plays a very important role even in the private creation of money. Setting the "risk-free" interest rate for the economy determines how much money banks are going to be willing to lend, which thereby determines how much money they will create. Just because the central bank is not printing the money themselves does not mean that their policy levers are not having profound effects on the money supply.

<comment><USER16> Graeber has an oddly dated notion of issues in macroeconomics. Targeting the money supply is a 70s era idea that the Bank of England tried briefly and abandoned in favor of targeting the interest rate.

</comment></comment><comment><USER28> This article lost me at "printing money does not cause inflation." How would that be possible? The only answer would be that money is increasing in value for some reason, and the government must print more to keep prices stable (otherwise they would fall). Even then, it would be a technicality.

<comment><USER29> Yup, came here to make the same complaint. The article just throws that out there as fact with no justification or citation.

Just need to look at what's going on in Venezuela, right now.

Increased supply of anything lowers it's value.

<comment><USER21> > Increased supply of anything lowers it's value.

Network goods? Are telephones more valuable when more people have them? Road networks?

Just pointing out that many things in economics are not so obvious.

You're right that you need to cite things that go against the orthodoxy. At least to have sane debates. But of course he could have cited the current money printing era, where if you believe the official figures there's not a lot of inflation anywhere in the west. I'm not so confident in the figures, but that's at least some evidence that printing a load of money doesn't cause inflation.

<comment><USER30> I know there's an economic element to networks, but in the context of what we're talking about, more people having a telephone is a measure of the products quality, not supply. Capacity of the network would equal supply. Right?

Unless I'm grossly missing something.

<comment><USER31> The value of a single phone is zero, 2 phones grants each owner the ability to contact one person (2 units of value total), 3 grants 3 owners 2 each (6), 4 -> 3 (12), 5->4 (20). In other words, increasing the size of the network multiplies the value of the entire network by that amount (factorial).

In a phone network, there are a few different tipping points where the _ubiquity_ adds additional value. At a certain point, having a phone is worthwhile _because everyone you could possibly want to talk to also has one._ (this is also why I still have an account on Facebook).

The same can be said of a currency network. It becomes more valuable the more people you can exchange it with. People using US dollars outside the US gain value from knowing they have a trusted "stable third party" currency, and at the same time US dollars become more value to citizens of the US because they can now use that currency for purchases in that other country.

Having 20 phones with one owner is practically worthless, even though the network capacity is theoretically high. Distributing those phones among twenty people is what generates the real value. But you can't really distribute 20 phones equally among 200 people.

You need sufficient _saturation_ of currency for its distribution to be of any real value, because you need enough quantity to be able to use it to do its job as a holder of arbitrary value exchange.

<comment><USER30> I appreciate the response. I get that... (I think)

I just don't get why that necessarily has anything to do with supply itself. It has to do with the distribution, and as a result, the quality or utility of the network.

As you said, one person having 20 phones is off dubious value, but 20 additional people with phones might increase the network's quality.

The supply (20) is independent of the resulting quality/saturation/useful node count.

On the other hand, increased nodes _could_ be seen as a negative. Like the US- Russia hotline. Or Facebook after it opened up to users without college email accounts.

Sometimes supply might affect the quality of a network, and therefore the value of having a node (phone) on that network. But to say supply increases with demand is misleading, to me. Increased quality increases demand, at a rate greater than the rate demand is decreased due to increased supply.

If supply _happens_ to increase quality, then yes supply might dominate the equation such that demand increases as supply increases. But that doesn't mean the fundamental relationship between supply and demand has changed, it's just been minimized for particular cases.

Or maybe I'm just getting confused by transitive semantics.

<comment><USER31> I would agree with most of what you said here. To echo your semantics and in the greater context of this thread, I was merely pointing out that increasing the supply (and in the case of money, distribution/saturation) _could_ increase the "quality" at a rate faster than the forces that that push the "quality" down in terms of "quality" per unit of currency. In the specific case of money, there is an additional group psychology at play: if you believe your money won't be worth as much tomorrow as it is today, then you should spend it today if you can. Since the value derived from currency is in its exchange (it's not producing any value sitting under a mattress), it increases the "quality" of the currency for it to be circulating.

<comment><USER30> Yea, if we're talking about money supply I suspect the phone comparison might be apt in a slightly different way.

I haven't seen anyone touch on it in this thread, but I've read opinions where people have blamed companies for hoarding all of the newly available cash, especially for stock buybacks.

If there's any truth to that, it would make sense, since companies can usually get better rates and first dibs at market level loans/ bonds/ etc than small business or individuals.

In the phone analogy, (if we assume there's _some_ value having multiple phones) this would be like a new dialing prefix being released, and companies buying up the numbers hundreds at a time at bulk rate discount, leaving little or no additional numbers for individuals.

So supply was increased, but the businesses hoarding new numbers prevents any quality improvement if the network.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER32> note to self:

Required for education: Unskilled labor "must" pay less to motivate people to get diplomas.

Required for productivity: Wages "must" be low enough so that people have to keep working.

Since motivation to get a diploma depends on the size of the income advantage "ideally" people without diplomas should barely be able to sustain themselves - forever.

All other economic talk seems filler material. All excessive wealth "should" go towards sustaining the filler material or otherwise be destroyed. For this purpose we also see endless investment in businesses that exist only for the purpose of extracting wealth from everyone else. Some of course deliver useful products in return but if they could increase ROI by not making anything most if not all would do it. If they operate at a loss it is even more "beneficial" to the system. For this purpose we also have 32 Trillion "hidden" in tax havens.

The whole thing seems to have "evolved" so that we all are as productive as possible only to sacrifice the produce on the altar of productivity again. The bad thing about this is that all this "productivity" destroys everything around us. It all costs finite resources. We would be better off just making what we need efficiently.

</comment><comment><USER33> Can anyone recommend a book or other resource that gives an overview of the various schools of economics including the "heterodox" ones?

When I'm learning about a subject I find it much easier if I have a framework for categorizing and organizing the different approaches or topics that the subject consists of.

<comment><USER34> Well the best heterodox economist IMO is Michael Hudson. Recommend his blog, talks and books to anyone.

</comment></comment><comment><USER35> A few observations I generally do not see discussed.

Velocity of money has a large impact on the inflationary impact of circulating money.

Bank loans endogenously produce new money in the economy. This can dramatically impact the inflation seen relative to Fed printing.

Official macro stats, especially inflation are tweaked to death and are not a stable metric.

</comment><comment><USER36> Highly correlates with what is written in the Incerto[1] series by Nassim Nicholas Taleb.

[1] [https://www.goodreads.com/series/164555-incerto](https://www.goodreads.com/series/164555-incerto)

</comment><comment><USER37> I have an outsider's perspective, I studied economics but mostly ended up doing economic history (I am a practical person, and preferred stats to models)...

...the point of economics is not to produce models that are 100% accurate. Yes, there is an absolute ton of witchcraft in economics and especially in macro (CGE, DGE to name two areas beloved by civil servants/central banks) but it is very far from useless (and, contrary to what the author thinks, there is a hell of a lot of testing of theories). The issue, funnily enough given the author's perspective, is often that we use economics to just support whatever we already believe.

On his actual content: unsurprisingly, he gets his history totally wrong.

First, an important point, the UK never actually adopted monetarism. We were forced to adopt DCE targets by the IMF in 1968 but everyone thought it was bullshit. Even after Thatcher crushed inflation, monetarism was only popular amongst the small group of City economics/journalists who came to the idea in the 1970s (and were thought of as crackpots by non-risk takers). The UK was thoroughly Keynesian, that is why we persisted with utterly insane policies through govts under both parties (until Thatcher).

Second, saying monetarism causes disaster confuses the cause and effect. Monetarism, whatever its theoretical faults, was correct in 1979 but was only necessary because Labour/Heath had fucked the economy beyond belief (the UK went to a three-day week because the economy literally just stopped working).

Third, the 1960/70s were not a period of economic success. Inflation hit 25%, two devaluations, one trip to the IMF, one banking crisis, and endless begging other people to lend money (and the govt got a reputation for going back on agreements). Incomes policy was, objectively, one of the most disastrous policies ever conceived. It ended up, literally, with unions running the economy in 1974. Yes, growth was high but real growth was lower and supported by population growth. I am not aware of any history which concludes any economic policy pursued in this period worked. Everything failed.

Fourth, what everyone forgets about the 1950/60s was that there was almost no trade. That is why workers were richer. Most currencies weren't convertible until the late 50s. The UK could milk Commonwealth nations dry with no competition. But the evidence here is clear: trade makes us richer. Anyone who says this isn't the case, even Trump recognises this, is an ignoramus.

Fifth, Greenspan understood there was a bubble. He gave a speech in 1998 saying there was a bubble. The issue - which is perfectly logical if you look at what happened in 1958 when the Fed did burst a bubble - is that people will say you caused the downturn if you intervene (he blames monetarism for causing the downturn but also blames the Fed for not bursting the bubble...what a genius this guy must be, spotting bubbles like he is at a car wash). This is an attempt to inject some psychology into economics, it is amazing the author doesn't see this.

It is no surprise Graeber has thrown his lot in with Corbyn. The number of crackpot acolytes around Corbyn grows every day (thankfully, he remains unpopular with voters). I would vote for Labour normally...but their current policies are just...ignorant. These ideas have been tried, they didn't work, that is why Corbyn has support amongst young people who don't read books. The logic is: build a wall, make Goldman Sachs pay for it.

<comment><USER38> You dont sound like an outsider at all. "Trade makes us richer. Anyone who says this is the the case is an ignoramus".

Contrast that with this recent article

[https://foreignpolicy.com/2019/10/22/economists- globalizatio...](https://foreignpolicy.com/2019/10/22/economists- globalization-trade-paul-krugman-china/)

I think what you really need to define is what "us" means

</comment></comment><comment><USER39> This article is utterly nonsensical (claiming the money supply is essentially unrelated to inflation) but the specifics of their argument say a lot about the field and why things I think are about to get worse.

Their argument goes

A) current economic regimes are built on shifting sand and border on useless for predicting macro crises (this is true more or less)

B) there are other schools of thought out there which are sometimes more predictive than the main stream

C) therefore get rid of economics

D) and replace it with a different version of economics, specifically one which agress with my politics.

The problem is that they are right, mainstream economics is junk, and so it becomes really hard to discredit other wacky ideas like mmt, or endless unmoderated fiscal stimulus because hey, couldn't be much worse than our system which seems to blow up and screw everyone over.

<comment><USER40> > claiming the money supply is essentially unrelated to inflation

I don't think this is the actual claim. The key quote is this (emphasis mine):

> Doubling the amount of gold in a country will have no effect on the price of > cheese _if you give all the gold to rich people and they just bury it in > their yards, or use it to make gold-plated submarines_

It's not that they're unrelated, it's that increasing the monetary supply is a necessary but not sufficient criterion for inflation to occur. I don't think the author would likely deny that printing boatloads of money resulted in inflation in Zimbabwe or Venezuela, just that if you increase the monetary supply specifically by giving it to rich people who hoard and it never gets spent on consumer goods, it won't affect the price of consumer goods. That's not how it went down in Venezuela, but is (the author asserts) what kept QE from working.

<comment><USER41> >and it never gets spent on consumer goods

It doesn't need to be spent on consumer goods to cause inflation. It can also be spend on economic investment ie. new capital (new factories, new equipment, infrastructure inventory, supplies, training, R&D, real estate, mining operation etc. etc.). The money will quickly flow to employees and then to everything else.

Only if the rich keep all the new money in cash form would it not cause inflation but this would usually be a very risky and unstable situation for the money hoarders as some of the money on the sidelines can start moving at any time which would cause inflation to spike and the rest of the stockpile to lose value quickly.

<comment><USER40> > The money will quickly flow to employees and then to everything else.

Sure, I never said it was the rich people that had to do the spending, so we don't disagree there, but if "inflation" as commonly measured (CPI, say) is to occur, the prices of consumer goods have to change, and someone at some point has to buy some, whether it's the rich people or their employees, and if it's the latter it requires that the former sink their money into something that employs people. The author suggests that this happens less reliably than it used to (that they hoard cash, or I dunno, gold? whatever -- something societally unproductive)

</comment></comment></comment></comment><comment><USER42> This is not an argument against economics, but against specific ideas in economics holding true:

"Falling unemployment no longer drives up wages. Printing money does not cause inflation."

This is not fair.

A) Wages are the _last_ thing to rise and tend only to do so when unemployment is low. We're just now reaching that level.

B) Inflation doesn't well account for surpluses: we're getting a lot of bang for our buck in digital services, something that's super hard for the BLS to measure. 'Consumer Surpluses' are like 'profits' to the consumer that are not really measured at all - the only place we do this is when the BLS measures the 'quality' of a basket of goods to figure out inflation: i.e. if the Tomato is getting nicer, redder, juicier, then part of the increased cost of said tomato goes to value, the rest to inflation. This is hard enough to do already, but nary impossible with new services coming online.

Case and point: Fortnite. It's free. I've played quite a number of hours of that last year _and never spent a dime_. Apex is a big game, not free. This is a new trend. The surpluses there are vast. Games have a measurable effect on time spent on other things as well.

In a nutshell: consumers lives are improving in ways not always appreciated.

C) "Printing money does not cause inflation" \- generally, it absolutely does! It just depends where you measure said inflation: stocks, housing - <USER2> inflation. We just don't put that into our version of inflation. But there's inflation for sure!

Consider point 1 and 2 together: if stocks are doing well, and CEO's are getting their rewards for strong returns, why are they incented to innovate, pay more etc? Screw that - in a game of 'stocks going up because free money' \- the strategy is to 'do nothing' \- just keep operating as per, and avoid risk. 'Push the button, collect reward'. Risk changes the nature of the operating environment, and who wants that if there's steady 'returns'?

D) The Fed is not 'printing money' really, it's not quite fair to say that in the sense usually implied: a government (or anyone else) 'printing money' to pay for stuff has an entirely different implication.

I'll state the article misses the most important things:

1) Printing money almost assuredly does cause inflation, even now.

2) _All things equal_ wages will rise as unemployment lowers. It's just that 'all things are not equal'. Take a look at real surpluses. Take a look at debt-leveraging in homes. Take a look at bifurction of employment from 'tech workers' to 'powerless gig economy' people. Take a look at levels of migrants, their relative skill and their relative market power for wages (they have little power, and there are enough that it absolutely moves the needle).

'Economics' can be used to measure and address all of those things, you just have to start looking at the data, and if not, start measuring things we didn't before.

My bet is the answers are not actually that far off, and probably not very surprising if we could see 'all the data' otherwise ignored or unmeasured.</comment>


Show HN: Coding on Twitter - <AUTHOR>

Just tweet to @paiza_run, and you will get result as reply.
  @paiza_run ruby: puts "Hello" + "World" Just now, it is quite hot, and people are tweeting like 20 seconds. Language names available are: java,ruby,python,php,perl,c,cpp,csharp,javascript,objective-c,scala,go,haskell,coffeescript,bash,erlang,r,cobol,vb,fsharp<p>This service is provided based on
https://paiza.io/, Handy web-based only coding environment. <comment><USER2> :) [https://twitter.com/paiza_run/status/534654223909003264](https://twitter.com/paiza_run/status/534654223909003264)

</comment><comment><AUTHOR> Language names: java,ruby,python,php,perl,c,cpp,csharp,javascript,objective-c,scala,go,haskell,coffeescript,bash,erlang,r,cobol,vb,fsharp

</comment><comment><AUTHOR> So, tweet message is like: @paiza_run ruby: puts "Hello" \+ "World"

</comment><comment><USER3> Didn't seem to work. Is it down at the moment?

</comment><comment><USER4> Fun idea</comment>