Python idioms I wish I'd learned earlier - <AUTHOR> http://prooffreaderplus.blogspot.com/2014/11/top-10-python-idioms-i-wished-id.html <comment><USER3> I think the example in #4 misses the point of using a Counter. He could have done the very same for-loop business if mycounter was a defaultdict(int).

The nice thing about a Counter is that it will take a collection of things and... count them:

        >>> from random import randrange
        >>> from collections import Counter
        >>> mycounter = Counter(randrange(10) for _ in range(100))
        >>> mycounter
        Counter({1: 15, 5: 14, 3: 11, 4: 11, 6: 11, 7: 11, 9: 8, 8: 7, 0: 6, 2: 6})

Docs: [https://docs.python.org/2/library/collections.html#counter-o...](https://docs.python.org/2/library/collections.html#counter- objects)

<comment><USER4> Python noob here. What does the _ mean in "...for _ in range(100))"?

<comment><USER5> To add to specifics:

_ in python is commonly used as a variable name for values you want to throw away. For example, let's say you have a log file split on newlines, with records like this:

        logline = "127.0.0.1 localhost.example.com GET /some/url 404 12413"

You want to get all the URLs that are 404s, but you don't care about who requested them, etc. You could do this:

        _, _, _, url, returncode, _ = logline.split(' ')

There's no special behaviour for _ in this case; in fact, normally in the interactive interpreter it's used to store the result of the last evaluated line, like so:

        >>> SomeModel.objects.all()
        [SomeModel(…), SomeModel(…), SomeModel(…), …]
        >>> d = _
        >>> print d
        [SomeModel(…), SomeModel(…), SomeModel(…), …]

Which I think is basically the same behaviour; you run some code, you don't assign it, so the interpreter dumps it into _ and goes on about its day.

</comment></comment></comment><comment><USER6> _" Because I was so used to statically typed languages (where this idiom would be ambiguous), it never occurred to me to put two operators in the same expression. In many languages, 4 > 3 > 2 would return as False, because (4 > 3) would be evaluated as a boolean, and then True > 2 would be evaluated as False."_

The second half of this is correct, but it has nothing to do with whether the language is statically or dynamically typed. It's a tweak to the parser, mostly.

<comment><USER7> It's not just a tweak to the parser, and it does have to do with the type system, but you're right that it's not about static typing.

The issue is that there are languages (like C) where typing is static but weak, so e.g. booleans are also integers and can have integer operations like '>' applied to them. In other words, the problem is that in C True == 1 and 1 > 2 is a valid expression. In Python, which has strong(er) types, this expression can have an unambiguous meaning if you want to add the feature to your parser.

<comment><USER6> You can implement it entirely in the parser if you can avoid name capture - <USER2> may or may not be implemented entirely as a tweak to the parser in practice, but it's fundamentally a syntactic thing.

Your discussion of types here is all wrong - it's true that C treats booleans as if they were integers, but _Python does, too_ :

        >>> (3 > 4) < 2
        True
        >>> 3 > 4 < 2
        False
        >>> 3 > (4 < 2)
        True

It has nothing to do with types.

<comment><USER8> I think the comparison is more readable as (here with the >>> of the python shell):

        >>> 0 < x < 1

as opposed to

        >>> 1 > x > 0

Following the number line and placing x there is nicer IMHO. Other than that, very nice trick.

<comment><USER6> In terms of coding style, I agree with you that following the number line is usually going to be clearest. I think there might be some situations where descending is better than ascending, but certainly both are radically better than what I did above (low > high < lower).

As an example for what I was specifically trying to show here, though, that doesn't let me distinguish things quite as clearly.

I believe that (a < x < b) gives the same value as at least one of (a < x) and (x < b) for any value of x.

        x < a:
            a < x gives false
            a < x < b gives false

        a < x < b:
            everything gives true

        b < x:
            x < b gives false
            a < x < b gives false

So there's no way to get both of the parenthesized versions to disagree with the unparenthesized version in a single example.

</comment></comment></comment></comment></comment><comment><USER9> If you were underwhelmed by this blog post have a look at:

Transforming code into Beautiful, Idiomatic Python by Raymond Hettinger at PyCon 2013

[https://speakerdeck.com/pyconslides/transforming-code- into-b...](https://speakerdeck.com/pyconslides/transforming-code-into- beautiful-idiomatic-python-by-raymond-hettinger-1) and [https://www.youtube.com/watch?v=OSGv2VnC0go&noredirect=1](https://www.youtube.com/watch?v=OSGv2VnC0go&noredirect=1)

Topics include: 'looping' with iterators to avoid creating new lists, dictionaries, named tuples and more

<comment><USER10> Sorry for the offtopic but why did you add `&noredirect=1` to the end of that youtube url?

<comment><USER9> sorry, was only an accident.

</comment></comment></comment><comment><USER11> Sincerely, Transforming Code into Beautiful, Idiomatic Python – by Raymond Hettinger... [http://youtu.be/OSGv2VnC0go](http://youtu.be/OSGv2VnC0go)

<comment><USER12> I was lucky to watch this video while first learning the language. Every beginner (coming from another language) should watch this to understand the idioms of Python.

<comment><USER11> Ya, me too. It's also a very funny talk. :)

</comment></comment></comment><comment><USER13> One of my favorites:

        >>> print "* "* 50

to quickly print a separator on my terminal :)

Previous discussion on python idioms from 300 days ago: [https://news.ycombinator.com/item?id=7151433](https://news.ycombinator.com/item?id=7151433)

<comment><USER14> That's cute, but the result of a bad design decision.

Python overloads "+" as concatenate for strings. This also applies to lists. So

        [1,2,3] + [4,5,6]   yields  [1,2,3,4,5,6]

This is cute, but not what you want for numerical work.

Then, viewing multiplication as repeated addition, Python gives us

        [1,2,3]*4  yields [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]

This is rarely what was wanted.

Then there's numpy, which has its own array type, needed because Python's array math is slow. Numpy arrays have different semantics - add and multiply perform the usual numeric operations. You can mix numpy arrays and built-in lists with "+" and "*". Mixed expressions are evaluated using numpy's semantics. Since Python doesn't have type checking, it's possible to pass the wrong kind of numeric array to a function and have it treated with the wrong semantics.

Moral: when designing your language, using "+" for concatenation is tempting, but generalizing that concept comes back to bite you.

<comment><USER15> Then what would you have

        [1,2,'q',[1,('a',2)]] + 4

yield? The reason why numpy lets you do math operation on each element in an array is because you can safely assume that each element is a number. You can assume absolutely nothing about the types of the elements in a list.

<comment><USER14> "TypeError: cannot add 'str' and 'int' objects."

Just because you can define semantics for nonsense doesn't mean you should.

<comment><USER16> I'll modify the example slightly to something which doesn't have a type error:

        [1,2,'q',[1,('a',2)]] * 4

With element-by-element operations, that would be

        [1 * 4,2 * 4,'q' * 4,[1,('a',2)] * 4]

giving

        [4, 8, 'qqqq', [1 * 4, ('a', 2) * 4]]

applying that again, assuming that tuple * scalar is also applied element-wise gives:

        [4, 8, 'qqqq', [4, ('a' * 4, 2 * 4)]]

and ends up with

        [4, 8, 'qqqq', [4, ('aaaa', 8)]]

I can't think of any case where that's meaningful.

Also, what should this do:

        x = [1]
        x.append(x)
        print(x + x)
        print(x * 4)

? Currently these print:

        [1, [1, [...]], 1, [1, [...]]]
        [1, [1, [...]], 1, [1, [...]], 1, [1, [...]], 1, [1, [...]]]

because the print function knows how to handle recursive definitions. Do all of the element-wise operations need to handle cyclical cases like this? I think numpy can get away with not worrying about this precisely because, as wodenokoto pointed out, it can assume a flat structure.

</comment></comment></comment></comment></comment><comment><USER17> Wow - that's really, really great list.

In particular, #7 is something that I didn't even know existed, and I've been hacking around for 2+ years.

Instead of:

       mdict={'gordon':10,'tim':20}
       >>> print mdict.get('gordon',0)
       10
       >>> print mdict.get('tim',0)
       20
       >>> print mdict.get('george',0)
       0

I've always done the much more verbose:

       class defaultdict(dict):

           def __init__(self, default=None):
               dict.__init__(self)
               self.default = default

           def __getitem__(self, key):
               try:
                   return dict.__getitem__(self, key)
               except KeyError:
                   return self.default

       mdict=defaultdict(0)
       mdict['gordon']=10
       mdict['tim']=20
       print mdict['gordon']
       10
       print mdict['tim']
       20
       print mdict['george']
       0

I'll be sure to make great use of the dictionary get method - I'm embarrassed to admit how many thousands of times I could have used that, and didn't know it existed.

<comment><USER18> Do you know there's also collections.defaultdict ?

<comment><USER17> I do now! I had known (and used) collections.OrderedDict, but had never used defaultdict. Millions of keyerrors later...

I clearly am going to have to spend a few hours today grokking everything that collections.* has to offer. Thanks very much.

</comment></comment></comment><comment><USER19> This is something I do instead of writing a long if-else:

        opt = {0: do_a,
               1: do_b,
               3: do_b,
               4: do_c}
        opt[option]()

<comment><USER20> Do you consider that to be idiomatic? I've been out of touch with the a Python community for a few years, but back then I wouldn't have considered that remotely idiomatic, and if I was on a team writing software, I would have argued that we shouldn't be writing code like that.

<comment><USER21> I've done this before, I think of it as a more powerful form of a switch statement.

I'd love to hear why you think it's not ideal.

<comment><USER22> " _I 'd love to hear why you think it's not ideal._"

I'm not the poster you posed that question to. But for me, the one big drawback of using that idiom is that the function signatures have to be identical. So you either have to resort to args/kwargs, or you have an additional intermediary method between the actual "guts" of what you're calling, and the "switch" statement.

Or you live with the fact that you're passing unused/unnecessary parameters to your functions.

<comment><USER8> Good point, and in that case, I would say this idiom is not so great really. For functions with the same signature, it's a fine solution I think.

</comment></comment></comment></comment></comment><comment><USER23> _> There is a solution: parentheses without commas. I don't know why this works, but I'm glad it does._

It's worth mentioning that this is a somewhat controversial practice. Guido has even discussed removing C-style string literal concatenation:

[http://lwn.net/Articles/551438/](http://lwn.net/Articles/551438/)

You may wish to consult your project's style guide and linter settings before using it.

<comment><USER24> I personally don't like this style of using multiple strings. Makes radical changes of the text cumbersome.

I think in most cases it's better to use triple quotes. And if the content of these variables isn't exclusively shown in the shell, you should use translation files anyway.

<comment><USER25>
        $ cat triple.py
        def foo():
            print """this is a triple quoted string
                     this is a continuation of a triple quoted string"""

        if __name__ == '__main__':
            foo()
        $ python triple.py
        this is a triple quoted string
                         this is a continuation of a triple quoted string

This is really warty. In bash you can mostly get around this with <<\- for here documents (which removes leading indentation, so even if you're defining a here doc at a place that itself is indented, you don't have to align the text to the left column yourself). The man page in my version suggests it only works for leading tabs, not spaces, though.

e.g.

        $ function usage() {
                cat <<-END
                        this is a here document that
                        spans multiple lines and is indented
                END
        }
        $ usage
        this is a here document that
        spans multiple lines and is indented
        $

<comment><USER26> Use `textwrap.dedent()`?

<comment><USER27> I normally just do this for multiline strings:

        s = "\n".join(["one","two","three"])

<comment><USER25> This happens at run time whereas IIRC the string literal is crammed pre-joined into the ,pyc / .pyo file.

The performance hit of doing this kind of thing really adds up in a larger app.

</comment></comment></comment></comment></comment></comment><comment><USER28> I'm not much of a Python guy, but that chained comparison operator is sweet!

Sure, it's just syntax sugar, but it saves a lot of keystrokes, especially if the variable name is long.

Is Python the only language with this feature?

<comment><USER29> Common Lisp (and other dialects):

       (< a b c d)   ;; T if a < b < c < d
       (<= a b c d)  ;; T if a < b < c < d

Also:

       (lcm a b c d ...) ;; lowest common multiple

       (+) -> 0
       (+ a) -> a
       (+ a b)  -> a + b
       (+ a b c) -> (a + b) + c

       (*) -> 1
       (* a) -> a
       (* a b) -> a * b
       (* a b c) -> (a * b) * c

Is it just syntactic sugar? (< a b c) evaluates a, b and c only once, which matters if they are expensive external function calls or have side effects.

       (and (< (foo) (bar))
            (< (bar) (baz)))

isn't the same as

       (< (foo) (bar) (baz))

By the way, this could be turned into a short-circuiting operator: more semantic variation. Suppose < is allowed to control evaluation. Then an expression like (< a b c d) could avoid evaluating the c and d terms, if the a < b comparison fails.

<comment><USER30> But can any lisp dialect do:

        a < b >= c

    ?

<comment><USER21> (< a (>= b c)) same number of operators but a few extra parens

<comment><USER29> Here (>= b c) will return a boolean value, which you're then comparing to a.

<comment><USER29> Which means it could be done, but the relational operators (any one of which could be the leftmost constituent) have to all be defined as macros which analyze the rest of the expression with alternative evaluation rules.

</comment></comment></comment></comment></comment></comment><comment><USER31> I came across this when I was first learning Python and it has always impressed me:

        from random import shuffle
        deck = ['%s of %s' % (number, suit) for number in '2 3 4 5 6 7 8 9 10 Jack Queen King Ace'.split(' ') for suit in 'Hearts Clubs Diamonds Spades'.split(' ')]
        shuffle(deck)

<comment><USER32> I never liked how people in Python use stringWithSpaces.split instead of a list. Just feels wrong somehow.

But I've seen it many times so it's probably pythonic

<comment><USER31> As DaFranker points out, it's just easier to type than

        ('Hearts', 'Diamonds', 'Spades', 'Clubs')

and has less opportunity for typos and syntax errors. If I was concerned about performance I would replace it with a tuple, but it was Good Enough for a quick example.

<comment><USER32> Sorry, I realised I sounded negative. Nothing against you, it's just my private opinion.

It's not about performance, but about one more incidental step when reading the code. Small cost, but it's there.

<comment><USER33> One reason I like it is that you're probably going to be reading in the possible values from a stream or arg or config file anyway.

But you have a good point. YAGNI is YAGNI.

</comment></comment></comment></comment></comment><comment><USER15> Can someone direct me to a comparision of subprocess and os? I keep hearing subprocess is better, but have not really read any explanation as to why or when it is better.

(I'm glad I'm not the only one who was thrilled to discover enumerate()!)

<comment><USER34> The OS module interacts directly with the OS rather than abstracts it, so a lot of the functions in it have the "may not be available on all platforms" apology.

Subprocess uses OS under the hood but offers an abstraction that mostly works on all platforms, e.g. the way that "communicate" is implemented on Windows differs considerably from how its implemented on Unix.

</comment></comment><comment><USER35> I was grateful for the example of multilined strings, mysterious as it is. The lack of any way to do this has been an annoyance of mine for quite some time.

</comment><comment><USER36> Some comments:

1\. Am I the only one that really _loves_ that `print` is a statement and not a function? Call me lazy, but I don't mind _not_ having to type additional parentheses.

5\. Dict comprehensions can be dangerous, as keys that appear twice will be silently overridden:

      elements = [('a', 1), ('b', 2), ('a', 3)]
      {key: value for key, value in elements} == {'a': 3, 'b': 2}
      # same happens with the dict() constructor
      dict(elements) == {'a': 3, 'b': 2}

7\. I see

      D.get(key, None)

way too often.

8\. Unpacking works in many situations, basically whenever a new variable is introduced.

      for i, el in enumerate(['a', 'b']):
        print i, el

      {key: value for (key, value) in [('a', 1), ('b', 2), ('a', 3)]}

      map(lambda (x, y): x + y, [(1, 2), (5, -1)])

Note: the last example (`lambda`) requires parentheses in `(x, y)`, as `lambda x, y:` would declare a two-argument function, whereas `lambda (x, y):` is a one-argument function, that expects the argument to be a 2-tuple.

<comment><USER37> On the subject of "call me lazy", I really like the % syntax for string interpolation. I'd like perl-style interpolation even more. "".format() is going in completely the wrong direction for me. (I don't think % is being removed, but I think it's discouraged.)

> lambda (x, y): x + y

This syntax is removed in python 3: [http://legacy.python.org/dev/peps/pep-3113/](http://legacy.python.org/dev/peps/pep-3113/)

<comment><USER38> I'm still not sure why that was deprecated. It's much cleaner. I still use it… :/

<comment><USER39> Ideology.

</comment></comment></comment></comment><comment><USER40> I'm a fan of Python's conditional expressions.

        foo = bar if qux is None else baz

They're particularly interesting when combined with comprehensions.

        ['a' if i % 2 == 0 else 'b' for i in range(10)]

Though this particular example can be expressed much more concisely.

        ['a', 'b'] * 5

<comment><USER41> Before the conditional expression was introduced to Python I sometimes wrote things like

        foo = [baz, bar][qux is None]

</comment></comment><comment><USER42> I work with python full time, and the last (#10 string chaining) is one of the few times the syntax had caused me grief, due to missed commas in what were supposed to be tuples of strings. The chaining rules are one of the few sources of apparent ambiguity in the syntax, especially when you include the multiline versions.

</comment><comment><USER43> Most of these idioms actually make me sad.

When I first started using Python around 1999, it didn't even have list comprehensions. Code was extremely consistent across projects and programmers because there really was only _one_ way to do things. It was refreshing, especially compared to Perl. It was _radical_ simplicity.

Over the decade and a half since then, the Python maintainers have lost sight of the language's original elegance, and instead have pursued syntactical performance optimizations and sugar. It turns out that Python has been following the very same trail blazed by C++ and Perl, just a few years behind.

(At this point Python (especially with the 2 vs. 3 debacle) has become so complex, so rife with multiple ways to do even simple things that for a small increase in complexity, I can just use C++ and solve bigger problems faster.)

<comment><USER44> Are we reading the same article, though?

It's certainly up for debate whether named tuples and enums, various kinds of metaprogramming and decorators might be making the language more complex for fairly little gain... but this article talks about the `enumerate` function, about string formatting and dictionary comprehensions. Simple, straightforward stuff with no downsides.

</comment></comment><comment><USER45> There is an sweet in India called [0] _phirni_ when you start eating from outer layer to inner layer, you will feel like _walking in heaven_.Now you are in outer layer.I hope you enter to the inner level and feel the python still. :)

[0] [http://www.wikihow.com/Make-Phirni-%28a-Rice-and-Milk- Dish%2...](http://www.wikihow.com/Make-Phirni-%28a-Rice-and-Milk-Dish%29)

</comment><comment><USER46> _" Missing from this list are some idioms such as list comprehensions and lambda functions, which are very Pythonesque and very efficient and very cool, but also very difficult to miss because they're mentioned on StackOverflow every other answer!"_

Can anyone link to good explanations of list comprehensions and lambda functions?

<comment><USER31> This seems like an easy intro to list comprehensions:

[http://www.pythonforbeginners.com/basics/list- comprehensions...](http://www.pythonforbeginners.com/basics/list- comprehensions-in-python)

</comment></comment><comment><USER47> Nice list, but I was confused by the arguments to the dict .get() example until I looked up the definition.

</comment><comment><USER48> I wish there was an interval set in Python's builtins.

I also wish that ranges were an actual proper set implementation - so you could, for example, take intersection and union of ranges.

And I wish that Python had an explicit concatenation operator.

<comment><USER26> You mean like the built in `set` object? [https://docs.python.org/2/library/stdtypes.html#set](https://docs.python.org/2/library/stdtypes.html#set)

<comment><USER49> I think he or she meant a specialized set data structure that stores sets of numbers which can be written as finite unions of interval. Typically besides set operations you'd also want (1) that only endpoints of the intervals are stored, so that the structure is compactly represented in memory, (2) to be able to recover the canonical representation of the set as a sorted union of disjoint intervals.

<comment><USER48> This is exactly what I meant, thank you.

</comment></comment></comment></comment><comment><USER50> Oh, wow. I didn't know the dict comprehensions. Since when do they exist? I always used:

        d = dict((key(x), value(x)) for x in xs)

<comment><USER51> [http://legacy.python.org/dev/peps/pep-0274/](http://legacy.python.org/dev/peps/pep-0274/)

I'm not entirely sure how to interpret the PEP header. It dates back to 2001 and was updated in 2012. It's probably in python since 2.3 but maybe 2.7(2010)/3.0(2008).

</comment></comment><comment><USER52> Is there any such collection of advanced Python patterns, aimed at Python programmers with more than 2-3 years of experience?

<comment><USER53> I'd love other answers to the same question. Here are a few I've come across in the past:

[http://www.rafekettler.com/magicmethods.html](http://www.rafekettler.com/magicmethods.html)

[http://sahandsaba.com/thirty-python-language-features-and- tr...](http://sahandsaba.com/thirty-python-language-features-and-tricks-you- may-not-know.html)

[http://www.siafoo.net/article/52](http://www.siafoo.net/article/52)

</comment></comment><comment><USER54> haha.. in #1, the easter egg "not a chance" :) :)</comment>


Crafting Interpreters Is Complete - <AUTHOR> http://craftinginterpreters.com/contents.html <comment><USER2> Dupe [1], with 71 comments and 717 points a few days ago.

(btw, the blog post is an excellent read)

[1] [https://news.ycombinator.com/item?id=22788738](https://news.ycombinator.com/item?id=22788738)</comment>


Breaking into a Smart Home with a Laser (video - demo) - <AUTHOR> https://youtu.be/ozIKwGt38LQ <comment><AUTHOR> Related attack website with papers:

[https://lightcommands.com](https://lightcommands.com)

Wired article from Nov 2019:

[https://www.wired.com/story/lasers-hack-amazon-echo- google-h...](https://www.wired.com/story/lasers-hack-amazon-echo-google-home/)

HN article:

[https://news.ycombinator.com/item?id=21446760](https://news.ycombinator.com/item?id=21446760)</comment>


Onbrand Grader – grade the branding of your website - <AUTHOR> https://onbrandgrader.com <comment><AUTHOR> * We are on Product Hunt today! - will be answering all questions there / emails.

Branding > conversion Win the ZMOT, strengthen awareness, shorten decision making, grow loyalty - it's all about branding. But many brands don't have strong branding for their website, while online touching points becoming primary. How strong is your website branding? The free tool grades it from 4 objective aspects: consistency, message, visibility, accessibility. Share your score and thoughts with us!</comment>


The Direct Costs from NPE (Patent Troll) Disputes - <AUTHOR> http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2091210

<comment><USER3> For me, the best summary of the fucked up nature of the patent system comes from two nice soundbites...

First, just yesterday, I was at an event where a patent lawyer declared (I kid you not):

"You should be careful how much you innovate on top of existing products, because you might end up falling under someone else's patent."

Seriously. I couldn't believe my ears. Incentivising innovation fail.

The other soundbite came from an entrepreneur at a TechHub meeting in London, about the Hargreaves Report on IP, last year. He said:

"I wish I hadn't come tonight. The more I learn about IP, the less I want to start a business."

I think that pretty much sums up how well the patent system incentivises innovation.

<comment><USER4> I don't think the first comment is particularly controversial, though the speaker was being diplomatic in his use of the term "innovate." It makes more sense if you replace it with "rip off."

The fact of the matter is that a lot of people paint this idealized picture of the morally virtuous techie, where the only people who own patents are big bad patent trolls, and the only people who get sued are innocent innovators who independently arrive at an invention.

That's not the actual story, or at least that's not the whole story. Like in every other field, there is a gaussian distribution of business ethics at various companies. Look at how many companies get nailed for using GPL-ed software without releasing source. You think those same companies don't also copy competitors' designs wholesale? When our company was doing business with an American telecoms supplier, a manager there mentioned that a Chinese telecoms supplier was ripping off their designs wholesale, down to the silk- screening on the PCBs.

There is a difference between "let's innovate on top of this idea" and "oh this idea is good, let's just copy it."

Now, NPE's in their current form are clearly just rent-seeking. However, I think there is a role for NPE's that create value by serving to create a market for patents. Not every innovator wants to get into the business of making products. ARM wants to design microprocessors, they don't want to design and manufacture iPads. Patents facilitate that division of labor, and NPE's can make the whole system more efficient by creating markets for patents.

<comment><USER5> I agree that wholesale copying is an issue. However patents are almost never going to be the appropriate response to that for software companies. With software you can always go for copyright violation and/or misappropriation of trade secrets. By contrast, given that it can easily take the better part of a decade to actually get your patent assigned to you, you are very unlikely to have patents that cover the innovative parts of your technology.

Instead software patents seem to be mostly used to sue people who independently invented the same thing. They enable rent-seeking and provide no educational value to spread innovation. (Which naturally arises and spreads in our industry on a time scale that is too short to get patents assigned.)

How do I know this? Because the one has happened based on my work, and the other came close to happening. At one of my employers, a rogue employee cloned the code base and then took it to some Eastern European programmers to reimplement the website. It was litigated based on copyright and trade secrets - no patents were available for that lawsuit.

However a different employer of mine took out two patents based something I did when I was there. Since then a number of companies have infringed on those patents, and could be sued for large sums. By luck the patents have wound up owned by an organization that is unlikely to ever let them go to a patent troll. But I've spent years fearing that that work will get used to stifle independent innovation.

<comment><USER4> > I agree that wholesale copying is an issue. However patents are almost never > going to be the appropriate response to that for software companies. With > software you can always go for copyright violation and/or misappropriation > of trade secrets

Only if software is the product you're selling. I worked at two companies that had patents on software algorithms, but our software was just a reference implementation. Explain to me how a company like ARM would operate relying on just copyright and trade secrets. I think ARM represents a great and valuable business model, and patents enable that business model.

> Instead software patents seem to be mostly used to sue people who > independently invented the same thing.

I don't think you can point to any statistic to back this up.

<comment><USER6> >> Instead software patents seem to be mostly used to sue people who independently invented the same thing.

>I don't think you can point to any statistic to back this up.

I think that was already clear from the word 'seem'. To me, the same thing seems to be true, actually. That /might/ be caused by the number of software- patent cases I see that fall into this category, or are about trivial inventions, while I simply don't see the cases that do have some merit.

On the other hand, I've never yet seen a software patent related case where I could actually relate to the suing party.

</comment></comment></comment></comment></comment><comment><USER7> I am a non-US person. I was very close to set up and transfer my startup to a new C Corp in the US in order to get better payment APIs and make the startup more attractive to VCs. The patent trolls in the US is one of the biggest reasons why I choose not to move my startup to the US, at least not until I get funded. I guess many others also choose to stay away of the US for this reason. The total loss of business in the US must be great.

<comment><USER8> I wonder if there's a legally creative way to keep the IP outside the US, but license it to a US company that acts as a reseller.

<comment><USER9> I doubt it. Look at what happened to RIM.

<comment><USER8> Why, what happened to RIM?

</comment></comment></comment></comment><comment><USER10> As the ancients used to say, 'those that the gods want to destroy, they first make mad'. Accordingly, I see a lot of things going down the pan in an ever accelerating spiral.

There are too many unscrupulous, unethical people about, out to make lots of money for zero real creativity, value, and effort. They are forever inventing new artifices towards this end, be it indulgences (sin forgiveness chits), fractional banking (credit out of thin air), software patents, CO2 indulgences, etc. and then getting fat on trading them.

We are so far gone that many people can no longer even discriminate between real value and these things; sinking as we all are in this sea of BS.

<comment><USER11> There's also a glut of lawyers in the US, enabled by cheap student loans, law schools' statistics inflation, etc., all scrambling to put food on the table. It's not surprising that some new legal strategies and domains that arise from this demographic trend may be good for lawyers in the short term, but not for the country in the long term.

</comment></comment><comment><USER12> Alternate title: "Patent trolls give $29B boost to struggling legal profession"

<comment><USER13> This should be a textbook example of the Broken Window Fallacy.

</comment></comment><comment><USER14> You bunch of commie terrorists, stop trying to break the one mechanism fostering innovation that we have!

</comment><comment><USER15> It costs far more than that. What's missing is the lost wealth due to things that weren't created but would have been, not only because people were afraid or unmotivated to create them but because of the money the trolls took.

</comment><comment><USER16> I just wanted to say thank you for the title change - this is far more clear and informative and makes my earlier comment moot.

Actually it also made me click through to the paper, which also has this title. This is much better.

</comment><comment><USER16> This is ycombinator's hackernews, the title should read "Patent trolls created $29B of value." I don't condone it but let's be consistent.

<comment><USER17> Come now, you can't get away with a statement like that without explaining your argument.

<comment><USER16> all right, I'll explain it. One guy's cost is another guy's value (almost by definition - of course there are exceptions such as losing something to nature through accident instead of losing money to persons or companies [of any kind] by making an expenditure of any kind to them) - so the patent trolls "create" whatever value we add up to get to the number quoted.

I am not saying anyone supports patents. I'm saying hackernews should be more consistent - or otherwise admit that "creating value" isn't an end in itself. It's the wrong question.

Edit: I think the current title is fine. ("Patent trolls created $29B extra cost in the U.S. last year") I just want us to be clear that one guy's cost is another guy's "value".

I would love to see more cooperative-optimistic-tit-for-tat solutions to the prisoner's dilemma, so that instead of just saying "creating value" we are more specific about the whole system.

This is what (an unnamed restaurant review site) gets wrong and Google gets right, in my opinion. Google adds value whereas (unnamed) removes it.

Of course in a naive sense (unnamed) is also "creating value". Just as these patent trolls are.

We don't condone it, but let's be consistent.

<comment><USER18> You're free to argue that patents are a net positive to society, but to argue a priori that $29B of wealth transfer = $29B of wealth creation, almost by definition, is completely broken thinking.

By your standard, Bernie Madoff created $18B in value.

HN as a group may have many contradictions and blind spots in its general wisdom, but you haven't identified one of them.

<comment><USER19> There is a previous transaction though - the patent trolls acquire their patent portfolios from, in the long run, inventors. They "bought" and "own" them, and are now asserting those rights, to the expense of $29B to other companies who should be licensing the rights.

Nobody blames landlords of costing businesses billions of dollars a year - they own property and businesses pay rent. Nobody builds a business using a landlords property without paying rent, then plausibly claims their legal costs defending themselves against landlords asserting their rights are somehow an unexpected and unfair imposition. (Well, actually food carts probably do exactly that, but nobody writes academic papers claiming billions of dollars worth of cost for them…)

I haven't read the whole paper, but I wonder about two other numbers - 1) how much money did the NPE's pay to the inventors of the patents they're defending (who under the current system have every right to choose "selling their patents/IP" as their means of monetizing their inventingwork)? and 2) how much would licensing the existing patents (instead of running up legal bill later) have been, compared to the $29B losses described here?

I'm not saying the current system is "right", but it is reasonably well understood. I can only assume the $29B cost is accepted as a "cost of doing business" by companies who know (or even just suspect) they may be infringing patents? (or perhaps it's not an assumed "cost", and many businesses choose to gamble that they'll never be held accountable?)

<comment><USER18> If wealth creation happens at any step, it's when an invention that is beneficial to society is created, and the patent system exists to account for that.

If the invention is junk (like the Lodsys patents), it doesn't matter how wealth has been transferred around; no value has been created. Any rent sought on those patents is an economic distortion and (in my opinion) immoral.

I didn't even start this off to take a side (though I guess I have by now) - <USER2> was just pointing out a fallacy in GP's thinking.

<comment><USER20> Trademarks require proof of use in commerce to be valid.

Perhaps patents should require proof of use- If not by the inventor, then by the patent owner within a probation period of 3 years or so.

</comment></comment></comment></comment></comment></comment></comment><comment><USER21> I totally agree with the common belief that patents are the wrong way for protecting most startups... But, an interesting thought about patent trolling, I believe, is that if patents are useless then why can the trolls make $29B/year on trolling? I'm confused!

<comment><USER22> Patents are intended to incentivize people to reveal their secrets in exchange for a temporary monopoly on the secrets. They are not meant as vehicles purely for making profit, but that is how they are being abused - by people who buy up patents and then sue anyone who infringes, or by people who patent as broadly as possible and then sue anyone who infringes. Useful for making money, not useful for the intended purpose of contributing work for the greater good of all people.

The patent system is too broken. Anyone who writes software should hate patents. Anything you write will infringe on some patent out there. If all you want is money then writing software isn't the best way to go about getting it.

A better system would be one where patents do not give protection to ideas, but do give minor tax incentives to the people who own and use a related patent in their business. Then their ideas are shared, but not using the patents gives them nothing, and they cannot block others from using the all too often obvious ideas.

<comment><USER4> > The patent system is too broken. Anyone who writes software should hate > patents. Anything you write will infringe on some patent out there. If all > you want is money then writing software isn't the best way to go about > getting it.

I write software (open source on GitHub) and don't hate patents. I hate bad patents, the kind you can infringe upon just by writing software, but lots of patents aren't bad patents. E.g. IBM has a number of patents on compiler optimizations. Am I going to stumble upon Steensgard's pointer analysis by accident? No, the only reason I know about it is that IBM let him publish a paper based on the research they paid him to do at Watson.

<comment><USER20> >Am I going to stumble upon Steensgard's pointer analysis by accident?

Yes! Yes, you could stumble on Steensgard's algorithm. Like convergent evolution in nature, it's easy for requirements to shape implementation, and for multiple implementations to naturally overlap. There are so many software patents out there- it is a minefield.

Additionally, engineers at large companies are _discouraged_ from doing their own patent research, because of the risk of losing a "sorry, we created this organically in good faith" defense in litigation.

Publication of patents does not offset the chilling effect and legal overhead on our industry.</comment></comment></comment></comment>


Show HN: Built a widget to kickstart projects with lines of beta users waiting - <AUTHOR> https://www.makebuildy.com/ <comment><USER2> Add this to [https://startupstash.com/add- listing/](https://startupstash.com/add-listing/)

<comment><AUTHOR> Will do, big thankies</comment></comment>


New Climate Debate: How to Adapt to the End of the World - <AUTHOR> https://www.bloomberg.com/news/articles/2018-09-26/new-climate-debate-how-to-adapt-to-the-end-of-the-world <comment><AUTHOR> _Propelling the movement are signs that the problem is worsening at an accelerating rate. In an article this summer in the Proceedings of the National Academy of Sciences, 16 climate scientists from around the world argued that the planet may be much closer than previously realized to locking in what they call a "hothouse" trajectory—warming of 4C or 5C (7F or 9F), "with serious challenges for the viability of human societies."_</comment>


Roost (YC S14) Takes On Twitter, RSS With A Platform For Web Push Notifications - <AUTHOR> http://techcrunch.com/2014/06/10/roost-takes-on-twitter-rss-with-a-platform-for-web-based-push-notifications/

<comment><USER2> Finally! This will be extremely helpful for platforms across web and mobile that need to provide a consistent experience. A large portion of our engagement comes from being able to let our users know that relevant content has become available (e.g. potential purchases, in-app messages). The experience cannot start and end with simply opening up our app.

Users are inundated with countless emails from app/websites and it is difficult to separate yourself from the spam...even if your users want to hear from you. They simply do not have the time to sift through all the garbarge...nor should they have to!

I think Roost will finally allow us to engage with users on our and their terms. Excited to check this out!

</comment><comment><USER3> Really interesting. This will fuel my reddit addiction even more so. Not sure how I feel about that.

Actually... I do know how I feel about that. I love it.

</comment><comment><USER4> I wonder what kind of new interactions we can foster with users...? Might be better than mobile push to deliver auxiliary content!</comment>


The 5 Worst Things to Learn from a DNA Test - <AUTHOR> http://www.chromosomechronicles.com/2008/12/24/the-5-worst-things-to-learn-from-a-dna-test/

<comment><USER2> Mistaken ancestry? That's a very American thing to have (not fear). For example, the admixture is such that the African-American population has 20% 'white' ancestry. We're an admixed people. I always thought that was the great part about being American...

Mistaken paternity? That would be pretty lifechanging. But how exactly would a 23andMe style test let you know if you father "wasn't your father?" I suppose he would need to submit DNA as well? (Obviously if your true father is from Asia or Africa but you always thought he was European, you could easily discover this with principal components... but I'm sure that's not what this blog post's author is talking about.)

In my opinion, there is little to be gained, currently, from commercial genetic testing. Groups like 23andMe egregiously oversell their offerings: <https://www.23andme.com/store/> "Learn your genetic risk for type 2 diabetes, Parkinson's disease, and other conditions." Please - at present day, your genetic profile tells you no more about your risk for T2D than does your family history.

<comment><AUTHOR> Mistaken paternity would be readily apparent from a 23andMe test. There is a section where they compare family DNA, and a child is expected to share 50% of their chromosomal segments with their father. Of course, both child and parent would have to be tested.

I agree completely, the disease predispositions in the 23andMe service fall far from being of any value. <http://Navigenics.com> and <http://www.deCODEme.com> do a better job at this.

</comment></comment><comment><USER3> Mistaken ancestry? That's one of the worst things for Americans? Really?

How about significant genetic overlap with your significant other? Or you carry hereditary diseases that you'll pass on to your children? Or that your DNA is partially composed of frog's DNA? (Why do you think those dinosaurs were so angry?)

<comment><AUTHOR> I suppose mistaken ancestry is a very "American" fear (if one at all), although I can think of other countries (like Japan) where any "surprises" in ancestry might not be so hot.

Accidental inbreeding would be horrible.

</comment></comment><comment><USER4> "Nothing at all?"</comment>


Hermès's Refusal to Change Is Its Most Radical Gesture Yet - <AUTHOR> https://www.nytimes.com/2019/02/15/t-magazine/hermes.html <comment><AUTHOR> It's amazing that today the idea of employing 4,000 crafts people is novel but this is really a very cool story of doing business the same way for generations.</comment>


Jacques Derrida Interviews Ornette Coleman (1997) [pdf] - <AUTHOR> http://www.ubu.com/papers/Derrida-Interviews-Coleman_1997.pdf <comment><USER2> Since the onslaught of ignorant anti-continental quips has already begun, I'd like to suggest two texts by Richard Rorty—an American pragmatist with an extremely lucid writing style—that show how it is indeed possible to find Derrida interesting without being a charlatan or stupid:

Here, a short review that gives a very brief introduction/defense (in a sort of backhanded way, though): [http://www.lrb.co.uk/v06/n03/richard- rorty/signposts-along-t...](http://www.lrb.co.uk/v06/n03/richard- rorty/signposts-along-the-way-that-reason-went)

"Derrida's principal theme in these essays is the attempt of the tradition to make language look less sprawling by trimming off unwanted growth. This is done by making invidious distinctions between true (e.g. 'literal' or 'cognitively meaningful') language and false (e.g. 'metaphorical' or 'meaningless') language. He is arguing that this attempt cannot succeed, because it is just the latest version of the onto-theological attempt to contrast the Great Good Resting-Place with the sprawling world of time and chance. He wants to convince us that there is no natural hierarchy of discourses or jargons, no structure topped off by the super-language which gives us a grip on all the others, the words which classify all the other words. There is no privileged language in which to state invidious distinctions between true and false language. There is no linguistic material out of which we can forge clippers with which to snip off unfruitful linguistic suckers. He thinks Heidegger betrayed his own project by trying to separate 'real' language (the Call of Being, the kind of language which 'is what it says') from 'inauthentic' language (words used as means to technocratic ends, chatter, the jargon of this or that disciplinary matrix)."

And here, a full essay on Derrida titled "Philosophy as a Kind of Writing": [http://faculty.georgetown.edu/irvinem/theory/Rorty- Philosoph...](http://faculty.georgetown.edu/irvinem/theory/Rorty-Philosophy- as-a-Kind-of-Writing-1978.pdf)

I don't have time to write more in depth about this. It's at least heartening that the most cynical and flippant comments have been downvoted.

<comment><USER3> > _how it is indeed possible to find Derrida interesting without being a > charlatan or stupid_

Charlatan or stupid? How provincial one must be to come to that conclusion.

As hackers (geeks etc) we are generally mostly accepting of an empiricist, show-me-the-numbers, kind of analysis (and analytical philosophy), but it's by far not the only one, or the most potent, when outside the realm of hard sciences. The anglosaxon positivist/reductionist philosophical school is not the only one out there, just as Hollywood and the emphasis on the "plot" is not the only movie tradition.

It's like someone working on imperative programming all your life, and asking "what's this BS Prolog thing, that's not real code" or "LISP is pretentious and doesn't have a proper syntax".

<comment><USER4> > Charlatan or stupid? How provincial one must be to come to that conclusion.

It's a reference to Chomsky's criticism of postmodernism: [http://www.critical-theory.com/noam-chomsky-calls-jacques- la...](http://www.critical-theory.com/noam-chomsky-calls-jacques-lacan-a- charlatan/)

(Not that I particularly agree with Chomsky here, mind you...)

</comment></comment></comment><comment><USER5> What a pleasure this interview was to read. And plain spoken, too.

Many here have complained that Derrida is hard to read, or worse, simply makes no sense. You may take a side in this, if you like. But I would encourage you to read some short piece of his instead. In so doing, and as the interview itself remarks on reading, you may make your own interpretation.

@mbrock has listed several items. To these, I add what my instructor for composition at Deep Springs (himself a student of Derrida) assigned us, "Declarations of Independence." It is but a nine page talk on the US Declaration of Independence. But within it, many of Derrida's persistent concerns on language and action come to light.

You can find it online, starting at page 5 in this PDF: [http://blog.lib.umn.edu/cole0384/academics/files/Derrida.PDF](http://blog.lib.umn.edu/cole0384/academics/files/Derrida.PDF)

<comment><USER6> I took your advice and read a "short piece of his" ([http://web.stanford.edu/class/history34q/readings/Derrida/Di...](http://web.stanford.edu/class/history34q/readings/Derrida/Differance.html))

I found this monstrosity in the third paragraph:

"I will speak, therefore, of the letter a, this initial letter which it apparently has been necessary to insinuate, here and there, into the writing of the word difference; and to do so in the course of a writing on writing, and also of a writing within writing whose different trajectories thereby find themselves, at certain very determined points, intersecting with a kind of gross spelling mistake, a lapse in the discipline and law which regulate writing and keep it seemly."

This is a single sentence.

Is it that Derrida's thought is so complex that it is simply inexpressible in simpler language? Or it this sentence wilful obsurantism?

I find many supporter's of Derrida claiming that if you don't agree with Derrida it must be that you don't understand him. This is a dangerous intellectual cul-de-sac - verging on mysticism.

<comment><USER7> I agree with you. Every time I try explaining this to people, there will be at least one guy who will claim he has read Derrida and understood all his great mysteries, but that plain language can't explain those mysteries ... you need some powerful new language to do so.

Its so ridiculous. Its like this self-contained world of hysteria. They have no useful output that effects the world outside their narrow hysteria. No one outside the hysteria can criticize the hysteria because by not praising the hysteria you are immediately one who doesn't possess the sophistication to produce critiques.

Its pretty much indistinguishable from some sort of fundamentalist religion where the proponents just live in a sealed chamber and are immune to reason. Imagine physicists talking in really technical garble, but never producing any models that actual predict real phenomenon. That's what its like.

Post modernism seems to produce nothing useful but documents for other post modernists to study.

</comment></comment></comment><comment><USER8> Just so everyone is clear here, while Derrida had an "uncertain" reception in some parts of the academy (those crusty old anglo-American philosophers), he was _deeply_ influential, and by some peoples' accounts, one of the most influential philosophers of the 20th century. So, dismissing him out of hand (especially rejections based on his ostensible obscurantism) is akin to saying that Donald Knuth is no good. If you got the chops to critique Knuth, be my guest, but until then, I'll just revel in genius and struggle and struggle.

<comment><USER9> > So, dismissing him out of hand (especially rejections based on his > ostensible obscurantism) is akin to saying that Donald Knuth is no good.

This is an invalid analogy if I ever saw one.

Let me try to make it more accurate.

For Knuth to be like Derrida his magnum opus would have to have been generated by just typing

cat /dev/random

and later claiming that MIX was somewhat defined in there as well as programs written in it. Then he would become famous Paris Hilton style and get a bunch of sycophants that defend his void verbiage no matter what (some because their entire carreers depended on it, others just because they are useful idiots).

<comment><USER10> Hi. How much Derrida have you actually read?

Like sat down, with a pre-existing understanding of the fields he is interfacing with (particularly phenomenology and structuralism and semiotics a la Saussure) and then begin reading?

Most approaches to continental philosophy I read on these pages are like someone jumping into a halfway point of a complex essay on functional programming, quoting it and declaring it nonsense. To people outside particular discourses, things often seem like nonsense. Within them, with enough background, one can see that these things are meaningful, while one might, of course, disagree.

</comment></comment></comment><comment><USER11> "Lonely Woman" is one of the most iconic and haunting melodies in jazz.

I'm glad that the interview explains where its title came from. Though, I'd always assumed it must have come from a much darker place.

Also, this quote is a gem:

OC: I had a niece who died in February of this year and I went to her funeral, and when I saw her in her coffin, someone had put a pair of glasses on her. I had wanted to call one of my pieces _She was sleeping, dead, and wearing glasses in her coffin_. And then I changed the idea and called it "Blind Date."

</comment><comment><USER12> The original transscript of that interview, in French. [http://www.lesinrocks.com/1997/08/20/musique/ornette- coleman...](http://www.lesinrocks.com/1997/08/20/musique/ornette-coleman-et- jacques-derrida-la-langue-de-lautre-11232142/)

</comment><comment><USER13> Funny how Ornette Coleman is the subject of the interview but all of the discussion here is about Derrida.

</comment><comment><USER14> Derrida spoke of the absurdity of deriving meaning from an infinitely recursive and self referent system of language. Pureness of axiom isn't detectable in a mergable feedback loop. However, his critique doesn't show the shortcomings of how we neurologically handle symbols, it shows the incompleteness of human cognition. Derrida is to political epistemology as Turing is to serial bits or Godel is to arithmetic. Keep this in mind for compiler design and neural network structure.

<comment><USER15> _infinitely recursive and self referent system of language_

No idea if this is actually what he said, but when I say the word "dog" while pointing at a dog, the recursion of language stops. It's amazing how so much philosophy is almost intentionally incorrect.

<comment><USER14> ... until a later bystander asks you, "What is a dog?" and you now have to define it without the associated dog present.

Or someone looks at another breed of dog and asks "What is that?" because he isn't aware of canine taxonomy and thinks only that original breed is a creature called "dog".

Welcome to Derrida's version of the halting problem. These are actual problems of NLP today.

<comment><USER16> That's not what people do in natural language processing. Don't appropriate the terminology of other fields for your own purposes and claim you're doing that field.

<comment><USER14> That's not what is done in NLP because that cannot be done by NLP... for the reasons that Derrida pointed out decades ago.

<comment><USER16> Don't tell NLPists what not to do, thanks.

In NLP, people don't just throw up their hands and say "grounding is hard, it's so hard it's impossible, let's not do it". Grounding is sometimes hard, but it's often perfectly tractable for a given problem domain.

If we haven't solved strong AI yet, don't count that as a victory for your unrelated field.

<comment><USER14> Faith in an AI clasification that is invented from a human mind bound by the biases Derrida described long before people could put faith in strong AI?

Sorry, I don't do faith. I do correlation. You just hate Derrida and can't apply any of his observations.

The human does not discover AI. It invents it. And all of the cognitive biases we have are passively passed on with every "axiom" of AI we create. The idea of even classifying AI is ontologically invalid... for the reasons Derrida already pointed out.

</comment></comment></comment></comment></comment></comment></comment><comment><USER9> Why is this here? What's the relevance?

For those who don't know, Derrida was a French postmodern intellectual charlatan with absolutely no redeeming qualities.

A good example of what one should strive not to become.

<comment> steve-benjamins "For those who don't know, Derrida was a French postmodern intellectual charlatan with absolutely no redeeming qualities."

This is a ridiculously inaccurate way to explain Derrida to "those who don't know" him. Derrida is one of the most important continental philosophers of the 20th century.

<comment><USER9> > Derrida is one of the most important continental philosophers of the 20th > century.

I never stated otherwise. What we both wrote is in no way contradictory.

<comment><USER17> That's not fair. Daniel Dennett and Thomas Metzinger have said interesting things.

<comment><USER18> Are you suggesting that Dennett is a continental philosopher?

<comment><USER17> Sorry I skipped over that critical modifier. I agree with the GP then.

</comment></comment></comment></comment></comment></comment><comment><USER7> Derrida is one of those guys, that if you find a fan of his, you have almost certainly found someone who has a love of complicated verbiage over simple straightforward explanations.

Derrida takes a really simple concept and then dresses it up in so much complicated irrelevant nonsense that you have to take 30 minutes to deconstruct and understand an essay, that could be sufficiently restated in perhaps a paragraph of clear English.

<comment><USER19> Is this a generic comment, or based on reading the linked interview? He doesn't seem particularly verbose to me in the interview.

<comment><USER7> Accidentally commented on the main post instead of the comment where someone said Derrida is one of the most important philosophers of the 20th Century or something like that.</comment></comment></comment>


Bugs from the Future: Hadamard Coins and Implicit Measurement - <AUTHOR> http://algassert.com/post/1703 <comment><USER2> Ah, so quantum computation is even more subtly affected by evaluation semantics than non-strict languages. That was a very clear and enjoyable explanation!

</comment><comment><USER3> Note to self: start working qrust now, before it becomes a big problem.

<comment><AUTHOR> It's actually really difficult to determine if a given action will decohere the condition, which makes the language design issue interesting.

For example, consider this code:

        if (q1 != q2) != (H(q1) != H(q2)):
            apply Y to q1

Acting on a qubit used in the condition is a great way to ruin attempts to uncompute said condition. But actually, if you compile this into a circuit, the ancilla used to hold the condition uncomputes just fine:

[https://goo.gl/VD5Z2t](https://goo.gl/VD5Z2t)

It has to with the fact that we're measuring X and Z parities of these two qubits, and yes applying a Y gate affects those parities, but it flips _both_ so the parity-of-parities stays the same.

(And this is on top of all the classical obstacles to perfect classification, like the halting problem.)

<comment><USER4> I'm probably grossly misunderstanding this, but there's no way that you could have a "force a measurement" operator and/or a "caught you peeking" predicate in a language for quantum computers?

<comment><AUTHOR> Forcing a measurement is easy. The language would have something like:

        result = measure q

Forgetting to use that was the source of the bug in the post. The code should have read `if measure qubit`.

'Caught you peeking' depends on what you mean. Measurement has effects that matter, and you can check for those effects. You run the circuit many times, collect statistics, and thereby figure out what the black box is doing. But there's no primitive operation like "is qubit not measured".

<comment><USER4> By "caught you peeking" I meant something reminiscent of the "taint" mechanism you see in languages like Perl and Ruby. Once the qubit was measured, it would be marked so, and the compiler or interpreter would complain if you attempted to use it as if it were unmeasured.

<comment><AUTHOR> Oh, yes, you can of course use a static or runtime type system to try to keep track of that kind of thing.

The tricky thing is that measurement isn't always associated with a single qubit. For example, consider:

        if q1 != q2:
            apply H to q1

This code will cause some decoherence, because we need q1's original value to uncompute the condition but we changed it. But that decoherence isn't specifically associated with just q1, it will also hit q2 because the thing we decohered was the parity between the two.

Now you could detect this happening at runtime, sometimes. The ancilla holding the condition value fails to uncompute consistently, so it will sometimes end up ON. The runtime could notice that ON ancilla and warn you that an ancilla failed to uncompute, but there could be many many actions in between that ancilla being computed and uncomputed. It's hard to figure out which action or combination of actions is the problem, and it's hard to figure out what exactly was decohered. Plus this check is only probabilistic; decoherence is a property of the program not the ancilla's final state. Decoherence still happened if the ancilla ended up OFF but could have ended up ON.

<comment><USER3> Static types are the qrusty way to do it. Runtime bookkeeping is wasteful.</comment></comment></comment></comment></comment></comment></comment>


The "Interstellar" review I wish I read first - <AUTHOR> http://www.filmcomment.com/entry/film-of-the-week-interstellar-christopher-nolan

<comment><USER2> It cheats; the characters are stupid; I felt sticky leaving the cinema.

Why go to immense effort to part your ship outside the orbit of a black hole (yet somehow matching the orbit of a planet further in - which is impossible in any inertial frame I can think of), so you can land a dingy on a planet further in? Then get back and act surprised that while you spent 1 day on the planet, the universe spent 20 years.

That was actually what they meant to do... so why act surprised? Then act surprised that the ship had spent half its fuel over those 20 years keeping the lights on? Why the urgency to land in the first place, when you knew it would take years to return? A couple days thinking could have avoided all that, and not wasted any time compared to those years. Maybe park the ship around the planet, so it would age approximately the same as you ... and save all that fuel, not to mention the wasted years of life of the guy who stayed on board.

The so-called plot was exhausting, trying to keep my belief suspended. After a while it was just inertia that kept me in my seat.

And the wasted talent, playing thankless roles that could have been omitted without any effect on the movie. John Lithgow! Playing a taciturn grandfather, with maybe 3 lines that made it out of the cutting room. Who dies 2/3 of the way through, with an offhand comment by someone else on a video call, no death scene, no farewall, no real purpose in the movie at all.

And the brother, another guy with maybe 3 lines total, no personality to speak of, no reason to be in the movie. And the baffling decision to have the father love the daughter, but care nothing for the son. And never address this in any scene anywhere. Just let it go.

<comment><AUTHOR> I certainly felt cheated after seeing this movie. The Nolans spoiled audiences with fantastic feats of imagination and well crafted storytelling. I did not expect such a trite delivery worthy philosophical notions. I found it interesting Chris Nolan is quoted basically saying don't try to think too much when watching his movies, but much of his body of work is thoughtful and thought provoking.

</comment></comment><comment><AUTHOR> Thanks to my sweetie for directing me here.</comment>


Insider Trading Inside the Beltway  - <AUTHOR> http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1633123

<comment><USER2> All I can say is that I am surprised at how un-surprising this is. There should be more of an outrage. News outlets should be broadcasting this. But somehow, everyone just expects this to happen anyway.

Being inside the beltway (figuratively speaking), between the govt. and its many military contractors, one can really see how corrupt the system is.

There is rampant nepotism, favoritism and waste going on. Those usually are proportional to the cost of the project. I am sure the same thing goes on between the legislative branch, the financial sector, and K street lobbyists.</comment>


Show HN: Our fight against terrible restaurant websites - <AUTHOR>

Today we've launched happytables ( http://www.happytables.com ), a squarespace / wordpress.com for restaurants. I had posted on HN before about a previous iteration we performed ( http://bit.ly/sn0FWc ), and am really satisfied how far we've gotten with it all.
The entire solution is built on top of WordPress, it's allowed us to quickly prototype and build various components. It'll be interesting to see if other solutions pop-up for unrelated niche markets using WordPress too (i.e. real estate, sports clubs, etc.).
Would love to hear your feedback on our concept and would gladly answer any questions too... <comment><USER2> I've wondered about the price point for this, but am skeptical a monthly cost >$10 will work for low margin businesses such as small cafes and restaurants. My brother in law recently opened a taco truck on the island of Kauai. His website is very vanilla, no map, and a very generic menu. Happytable's design is worlds better, but I know the price point will be regarded as too high of a monthly expense. Are you targeting 10+ table size restaurants and high end small eateries?

<comment><AUTHOR> I'd say so, but interestingly enough, we were talking about (and very specifically) food trucks as a potential client for a well optimized one pager. This would work nicely I think for pizzeria's, cheap takeaways, etc.

</comment></comment><comment><USER3> I totally agree, the smb market needs to standardize all of their websites, but I don't think wordpress is the solution.

If you want some ideas, you should really check out some IYP sites like yellowpages, AT&T, etc..

Yes, IYP's have horrible names, but some of them are trying to innovate on top of their huge customer base. If anything, you'll get an idea on pricing.

You might want to try to build something, and source someone locally that has a salesforce to push your product? Another idea, would be posting this locally on craislist that could be 100% commission based... something a starving uni student would love to push for you.

good luck!

<comment><USER4> Or a white-label pricing level

</comment></comment><comment><USER4> I think that everyone but restaurant owners hate the sites. A few years ago I was exploring this area, and offered my view to a few dozen local restaurants. Those that had no site were receptive, but those with a flashy, music playing slideshow were the least receptive.

Hopefully your sales team can educate the restaurant industry on proper web dev etiquette, but it didn't seem to matter to them much earlier. Good Luck!

</comment><comment><USER5> Looks great. Everyone is sick of crappy restaurant websites.

One nit-picky non-technical thing – the first thing I see is the h2 with "Manage your own Restaurants Website." You need an apostrophe in there... and maybe you should think about changing the capitalization scheme. Dunno, I'm probably the exception, but when I visit a website and see bad spelling or grammar, I immediately am turned off.

<comment><AUTHOR> That's what I get for being a silly Swiss :) Thanks for the feedback, fixed it up!

</comment></comment><comment><USER6> This is a great solution, we get a few restaurant clients that just need a simple site, but when you add in all of the integration the simple becomes a bit of an effort for what many restaurants can budget. I sent your white-label page to my partners as this would be perfect for those clients.

<comment><AUTHOR> Great! Look forward to hearing from you guys!

</comment></comment><comment><AUTHOR> Link: <http://www.happytables.com></comment>


To Crowdfund Research, Scientists Must Build an Audience for Their Work [pdf] - <AUTHOR> https://peerj.com/preprints/393.pdf

<comment><USER2> Should be noted that the original authors are the founders of the SciFund Challenge, and they've gathered tons of great empirical data.</comment>


The first version of Voxel Quest (with source) has been released - <AUTHOR> http://www.voxelquest.com/news/first-release <comment><USER3> Thanks Gavan! This is exciting, I've been waiting for this for a while. The code looks super hacky, but that's to be expected :)

Hopefully it gets ported to Mac and GNU/Linux soon. If not, I'd definitely like to try and port it over when I get some spare time. Cheers!

<comment><USER4> Your welcome. :) The porting process should not be all that difficult - <USER2> a few things have to be done:

      1) Create a bash script to replace the batch scripts
      2) Rebuild dependencies for the right platform
      3) Ideally have some sort of cross-platform build generation like cmake
      4) Pray to your gods

<comment><USER5> I've started the process of writing a Linux port. I already have a few shell scripts I can push back into your git repo, but still having a few issues compiling:

        $ g++ -Wall  -I./SFML-2.1/include compiled/main.cpp -I./glew/include -I./freeglut/include -o voxelquest
        compiled/main.cpp:124:19: fatal error: gl/gl.h: No such file or directory
         #include <gl/gl.h>
                           ^
        compilation terminated.

I can't seem to find gl.h anywhere in your project sources. Any ideas where I can find it?

edit: nevermind. It was already installed on my system. Seems to be a few cases where you've used lowercase _gl_ paths in your includes which is breaking on Linux because the paths are in uppercase. Easily fixed with a ` _sed_ ` script though.

<comment><USER6> As you seem to use shell scripts to build the game, I suggest to use redo, which provides dependency management for shell scripts: [http://news.dieweltistgarnichtso.net/bin/redo- sh.html](http://news.dieweltistgarnichtso.net/bin/redo-sh.html)

Where can I find your code?

<comment><USER7> I don't speak for M. Woolery, but one can find _my_ code here:

* [http://jdebp.eu./Softwares/redo/](http://jdebp.eu./Softwares/redo/)

* [http://jdebp.eu./Softwares/redo/grosskurth-redo.html](http://jdebp.eu./Softwares/redo/grosskurth-redo.html)

* [http://jdebp.eu./FGA/introduction-to-redo.html](http://jdebp.eu./FGA/introduction-to-redo.html)

<comment><USER6> Thanks. I thought your web site was permanently offline!

</comment></comment></comment></comment></comment></comment><comment><USER8> Great to see this finally get a release, I've been following the story since the first post. Curious why you aren't looking to generate income from VQ though. Also, the initial world construction process seems to take a very long time on a pretty fast machine. Perhaps a progress bar of some kind that lets the user know approximately how much longer it will take would be helpful. Keep up the great work!

<comment><USER4> Progress bar would be good, just a level above the polish I ever reached.

I do not want income from it because I feel this makes me more obligated, and I do not know how much time I can spend down the road (I will still spend time, I just don't want additional obligations hovering over my head) :)

World construction takes a few seconds on my computer, although IIRC some of it is tied to the GPU, but mostly it uses the CPU.

<comment><USER9> I contributed to your Kickstarter and am perfectly happy with this outcome. I'm excited to see what what you do next! Don't feel obligated to put any more of your most valuable resource (time) into this project!

</comment></comment></comment><comment><USER10> Looking good! For those of us that can't actually run it yet, here's the latest video:

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

<comment><USER4> That was a montage of old videos meant to be used for this site: [http://www.sixdf.com](http://www.sixdf.com) but I ended up just making another custom video that was less chaotic. Here is a video of the latest iteration of the engine: [https://twitter.com/gavanw/status/728244177952071680](https://twitter.com/gavanw/status/728244177952071680)

</comment></comment><comment><USER11> Error loading shader 129. Water loaded at first execution, not at the second one. I deleted and re-extracted, still no water, only bridges and slow-loading trees without leafs.

I guess the hardware requirement for this are quite unusual, I have an ATI 6870.

<comment><USER4> Another user hit the same error, I will look into it. I built it mostly on nvidia hardware so there are some things to work out for amd

<comment><USER11> Good luck with that, I wish you will try, but I would not spend too much time trying to fix it.

I can remember a recurring bug I had on a blizzard game which happens on the same level all the time, and they refused to fix it because they said it was caused by the AMD driver. That's a bad sign for AMD.

</comment></comment></comment><comment><USER12> Congratulations on your release!

What's the reason behind weird prefixes in source files (like f00300_singleton.hpp)?

<comment><USER4> All files get concatenated in alphabetical order. Its a strange technique but it escapes what is known as "header hell" where you have hundred of headers cross-referencing each other. Supposedly it also speeds up compile time. See: [http://stackoverflow.com/a/373179](http://stackoverflow.com/a/373179)

<comment><USER6> I doubt it speeds up compile time on subsequent builds, as any change in one part of the project means that everything has to be recompiled.

<comment><USER13> Not quite. It presumably only concatenates the headers, which are read any time a dependant file is complied. The advantage is that the compiler doesn't have to open and read a header every time it encounters an include at the top of a dependent file. Instead, the dependency tree is given once, and each header is opened once.

This is apparently the same approach taken in the Plan9 source code to reduce compile times, and by basically any language with a module system (except module systems allow you to give the dependencies in each file).

</comment></comment></comment></comment><comment><USER14> Doesn't seem to work on macOS under Wine:

        $ wine VoxelQuest.exe
        err:process:create_process L"Z:\\Users\\username\\Downloads\\vqprecomp\\bin\\VoxelQuest.exe" not supported on this installation (x86_64 binary)
        wine: Bad EXE format for Z:\Users\username\Downloads\vqprecomp\bin\VoxelQuest.exe.
        $ wine.bin(52265,0x407fc000) malloc: *** error for object 0x401c2f08: pointer being freed was not allocated
        *** set a breakpoint in malloc_error_break to debug

</comment><comment><USER15> Looks beautiful! I can't figure out how to use the "edit buildings" mode or the green box cutaway.

<comment><USER4> Thanks :) For the edit buildings mode:

Assuming you just started up, press "g" twice. Move your cursor over a building, it should display a white box around it.

Click on the building. Press "v" to toggle it on and off. Anything more complicated than that you have to get into the code, but you can do some neat things just by editing the shader (GenerateVolume.c"), saving it, then pressing "r" (refresh shaders) in the program (and then press "c" to clear the chunks and refresh them).

Future iterations have much more complex methods for adding arbitrary geometry, as demoed in the videos.

The green box cutaway:

Hold down ctrl (and keep it held), Move it while holding the left right mouse button to get it at the appropriate z level (up/down) You will likely ALSO need to move it on the XY axis holding the left mouse button just to keep it in view. That probably sounds confusing, but in isometric mode keep in mind that xyz in worldspace all project to another xy axis in screenspace. You can see in some videos how I move the cutaway cube down along the z axis while keeping it in the screen by moving it back up along the ground plane (xy).

At 6m44s in this video you can see how it should function when you move the green cube if it is at the right z level: [https://youtu.be/R0ul1674F1k?t=6m44s](https://youtu.be/R0ul1674F1k?t=6m44s)

</comment></comment><comment><USER16> Gavan - one idea for you is to do a mini tutora on the source code on Udemy or one of those sites. It would not have the obligations you allude to yet still provide you with some income for your work. Of course doing the tutorial would require some efforts but you can keep it raw and not put too much effort into it. Almost like a walkthru that handmade quake or handmade hero are doing. Just my two cents. Thanks for your work!

</comment><comment><USER17> voxels! this reminds me so much of that old outcast game. good times.

</comment><comment><USER18> Congrats, nice milestone!

<comment><USER4> Thanks! One down...three or four more iterations to go :)</comment></comment>


Ewww, You Use PHP?  - <AUTHOR> http://blog.mailchimp.com/ewww-you-use-php/ <comment><USER2> I wouldn't want to go back to programming PHP due to its many issues[1]. I especially wouldn't want to work somewhere that spends development energy on BobX[2] to make PHP easier to work with. That means I have to use two technologies that won't give me any way to advance in the industry, and will most likely hinder me at this point.

[1] [http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad- de...](http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/) [2] <http://thedailywtf.com/Articles/We-Use-BobX.aspx>

<comment><USER3> People really need to stop posting that fractal article. Any PHP dev worth their salt would be able to tell you that guy clearly has no major experience with PHP (or any understanding of OOP for that matter).

Here's a few discussions on just how wrong [1] and clueless he really is [2].

[1] <https://news.ycombinator.com/item?id=4177516> [2] [http://forums.devshed.com/php-development-5/php-is-a- fractal...](http://forums.devshed.com/php-development-5/php-is-a-fractal-of- bad-design-hardly-929746.html)

</comment></comment><comment><USER4> I have no doubt you can do a lot of powerful things with PHP, provided you have the experience and put in the man power + time. But this does not justify the use of PHP now (for new projects), it just means that if you happen to be stuck on PHP because of legacy code, you could make it work.

<comment><USER5> But to be fair, wouldn't you also have to put in the manpower+time to get the experience to learn to do it in another language?

PHP is not all procedural spaghetti code, it does have modern frameworks, some of which are quite nice. And despite it's flaws (yep... someone posted Veekun's thing, everybody take a shot) there are reasons for choosing it, such as low overhead for deployment, and ubiquitous availability.

<comment><USER2> Yeah, I posted Veekun's thing.

Low overhead for deployment and ubiquitous availability are definite advantages for the beginning of a project. Unfortunately, those two advantages disappear when your site becomes successful. For a large user base, there's more overhead involved in keeping a PHP webapp running smoothly, and by that time you won't need ubiquitous availability because you'll be, hopefully, running and configuring your own servers.

<comment><USER5> I can only assume you're right because I have no experience with having a site that's successful by anyone's standards (much less doing it in Python or Rails), but to me that still leaves a lot of room at the bottom of the pyramid for sites and apps that might not have any reason to expect such a large userbase.

</comment></comment></comment></comment><comment><USER6> What I'm confused by, is why is this even a conversation? PHP is possibly the most used language in the world. I'd presume that there's tons of highly qualified engineers to choose from, who are already bought in to the value of the language.

<comment><USER7> There is a lot of stroke inducing legacy PHP code out there in the wild. A lot of people have had a really bad experience working on projects that used PHP. The ease of entry allowed flocks of inexperienced software developers to grow PHP projects like mushrooms throughout the world.

I think it's largely bad rep due to the ease of misuse and dodgy frameworks.

</comment></comment><comment><USER8> So if you replicated their special and custom 'platform' in Ruby or Python and it exceeded PHP's performance by miles what would their reasoning for continuing to use PHP be?

<comment><USER9> Because they're costs in replacing an entire infrastructure that go beyond simply making the choice to switch to something else.

\- How knowledgeable your current employees are with it (and willingness to adapt and switch, as well as how long it will take to be as productive after the switch)

\- Time taken redo all your servers to support it and pay someone to do it

\- Subtle bugs that may appear related to the platform switch and not being as knowledgeable about it at first.

\- As someone else mentioned, they may actually like PHP. That may seem hard to understand for some, but heck, there are even people like that like Java. We might not fall under either case, but for the same reasons people like other things that people may find inferior (certain car brands, TVs, PCs components, etc), people apply the same logic to programming languages.

<comment><USER8> >Because they're costs in replacing an entire infrastructure that go beyond simply making the choice to switch to something else.

I'm assuming that they don't have to worry about any of that and are given three platforms (PHP/Ruby/Python) that, for the sake of my argument, all do the same thing. Then we ask the question, which would they choose and why?

<comment><USER9> While it's a worthy question to ask, it's not applicable to them outside of theory, since they have been using PHP since they started some years ago. If you rephrase the question to a company just starting out, then it would be more fitting :)

If you look at the larger companies that do switch platforms, the ones that generally make the leap usually do so without replacing the entire stack (Java to jRuby or Java to Scala, etc). Not always the case (since the language can still be hurdle itself), but the cost to switch in those sort of cases is far lower than jumping off the jvm/clr/etc.

I'm sure if you asked Facebook now (and got an honest answer) that they would totally agree they would have picked another language and platform than PHP to build on given what they have had to go through since. However, PHP is what the developers knew starting out and sometimes it's better to go with what you know than learning something entirely new as building something from scratch is already a huge undertaking that can wear you down. Adding the burden of learning a new language/platform at the same time can lead to taking on too much and slow progress/motivation as well as lead to procrastination or distraction. It might lead to regrets later, but the greater regret is not building at all than choosing the right platform.

</comment></comment></comment></comment><comment><USER10> This article was written in Oct 2010, but it looks like they still use PHP.</comment>


Contribute to READMEs - <AUTHOR> https://ryanseys.com/blog/contribute-to-readmes/

<comment><USER2> I was more intrigued by the article linked in the second paragraph: _Readme Driven Development_ ([http://tom.preston-werner.com/2010/08/23/readme-driven- devel...](http://tom.preston-werner.com/2010/08/23/readme-driven- development.html))

This is close to what I do (and encourage my team to do). I usually start by writing a commented code snippet demonstrating proper usage of the class/function I'm about to implement.

</comment><comment><USER3> Fixing typos or improving documentation is another super easy way to contribute. You could probably find many typos in many repos you use, especially in code samples.</comment>