Swift 3.0 Unsafe World - <AUTHOR> http://technology.meronapps.com/2016/09/27/swift-3-0-unsafe-world-2/ <comment><USER2> The article includes the following example:

        let a = UnsafeMutablePointer<Int>.allocate(capacity: 1)
        a.pointee = 42

FYI, you should never do this.

Assignment to the `pointee` is only safe where the `pointee` is already initialized. If the pointee is uninitialized, you should be using `initialize`. e.g.

        let a = UnsafeMutablePointer<Int>.allocate(capacity: 1)
        a.initialize(to: 42)

While it doesn't actually matter for `Int`, it _does_ matter for classes, unspecialized generics and other Swift reference counted types since Swift will try to _release_ the destination before assigning a new value into it. If the destination is uninitialized garbage, this can cause a crash or other misbehavior. Following proper practice is a good idea – even if you're using a hard coded pure value type like `Int` – since it prevents problems down the road if you decide to change.

Similarly, you should `deinitialize` the buffer when you're finished, not simply `deallocate`.

<comment><USER3> From the doc comments:

      /// Accesses the `Pointee` instance referenced by `self`.
      ///
      /// - Precondition: Either the pointee has been initialized with an
      ///   instance of type `Pointee`, or `pointee` is being assigned to
      ///   and `Pointee` is a trivial type.
      public var pointee: Pointee

So, `a.pointee = 42` is fine since we all know that `Int` is a trivial type.

<comment><USER4> Jaywalking when a street is empty is safe; it does not mean that jaywalking is safe _in general_ , and that one should get used to it.

In this case, `.initialize` is likely also _faster_ because any previous- value-checking logic than might be there is explicitly not used.

<comment><USER5> When it's explicitly allowed by the rules, it's no longer "jaywalking."

You're right that it doesn't mean this is safe in general, but the original comment is wrong that you should _never_ do this.

What previous-value-checking logic are you referring to? I would expect .pointee = 42 to compile down to a single store instruction.

</comment></comment></comment></comment><comment><USER6> Is garbage collection strictly worse than other memory managementarment techniques?

Got distracted one sentence in by an assertion that's so at odds with my understanding of the world.

<comment><USER7> The Garbage Collection Handbook [[http://gchandbook.org/](http://gchandbook.org/)] has a good overview of the advantages and disadvantages of reference counting as garbage collection.

In summary,

Advantages:

A. Objects are collected immediately when they become garbage.

B. Programming language runtime support is simpler.

C. Memory can be reclaimed easily in programs with distributed heaps.

Disadvantages:

A. Natural race conditions exist in multi-threaded programs when reference counting is used. Atomic read/writes are necessary when incrementing/decrementing the reference count for an object.

B. Cyclic data structures cannot be reclaimed. (This is why you have to jump through hoops to avoid this in Objective-C and Swift.)

C. Every object in your language which is reference counted needs a field to hold the reference count. Or you need a special object in its stead which "points" to your object, like a shared pointer.

D. Pauses with reference counting are still possible. As stated in the book, "When the last reference to the head of a large pointer structure is deleted, reference counting must recursively delete the descendant of the root."

<comment><USER8> Two more advantages which are relevant for Swift:

1\. Memory high-water-mark is generally lower with RC, which is important for mobile.

2\. RC lets you easily determine when there is only one reference to an object. This enables Swift's collections to be value types, one of Swift's key semantics.

<comment><USER9> > 2\. RC lets you easily determine when there is only one reference to an > object. This enables Swift's collections to be value types, one of Swift's > key semantics.

It also enables some optimisations e.g. Python has immutable strings, but CPython can take advantage of rc=1 to extend strings in-place (avoiding accidentally quadratic concatenation loops until you start storing intermediate references or you try to run the software on alternate implementations)

</comment></comment></comment></comment><comment><USER10> Great read on a topic I've been looking for more info on, recently coding an audio app that needs to manipulate audio buffers. And this is the only way to access them. I've been working in swift since 1.0 and this is the first time this all makes sense.

<comment><USER11> It's one of the clearest articles I've read on the subject, too. I would have liked it if there had been a section on calling "malloc" and "free" directly from Swift though. I do that a few places in my audio app, and there are a few gotchas involved (eg: at least in Swift 1, shouldn't use "free" and "dealloc" interchangeably. Probably still the case).

</comment></comment><comment><USER12> To someone unfamiliar with swift, it seems quite informative about the mechanics of unsafe pointers. Where it misses is in discussing how best to segregate the "parts with unsafe" from "the bulk of your code (hopefully)", since the parts with unsafe by definition deserve more careful review and auditing (or even that you _should_ do this sort of segregation)

There are probably many ways you could design the partition; for instance, I would probably try to design a safe API that was patterned closely after the underlying one (Posix, OpenGL, etc); others would prefer to design more Swift- ian APIs that still expose all the useful capabilities of the underlying libraries.</comment>


New kernel.org - <AUTHOR> https://www.kernel.org/category/site-news.html

<comment><USER2> Here's what I did on the old kernel.org:

1\. I typed in www.kernel.org

2\. I looked for the new kernel on the page that loaded.

3\. I clicked on the link and my download started.

On the new kernel.org:

1\. I type in www.kernel.org

2\. I look for the new kernel on the page that loads.

3\. I click on the link and my download starts.

Conclusion: Good job. You made the site look more modern without disrupting the most common workflow.

The only 2 suggestions I have are

1\. The entire container for "Latest Stable Kernel" should be the hit point; yes, all of it, including those words.

2\. When I hover over the tabular download links, my eye can get confused on which row I'm on. Something purely css and really subtle would alleviate that; for instance:

* changing the row background color

* changing the color of the font for the row

* prepending a UL style dot to the LHS of the row

* making the bordertop and borderbottom more distinct

* underlying or italicizing the words

* etc...

any of these things would help and I'm totally agnostic to what is done; it would be a quick fix that would really make the thing less prone to human error.

</comment><comment><USER3> As a member of the Pelican dev team, I think I speak for all of us when I saw we were thrilled to see such a high-profile site running on Pelican. The folks at kernel.org were even kind enough to mention it on their new site: <https://www.kernel.org/pelican.html>

Those of us in the #pelican IRC channel had a rousing cheer and virtual clinking of the glasses. :^)

If anyone has questions about Pelican, please feel free to ask here or on our IRC channel.

 _Edit:_ And if you're going to PyCon in Santa Clara, CA this month, hit us up on Twitter (@getpelican) to get info about our pre-PyCon meetup.

<comment><USER4> Any guides on making a pure "portfolio" sort of page, no blog whatsoever? All of the examples that I have seen have a blog component. I am just looking to make some basic header/nav/content/footer type templates. Thanks for your work on Pelican! I found it two days ago while looking for a static site generator and I was excited to see it mentioned in the news.

<comment><USER3> That's certainly been requested and is coming in the next version, hopefully to be released sometime this month. Thanks to the hard work done by Bruno, one of the other dev team members, you will soon be able to override pages by specifying a source file and a destination URL: <https://github.com/getpelican/pelican/pull/623>

With this in place, you should be able to populate your site with pages (e.g., /content/pages/{index.md,about.md,portfolio.md,contact.md,etc}) without any chronological blog content.

</comment></comment></comment><comment><USER5> I knew I saw this design somewhere else: [http://coding.smashingmagazine.com/2009/08/04/designing-a- ht...](http://coding.smashingmagazine.com/2009/08/04/designing-a- html-5-layout-from-scratch/)

Granted, it's not "complicated" but it's also the same colors...

 _Edit:_ Smashing Mag is mentioned on Pelican blog: <http://blog.getpelican.com>

<comment><USER6> At least they give him credit:

<https://www.kernel.org/theme/css/main.css>

<comment><USER3> Pelican's default theme includes explicit thanks, and a link, in the footer of _every single page_ \-- which is certainly more noticeable than attribution inside a CSS file.

</comment></comment></comment><comment><USER7> I appreciate the move from gitweb to cgit; I've encouraged countless others to make the same transition, and now have a good reference to point at when I do so.

</comment><comment><USER8> Nice font, kernel.org

<http://i.snag.gy/05FuX.jpg>

I always love websites with custom fonts that don't render correctly. When I see a website with great typography, most of the time it turns out to be Georgia or Arial, or sometimes even Timew New Roman (which his a good font, but simply overused). I've yet to see a custom font that reads better than correctly applied default fonts.

<comment><USER9> Works for me.

Probably you are using some Linux distribution with misconfigured freetype.

<comment><USER10> I knew these kind of answers would pop up, I had one sentence predicting this in my text, but erased it to let the magic happen.

Are you able to realize that it is, of many options you have, the dumbest possibility to just burp a simple "it works here". Would you answer this on a bugreport?

I assume, it was an ironic answer, in this case I congrat you for holding the mastership of the highest art of subtile trolling, very inspriring.

In fact you are simulating the typical xtreme-dumb answers perfectly, that are received on "bad-font-whining" regularly - this is exactly the reason why we need a major bad-font-campaign, because this is not only a technical problem, but the roots seem to be hidden in a deeper socio-techno-cultural level of our brains - that "systems are getting too complex"-stuff leads in the end to the human brain regressing strongly in certain areas to amoeba-state.

<comment><USER11> > Would you answer this on a bug report?

If I was unable reproduce the bug with the information given, it seems reasonable to mention that. Also, the effort required by the bug reporter to mention basic information on the setup they use is much less than for a web developer to boot up 5 different systems (including iOS and Android) to test out each major browser in them.

I'll have you know that I have been wary of using non-default fonts because of these reports.

</comment></comment></comment></comment><comment><USER12> Seems like a common sense design, no complaints, but it's funny to notice how the wider our screens become, the narrower the sites get.

<comment><USER13> That's no surprise to me - monitors are so ridiculously wide these days that it's impossible to ignore the need to limit the length of a line of text. When you're working at 1680x1050 you can kinda ignore it, but with 1920 or more horizontal pixels, text needs to be broken up into columns, and you've also got enough horizontal space to have two windows side-by-side without feeling cramped.

<comment><USER8> That has always surprised me about Wikipedia. So many articles on recommended line width, height, font, etc., and Wikipedia gets away with just _one_ style rule (font-family: sans-serif). Never heard any complaints or noticed that it was bad typography.

Yeah they have more style rules, but disabling them doesn't visibly change anything so they're the defaults.

</comment></comment></comment><comment><USER14> I started using pelican recently and I really enjoy static site generation. It's amazing how little needs to actually execute server side (blog content in a database?) It's also much easier to focus on writing when I don't have shiny objects distracting me.

<comment><USER15> I wish it were a more mainstream thing. It's impossible to compromise a statically generated website (discounting webserver/OS level vulnerablities). It's significantly more secure then Wordpress running tons of plugins

<comment><USER16> I was never much of a blogger but i liked tumblogs the old days.

My webspace could not run ruby so i took the approach 3 times to write a static site generator. For me, i would take that route again. I have my favourite editor to write stuff and who the hell needs a database for a blog or something small?

I use the last system i wrote still, but I take notes with it and save images to a local repository.

</comment></comment></comment><comment><USER17> Hm... seems like there's no way to download a tarball in cgit, but I'm not sure if this functionality was enabled in kernel.org's gitweb either.

<comment><USER18> I know that cgit supports downloading tarballs of tags at least, but they seem to have disabled that. I can't say I blame them, they already host the official release tarballs, and tag tarballs would only contain the same thing.

</comment></comment><comment><USER19> Well done. I happened to visit kernel.org earlier this week for the first time in many years and I was surprised at the dated appearance.

</comment><comment><USER20> Nice. Looks clean, things are well sorted.

</comment><comment><USER21> Nice... Good... Cool... Required. Thanks for keeping the structure same and putting no 'extra features'.

</comment><comment><USER22> Finally a change... but.. the font looks weird, looking at the CSS:

<https://www.kernel.org/theme/css/main.css>

that style was made on 2009!!!

Please somebody fix that fonts

</comment><comment><USER6> Oh hey now it looks like every other site on the Internet.</comment>


What an Amazon-fulfilled Thanksgiving would look like? - <AUTHOR> https://datahub.packtpub.com/low-snr/mid-autumn-shoppers-dream-amazon-fulfilled-thanksgiving-look-like/ <comment><AUTHOR> A story of how a machine learning, AI and robotics combo backed holiday lets you focus on the truly important things your life</comment>


Show HN: mysql-unsha1 – MySQL authentication without cleartext password - <AUTHOR> https://github.com/cyrus-and/mysql-unsha1 <comment><USER2> In other words, SHA1 (password) becomes the actual password. As the author writes, "hardly an exploit": just a gentle reminder how insecure the default auth is.</comment>


Show HN: Have you last minute tax questions answered with Andy, Siri for Taxes - <AUTHOR> http://ask.andyvirs.com/ <comment><AUTHOR> We have created an AI assistant to answer tax questions. It does a better job (for the most part) compared to a system developed by IRS called Interactive Tax Assistant (ITA). I appreciate any feedback for improvement.</comment>


Don't Romanticize the Present - <AUTHOR> https://thefrailestthing.com/2019/02/06/dont-romanticize-the-present/ <comment><USER2> > We should romanticize neither the past nor the present, nor the future for > that matter.

I disagree. Seeing the world strictly through a lens of cold eyed rationalism is demotivating. Awe is a perfectly practical use of the senses. I watched Neil and Buzz bound around on the moon. That's a romantic past that was once my romantic present. There's no particular benefit in discounting those feelings.

Here's some cold eyed rational scientific work demonstrating the massive collapse of poverty in our time:

[https://ourworldindata.org/extreme-history- methods](https://ourworldindata.org/extreme-history-methods)

If we can't romanticize this present day accomplishment then what the heck is romanticism for? We're participating in a culture that is reducing extreme human suffering at an unprecedented pace. A rationalist would miss the full picture if he couldn't feel the heroic nature of that.

<comment><USER3> Being in awe of an achievement, past or present, does not necessarily mean you are romanticizing it. You can have strong emotions and positive feelings about something without romanticizing it. Romanticizing means viewing something in an idealized or unrealistic way, ignoring or downplaying anything that does not fit into that "Romantic View" of it.

We can be proud of our accomplishments, past an present, and feel good that in some areas there have been huge advancements. But, we do ourselves a disservice if we romanticize the world and and don't view things in context. We need to understand what it took to make those advancements, accept that some advancements come with consequences, and not ignore those areas where there are still much to be done.

<comment><USER2> We seem to be converging on this sense of the word (Merriam-Wester 4):

> marked by the imaginative or emotional appeal of what is heroic, > adventurous, remote, mysterious, or idealized

Surely, even in full context, certain things can be legitimately seen as heroic, adventurous, remote or mysterious without being overly idealistic in an unrealistic way. It seems valuable, to a point at least, to allow our emotional reaction to such events guide our dreams and plans. That's an upside to romanticism.

I'm a fan of SpaceX, et. al. If those outfits had to be funded and staffed by unromantic people primarily interested in return on investment, would they exist?

<comment><USER3> I think this is just a subtle semantic issue. In my previous post, and what I think the original article is talking about is the act of romanticizing something that is not romantic (or not entirely so). Parts of it may be so, but automatically extending that to a larger context is fallacious and potentially dangerous.

The moon landing example you made is a good one. It is a grand achievement, and is rightfully a romantic vision of what humanity can accomplish. But over- extending that romantic view to the entire area in history that it occurred in would mean ignoring the cold war and the ever-present threat of nuclear war.

I'm not saying, and I don't think the articles authors was intending to say, that you shouldn't have emotional and romantic responses to things, but rather that we need to not let those responses (and perhaps our desire to focus on the positive/romantic) blind us to the wider contexts that may not be so romantic.

</comment></comment></comment></comment><comment><USER4> I find works of philosophical non-fiction written by horror fiction writers useful for not romanticizing the present:

"Like many who have tried their hand at metaphysics, Bahnsen declared that, appearances to the contrary, all reality is the expression of a unified, unchanging force—a cosmic movement that various philosophers have characterized in various ways. To Bahnsen, this force and its movement were monstrous in nature, resulting in a universe of indiscriminate butchery and mutual slaughter among its individuated parts. Additionally, the "universe according to Bahnsen" has never had a hint of design or direction. From the beginning, it was a play with no plot and no players that were anything more than portions of a master drive of purposeless self-mutilation. In Bahnsen's philosophy, everything is engaged in a disordered fantasia of carnage. Everything tears away at everything else … forever. Yet all this commotion in nothingness goes unnoticed by nearly everything involved in it. In the world of nature, as an instance, nothing knows of its embroilment in a festival of massacres. Only Bahnsen's self-conscious Nothing can know what is going on and be shaken by the tremors of chaos at feast."

\- Thomas Ligotti, "The Conspiracy Against the Human Race"

<comment><USER5> Eugene Thacker's 'In the Dust of This Planet', 'Starry Speculative Corpse', and 'Tentacles Longer Than Night' could probably also fit into this category.

</comment></comment><comment><USER6> I have heard a similar term : "Don't be a chronological bigot." Essentially assuming that folks in the past, even in the ancient past, were less intelligent or less enlightened. I am mesmerized how Bronze Age folks figured out how to form an alloy out of copper and tin ... I am not sure how many folks could reproduce this from first principles and the knowledge base they had to work with.

</comment><comment><USER7> The article's main argument is: "We are not obligated to love technology. [...] If we allow ["technology"] to stand as an umbrella term for everything from modern dentistry to the apparatus of ubiquitous surveillance, then we are forced to either accept modern technology in toto or reject it in toto. We are thus discouraged from thoughtful discrimination and responsible judgment."

This seem uncontroversial -- I doubt even Steven Pinker would disagree with that.

Maybe some internet trolls make low-quality arguments like "so you want to go back to horses and buggies?!?" but basically nobody is arguing that technology should reign unregulated. Who thinks civilians should be able to own nuclear weapons?

All of this seems quite unrelated to the dispute between Pinker and Hickel of whether global poverty is decreasing or not.

</comment><comment><USER8> As someone relatively new to following "public intellectuals" (think Tyler Cowen, Jonathan Haidt, Pinker, etc.) I've been surprised at who reductive their arguments seem to be.

There is a lot of talk among this class of people regarding the current state of debate but as in many cases I've seen examples of two people who are absolutely grounded in their beliefs and use straw man arguments, diversion and reductive reasoning to defend their points. If you ever listened to the Ezra Klein v. Sam Harris podcast you know what I mean.

This isn't the first occasion that I've seen someone rebute the philosophy of Pinker's work only for him to double down on the same argument. I guess I shouldn't be surprised because persuasion is difficult in general, but I expected a deeper dive into the complexities of these arguments.

<comment><USER9> Once a public intellectual reaches a certain level of public visibility/celebrity, they spend most of their time having softballs lobbed at them by worshipful audiences at venues like TED and Davos. It's not hard to imagine how that sort of treatment would atrophy their muscles for engaging with criticism.

</comment></comment><comment><USER10> There's far more romanticizing the past than there is of romanticizing the present. So naturally it presents a better focus for critical examination.

If you ask the average person, the majority (in my experience) are far more likely to think that the world has more poor people than ever or that people have fewer rights, that opportunities are less, that corporations have more power, that kids were safer, etc.

Pinker and the rest do a valuable service to point out that these lazy assumptions are questionable to say the least and they do so using quantifiable indicators and statistics. This is important in my opinion because this narrative of a world getting worse and worse seems to be promoted by the extremists at both left and the right.

I had to force myself to read past the words "neoliberal globalists" in Hickel's rebuttal. Like the phrase "neomarxist progressives", you know already that the content will be about politics instead of any sort of historiography, statistics, facts, etc. Generally articles containing phrases like this are about appealing to an existing political base - and not about honest debate. Some other comment got downvoted for claiming this article is "pure politics" but I agree with this assessment.

The article's link to Pinker's rebuttal of Hickel (strictly speaking the rebuttal isn't Pinker's although the meat of it includes lengthy quotes from Pinker) is actually worth a read - [https://whyevolutionistrue.wordpress.com/2019/01/31/is- the-w...](https://whyevolutionistrue.wordpress.com/2019/01/31/is-the-world- really-getting-poorer-a-response-to-that-claim-by-steve-pinker/) \- as the quoted email from Pinker clearly provides supporting citations. Admittedly, I think he could have avoided pointing out Hickel's professed political leanings as the facts themselves are convincing enough.

</comment><comment><USER11> flagged - pure politics

<comment><USER12> I wish you hadn't, I thought the article was worthwhile, and very much at home on HN.</comment></comment>


Ask HN: Auditing a Class as a Non-Student? - <AUTHOR> I'm a college graduate who'd love to take a couple college classes (math, maybe econ and computer science) in my spare time.
I don't care about getting credit in any form, though ideally I'd like to sit for the exams (accountability is good for me).
Has anyone done this? If so, how did you go about it? Did you reach out to professors directly? Universities don't seems advertise this, for understandable reasons; presumably it's not profitable in the same way credit-earning courses would be--though actually I'd be happy to pay some (smaller) amount.
Thanks! <comment><USER2> Generally speaking, auditing is allowed solely at the professor's discretion (though as you surmise, I don't think institutions are fans of the concept). So, I'd definitely approach the professor directly. BUT I do think you might have a hard time winning them over -- usually it's only people who are registered students or faculty/staff at the institution that are allowed to audit there (and plenty of faculty will say no, esp. if the class isn't a large lecture). Sometimes alumni are allowed to audit, but there may be security concerns, etc. about letting total outsiders into the classroom. (And as test grading takes time, that may also be a no-go.)

My advice would be to 1) consider MOOCs or MIT OCW, and 2) attend lectures and events open to the public at the institution. The latter may be interesting in themselves, and would be a way for you to get to know the scholarly community a bit better (so you're not just a random person asking for consideration).

</comment><comment><USER3> If you're in California, the California State University System has Open University at all campuses. [1] If not, basically an open university is most likely to give you what you want. In the US, community colleges are also an option for foundational classes.

[1]: [https://www2.calstate.edu/attend/professional-and- continuing...](https://www2.calstate.edu/attend/professional-and-continuing- education/Pages/open-university.aspx)

</comment><comment><USER4> My experience has been as an enrolled PhD student in the US, so my thoughts may not completely apply.

I would just go talk to the professor teaching the class if you do not care about any documents saying you took the class. I have sat in on many different classes this way.

Things to note: -You may have some trouble on both extremes of class enrollment. Some courses require a minimum number of students to be enrolled for the class for it to be offered, so if there are not enough or bare minimum number of people taking the class you might experience some resistance. On the opposite end, for classes with long waitlists, you may not be able to sit in. -If you are not affiliated with the university, you may have trouble accessing course files that are locked behind a university authentication.

My advice if you want to go this route is to minimize your impact on the professor. Wanting special accommodations, such as special delivery of class materials or participating in homeworks/projects/exams may give some professors pause.

</comment><comment><USER5> To take the class officially, it is called "a non-matriculating student". The cost per credit is usually less than the matriculating cost.

In the US, many states offer workforce development grants that will pay for all/some of the costs to take the class officially as a non-matriculating student.

Many employers in the US also subsidize such courses. Talk to your boss/hr.

</comment><comment><USER6> I took many courses through UC Berkeley's concurrent enrollment program. It allows non-students to attend courses on a space-available basis. The professor has to sign off on it and it costs a thousand bucks or so.

</comment><comment><USER7> You will probably have to slightly reword your question, but Academia[1] would probably be a better audience for this question than HN.

[1] [http://academia.stackexchange.com](http://academia.stackexchange.com)

</comment><comment><USER8> If it's a large class, I wouldn't recommend saying anything. You can take the exams and do the assignments, but don't hand them in.</comment>


Browse Hacker News Like a Haxor - <AUTHOR> https://github.com/donnemartin/haxor-news <comment><USER2> I know we're supposed to be focused on the end-result, but I'm really just in awe of the code. Everything is so incredibly well documented, tested, and structured. I already see a few things I want to borrow... will definitely be coming back to this project for ideas.

<comment><USER3> This guy started committing for this project back in November of this year [1]. This was a true labor of love if I ever saw one.

[1]: [https://github.com/donnemartin/haxor- news/commits/master?pag...](https://github.com/donnemartin/haxor- news/commits/master?page=16)

<comment><USER4> >back in November of this year

Teach me your ways.

<comment><USER3> Darn that one slipped. I wasn't supposed to tell anyone about the time machine.

</comment></comment></comment></comment><comment><USER5> The autocompleter feature looks neat, it's built on top of python-prompt- toolkit [0].

[0] [https://github.com/jonathanslenders/python-prompt- toolkit](https://github.com/jonathanslenders/python-prompt-toolkit)

<comment><USER6> Does anyone know if something like this exists for other languages as well? Ruby, nodejs?

<comment><USER7> Have a look at Vorpal JS

[http://vorpal.js.org/](http://vorpal.js.org/)

The vorpal object emits Inquirer[1] and Chalk[2]

[1] [https://github.com/SBoudrias/Inquirer.js/](https://github.com/SBoudrias/Inquirer.js/)

[2] [https://github.com/chalk/chalk](https://github.com/chalk/chalk)

</comment></comment></comment><comment><USER8> very cool. love the interaction. laughing at the quote.

 _Coworker who sees me staring intently at a command prompt: Backs away, slowly..._

<comment><USER9> Haha...right there. He's just gotta back away, no matter what's on cmd.

<comment><USER10> Of course, you could also just open the developer console of your browser.

By the way, didn't we have a "boss key" for situations like this?

<comment><USER11> Doesn't your boss have a remote desktop viewer?

<comment><USER12> What? Like they look at your session while your logged in? Ha Ha fuck that shit. When do they have time to hand out hall passes?

No my boss doesn't have a remote desktop client. The default install blocks the port inbound. If you need IT help you walk your ass down to IT. If your boss needs to see what you are doing, HR and Legal talk it over then take your laptop and send you home then send the machine to a real forensic examiner who will preserve chain of custody and not miss anything.

Boss snooping is just bad for everyone. If you're not getting your work done that should be all the evidence she needs to help or fire you.

<comment><USER13> That's a real rosy outlook you have there. Here's the real scenario: Boss walks to your cube with or without HR/Legal/Security/IT personnel and says "We need to look at your computer for a moment. Step aside."

Unless you're doing anything illegal enough to get the feds or local government on you, they're going to take a look right there.

<comment><USER12> >That's a real rosy outlook you have there.

What do you mean? I don't want to work for someone who micro manages to that level. ie checking if you're on hacker news. I've walked out of jobs on my first day because their computer use policy was so petty I didn't want to deal with it. I've quit jobs because I was asked to put facebook firewall rules in and such. Not my problem and I don't want to work for you if that's the deal (I don't even have a facebook). I've also left/refused to give packet/connection logs by employee (all employees) to people. It's lazy management and the number of daily connections to facebook doesn't really have any bearing on who get's what done. You're welcome to do that if you like but I won't help. It's just lazy, if people aren't doing what they should be then bring it up with them not me.

> Boss walks to your cube with or without HR/Legal/Security/IT personnel and > says "We need to look at your computer for a moment. Step aside."

Sure, but that's much closer to the scenario that I mentioned where it's an event not just passive eves-dropping. Not every company has a big legal/hr team to do that shit but that kind of thing generally takes a real reason, and it's a lot more conspicuous than just firing up a vnc client to check on you.

>Unless you're doing anything illegal enough to get the feds or local government on you, they're going to take a look right there.

Unless it's illegal, which includes the nda and basic employment contract, they shouldn't dig through your laptop anyway.

Where do you work that someone has the time to actively monitor user sessions to see what they are up to? Sounds like daycare.

</comment></comment></comment></comment></comment></comment></comment><comment><USER14> This is a refreshing alternative to existing tools like my long-time favourite pyhn [1] as well as the newly-announced go-hn [2].

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

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

</comment><comment><USER15> Really wish the HN-API supported pushing data to HN. Has this ever been offically addressed and if so where?

</comment><comment><USER16> Ive been using [http://hckrnews.com](http://hckrnews.com) since it's launch long ago. If I go on vacation, and come back, simply filter for top 10, or, if I have loads of time look top 50%. It's great!

</comment><comment><USER17> this is why I'm a big fan of the command line browser lynx. This is a bit of an improvement over my usual lynx [https://news.ycombinator.com](https://news.ycombinator.com) (aliased to lynxhn), but not sure it's worth it to add a one-off when my current tool is so flexible. I frequently use lynx to browse not only HN but also reddit, wikipedia and even do google searches.

</comment><comment><USER18> It's just so neat and considering I usually have too many browser tabs open and still want to have hn open without having more tabs. Loving it

</comment><comment><USER19> This is amazing. Also love the syntax color scheme

</comment><comment><USER20> great documentation .. plus a very good reference for using Hackernews API .. great job

</comment><comment><USER21> It's... Gopher for HN?

<comment><USER22> Now there's a good idea. I might add a HN gateway to my Gopher server.

<comment><USER21> Oh boy - if you do, then please post to HN itself!

<comment><USER22> I have recently written a 'modern' Gopher client and server for Windows. They are going through final testing at the moment, before I release them out into the world:

[http://www.weegeeks.com/upload/Jar-Gopher-Browser-Full- Scree...](http://www.weegeeks.com/upload/Jar-Gopher-Browser-Full- Screenshots.jpg)

<comment><USER21> Oh boy... post it on HN when you are done with it also :-)

I'd love to see Gopher come back again.

</comment></comment></comment></comment></comment><comment><USER23> I already use w3m to read hacker news most of the time anyways.

<comment><USER24> I use emacs' built-in browser (eww) when I want to procrastinate in peace.

</comment></comment><comment><USER25> Very neat, but am I missing something obvious... I can get the top 10, but how can I page through posts?

I often find that if I've been away from HN for a day or two that there's interesting stuff way down the list.

</comment><comment><USER26> I thought we resolved this with hackernews.el - why would you read hackernews with anything but Emacs?

IT MAKES NO SENSE>

<comment><USER12> Because emacs?

</comment></comment><comment><USER27> The author's GitHub graph is pretty epic... Not to mention his 495 day commit streak.

</comment><comment><USER28> This is very cool, but even with the cli it still looks unmistakably like web content.

<comment><USER29> There should be different obfuscation modes to disguise the content for your relevant work environment.

</comment></comment><comment><USER30> Very cool, but why not use lynx?

<comment><USER31> Or links2.

<comment><USER32> Or a web browser?

<comment><USER31> Sigh...

"Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, this, this..."

Coworker who sees me staring intently at a command prompt: Backs away, slowly..."

First 2 lines of the text behind the link.

</comment></comment></comment></comment><comment><USER33> I would like to use this but until you can comment and vote it is of limited value.

</comment><comment><USER34> I really like the user interface for this (color-coding and auto-complete are nice). I'm also trying out w3m.. which seems a bit more usable thank I found `links` previously.

</comment><comment><USER35> lynx also does the job

<comment><USER36> I was just going to say this but add w3m. If anyone hasn't tried w3m for this purpose they should give it a 30 minute trial run.

Also this has the same issue of not being able to vote or comment like many other Hacker News Apps.

<comment><USER37> Wow, this is actually very useable. It's actually super nice that it automatically uses my default editor for writing into textareas. Yay, using vim to comment on HN.

EDIT: For anyone else that wants to try this, it seems you need to open it with `w3m -cookie news.ycombinator.com` to be able to stay logged-in.

</comment></comment></comment><comment><USER38> Amazing readme. This project is so well documented.

</comment><comment><USER39> Very nice theme.

</comment><comment><USER40> What is Haxor?

<comment><USER41> From [https://github.com/donnemartin/haxor- news/blob/master/haxor_...](https://github.com/donnemartin/haxor- news/blob/master/haxor_news/lib/haxor/haxor.py)

      haxor
      Unofficial Python wrapper for official Hacker News API

<comment><USER40> Ah, thanks @ngzhian.

</comment></comment></comment><comment><USER42> It's pronounced `hax0r`

<comment><USER43> It's spelled 'spelled'.

</comment></comment><comment><USER44> test comment</comment>


Ask HN: Outside of SV, is age discrimination in IT common? - <AUTHOR> It seems to be pretty well established that there is a preference for younger candidates in IT/software development jobs in Silicon Valley.  Is this true in other areas?  Should I be looking for a new career as an individual contributor past 40/50? <comment><USER2> At my day job we value older programmers as we because it takes a long time to build the skills and experience needed to be effective.

</comment><comment><USER3> From my experience, Experience is not all that valued in Software development field. They don't want brand new grads either. They seemed to want some one with 3-5 years of experience or so.

</comment><comment><USER4> Here in Florida, there seems to be less ageism than in SV. Maybe it's because our industry is more oriented towards medical, defense, and aerospace. There is still pressure to use the latest languages and frameworks, but it seems less intense than on the west coast (I think this is one of the drivers of the ageism). Also, when you write software that has life or death consequences, it's nice to have a few people with 15+ years of experience on your team.

Or it might just be that everyone else here is old too. :)

</comment><comment><USER5> Every competent older developer that I know, below retirement age, is either employed or contracting.

</comment><comment><USER6> am in my early 40's and didn't experience ageism so far. yeah, it's pretty much a silicon valley thing</comment>


A simultaneous OS X binary, PDF file, jar file, and HTML page - <AUTHOR> http://mix.corkami.com

<comment><USER2>
        They serve no purpose, except proving that file formats not starting at offset
        0 are a bad idea.

Au contraire–they are a wonderful idea. If, say, a polyglot pdf+executable could gain code execution enough to execute itself as a binary, it could just as easily execute far more dangerous code while being far less likely to tip off an automated scanner. So it goes for many of the other stackable formats.

The benefits seem to far outweigh the drawbacks. As an example, look at the concept behind ext[234]fs migration in btrfs (which is not fixed to block 0 in a volume)–Take an ext4 filesystem, generate new inodes pointing at the original b-trees, and away you go! You get a filesystem that is valid ext4 (retaining the old data), and valid btrfs (which, being copy-on-write, doesn't destroy the old data.)

<comment><USER3> Also, these aren't all "file formats not starting at offset 0". For example, PDF files must start with %PDF. The problem is that several tools are happy with a PDF prefixed by noise. That probably is because PDF, originally, was a text format (just as PostScript still is). Compression of content was added later, but the structure still is pure ASCII (for example, the table of contents at the end of a file has file offsets in ASCII, and you can find the start of the table of contents as an ASCII string, too).

</comment></comment><comment><USER4> I also did the same with PE or ELF instead of Mach-O.

I recommend also checking my latest slides @ [https://corkami.googlecode.com/files/44CON2013-Messing%20wit...](https://corkami.googlecode.com/files/44CON2013-Messing%20with%20binary%20formats.zip) where the 'inception' slides contain the PDF slides and the actual PDF viewer Sumatra, and an alternate PDF to be viewed under Chrome ;)

</comment><comment><USER5> BTW, if you're interested, Ange also built a really awesome pair of posters on the Windows PE binary format for you to print out:

[https://code.google.com/p/corkami/wiki/PE101](https://code.google.com/p/corkami/wiki/PE101)

[https://code.google.com/p/corkami/wiki/PE102](https://code.google.com/p/corkami/wiki/PE102)

</comment><comment><USER5> Ange was at 44CON[1] this month and did a great talk about Windows PE binary formats. He also ran a workshop on the PE binary format. Awesome guy to talk to, just make sure you don't have any fez's lying around ;)

[1] - [http://www.44con.com/](http://www.44con.com/)

<comment><USER6> I'm intriguied by his fez obsession. Does he toss/eat/steal/stomp them?

<comment><USER4> Fezzes are cool.

<comment><USER7> Was that an intended Doctor Who reference or am I just showing my nerdiness now?

reference: [http://www.youtube.com/watch?v=bvWYw0CnuSI](http://www.youtube.com/watch?v=bvWYw0CnuSI)

<comment><USER8> Ha, don't worry, I read it that way too.

</comment></comment></comment></comment></comment><comment><USER9> ELF and PE hybrid

[http://stackoverflow.com/a/2083161/41948](http://stackoverflow.com/a/2083161/41948)

Now someone could just add Mach-O to it...

<comment><USER4> it's not a PE, it's a (headerless) COM.

PE, ELF, and Mach-O all enforce a different signature at offset 0. Thus it's impossible to combine them - otherwise, I'd have done it already ;)

<comment><USER9> Getting around the offset 0 is always the hardest part in all hybrid format hacks.

I tried .vbs+.bat hybrid and .bat+.com hybrid.

</comment></comment></comment><comment><USER10> Is it possible to do the (somewhat) simpler (in concept, not process) task of making gif or png that is also a valid HTML file? It might be kind of tricky given they both have magic numbers at the head...but perhaps there is some way to trick a browser into ignoring the "garbagey" bits?

<comment><USER11> You mean like this?

[http://demoseen.com/windowpane/magister.png.html](http://demoseen.com/windowpane/magister.png.html)

(I'm not the creator, I just happen to share an IRC channel with them.) There is a description of how it works at [http://daeken.com/superpacking-js- demos](http://daeken.com/superpacking-js-demos)

<comment><USER10> Thanks! yes that's what I mean

</comment></comment></comment><comment><USER12> I remember that the NE executable files had hardly any virus I always wondered why? Is it the format or the fact that they where not used that much (due to the short presence of Win3)?

<comment><USER4> I might be wrong, but IMO: short lifespan (16 bits), complex format while standard DOS executables could still run...

</comment></comment><comment><USER13> What's the font used in the top-right image (begins "db 'MZ'")?

<comment><USER4> Envy Code R: [http://damieng.com/blog/2008/05/26/envy-code-r- preview-7-cod...](http://damieng.com/blog/2008/05/26/envy-code-r- preview-7-coding-font-released)</comment></comment>


Boeing 787 Dreamliner software bug could cause loss of power, control - <AUTHOR> http://www.theverge.com/2015/5/1/8530737/787-dreamliner-software-bug-faa

<comment><USER2> Looks like there's a 5ms clock tick on a 32 bit unsigned variable which rolls over to 0! (10ms if 32 bit signed var).

2^32 / 200 / 3600 / 24 = 248.55 days !</comment>


How to Obfuscate: What misinformation on Twitter and radar have in common - <AUTHOR> http://nautil.us/issue/49/the-absurd/how-to-obfuscate <comment><USER2> This is pretty common in the reputation management arena too.

Say, for example, you have some criminal charge like assault and it shows up for google searches of your fairly unique name.

A reputation management company can flood the internet with other content containing similar keywords, but a positive context. And links to the content that raise it up the ranks, burying negative info down off the front page of the Google results.

"Frank Billingsly Assaults High Prices by..."

"Bailing Out My Sailboat, by Frank Billingsly"

And, of course, also content without those keywords, but with the name.

</comment><comment><USER3> The introduction with WW2 era radar and chaff was a great starting point and I think other privacy-related discussions and articles should follow suit: framing the whole discussion in relation to some real-world phenomenon makes it a lot easier to follow and understand, especially for non-technical people.

</comment><comment><USER4> Good read

Some thoughts

How does one die on facebook? Can i die myself?

More and more it seems that we just cant rely or believe internet connected words. Too much doubt

From genealogy perspective a) did my ancestors obfuscate - is the letter my ggggm wrote about family during the revolutionary war true? And b) imagine 4-5 generations from now when they look back at all our data morsels and get totally confused</comment>


Cloudflare app for thedaywefightback.js - <AUTHOR> http://www.cloudflare.com/apps/the_day_we_fight_back/

<comment><USER2> Will there be a way to access metrics for this to know how many people did it VIA your site?

<comment><AUTHOR> I really wish we had time to add something like that in. Hopefully down the line.

<comment><USER2> All good. Thanks for adding this, definitely significantly reduced the friction to getting this done for me!

<comment><AUTHOR> Glad it made it easier :). The awesome folk at Cloudflare actually did all the hard work to get the app built.

</comment></comment></comment></comment><comment><USER3> Is the code available for this version too?

<comment><USER4> [https://github.com/dkoston/thedaywefightback](https://github.com/dkoston/thedaywefightback)

The banner code is pulled in from the awesome work that thedaywefightback.org folks did. The repo basically shows how to package an app for CloudFlare.</comment></comment>


Show HN: I made an extension that adds time cost to Amazon products - <AUTHOR> https://moneyistime.vilva.io/ <comment><AUTHOR> Hi everyone, author here! I just released this project I made for fun for myself, I had the idea in my mind for forever now and wanted to try my best at building and extension over it. So here it is. Hope you like it and contribute!

Right now it only supports Amazon since it is the site I use the most, but it is pretty trivial to add more shops.

BTW, I just searched for myself on the Chrome Store and found a surprisingly identical extension O_o. [https://chrome.google.com/webstore/detail/time-is- money/oopp...](https://chrome.google.com/webstore/detail/time-is- money/ooppbnomdcjmoepangldchpmjhkeendl) it seems it's more mature than mine, so here you have another option!

</comment><comment><USER2> I like the idea, what are the chrome permissions like? Is the code open-source so I can analyze?

<comment><AUTHOR> Sure, you can find the repo in the site, here it is: [https://github.com/vilvadot/money-is- time/](https://github.com/vilvadot/money-is-time/)

Only explicitily asks for storage access to set a flag when the extension is enabled and to save the hourly rate.

It does have access to execute the code on amazon too, which basically is reading info from html and inject another html node.</comment></comment>


Num command – new tool for simple statistics - <AUTHOR> http://www.numcommand.com and Twitter @NumCommand
Num is a command line tool for mathematics and statistics data processing.
Num can calculate sum, median, quartiles, standard deviation, and much more. Num is free open source, runs on any Unix system, and includes code libraries in Awk.
The site has a tutorial, FAQ, and notes on related command line tools, R/CRAN and Python/pandas, datamash and qstats.
There's a Kickstarter link if you want to fund.
I'm the author and happy to answer questions about Num. <comment><USER2> I find the idea of you funding this via kickstarter really interesting. So, you're looking to get $1000 which, if all goes well you will have in 3 days. What exactly do you plan to use the $1000 for? How do you see this pushing the project forward? Where are you hoping to go from here?

<comment><AUTHOR> Thank you. Yes, I'm aiming to raise $1000, and we have 93% so far with 3 days to go.

Kickstarter is really interesting to me for encouraging creativity; I personally fund many nonprofit projects at $1 akin to a thank you tip jar. I also donate more directly to long term open source projects.

I'm trying the Kickstarter for Num as an experiment. The $1000 goal is covering some of my time to push the project forward, from a little hobby program to a real general purpose tool. Top improvements are adding descriptive stats (e.g. skewness, kurtosis), IO options (e.g. comma separated values, floating point precision), documentation (e.g. tutorial guide, helper guide), contactability (e.g. dedicated accounts on GitHub, Twitter), etc.

Where I'm hoping to go from here is getting Num in the hands of more people, especially for developers, sysadmins, and hackers who want a quick way to do stats. Num is a great candidate for Unix distros because it's lightweight, simple, and runs on so many systems.

</comment></comment><comment><USER3> How does it compare to GNU Octave or J?

<comment><AUTHOR> Num is much simpler than GNU Octave or J.

Num takes command line input, such as file of numbers or a standard input pipe, and outputs common statistics. Num has a goal to be similar to Unix standard tools such as sed, awk, and wc. We're working to make Num fully POSIX compatible so we can write fully portable scripts.

GNU Octave and J are full featured languages, with excellent data structures, and you can do much more in these environments. R/CRAN and Python/pandas are similarly powerful. These all require installations of binaries or compilers, and involve ongoing updates of versions, libraries, dependencies, and the like.

Why use Num? Num is great when you're writing a shell script and you want a lightweight way to do simple statistics. Num is great when you want your script to be able to run on a wide range of standard systems and be able to run as is for a long time. For example, we use Num for our system monitoring scripts, continuous delivery processing, and Ansible deployments.</comment></comment>


Humans.txt - <AUTHOR> http://disqus.com/humans.txt <comment><USER2> I was expecting something along the lines of [http://humanstxt.org/](http://humanstxt.org/) but fun little easter eggs like this are always nice!

</comment><comment><USER3> Github - [https://github.com/humans.txt](https://github.com/humans.txt)

Bitbucket - [https://bitbucket.org/humans.txt](https://bitbucket.org/humans.txt)

Flickr - [https://secure.flickr.com/humans.txt](https://secure.flickr.com/humans.txt)

</comment><comment><USER4> [http://www.google.com/humans.txt](http://www.google.com/humans.txt) [http://facebook.com/humans.txt](http://facebook.com/humans.txt)

<comment><USER5> why did you include facebook?

[https://www.facebook.com/centipedes.txt](https://www.facebook.com/centipedes.txt)

<comment><USER6> To contrast it with Google. Activate your humor subroutines and scan again.

<comment><USER7> I get 404 on all of those.

<comment><USER8> The Google one apparently is a 404 on HTTPS, and a text file on HTTP.

</comment></comment></comment></comment></comment><comment><USER9> I've always been partial to transformers.txt (it's robots.txt in disguise).

</comment><comment><USER10> Oh, hey:

[https://medium.com/humans.txt](https://medium.com/humans.txt)

</comment><comment><USER11> Cute! I wish more sites actually _had_ humans.txt files.

</comment><comment><USER12> [http://www.googleventures.com/humans.txt](http://www.googleventures.com/humans.txt) Is a pretty swish one.

[http://liverpool.gov.uk/humans.txt](http://liverpool.gov.uk/humans.txt) "BEWARE OF THE LEOPARD" (bottom of text)

I'm surprised this passed on a Government site, slipped it past compliance eh?

</comment><comment><USER13> I was wondering how long it would take someone to find this.

</comment><comment><USER14> Interestingly, there isn't a robots.txt

</comment><comment><USER15> Hey, sexy mama, wanna kill all humans?

</comment><comment><USER16> Haha this is great

</comment><comment><USER17> wow lol, didn't expect that.

</comment><comment><USER18> hah! a reference to a popular aspect of geek culture! more of this, please.

<comment><USER19>
      I understand the subtext of your comment which has
      subsequently provided me with a degree of positive
      emotions.

</comment></comment><comment><USER20> best. humans.txt. ever.</comment>


MIT setting up industrial-scale graphene printing press - <AUTHOR> http://idealab.talkingpointsmemo.com/2011/09/mit-setting-up-industrial-scale-graphene-printing-press.php

<comment><USER2> Straight out of the opening pages of The Diamond Age!</comment>


Seemingly Impossible Swift Programs - <AUTHOR> https://www.fewbutripe.com/2018/12/05/seemingly-impossible.html <comment><USER2> I have translated the pretty long Swift code belabored with manual laziness handling into Haskell where lists are inherently lazy:

        type BitSequence = [Bool]

        allSatisfy :: (BitSequence -> Bool) -> Bool
        allSatisfy p = not (anySatisfy (not . p))

        anySatisfy :: (BitSequence -> Bool) -> Bool
        anySatisfy p = p (find p)

        find :: (BitSequence -> Bool) -> BitSequence
        find p =
          if anySatisfy (\s -> p (False : s))
            then False : find (\s -> p (False : s))
            else True : find (\s -> p (True : s))

The code still works the same. But now, it is clearer what actually happens. The lexical call chain goes like this:

        anySatisfy p
        ===>
        find p
        ===>
        anySatisfy (\s -> p (False : s))
        ===>
        find (\s -> p (False : s))
        ===>
        anySatisfy (\s -> (\s -> p (False : s)) (False : s))
        ===>
        find (\s -> (\s -> p (False : s)) (False : s))
        === (by alpha conversion)
        find (\s -> (\s1 -> p (False : s1)) (False : s))
        === (by beta reduction)
        find (\s -> p (False : False : s))

where I used the long arrow to mean a deeper lexical call chain, and triple- equal to mean a single step of reduction and/or .

In other words, as long as the given predicate p consumes a finite prefix of the infinite bit sequence to produce a result, this will successfully return a result. Which is quite intuitive because the function is essentially doing an exhaustive search. It has nothing to do with topology or continuous functions or compactness, IMO. It also has nothing to do with Curry–Howard correspondence.

Here's an example when the function fails to terminate:

        anySatisfy and

Here's another example:

        let parity (False : s) = parity s; parity (True : s) = not (parity s) in anySatisfy parity

<comment><USER3> > _Here 's an example when the function fails to terminate:_

I figured this seemed too good to be true. In fact, isn't there a simple reduction to the halting problem? Make a "sequence"

      i -> M halts in i steps

for an arbitrary Turing Machine `M`. You can implement the "bit lookups" by simulating `M`. The author says their Swift code can run `anySatisfy` on this "sequence" in finite time, right?

EDIT: quoted at the top, but afaict not mentioned later, the article says,

>> _It is well known that it is impossible to define equality between arbitrary functions. However, there is a large class of functions for which we can determine equality_

It would have been nice if the author had been explicit about the class of functions for which their program terminates.

<comment><USER4> It works for any decidable/recursive predicate on bit sequences, i.e. one that is guaranteed to halt for any input.

`and` on an infinite bit sequence is not guaranteed to halt because it is co- recursively enumerable, i.e. it will reject bit sequences that contain `False`, but it will not halt on bit sequences that contain only `True`, since to verify that a bit sequence only contains `True`, you have to check all elements of the sequence.

In ghci,

        > and $ repeat True
        <doesn't terminate>

        > and $ (replicate 10000 True) ++ (False: repeat True)
        False

<comment><USER3> I noticed my post missed the point a bit... I was thinking about functions that check properties of bit sequences, not functions that check properties of predicates on bit sequences.

I get how it works now, thanks. Wish I could edit/delete my old post :-/.

Just to check my understanding: a terminating program that decides bit sequences will have

\- a maximum number of bit checks it will make regardless of input, and

\- a maximum bit index it will access regardless of input, and even

\- a maximum running time (measured however).

</comment></comment></comment></comment><comment><USER5> > It's going to seem incredible, almost magical, but be assured you there are > no tricks involved.

The trick involved is: BitSequence.find is a naïve brute-force search, but the predicates only check n bits (for some n), and laziness ensures that at most n bits are generated.

We run into the expected problems if n is large, or there is no such n. For example,

        func evenNumberOfOnesAtStart(_ s : BitSequence) {
          return (s.atIndex(0) == .zero ||
            (s.atIndex(1) == .one &&
            evenNumberOfOnes(BitSequence { s.atIndex($0 + 2) })))
        }

        evenNumberOfOnesAtStart == evenNumberOfOnesAtStart

will never terminate. (Disclaimer: I don't write Swift.)

While it's nice to try smuggling in some mathematics at the end, I think a better conclusion for the article to draw is: if you ask a computer to do a brute-force search on some fixed number of bits, it will do it, even where has to compute this number of bits itself along the way.

<comment><USER6> I think there might be a clearer explanation.

If a predicate only looks a finite number, n, of bits of a bitsequence then you can brute-force search the space containing the (2^n) sequences shorter than n. And a predicate can't possibly look at infinitely many bits of a bitsequence as the function which resolves that predicate would never terminate.

<comment><USER5> Agreed.

(Although it's (2^m) sequences, where m is the largest index of the n.)

</comment></comment></comment><comment><USER7> See also "Seemingly impossible functional programs" by Martin Escardo, from 2007 ([1], also at [2]).

It covers similar ground and is referenced at the bottom of the article (along with three other references also by Martín Escardó), but I thought it worth mentioning explicitly because I remember reading it many years ago and finding it really fun.

[1]: [http://math.andrej.com/2007/09/28/seemingly-impossible- funct...](http://math.andrej.com/2007/09/28/seemingly-impossible-functional- programs/)

[2]: [http://www.cs.bham.ac.uk/~mhe/papers/seemingly- impossible.ht...](http://www.cs.bham.ac.uk/~mhe/papers/seemingly- impossible.html)

</comment><comment><USER2> Nitpicking but I don't think this is quite right:

> The BitSequence type holds infinitely many values. In fact, it holds an > unconscionable number of values. It has more values than String does.

Assuming UInt is infinite precision and Strings can be infinitely long, there is an easy injection from BitSequence to String, therefore String is at least as equinumerous as BitSequence.

If we bend the definition a bit and allow UInt to be infinite precision (which it is not), there's no reason not to allow String to have infinite length as well.

Also, the article mentioned multiple times how awesomely large the cardinality of BitSequence is. But in fact, the cardinality is the same as that of the real numbers—both have cardinality $2^{\aleph_0}$. So its size is rather intuitively grasped.

<comment><USER8> > Assuming UInt is infinite precision and Strings can be infinitely long, > there is an easy injection from BitSequence to String, therefore String is > at least as equinumerous as BitSequence.

You're right that a particular series of bits can be mapped to a string, but here the article is talking about the function that produces the bit sequence not the bit sequence itself. There are an infinite number of functions that can create a particular bit sequence, and each bit sequence can be mapped to a single string, so there must be more functions than strings.

<comment><USER9> > There are an infinite number of functions that can create a particular bit > sequence, and each bit sequence can be mapped to a single string, so there > must be more functions than strings.

I don't think this logic works. For example, there are an infinite number of "rational numbers" of the form np/p where n, p ∈ ℤ, and each of these can be mapped to a single integer (namely, n). But there are not more these "rational numbers" than integers.

<comment><USER2> When you have an injection from A to B, you only know that B is at least as equinumerous as A. Maybe their cardinality is the same, and maybe the cardinality of B is strictly bigger.

For your example, we can construct an injection from rational numbers to integers, as well as an injection from integers to rational numbers. Therefore, by the Schröder–Bernstein theorem they are equinumerous.

</comment></comment></comment></comment><comment><USER10> Here is a more imperative version (using exceptions):

The assumption is (as in the article) that each predicate terminates for every bit sequence and that the predicates are actual functions, i.e. they have no state. Also, predicates don't catch exceptions.

We can implement find as follows: Start with n = 0 and generate the bit sequences with all prefixes of length n. Have them throw an exception if somebody tries to access an index past that prefix. This way, you get finitely many partial bit sequences. Apply the predicate to all these sequences. There are three cases:

\- The predicate returns true for one of the partial sequences. Because it doesn't catch exceptions, it only looked at values within the prefix. Hence, the result of the predicate doesn't change if we change the rest of the sequence—for example, we can set the rest of the sequence to 0 and we have found a sequence that satisfies the predicate.

\- The predicte returns false for all our partial sequences. Similarly to the case above, the result does not depend on bits beyond the prefix, so no matter what we do, we will not find a sequence satisfying the predicate and we can return any sequence (by the definition of find, it returns any sequence if the predicate is unsatisfiable).

\- For some of our partial sequences, we get an exception. Then we increase n and try again.

This algorithm has to terminate: if it doesn't, we get the third case each time. But taking the bit sequence that we get by always extending our prefix on a path that keeps throwing exceptions, we get a bit sequence on which our predicate does not terminate, contrary to our assumption that it always does.

</comment><comment><USER11> Noob here woth a doubt:

"Incredible! We are exhaustively searching an uncountably infinite space in finite time"

Isn't this like a long stretch? Once lazy evaluation is introduced he is pretty much checking until a first hit happens, isn't he?

What would happen if I call the function with predicate 'x == one AND x == zero'?

<comment><USER12> This algorithm is only total if the predicates supplied are total. Since `x == one AND x == zero` is not total the algorithm will diverge. It will not return the incorrect answer though.

</comment></comment><comment><USER13> He lost me when he started talking about the Halting Problem.

How is checking all Swift.String or Swift.Int values equivalent to that? There are a lot of Swift.Int values to check (2^64, on a 64-bit platform), and even more Swift.String values (every combination of characters up to that length), but simply being infeasibly slow to run on your Pentium "in a reasonable amount of time" doesn't mean it's an "impossible function to implement, and also equivalent to the halting problem". We could easily write a function to enumerate all Swift.Int values (though it might take 100 years to run).

He throws out the parenthetical remark "it's best to think of Int as modeling the infinite set of all integers" without explanation. When you're discussing whether something is theoretically impossible or not, thinking of a finite set as equivalent to an infinite set is brushing over a pretty major distinction.

<comment><USER14> With Int you may be right.

But there are an infinite number of strings (and indeed every Turing machine may be represented as a String in swift), so it is indeed related to the halting problem.

<comment><USER13> Swift.String is composed of a finite set of symbols, with a finite maximum length. How can you create an infinite number of these?

The article ignores the distinction in many places, but "String" in a Swift function means "the Swift.String type", not "an abstract string type like those used to represent Turing machine state".

<comment><USER15> You're not wrong, but the author's code does in no way rely on the fact that you could theoretically iterate over all the valid Int values in Swift, so it would have made no difference if the Int type was somehow truly infinite.

And the author clearly acknowledges this:

>it's best to think of Int as modeling the infinite set of all integers

</comment></comment></comment></comment><comment><USER16> Hmm, some questions from someone who isn't familiar with Swift or much functional programming:

\- What does this have to do with Swift? Other commenters seem to agree that Haskell would be more appropriate.

\- What does this have to do with functional programming? As far as I can tell, an algorithm about bitstrings has been wrapped up and reframed in terms of types. Could you not do this in C without too much headache?

\- The recursion aspect confuses me a bit; is it possible to "find" a predicate like "all indices of the bitstring are 1"? Or is that not an allowed type of predicate?

\- Again with the recursion, how does the "find" procedure know to terminate if no viable bit string exists?

EDIT: I should have read kccqzy's post more carefully. I believe it answers the third and fourth questions.

<comment><USER9> For the first two: not much, and somewhat. The commenters are correct that this logic is much more easily expressed in Haskell, since it has better support for this kind of programming. Swift is able to do this because it has lazy evaluation as a opt-in feature as well as the parts of the type system that matter; I don't think you would be able to port this to C easily.

</comment></comment><comment><USER17> I don't get it. What prevents us from doing the exact same approach for the natural numbers? I.e. represent the naturals lazily via the successor function and use the same exhaustive search as the OP for BitSequence. Of course if the predicate doesn't stop evaluating successor(x) for any finite x then we're out of luck and the computation doesn't halt, but this caveat also holds for OP's BitSequence, as others have pointed out in this thread...

<comment><USER12> So this article shows how to check equality on `(nat -> bool) -> bool`. Your question, I think, is to figure out how to check `nat -> bool` for equality.

The issue is that there are more operations we can do with `nat`, more properties we can check, than there are with `nat -> bool`. With `nat -> bool` we can basically check `i` indices and so the behavior of any predicate `(nat -> bool) -> bool` is basically determined by the first `i` indices. And that's finite. This algorithm is basically implicitly finding the indices considered by the supplied predicate and then brute-forcing all those entries.

With `nat` there's no such finite cut off point. It's never the case that it suffices to test a predicate `nat -> bool` on finitely many entries to fully determine it. So we cannot do the same brute force search.

<comment><USER17> But a natural number can be viewed as a function from the natural numbers to {0, 1} via its binary expansion.

There's a trivial isomorphism between the natural numbers and binary sequences with finitely many ones, so a predicate of type `nat -> bool` can be viewed as a predicate of type `(nat -> bool) -> bool`.

<comment><USER12> It's not an isomorphism though, it misses the always true map. This means that many predicates on nat do not terminate on nat -> bool.

</comment></comment></comment></comment><comment><USER18> This article does a great job at pointing out just how needlessly difficult computer science makes itself when it doesn't have to. Example:

        !(a || b) == (!a && !b)

`a` and `b`. They're meant to represent, well _anything_ really but to the average person (or weirdos like me) it would be infinitely easier to understand if the author wrote it like this:

        !(Bob || Sally) == (!Bob && !Sally)

I don't know why but whenever I encounter single-characters-as-math-variables in computer science I have to spend _far_ more time unpacking such statements into things my brain can understand. It is _so much easier_ if such statements are written as _nouns_ that describe actual _things_.

I remember having a hard time working with C for loops until a friend of mine wrote one like this:

        for (int number = 0; number < 10; number = number + 1)

Suddenly it all made sense! I am not alone in this! I have taught programming to kids and others who have struggled to learn programming and this seems to be how _normal_ people think.

Note: We, as a geeky community are _not_ normal. I just have a strange exception in that at least one little part of me thinks like a normal person and that is with "what we name things" :)

<comment><USER19> I can't understand any point to writing 'a' rather than writing 'Sally'. What practical difference does it make?

<comment><USER20> It makes it WAY easier to understand exactly why !(a || b) == !a && !b.

Bob and Sally are things that people already understand and relate to. a and b are not, so there is an extra layer of indirection there when attempting to reason about them.

!(Milk || Sugar) == (!Milk && !Sugar), duh.

<comment><USER19> Sorry I still don't get it.

> Bob and Sally are things that people already understand and relate to.

People understand they're people's names. But that's not a relevant detail for the equation, so why add that to the problem? It complicates, rather than simplifies, my understanding of it.

> !(Milk || Sugar) == (!Milk && !Sugar), duh.

I don't get what the 'duh' is. You've added nothing to the equation! They're just different names!

<comment><USER21> _`with_milk`_ and _`with_sugar`_ are booleans that people have (lots of) experience with. this seems to help us think about this stuff – we've seen how milk/sugar "work" many times, and we've already internalized some model of that situation – we already "get it" on an intuitive level. hence, reusing that model for general Boolean variables reduces the cognitive effort required[0].

for a similar example, see [1]. summary: a study presented people with a logical problem. they failed miserably if the question was about abstract math-y stuff, but got it right most of the time if the variables were like _`X is underage`_ and _`X can buy beer`_ (explained in the "Policing social rules" section)

\---

[0] as a bonus, we can quickly sanity-check if our reasoning is correct – if there's _`no (milk or sugar)`_ in my coffee, there's obviously _`(no milk) and (no sugar)`_ in it!

[1] [https://en.m.wikipedia.org/wiki/Wason_selection_task](https://en.m.wikipedia.org/wiki/Wason_selection_task)

</comment></comment></comment></comment></comment><comment><USER22> > It's so large that it can hold an infinite number of disjoint copies of the > natural numbers inside it!

Nit: you can embed infinite copies of the natural numbers inside the natural numbers as well, with room to spare. Consider the primes raised to integer powers.

</comment><comment><USER23> Off topic: DeMorgan's law

> the negation of a disjunction is the conjunction of the negations

As a non-English speaker I hated this definition until someone told me to remember

> 'break the line, change the sign'.

This is of course referring the representation in boolean algebra, where, NOT(A AND B) is represented with a single long horizontal line on top of (A AND B). This becomes NOT(A) OR NOT(B), i.e., Ā | B̄ according to DeMorgan's law.

<comment><USER24> De Morgan's law is just "not all true <=> at least one's false". I'm not sure why people complicate it beyond that.

<comment><USER25> In university I had a course (curse?) called "logic in formal systems" (or something like that); I doubt many using only the course's materials truly understood the logic principles demonstrated there. Coincidentally, the course insisted on using ∧, ∨, ¬ etc., while another course also dabbling in a lot of logic using natural symbols was far better in terms of presentation and explanations. (To this day I have to look ∧, ∨, con- and disjunction up to be sure which is which).

<comment><USER26> > To this day I have to look ∧, ∨, con- and disjunction up to be sure which is > which

Tip: ∧ is shaped like the "A" in "And".

Hopefully others know tricks for the other symbols.

<comment><USER25> > Tip: ∧ is shaped like the "A" in "And".

Meanwhile ∨ is shaped like the "U" in "Und" ...

</comment></comment></comment></comment></comment><comment><USER27> Apple's been in this game a long time. NewtonScript had a powerful function called "IsHalting". See Page 23-84 of [http://www.newted.org/download/manuals/NewtonProgrammerRef20...](http://www.newted.org/download/manuals/NewtonProgrammerRef20.pdf)

</comment><comment><USER28> That was really interesting!

> This is completely impossible to do with Int's and String's, but here we > have done it for BitSequence

I'm still confused by this part. Can't you convert any Int or String value into a BitSequence?

<comment><USER29> He means that it's impossible to write such a function from the natural numbers. It's possible for all finite types such as UInt in Swift.

In general, you can do this exhaustive search with any "compact" type and there are a lot of compact types. In particular, the (total continuous) functions from a discrete (i.e. a type with decidable equality) into a compact type are compact. And as the article shows, the (total continuous) functions from a compact into a discrete type are discrete. Together with the observation that the type of natural numbers is discrete and that every finite type is compact and discrete already gives you infinitely many compact types to play with.

One caveat with this whole work (which goes back to Martin Escardo by the way) is that this doesn't work with general recursion. E.g. in a language with general recursion you can write a program

      kleene : (nat -> bool) -> bool

which computes the paths in the Kleene tree, where roughly "all total computable paths are terminating, but all uncomputable paths diverge". However, if you have a (total) language with, e.g., only structural recursion, everything works out and you can apply this epsilon operator to arbitrary programs.

<comment><USER28> Thanks for your reply! I think I understood some of your comment, but got very lost at the end. I don't know anything about: Kleene trees [1], "total" languages [2], general recursion vs structural recursion [3], or epsilon operators [4]. (But I've looked those up and provided some links.)

I think I understood some of the first paragraph. I'll have to do some mathematics and computer science courses on Khan Academy.

[1] [https://en.wikipedia.org/wiki/Kleene%E2%80%93Brouwer_order](https://en.wikipedia.org/wiki/Kleene%E2%80%93Brouwer_order)

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

[3] [https://stackoverflow.com/questions/14268749/how-does- struct...](https://stackoverflow.com/questions/14268749/how-does-structural- recursion-differ-from-generative-recursion)

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

This seems like a very advanced topic!

</comment></comment></comment><comment><USER30> Balderdash, as others have more graciously pointed out. How wrong do you have to be before having your nonsense deleted from HN?

<comment><AUTHOR> Even if it is balderdash, isn't there value in analyzing(/refuting) it? I submitted the post (it's not mine) because I was interested in hearing people with more maths than I have expand/comment on it -- perhaps even people who had read the original papers.

If there's something particular in the post that you find problematic, I personally am all ears.

<comment><USER30> The author is correct that checking if two functions having infinite domains are equal is often impossible. He also has correct statements of some mathematical theorems. But people in this thread have provided counterexamples to his claim. That means he needs to fix the mistakes he made. If you are interested in what serious mathematicians have to say on this topic see [https://homotopytypetheory.org/](https://homotopytypetheory.org/).

<comment><USER12> It is possible in certain cases, that's the point of the article. One of the contributors to HoTT is the author of the paper introducing these algorithms :)</comment></comment></comment></comment>


Elsevier, that just freaked me out - <AUTHOR> http://swaldman.dreamwidth.org/352778.html <comment><USER2> Now that the news has been getting out in recent years that Elsevier is evil, you'd think they'd start to be more careful about behaving questionably in easily avoidable ways.</comment>


Laziest Christmas Ever: Using a Raspberry Pi, Graphite, and Nagios to Cook a Ham - <AUTHOR> http://sysadvent.blogspot.com/2015/12/day-25-laziest-christmas-ever.html <comment><USER2> How did they route the temperature sensors out of the oven? I'd imagine the PVC insulation wouldn't be too happy above ~100 _C, and the oven was supposedly around 160_ C. Toxic ham?</comment>