Anagram Scoring - <AUTHOR> http://blog.plover.com/lang/anagram-scoring.html <comment><USER2> Ahh... so much poetic inspiration in this post!

"Timesaving negativism" said the earringed grenadier, with dispensable piebaldness, "can be the intermediator for chronic endometritria!"

"Ah nay!" the cinematographer megachiropteran replied! "it is only with maths --integrals, triangles, that can cause such excitation, can intoxicate!"

But I, though their admirer, now married had to disagree: "it would be a series of masculine calumnies to give such clitoridean, directional advice to women! We cannot precipitate such peripatetic thoughts!"

<comment><USER3> True then, as I believe best anagrams transcend mere good manipulation of dictionary entry,

a letter rearrangement goes beyond the plain, ordinary substitutions of vain academic men.

<comment><USER4> In case anyone is wondering, the two lines above are anagrams of each other. It's pretty impressive, any hints on the method you use to come up with this?

<comment><USER3> Work on both sides at once. I knew the phrase had to contain the word "anagram", so I started with that. At first, it was "better anagram", and so it looked like this:

      better anagram lerrneet
      letter rearrangement ba

So then I think of a word that both uses up the excess letters and can reasonably fit into the phrase. Whatever letters in the word that are not in the stock for that side get added to the other side. Sometimes I add words specifically to up vowel count or supply low frequency letters needed for words that fit that half of the phrase.

At some point, I had an excess 's', so "better" got turned into "best", and I had to use up its excess "ter", which got stuck with an excess 'u' to make "true". I also had an excess 'n', so a "the" became "then". Those somewhat awkward words go in last, which is where that "True then, as" came from. Getting rid of the last letters on both sides is the hardest part, because there is rarely a perfect word that uses up all your letters, just like in Scrabble. Sometimes you just have to unravel a few words and try different ones in their place. In the end, I just ran out of time to work on it.

It's a bonus if I can get near synonyms on both sides, like "transcend" and "goes beyond"

<comment><USER5> You might like the anagrammatic sonnet "Washington Crossing the Delaware", in which every line is an anagram of the title and the story of the titular event is told: [https://en.wikipedia.org/wiki/Washington_Crossing_the_Delawa...](https://en.wikipedia.org/wiki/Washington_Crossing_the_Delaware_\(sonnet\))

</comment></comment></comment></comment></comment><comment><USER6> In the same vein, I wrote a Twitter bot that finds and retweets pairs of tweets that form anagrams:

[https://twitter.com/anagrammatweest](https://twitter.com/anagrammatweest)

It's a clone of anagramatron, the original anagram Twitter bot that went inactive almost a year ago.

I use a combination of Damerau–Levenshtein distance, longest common sequence, length, number of English words, and number of different words to score and rank anagrams to figure out which ones to retweet.

<comment><USER7> It took me a while to realize which tweets go together, particularly since Twitter shows only the original tweet time, not when they were retweeted. Maybe you could retweet them as links?

<comment><USER6> They're also posted to tumblr, which can make it easier to see the pairs:

[http://anagrammatweest.tumblr.com/](http://anagrammatweest.tumblr.com/)

</comment></comment></comment><comment><USER8> Super fun!

The list of examples in the 7-11 range seemed to have a high number of pairs that have strangely coincidental meanings somehow. I thought maybe that was because they are hand-picked, but looking at the complete list, I honestly see more of those than I'd expect. I'm not sure why it's surprising, there's no actual pattern in a pair, and it's not surprising that lots of pairs of words have _some_ way to connect them. But it still feels surprising when looking at them. It's like a lot of high scoring pairs of words share some kind of root, even though high scoring should mean high dissimilarity.

Anyway, great post. Weekend coding projects looking for anagrams and palindromes and boggle solutions are often rewarding for me, above and beyond just being fun.

<comment><USER9> I bet that the "strangely coincidental meanings" are your human brain doing pattern-matching, rather than any etymological similarities. Which I think is why the anagrams are so fun in the first place!

<comment><USER10> Words with similar letter distributions will tend to be from the same root languages, which frequently maps to category of discourse (scientific, sophisticated, coarse, exotic, etc.)

</comment></comment></comment><comment><USER11> Love this guy's blog. His article about Your Age as a Fraction [0] caught my eye a couple years ago and I've been hooked ever since. I love checking the script to see how far into my year I am.

[0]: [http://blog.plover.com/math/age- fraction-2.html](http://blog.plover.com/math/age-fraction-2.html)

<comment><USER12> Here is a program I wrote a while ago that is vaguely related to that:

[https://gist.github.com/jedberg/61b2587b298af92adc5f985b11a2...](https://gist.github.com/jedberg/61b2587b298af92adc5f985b11a20642)

Basically, if you run "watch ./remaining.py" on your command line, you can see a running countdown of how long is left in the day, month, year, and your life.

</comment></comment><comment><USER13> This is a fun read, I've always enjoyed anagrams and palindromes. The "best anagram" was cinematographer megachiropteran.

However, it comes across as a little "smarter than thou" with the section:

"The thing you do not want to do is to compute every permutation of the letters of each word, looking for permutations that appear in the word list. That is akin to sorting a list by computing every permutation of the list and looking for the one that is sorted. I wouldn't have mentioned this, but someone on StackExchange actually asked this question."

That statement makes sense to me when I think about it, but it wouldn't have appeared as totally obvious to me from the outset. And I can't see casting derision at someone because they asked this question.

<comment><USER14> I think that paragraph perfectly demonstrates why all the commenters on Why I Don't Talk to Google Recruiters ([https://news.ycombinator.com/item?id=13696004](https://news.ycombinator.com/item?id=13696004)) who insist that programmers don't need to know algorithms are wrong. It should be immediately obvious to anyone with a cursory understanding of algorithms that computing all the permutations of every word is much more expensive than necessary, and from there it's not all that hard to figure out that sorting the letters produces the desired effect.

<comment><USER15> The observation that two words are anagrams if they contain all the same letters isn't a huge leap from two words that contain all the same letters are anagrams.

That being said: Sorting isn't required. (An O(kn) solution exists to beat your O(nk log k))

<comment><USER16> It's not entirely clear that the O(nk) solution actually wins because k is small in this case, and so log(k) is _very_ small. Unless you do some careful bit packing, the O(nk) algorithm will use more memory, which could make it slower because of increased cache misses.

<comment><USER15> The O(nk) solution has fewer branches (O(1) versus O(log k)), and even if you use a naïve implementation, O(nk) will still fit into L1 (assuming n is bigger than k).

<comment><USER16> > O(nk) will still fit into L1

Not even close. The lexicon is 230k words, times 26 letters is nearly 6MB. The i7 has a 64kB L1 cache and a 246kB L2 cache.

I think the only way to resolve this would be to actually do the experiment. I wouldn't bet my life savings on the outcome either way, but I'll give you even odds at low stakes that sorting is faster.

</comment></comment></comment></comment></comment></comment><comment><USER17> So the author ends up scoring anagrams by the minimal number of 'chunks' such that one word can be rearranged into the other, and points out that this maps to the NP-complete independent set problem.

Another way you can do it is to score each pair by the length of the longest shared substring, which can be done in linear time with a suffix trie or quadratic with dynamic programming. Under that metric the 15-length word is no longer 'best', you'd end up picking the longest pair that fully permutes the other word.

<comment><USER18> Sorting by edit distance might be interesting, too.

<comment><USER19> I also immediately thought of edit distance as the obvious metric, and it has a reasonably simple and efficient algorithm too:

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

But then i realised that it was only obvious to me because i spent years hunched over a computer crunching DNA sequences.

I'd also be interested in normalising edit distance by length somehow. It's no coincidence that higher-scoring words tend to be longer.

<comment><USER20> I was curious, so I rescored his list using Levenshtein. No normalization for long words though:

[https://gist.github.com/anonymous/431b163b2a2d532bfd0a3bdcc7...](https://gist.github.com/anonymous/431b163b2a2d532bfd0a3bdcc711f7b3)

I sorted it reverse so that the interesting pairs would be on top.

Compare to his original scored list, here: [http://pic.blog.plover.com/lang/anagram-scoring/anagrams- sco...](http://pic.blog.plover.com/lang/anagram-scoring/anagrams-scored.txt)

<comment><USER19> Thanks for doing the legwork!

Sadly, it turns out our genius idea doesn't work so well - the infamous cholecystoduodenostomy/duodenocholecystostomy is in joint fourth place, and the scarcely any better duodenopancreatectomy/pancreatoduodenectomy is joint second.

mjd's key insight was that good anagrams are ones where all the letters are thoroughly scrambled; both of the cases above are ones where large blocks of letters remain intact. I don't know if you've had scrambled eggs where large lumps of white or yolk remain intact, but i have, and they're vile.

So, anyway, perhaps a better edit distance metric is one which allows cut-and- paste of whole blocks as an edit, since it would give those words much lower scores. My years of DNA-hunching immediately led me to think of sequence alignment algorithms, because that kind of cut-and-paste is exactly what happens in DNA:

[https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorit...](https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm)

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

But i'm not sure those algorithms are much good, because they model the editing as deleting, inserting, and modifying runs of letters, rather than moving them around.

Next, i thought of compression, because that often works by finding repeated runs of characters, and also i don't really know any other areas of string algorithms. What if you concatenated two strings, compressed them using LZ77, and measured the amount of compression? Or what if you did it with something simpler and more local, like Predictor [1]? Could you use the Burrows–Wheeler transform?

[1] [https://tools.ietf.org/html/rfc1978](https://tools.ietf.org/html/rfc1978) \- your daily obscure blast from the past!

<comment><USER20> I had the best luck with "Anagrams by percent of string not part of longest common substring, then length"

The top-to-bottom ranking isn't quite right...need some better way to push down short words, but it does seem to put most of the good stuff near the top.

[https://gist.github.com/anonymous/ec28b75fb6c841b56def8eefec...](https://gist.github.com/anonymous/ec28b75fb6c841b56def8eefec813656)

</comment></comment></comment></comment></comment></comment><comment><USER21> I was always fond of "presbyterians" "britneyspears".

</comment><comment><USER22> Not to get political, but I thought as far as name anagrams go

Rex Tillerson -> Risen Ex Troll

is pretty amazing. Not sure how it would score with the OP's metric though - typing this as I'm on the ski lift lol

<comment><USER23> From [http://wordsmith.org/anagram/hof.html](http://wordsmith.org/anagram/hof.html)

Clint Eastwood = Old West Action

Madam Curie = Radium came

It's good fun to go find anagrams of friends and family. One of my nephew's comes out Alpaca Tits. He's not real happy about it but the rest of us think it's pretty good.

<comment><USER24> alec guiness = genuine class

not original , but certainly on topic.

</comment></comment></comment><comment><USER25> Shitposting -> Top insights

<comment><USER26> More interesting is that you made a novelty account just to post this.

</comment></comment><comment><USER27> His blog title is an anagram of "code overuse ruins fetish".

<comment><USER28> "Fetish overuse ruins code"?

</comment></comment><comment><USER29> Winner of most metal anagram goes to "incorporate procreation"

</comment><comment><USER30> Interesting article! The metric you use does eliminate triviality, but it sometimes uses very obscure (and arguably uninteresting words), such as calumnies, ivoriness, coprophagist, etc. That's what you describe as Webster's Second jargon that nobody knows".

It would be interesting if you could adapt your metric to account for general prevalence of the word in English. Scan a giant subsection of say Wikipedia, and assign a frequency to each of the 234,000 words in a map, giving unseen words an infinitely small frequency, and then use the sum or multiple of the frequencies of each of the anagrams to bring out some truly interesting ones!

<comment><USER31> I would strongly argue that coprophagist is a very interesting word, and should be less obscure. But then again, that might just be my juvenile sense of humor.

</comment></comment><comment><USER32> Fun stuff - especially debugging the time printout ;) A really ancient but still functioning site I always go to is wordsmith.org. He calls it "Internet anagram server" == "I rearrangement servant" !

</comment><comment><USER33> Why didn't he just calculate the Levenshtein distance instead of coming up with that custom difference calculation method?

<comment><USER34> The Levenshtein distance from duodenocholecystostomy to cholecystoduodenostomy is actually pretty high: 14. Transposing two contiguous chunks of letters has a high edit distance if both chunks are long.

A "good" anagram doesn't just have letters being moved a long distance, but also requires that the movements of letters be independent, something that Levenshtein distance doesn't measure.

</comment></comment><comment><USER35> I wrote a javascript game based on anagrams as part of a 'get to know your team' exercise at a previous job. It was a weekend project.

The game asks the user to guess the name of a team member from anagrams of that name displayed for short time periods on screen.

Click the 'automate with answers' button for a nice animation of rearranging the letters.

[http://tomcdonnell.net/submodules/anagram_game](http://tomcdonnell.net/submodules/anagram_game)

Here is the tool I used to find the anagrams:

[http://tomcdonnell.net/submodules/anagram_finder](http://tomcdonnell.net/submodules/anagram_finder)

</comment><comment><USER36> Those of those who are word freaks already knew about MEGACHIROPTERAN CINEMATOGRAPHER, as this pair is mentioned in the best seller Word Freak from ~15 years ago :)

Some of my favorite pairs are descriptive ones, like GULLIBLE BLUEGILL and HAPPIEST EPITAPHS.

</comment><comment><USER37> [http://www.anagrammy.com/anagrams/faq6.html](http://www.anagrammy.com/anagrams/faq6.html)

18 letters

        conversationalists = conservationalists

17 letters

        basiparachromatin = marsipobranchiata
        Charles Holding, 1971

16 letters

        thermonastically = hematocrystallin
        John Edward Ogden, 1978

15 letters

        nonuniversalist = involuntariness
        refragmentation = antiferromagnet
        megachiropteran = cinematographer
        centauromachias = marchantiaceous
        Eric Albert, c. 1986

<comment><USER38> Of course, the key idea of the linked article is that it's easy to find long anagrams, but it's hard to find _interesting_ ones. The anagram "megachiropteran = cinematographer" is ranked higher than "conversationalists = conservationalists" because of the more complex rearrangement.

</comment></comment><comment><USER39> I just experimented with building n-grams for each anagram candidate and calculating the dissimilarity of pairs within each group, then multiplying this score by the length of the word.

The results look pretty decent, but I get "BASIPARACHROMATIN" vs "MARSIPOBRANCHIATA" as number 1.

[https://gist.github.com/aclemmensen/725f60a0746382521faefa0d...](https://gist.github.com/aclemmensen/725f60a0746382521faefa0df9ecd8a1)

</comment><comment><USER40> That's a lot of fun. I'd like to see someone go further with some of the suggestions the author mentions at the end, like weighting the scores by word familiarity and word length.

<comment><USER41> I did something like that for multiword anagrams: scoring them by their probability in a word-bigram model of English. It's expensive because I had it pick the best permutation of the words, by brute force. It's far from a measure that could really judge "this is a great anagram", but there are so astronomically many boring ones to filter out that it's still a big help.

</comment></comment><comment><USER42> Kind of related: The anagrams problem is probably my favourite interview question to dole out. Always shows completely different ways of thinking and normalising things.

</comment><comment><USER43> I think the "best" one would be the word(s) with the most letters that are both common, and also somehow related.

<comment><USER44> "nonuniversalist" and "involuntariness", listed in another comment, both have a theological aspect. While not terribly common, they're not hard to understand either.

</comment></comment><comment><USER10> A scoring rule I'd like to try maximizes the product of the lengths of the chunks / length of the word. This makes individual letters shuffling less interesting and many medium chunks most interesting, which matches my intuitions.

</comment><comment><USER45> He makes a good point that the "scoring function" for what we think of as a good anagram is actually the more important.

In general just generating the solution space is actually much easier than coming up with a satisfying scoring function.

</comment><comment><USER46> If you like anagrams and a bit of a challenge, you should check out [https://twitter.com/anagramdaily](https://twitter.com/anagramdaily)

<comment><USER13> They've taken a lot of liberties with the "Daily" in "Anagram Daily." Fifteen days between today's anagram and the last one!

Plus one that is marked easy: MYTH. Maybe I'm just an idiot, but I cannot think of an anagram for MYTH.

<comment><USER47> My /usr/share/dict/words does not have an anagram for "myth" in its 99171 words, which is already larger than almost everybody's vocabulary.

<comment><USER48> SCOWL[0] has 675491 words. There's no anagram of "myth" there either.

[0] [http://wordlist.aspell.net/](http://wordlist.aspell.net/)

</comment></comment></comment></comment><comment><USER49> You could also use their Levenshtein distances.

<comment><USER14> See this comment ([https://news.ycombinator.com/item?id=13698252](https://news.ycombinator.com/item?id=13698252)) by lmkg for an explanation of why Levenshtein distance isn't good.

</comment></comment><comment><USER50> I'm going to use his "coprophagist topographics" pair the next time I write a post about readers of fake news.

</comment><comment><USER51> computers have taken a bit of the fun out of searching for interesting anagrams :) my favourite one i found "by hand" (mostly a mental tic where i randomly anagram words i encounter) was {antipyretic, pertinacity}, followed by the fact that cremate, cremating and cremation all have nontrivial anagrams.

</comment><comment><USER52> I really enjoyed this.

Nice solution to put the (sorted by letters) words into a hash table to find the anagrams.

</comment><comment><USER53> Wondering if there is class of poetry where the rhyme is via palindrome rather than phonetic.

<comment><USER54> unrelated but reminded me of another non-rhyme-based form of poetry, [https://en.wikipedia.org/wiki/Ci_(poetry)](https://en.wikipedia.org/wiki/Ci_\(poetry\))

</comment></comment><comment><USER55> senorita = not a word. That would be "señorita", with an "ñ". It doesn't really work as an anagram for "notaries" because "ñotaries" is also definitely not a word.

<comment><USER36> SENORITA is acceptable in the English-language Scrabble dictionary. Its other anagram is NOTARISE.

<comment><USER55> Huh, that's extremely surprising! TIL.

</comment></comment></comment><comment><USER56> No triplets or quadruplets?

</comment><comment><USER57> would be fun to measure the word/context similarity for each pair and order by that..

<comment><USER20> I gave that a shot using Wordnet. It's flawed for a few reasons. A lot of the more unusual words in his list aren't in Wordnet. I also had the stem the words first, and had to pick just the most used sense if the word had multiple senses.

So, the list is only those pairs that made it through the processing.

[https://gist.github.com/anonymous/e69f448fa08481603d1ca77ea7...](https://gist.github.com/anonymous/e69f448fa08481603d1ca77ea76d458a)

Would have been better if I had also weighted using his approach, as pairs like "theater theatre" end up on top.

Still interesting though. It found these, which I liked:

      0.33  swinger wingers
      0.33  parrot raptor
      0.33  borsht broths

<comment><USER20> I also tried a variation based on "Anagrams by Percent of String Not Part of Common Substring, then Length"

It's flawed too, but does put some good ones at the top.

[https://gist.github.com/anonymous/ec28b75fb6c841b56def8eefec...](https://gist.github.com/anonymous/ec28b75fb6c841b56def8eefec813656)

</comment></comment></comment><comment><USER58> it's not "flirting geisha abandons the menu"?

</comment><comment><USER59> predators = teardrops

</comment><comment><USER60> tldr: cinematographer megachiropteran (the latter is a giant bat)

</comment><comment><USER61> For anagram scoring, why not just determine the overlap between both words in terms of shared bigrams (i.e., two-letter substrings), relative to their length? Has anyone tried that? Is it equivalent to what mjd did?</comment>


Court rules that ISPs do not need to give up information on copyright infringers - <AUTHOR> https://www.privateinternetaccess.com/blog/2016/08/court-rules-isps-not-need-give-information-alleged-pirates-copyright-infringers/ <comment><USER2> But they did find Cox is liable for contributory copyright infringement and needs to pay $25 million in damages to BMG, for not passing on the extortion, ahem, I mean infringement notification letters. Eck.</comment>


Neanderthal 'minibrains' grown in dish - <AUTHOR> https://www.sciencemag.org/news/2018/06/exclusive-neanderthal-minibrains-grown-dish <comment> King-Aaron Obviously this is a long, long way from a functional brain being grown. But I have to wonder where the moral line is drawn when you're talking about growing an organ that (may-or-may-not) hold the ability to form a level of consciousness.

<comment><USER2> The quick answer is to say it's not ethical. But what if the brain is given full autonomy and ability to communicate with others and then let the brain decide if it wants an organic or machine body?

<comment><USER3> I don't think you should be so quick to call something moral or not. Let's take your statement and apply it to a few real life situations ...

So what you're saying is we should take anything with a brain, figure out what it's answer would be to "do you want to be alive ?" and then support that decision ?

Boy, you must hate abortion ...

(just saying that those things obviously have a brain, and every last kid on the planet will say they want to be alive, so those embryos being aborted can be easily assumed to either be conscious or at least said to be rapidly becoming conscious, and we can be likewise sure they want to be alive as well. Human embryos have functional brains 20 days after conception, which is just barely after a woman would become aware of a pregnancy, and we support abortion up to 6 months or even later, at which point a human embryo has a brain with more functional neurons than almost any animal on the planet, and more than every dog, cat, primate, dolphin)

(and just to defend this research, any research that gets us closer to being able to grow specific tissues - especially neural tissue - has the potential to alleviate the suffering of a great many people that have damaged nerves and/or brains)

But we all know how we judge morals in practice. Things that can complain get preference. Brains in jars won't complain. Nobody will ever make a picture of them showing big eyes behind bars. There will never be a scream or panic reaction available in full-color video of them. So they'll be abused, even tortured, even for very little gain. Because that's how humans judge morality ... in practice. If you believe otherwise, good luck explaining the morality of abortion.

<comment><USER2> Yes abortion has serious moral questions. In that case the brain is being grown inside another human body connected to another brain. That's a far different moral question than a brain being grown by itself in a lab.

When my rights negatively impact your rights it's a moral dilemma. In a lab though, there's no affect in another person's rights by keeping the brain alive, no host body being affected, no physical/emotional pain, no financial responsibilities and no parenting role to factor in.

That's why it seems immoral to me to create a conscious brain and then destroy it or make decisions without it's consent because it only seems like the brain's rights are bring affected. Abortion is more complex because it involves the rights of two brains.

</comment></comment></comment></comment><comment><USER4> > Several of these differences mirror what Muotri has found studying neuronal > development in the brains of children with autism. "I don't want families to > conclude that I'm comparing autistic kids to Neanderthals, but it's an > important observation," says Muotri, who has a stepson with autism. "In > modern humans, these types of changes are linked to defects in brain > development that are needed for socialization. If we believe that's one of > our advantages over Neanderthals, it's relevant."

</comment><comment><USER5> ... wiring the organoids to robots ... = daleks

<comment><USER6> dunno man... expecting a neanderthal brain to crisply repeat a four syllable word is a bit much...

<comment><USER7> That word may be just an audio file in the robot's memory, that is played back when a single particular neuron fires.

<comment><USER8> Ex-ter-mi-nate!

</comment></comment></comment></comment><comment><USER9> Future home of The Island of Doctor Moreau or a Four-Assed Monkey (s01e05). Srsly: At some point, a sizable-enough brain develops a degree of consciousness. Are we really going to test the mad scientist hypothesis that your brain might be in a Petri dish somewhere and that your senses are artificial? NM: [https://nypost.com/2015/08/19/scientist- creates-99-complete-...](https://nypost.com/2015/08/19/scientist- creates-99-complete-human-brain-in-lab-dish/)

</comment><comment><USER10> now all we need is to connect them to a virtual grid of sorts. some kind of brain over silicon tech.

<comment><USER11> BAAS (Brains As A Service). Good idea, know plenty who could use it.

<comment><USER12> One could then provision a fleet of brains as parallel processors to do machine learning.

</comment></comment></comment><comment><USER13> Is this ethical?

<comment><USER14> Could you elaborate? What part do you find to be unethical and for what reasons? What alternate ethical studies do you recommend to gain the same information being gained here?

<comment><USER13> That wasn't a rhetorical question. I'm genuinely curious if this is ethical or not.

</comment></comment></comment><comment><USER15> >>> "We're trying to recreate Neanderthal minds," Muotri says."

Get the pitchforks. This scientist has gone too far. Really. I'm a totally against growing "minds" in jars. I'd be against doing this with any animal brain, let alone something functionally equivalent to human. There are ethical lines that shouldn't be crossed. The concept of a non-corporeal mind living a non-sensory existence in a jar of goo is too horrible to be allowed. This nightmare should live only in the pages of science fiction.

<comment><USER3> How exactly do you think scientists investigate which areas of animal (and human) brains are responsible for which functional area ?

With humans it comes from papers describing the treatment of "brain trauma". Within animals, where the majority of research is done, depending on the animal, they just nail them to a board, or nail a board or a wire into their skull, cut out half the brain, insert some sensors, and record data in the few hours that the pain does not totally immobilise the animals, usually while making the animal perform some trick, like navigating a maze, or looking at prey, or ...

<comment><USER15> The same ways they have done in the past. Persuit of knowledge isnt a free pass to do horrific things. We have rules and they follow them.

In the real world, most knowledge of human brain function has come from people with brain injuries or disorders. For anything above basic motor skills you want a subject you can talk to.</comment></comment></comment>


Show HN: MockREST – Create REST APIs from Your JSON Content - <AUTHOR> http://mockrest.com/ <comment><AUTHOR> Hi HN, I'm a teacher in a local university, and in one of my courses (Service's-Oriented Mobile Development) I need the students to access a CRUD API. Since some of them are not attending my other course (Backend development), and the project is "open" (they can implement a CRUD mobile app for any domain), I've built MockREST to allow them to mock APIs to their wishes.

So, for a JSON like this:

        {
          "person": [
            {
              "id": 1,
              "name": "John Smith",
              "age": 22
            },
            {
              "id": 2,
              "name": "John Doe",
              "age": 23
            }
          ],
          "post": [
            {
              "id": 1,
              "title": "Hello World",
              "format": "text"
            },
            {
              "id": 2,
              "title": "Goodbye Cruel World",
              "format": "text"
            }
          ]
        }

It will allow you to access /api/person (/api/person/<id>/) and /api/post. You can use all HTTP verbs such as GET/POST/PUT and DELETE to change the information, and then access the modified json in the api backend.

I've polished it a little bit, and I'm trying to see if there is a larger interest in this. If all goes well, I may add "pro" features such as longer sessions (the API tokens only last 24h for now), password protection, etc.

Hope you like it, let me know if you find any errors, or have comments or suggestions! Thanks!

<comment><USER2> Looks useful!

Do you plan to open source this and/or try to commercialise it?

<comment><AUTHOR> I'm mostly testing the waters, but if people find it useful in the long term, I would like to commercialise it (probably as a SaaS), maybe by providing "pro" features such as authentication, longer expiration dates for the API tokens, things like that..

</comment></comment></comment><comment><USER3> A small bug: if you hit the GO button without entering an apitoken, you get a 500 server error.

<comment><AUTHOR> Fixed, thanks!

</comment></comment><comment><USER4> Doesn't work...

<comment><AUTHOR> Ups, there's something wrong, I'll have to check..

Edit: it's working now! All new tokens were having the expiration date incorrectly set.

Thanks for lettting me know!</comment></comment>


Overview of JavaScript ES6 features - <AUTHOR> http://adrianmejia.com/blog/2016/10/19/Overview-of-JavaScript-ES6-features-a-k-a-ECMAScript-6-and-ES2015/#.WA4G-3dZebs.hackernews <comment><USER2> I'm surprised by the state of const/let nowadays.

The well-known good practice: use const by default; use let when it's needed. At the release of ES6, it was the way to go. But everyday I notice libraries—and some really famous— that use let everywhere in their docs, or some really influent developers from Google or Facebook who share samples of code on Twitter using let when it's not needed [1]. I don't know why. Seems like most people now think that const is for declaring constants (in the traditional meaning, like const API_URL) when it's just the normal way to declare variables that don't need to be reassigned (so basically most variables).

Dan Abramov said: "some people say const is ugly" [2]. Well, if it's a matter of appearance...

[1] [https://twitter.com/addyosmani/status/789126892402204673](https://twitter.com/addyosmani/status/789126892402204673)

[2] [https://twitter.com/dan_abramov/status/783708858803978240](https://twitter.com/dan_abramov/status/783708858803978240)

<comment><USER3> Is it just me, or is Javascript (and more generally, all front end technology) more susceptible to these trivial holy wars?

While I agree that const/let is a useful convention for communicating mutability, it isn't nearly a big enough deal to warrant the attention it receives from the community.

It's not just const/let; I rarely make a front end PR that isn't bike-shedded to death over subjective styling choices, single quotes vs double quotes, etc. It often feels like conforming to flavor-of-the-week, subjective decrees from frontend trendsetters is more important than the substantive work that your code is doing.

<comment><USER4> > Is it just me, or is Javascript (and more generally, all front end > technology) more susceptible to these trivial holy wars?

\- Tabs vs spaces.

\- Vi vs Emacs

\- Weak vs strong typing

\- where to place {} in block statements

\- where to put commas

No, _programming_ in general is susceptible to these trivial holy wars.

<comment><USER5> Vi vs Emancs? Weak vs strong typing?? tabs vs spaces??? where did you get those??

The ONLY holy war in JS is the semi-colon one

<comment><USER6> That's what OP is saying: programming has plenty of holy wars that predate JavaScript.

<comment><USER5> You are right, I misread his comment

</comment></comment></comment></comment></comment></comment><comment><USER7> The most interesting part about template strings was skipped over: tagged template literals. You can prefix a template string with a function which will get called with the list of string parts and the values passed in ${...} parts, and then it's up to the function to choose how to join the values up into the resulting string (or hell, you could make it return something besides a string if you want). The function can even access the raw version of the string containing any backslash escapes in it as-is. The default `String.raw` function is handy if you're writing something like an SQL query with a few \ characters that need to be in the final query. Both of these strings are the same here:

        const a = "SELECT id FROM foo WHERE name CONTAINS r'\\n'";
        const b = String.raw `SELECT id FROM foo WHERE name CONTAINS r'\n'`;

You could even assign `String.raw` to a variable first, and then make strings look like raw string literals of other languages:

        const r = String.raw;
        const s = r`SELECT id FROM foo WHERE name CONTAINS r'\n'`;

Another good use of template strings is automatic HTML encoding (with a small module of mine on npm): [https://www.npmjs.com/package/auto- html](https://www.npmjs.com/package/auto-html)

<comment><USER8> How does this work? I can't find any examples and I also don't really understand what mechanism makes your npm module work.

<comment><USER7> A tagged template literal is just a special ES6 syntax for calling a function with a specific set of arguments. You could pass a function which returns all of the arguments as an array to see what's passed in. Try the following in the console of a modern browser:

        function log(...args) { return args; }
        log `abc ${'blah'} fooo\n ${12+3} bar`;

Or you could even shorten the above down to this:

        ((...args)=>args) `abc ${'blah'} fooo\n ${12+3} bar`;

The expression will evaluate to this:

        [["abc ", " fooo\n ", " bar"], "blah", 15]

The first argument is an array of the parts of the literal text, and then the rest of the arguments are the values that were passed in. Additionally, the first argument (the array of string parts) has the `raw` property set to point to an array of string parts with the backslash escapes uninterpreted.

Here's an example re-implementation of `String.raw`:

        function raw({raw}, ...values) {
          const parts = new Array(raw.length*2-1);
          parts[0] = raw[0];
          for (let i=0, len=values.length; i<len; i++) {
            parts[2*i+1] = values[i];
            parts[2*i+2] = raw[i+1];
          }
          return parts.join('');
        }

<comment><AUTHOR> Tagged templates look interesting. It's an overlooked feature that not many people know about

</comment></comment></comment></comment><comment><USER9> For those using Babel already or want to use ES6+ on a set of supported browsers: we have started work on [https://github.com/babel/babel-preset- env](https://github.com/babel/babel-preset-env). Would appreciate more testing!

It allows passing in a set of supported browsers and transpiling what is required using the lowest common denominator env (uses [https://github.com/kangax/compat-table](https://github.com/kangax/compat- table) for data).

      // .babelrc with preset options
      {
        "presets": [
          ["env", {
            "targets": {
              "chrome": 52,
              "ie": 11,
              "browsers": ["last 2 versions", "safari 7"]
            }
          }]
        ]
      }

If you have questions, ask below (or make an issue)

<comment><USER10> Wow, this is really excellent. Definitely will give this a shot!

</comment></comment><comment><USER11> "you can start using it right now" if you don't care about IE8, IE9, IE10, and many mobile browsers and are willing to ignore 20% of your customers.

e.g: [http://caniuse.com/#search=let](http://caniuse.com/#search=let)

const does not have block scope in those browsers either, but will work, adding to your debugging confusion.

template literals and multiline string has no IE support at all (you need edge: [https://developer.mozilla.org/en- US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Template_literals)) so you can forget most most enterprise clients

Similar things are missing for most features from the article.

I wonder how many JS dev have to answer to actual customers because none of my clients in the last decade who would have accepted to have a possible failure on 1/5 of their visitors. Are they all bloggers or working in hype start ups ?

<comment><USER2> We use Babel to compile ES6/ES7/ES8 to ES5.

[https://babeljs.io](https://babeljs.io)

<comment><USER11> It's not what the article is about. The article is obviously talking about native ES6 features, otherwise it would advertise es7 features as well and advise to use transpilers.

<comment><USER12> There's no reason why someone using babel needs to use ES2016+ features, they can stick to ES2015 just like this article.

I'd actually recommend avoiding the still-not-standardized features as you'll have less/no change when it lands in browsers.

<comment><USER13> I looked at the prospects of starting a React, Aurelia, or VueJS projects a few days ago and a year ago. Anyone who wants to wait to upgrade to these new things will be really happy to see how much nicer these things get every year. Tooling and starter kits just keep getting better, and best of all, you could probably wait a long time to switch and miss out on nothing important.

</comment></comment></comment></comment></comment><comment><USER14> I always turn to an ES6 article on babeljs.io when I check out ES6 features.

[https://babeljs.io/docs/learn-es2015/](https://babeljs.io/docs/learn-es2015/)

One of the features I like is default parameters. I'd like to add a usage that isn't mentioned in the article. It's really handy to pass optional parameters since default parameters can be nested.

        class Hoge {
          foo({active=true, collapsed=false, silent=false}={}) {
          }
        }

        let hoge = new Hoge();
        hoge.foo({collapsed: true});

</comment><comment><USER15> On the web browser side, I don't recommend using ES6 yet, without any kind of fallback. Internet Explorer 11 is still used, as are devices on older iOS versions. (without counting people using the default browser on pre-Lollipop Android)

<comment><USER16> Also - for anyone writing code where performance matters, the question isn't when browsers _support_ the syntax, it's when each JS engine's optimizations support it.

E.g.: until some months ago just putting "let foo" into a function would cause V8 to bailout (meaning the whole function gets executed slowly, even if the actual let statement gets removed as dead code).

Unfortunately I've never found any good references on the optimizability of ES5+ features, so I've been avoiding them so far.

<comment><USER17> This is a real concern, but it definitely carries the usual caveats about premature optimization and needing to measure regularly to confirm that it is a real concern and that the performance landscape hasn't shifted since the last time you measured it.

The best suite I've seen is [https://kpdecker.github.io/six- speed/](https://kpdecker.github.io/six-speed/) which measures node and the various modern browsers which Sauce Labs supports and appears to be run semi- regularly.

<comment><USER16> That is a great reference, but in general I don't find myself caring much about the raw performance of individual statements that way. My concern is that this or that new syntax will prevent a function from getting inlined, or prevent the engine from guessing type information it otherwise would have guessed, or whatever - just because those bits of the optimizing compiler are newer and less robust.

<comment><USER17> I'd assume the author would be receptive to pull requests for things like the `let` deoptimization.

<comment><USER16> `let` doesn't deoptimize anymore - actually V8 has made great strides here, and a lot of new syntax will go through the optimizer. More generally though, I wouldn't think the stuff I'm worrying about would show up in microbenchmarks.

</comment></comment></comment></comment></comment></comment><comment><USER18> While I'm a big believer in most of the ES6 changes (arrow functions! let/const! classes! generators!), I am not a big fan of many of the new destructuring features. They can actually make your code less approachable if you don't already know what's going on.

<comment><USER19> Exactly, and this is a big problem where I work. I believe code should be readable, even by those with only cursory knowledge of the language. Object shortcuts is also a problem I think. For example, I had a method like this:

const getObj = (id, store) => { return { id: id name: store.something.name }; };

The linter gave an error on it because I used {id: id}. It was like the linter was trying to make my code harder to read.

I think es6 in the wrong hands quickly falls prey to the problems of ruby/scala where it can become incredibly terse and hard to parse unless you are used to the author's particular style.

<comment><USER20> You know instead of:

      const getObj = (id, store) => { return { id } }

You could write:

      const getObj = (id, store) =>  ({ id })

<comment><USER19> I'm pretty sure that's a good illustration of my point.

<comment><USER21> This is a matter of personal preference.

I find `return` to be quite distracting and annoying for a small function that spans part of a line, while you and some others may prefer the explicitness of the `return` keyword.

I would agree that nested destructuring should be used quite cautiously. Code legibility is incredibly important to the success of any serious project.

</comment></comment></comment></comment></comment><comment><USER22> > Because even though the if-block is not executed, the line 4 still redefines > var x as undefined.

This is because of hoisting. Not quite right as described.

<comment><USER16> Yeah, that example should be changed - the "before" version isn't code anyone would write on purpose, and which JSHint/JSLint would flag as a bug.

</comment></comment><comment><USER23> Appreciate the article, but this is relatively dated information. While I can see that many enjoyed the article, many have also been working in ES6 for over a year now. If you're ready to join, I highly suggest everyone make their way to [https://babeljs.io/](https://babeljs.io/) and everything it has to offer resource-wise or tooling-wise.

</comment><comment><USER24> You might as well use babel and then you can use async/await which makes code way more readable.

</comment><comment><USER25> "best practices": "use class instead of manipulating prototype directly"

Who comes up with these "rules"? This is not a hard and fast rule. Manipulating the prototype of an object is not "dangerous".

I'm sick and tired of some loud mouth saying something is dangerous without explaining why. WHY? Why it it dangerous? Don't talk at me. Provide me a sound reason and case to justify what you say. Talk is cheap.

It makes me not trust anything else in this article when someone is flippant.

<comment><USER8> [https://developer.mozilla.org/en- US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto)

This has some warnings at the top as to why.

<comment><USER26> __proto__ !== prototype

One points to the parent of an object and the other points to the object's prototype (which in turn has it's own `__proto__ property). Accessing `prototype` is just fine, but if you want to access `__proto__` then you should use `Object.create()` instead.

</comment></comment></comment><comment><USER27> Ugh. All this "make Javascript like Java" stuff needs to stop.

Cool stuff: Tail call elimination. Arrow functions. Assignment spread for multiple return values and "rest" / default parameters. Proxying (combined with computed get/set on properties) for easy decoration.

Classes and let: meh.

<comment><USER28> Let is a game changer imo. In the world of tens of dependencies, knowing that your variables are scope restricted reduces your cognitive load. It's one less thing that can go wrong.

I agree with you on classes, but that's probably more because I've never been a big fan of OO in practice. It doesn't really seem to have seen much use in the greater js ecosystem though, unlike let/const.

<comment><USER29> Honest question here ---

What is the difference between let and global variables? There are hundreds of articles written about the doom associated with PHP globals, but let appears to be universally lauded. I must be missing something, but I can't tell where.

<comment><USER28> It's spelled out pretty well in the article. But if you want another example, consider these two code blocks:

      var foo;
      var bar;
      {
        let foo = "hello";
        var bar = "world";
      }
      console.log(foo);
      console.log(bar);

This produces:

      undefined
      world

The reason being that the `let` statement restricted that variable to the block it was in (defined by the { and }). `var` declares the variable globally, allowing it to be accessed outside of the {}.

We prefer now to use `let` and `const` over `var` because it doesn't pollute the global namespace. With the asynchronous nature of Javascript, it's theoretically possible for you to declare a variable with `var`, assign it a value, then immediately use that value and find that it's different than what you expected because of another function using the same variable name. This isn't possible with `let`.

<comment><USER29> From the article--

let x = 'outer';

function test(inner) {

      if (inner) {

        let x = 'inner';

        return x;

      }

      return x; // gets result from line 1 as expected

}

test(false); // outer

test(true); // inner

This makes it seem like let creates global variables. Why would you want to return a variable from outside the function? Doesn't that create massive overhead in terms of keeping track where variables are initially set? Easy to understand in this example, but what if let x = 'outer'; is defined at the top of a 5000 line script and this function appears near the bottom?

Edit: Turns out I don't know how to format code. This is in the first example of section 3.1 Block Scope Variables.

<comment><USER28> If you were to then reference 'x' from another block of code, say in another <script> element in the case of web development, 'x' would not be a defined variable, whereas with 'var', it would be.

This is mostly just a case of 'let' restricting a variable to the block it is in, and the child blocks. In your example, `let x = 'outer';` is sort of acting like a global variable, but the importance is that if another script were to be running, it could not access that instance of 'x'.

<comment><USER27> Ehw. Yeah, I sort of assumed that you had a top level function / IIFE (in a .js file, FWIW) in which the var's were nested.

Somebody writing stuff, into the global namespace, directly in <script> tags, has bigger problems :-)

</comment></comment></comment></comment></comment></comment></comment><comment><USER30> I have a question:

What does `for element of arr` buy me over `arr.forEach(element => ...)`

I don't find the for...of syntax particularly appealing or useful, but I might be missing something. Is it a matter of preference?

<comment><USER31> for...of isn't only for arrays. Anything that implements the Symbol.iterator functionality can use for..of, which is pretty nifty for some custom classes and also includes things like the new Map and Set collections, see: [https://developer.mozilla.org/en- US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)

However, even in just arrays there is arguably a benefit. Namely, an extra function being created and invoked with forEach. While in a JITing compiler, the performance difference between for...of and forEach might be negligible (or non existent), you can't always be sure what the JIT is going to do. For hotspots, I would probably prefer for..of

<comment><USER32> If you're not in a JIT, for-of performance is going to be terrible too. Instead of creating a single function (which may not happen _anyway_ in the non-jit case, depending on how it's implemented) you now have to create an iterator result object for every single thing you get out of the iterator.

In a JIT, forEach is actually _easier_ to optimize well (just need to inline the callback function, though of course that can fail for various reasons) than for-of (need to inline the calls to next() on the iterator, need to do escape analysis on the return value of next(), need to do scalar replacement on the return value of next; note that this is a strict superset of the work needed to optimize forEach).

for-of can be nicer to read, and can work on arbitrary iterables. Those are its key strengths. Performance just isn't, unfortunately.

</comment></comment></comment><comment><USER33> I gave a more complete overview of ES6 (and ES2016 and so on) features at a user group last month. Slides:

[http://files.meetup.com/11421852/WhatsNewInJavaScript.pdf](http://files.meetup.com/11421852/WhatsNewInJavaScript.pdf)

The slides are mostly code examples and I tried to go for completeness rather than detail, so there are some mentions you don't normally see in these overviews (e.g. the article doesn't mention proxies).

</comment><comment><USER34> Equally spacing the points on the timeline may make for an aesthetic image, but it fails to illustrate the author's point. "As you can see, there are gaps of 10 and 6 years between the ES3, ES5, and ES6. The new model is to make small incremental changes every year." No, we can't see. In that pretty graphic, ES5->ES6 is exactly the same distance as ES6->ES7.

</comment><comment><USER35> If someone wants to dig more on ES5 vs ES6 , check this presentation (use side arrow for navigation) [http://coenraets.org/present/es6/#1](http://coenraets.org/present/es6/#1)

<comment><USER27> This one is a useful reference, as well: [http://es6-features.org/#Constants](http://es6-features.org/#Constants)

</comment></comment><comment><USER36> Probably add pointers to where the images were taken from.

Ex:

[https://kangax.github.io/compat-table/es6/](https://kangax.github.io/compat- table/es6/)

</comment><comment><USER37> Great article!

It would be fantastic to make all the code snippet interactive with the klipse plugin.

[http://blog.klipse.tech/javascript/2016/06/20/blog- javascrip...](http://blog.klipse.tech/javascript/2016/06/20/blog- javascript.html)

</comment><comment><USER38> If you want to learn ES6 I highly recommend the Tower of Babel interactive tutorial: [https://github.com/yosuke-furukawa/tower-of- babel](https://github.com/yosuke-furukawa/tower-of-babel)

</comment><comment><USER39> What about import from? (modules)

<comment><USER2> In my opinion it's the biggest improvement from ES6. However, you still need Babel to use this feature, even in Chrome/Firefox.

For those interested:

import: [https://developer.mozilla.org/en- US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Statements/import)

export: [https://developer.mozilla.org/en- US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Statements/export)

</comment></comment><comment><USER40> Some of these features are really nice, but JS is on a path to become as complex as C++.

<comment><USER41> That's the natural result of being unable to remove any features to maintain legacy compatibility.

<comment><USER12> Well unlike the majority of C++ warts, JS is doing a very good job of "hiding" it's ugly parts with things like "use strict"

Things like `with` and a bunch of ugly parts were hidden with the introduction of "use strict", and i'm more than confident it will happen again in the future with something similar that can let you "opt in" to an even stricter JS that leaves behind the "current" warts of javascript in favor of much better ways.

</comment></comment></comment><comment><USER42> Can someone smarter than me (not a high bar) explain why they didn't just fix var, rather than introducing let?

<comment><USER43> backward compatibility would be one reason.

</comment></comment><comment><USER44> Helpful article. Small typo on section 3.5. shouldn't 'construtor' == 'constructor' ?

<comment><USER45> Javascript's weak comparison operators aren't _that_ bad.

</comment></comment><comment><USER46> Can anyone recommend books or online courses that teach ES6 for someone just starting out with JS?

<comment><USER47> The book from the "You Don't Know JS" series is very thorough: [https://github.com/getify/You-Dont-Know- JS/tree/master/es6%2...](https://github.com/getify/You-Dont-Know- JS/tree/master/es6%20%26%20beyond)

</comment></comment><comment><USER48> What's interesting is that the author apparently has a QUERTY keyboard layout...

<comment><AUTHOR> ha, I do

</comment></comment><comment><USER49> var's function scope is a feature! You don't have to place variable declarations in the header! (they are hoisted) Placing the var declarations where they are used makes the code easier to understand.

The point of constructor functions is not having to write _new_. So classes does nothing besides syntactic sugars over the prototype system, witch actually makes it more complicated and the code harder to maintain.

Async programming _is_ hard, but not because of callbacks. Promises is just a wrap around callbacks, witch just adds complexity and more boilerplate. It will get better with async/await but I will still prefer simple callbacks.

Arrow functions are very nice for one liners, but will ruin your code if you use them everywhere instead of named functions. You should always name your closures, then it's easier to debug and lift them out.

<comment><USER50> Arrow functions get auto-named in many browsers based on how they are used. This auto-naming is actually being somewhat standardized between browsers and means there is no difference between anonymous-style function () {} and arrow functions.

Promises are more than just a wrapper around callbacks because they also standardize behavior between "stacks" of callbacks, by instead "chaining" them and creating a standard infrastructure for things like error propagation down a chain. That error propagation and the ability for simple action chaining is worth having over "simple" callbacks, even without the syntactic sugar of async/await.

let/const have similar benefits to function hoisting in that you don't need to declare let/const variables until when you use them. In this case the runtime behavior throws an exception if you try to use them before they are declared (in the so-called hoisting dead zone).

<comment><USER49> Promises spreads like a virus so that all asynchronous functions eventually end up returning a Promise. They are hard to understand and it's easy to forget handling errors or return values. I think callbacks are much easier to understand and get right using named functions and closures.

If you want to call everything in serial and wait between each step, why not make it synchronous instead of .then chaining ?

<comment><USER50> There are other high level operations (combinators) with Promises beyond just .then() chains: Promise.all(), Promise.race() out of the box of the spec; others from various libraries. Doing the equivalent with raw callbacks is much more complicated.

The "magic" that Promises bring to code is that they "just look serial" with .then() chains. That's part of the point of Promises and that's part of the infrastructure what powers the ability to write async/await code. Just because it looks nice and serial doesn't mean it is synchronous. (In High Functional speak, Promises are the Continuation monad, and the near isomorphism with synchronous code (especially async/await) is a wonderful product of standardizing the monad.)

Which is to say: tl;dr: Promises spreading like a virus is a feature, not a bug.

</comment></comment></comment></comment><comment><USER51> uhhh edge still hasn't destructuring

</comment><comment><USER52> [a, b] = [b, a];

Great !

</comment><comment><USER53> Using const and `splice` breaks the rules:

const info = [1,2,3,4]

const newInfo = info.splice(2);

'info' has changed

<comment><USER54> The const keyword makes the object _reference_ constant. It doesn't make the object's _value_ constant. You can change the _contents_ of 'info' (info.push(5) is fine). You just can't change which object the variable points to. (info = [] will throw).

If you know C/C++, the code 'const info = []' makes 'info' a _constant pointer to a list_ not a _pointer to a constant list_.

If you want to stop a variable from being changed, use Object.freeze() - [https://developer.mozilla.org/en/docs/Web/JavaScript/Referen...](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)

<comment><USER55> This was what I came to comment on; when introducing ES6 features, this always trips people up. Thanks for "constant pointer to a list, not pointer to a constant list", I will use that next time I explain this.

This also means that objects defined with const can be mutated:

const x = { y: 2 }; x.y = 3;

Doesn't error. However with types that are immutable, like numbers and strings, const really is a constant: const HELLO = "hi" will never change.

</comment></comment></comment><comment><USER56> _destructing is very useful and encourage good coding styles_

Is it? Personally I'd say that was bad code. What so wrong with using the original objects?

Putting aside the need to variable swap once a year or so, all the other examples look really confusing to me and unclear what they're doing. The `Deep Matching` especially.

<comment><USER57> It's really nice for when you have to do operations where you want a "tuple" in Javascript.

Consider the case of finding all companies along with their hires from the last week, but only if the company _has_ a hire from the last week:

        companies.map(c => [c, employeeStorage.getEmployees(c)])
                 .map(([company, employees]) => [company, employees.filter(e => e.hireDate > aWeekAgo)])
                 .filter(([company, employees]) => employees.length > 0)</comment></comment>


So Long, Bill Gates, and Thanks for the Monopoly - <AUTHOR> http://www.wired.com/techbiz/people/news/2008/06/gates_monopoly

<comment><USER2> "But the upside was enormous because the monopoly created a stable environment where entrepreneurs could develop new companies and new products around a common platform."

This is false. Multiple platforms mean porting and compatibility problems, but they evolve faster.

Right now developers are pulling their hair out trying to make things work on incompatible browsers, but who would go back to the days when Explorer had 96% market share?

The Windows monopoly didn't encourage hackers to create new companies and new products. Quite the opposite. Little of the work that hackers did reached ordinary people, because ordinary people used an OS hackers didn't use, and didn't want to write programs for.

<comment><USER3> The Windows monopoly allowed entrepreneurs to develop software for the largest unified computer user-base in the world.

If we agree that the ultimate success of a software development business (or any for-profit business) is rooted in its ability to maximize net income, then how can you explain that multiple platforms and user-base fragmentation are beneficial to that ultimate goal? One massively unified market clearly has more income potential than several fragmented markets that individually require additional effort to enter.

Also -- "because ordinary people used an OS hackers didn't use, and didn't want to write programs for."

If hackers were too stubborn to build for the O/S that clearly had (and still has) market domination, then I would argue that they really were not entrepreneurs when they chose to overlook an obvious business opportunity.

Edit: I hope this comment doesn't come off as abrasive, because it was not my intention. Please respond if you think if I've made a mistake in my argument.

<comment><USER2> _The Windows monopoly allowed entrepreneurs to develop software for the largest unified computer user-base in the world._

I wouldn't deny it. What I'm saying is that a unified user base is not nearly as important as rapidly evolving platforms.

 _If hackers were too stubborn to build for the O/S that clearly had (and still has) market domination, then I would argue that they really were not entrepreneurs_

You're right about that too, though again, wrong about the bigger picture. Hackers aren't motivated mainly by money. When the only businesses you can start are boring or evil, they don't start businesses. But when they do start businesses, the fact that they're driven by curiosity and hope, rather than the mere desire to make money, causes them to create the fastest growing companies of all.

</comment></comment></comment><comment><USER4> "Without that standard, the computer industry in the 1990s would have resembled the web today: diverse, vibrant and flowering with abundant innovation, but also frequently broken because of the inability of disparate products to make the most basic connections with one another."

Wrong. Without Microsoft, the computer industry would have been forced to tackle the issue of interoperability far earlier and more earnestly.

If it weren't for this illegal monopoly, computers today would have a vibrant mix of operating systems and technology that would be able to share information seamlessly.

<comment><USER5> I'm of the opinion that operating systems form a natural monopoly. The average computer user doesn't thrive on diversity. She wants to use whatever her friends use, so they can help her when stuff breaks, they can all share documents easily, etc.

I'm not crazy about the stranglehold Microsoft had on the industry for so long. But I think if it hadn't been them, it would have been somebody else.

<comment><USER6> An operating system monopoly is not necessarily the problem, it's when an operating system monopoly is used to gain a monopoly on applications. In the same way users don't care about diversity, they don't care about operating systems. They care about applications. If Microsoft Office ran on other operating systems AND OPERATED EXACTLY THE SAME WAY (which excludes Microsoft's attempts to have Office and IE on the Mac), then the user could still get help from friends when stuff breaks and share documents.

It may have been someone else, but perhaps that someone else would have been about encourages standards and interoperability and not _application_ lock-in.

</comment></comment></comment><comment><USER7> _"If all that stuff worked right out of the box, we'd all be out of a job," said David Strom, an independent technology consultant and speaker in St. Louis. Strom has a speech praising Gates for, among other things, effectively guaranteeing full employment for IT people called in to make Microsoft products work properly._

This sort of thinking is exactly why hackers I respect stay as far away from Microsoft technologies as possible.

<comment><USER8> I love that the broken window fallacy is being applied to windows.

</comment></comment><comment><USER9> _"If all that stuff worked right out of the box, we'd all be out of a job," said David Strom_

I'm not sure if this argument is used to support monopolies (via fueling the IT industry), but if it is, it's ludicrous. It's like saying that companies insuring against vandalism should thank the vandals.

I do not see "fixing MS bugs"-companies as organic to the IT industry. Sure, more people are employed, but it does not create innovation, it does not contribute to the growth of the essence of the IT industry (different from the GDP resulting from the IT industry).

 _All of these problems are traceable to a lack of widely supported standards._

Pointing to a lack of standards to explain some of today's annoyances (MP3 compatibility, sync issues, etc.) is correct. However, linking the lack of standards with a lack of monopoly in those areas is wrong. I see soft anti- trust policies (in the case of DRM) or lack of motivation for creating standards-making bodies as more interesting causes. Diversity is not incompatible with the existence of common standards. Let's think of all web apps out there, offering competing products, all using HTTP.

</comment><comment><USER10> "it was the open architecture of the Microsoft-based PC that spurred massive creativity"

IBM-based, shurely? I mean, it ran MS software, but if they'd been in the hardware business they'd probably have done what Apple did, and produced a closed platform. That's more-or-less what they did with their software, after all.

</comment><comment><USER11> Standards are one thing, monopolies another.

I guess as the complexity of our systems grow it will be more and more important to keep the technology minimalist and easy to change.

Hmm what was i gonna say. Think virtual machines for example. There could be several different but still compile to bytecode so you could run all kinds of languages on different VMs and different hardware by making layers.

Hmm I will try to get this clearer and post again. But I stand by the first sentence.

</comment><comment><USER12> You know what? I think I'm really going to miss that guy....

</comment><comment><USER13> I just hope that his leaving is more permanent than "You won't have Richard Nixon to kick around anymore."</comment>


Ask HN: How do I go about open sourcing a project? - <AUTHOR> I've been working on a startup idea for over a year, and I have a fully functional prototype. I've decided that I don't want to pursue the idea, but I don't want all of my work to go down the drain. I do mentoring for startups often and find that there is a lot of reinventing the wheel when it comes to getting an MVP going.  It seems that the vast majority of the code that I've written could be repurposed for almost any other web-based startup in a couple weeks. How do I find out whether there's any demand for this and if so are there any guides to properly open sourcing a project? I don't want to just dump the code out into the ether. <comment><USER2> I'm no expert on this and have not yet done it but from what I've seen people used to create a project on SourceForge until it fell into disfavor and now they are putting it on GitHub.

I also have a project which I would like to open source and have been debating where I should put it. It is a processor design so I also have the option of putting it on OpenCores.

I would be interested in hearing recommendations about where I should put it.

</comment><comment><USER3> If you don't have people asking you for source, most likely there is no demand, end of story. Why would anyone work repurposing untested code instead of creating what they need? Sure, people reinvent the wheel, but they know its the wheel that suits them.

<comment><AUTHOR> Nobody knows about what I have. It's not public, and the product never went out of private beta.</comment></comment>


Ask HN: Which dual pane file manager do you use on Linux? - <AUTHOR> <comment><USER2> Two xterms.

Stop asking those boring, artificial questions about uninteresting trivia. There is enough traffic on HN without them.

<comment><AUTHOR> In which capacity are you asking for this? And if you are just a random one from the internet, I decline your request.

</comment></comment><comment><USER3> Midnight Commander: [http://midnight-commander.org/](http://midnight- commander.org/)</comment>


Your decisions can be affected by fleeting images and what you currently see - <AUTHOR> http://lesswrong.com/lw/3b/never_leave_your_room/

<comment><USER2> Related:

<http://www.youtube.com/watch?v=befugtgikMg>

</comment><comment><USER3> As a product owner, I am keenly aware of the correlation between sales people and susceptibility to this phenomena.

</comment><comment><USER4> Ah,

So Subliminal Seduction does work, after all.

Actually, Tor Norrestranders describes in his book The User Illusion how suggestibility by images has been well know to psychology more or less forever BUT how after a movie company began using automated suggestion machines in theaters, the psychology profession essentially suppressed its belief in the power suggestion _because this possibility made the profession extremely sinister to the average person_.

</comment><comment><USER5> So does beer, music, naked woman</comment>


Microsoft's AI Bot XiaoIce to Create 999 Virtual Women - <AUTHOR> https://www.scmp.com/tech/article/3046568/microsofts-ai-bot-xiaoice-create-999-virtual-women <comment><USER2> No bias in tech, say techies

<comment><USER3> This is in China so it pretty obviously has nothing to do with whatever western techies are saying one way or the other.</comment></comment>


Where the Super-Rich Go to Buy Their Second Passport - <AUTHOR> https://www.bloomberg.com/graphics/2018-buying-citizenship/ <comment><USER3> The concept of citizenship and passports always seemed so archaic to me. I never signed a contract with anybody, yet the place I was born in ultimately decides the boundaries of the space I'm allowed to live in.

Thankfully there is a lot of freedom of movement if you're lucky enough to have a "good" passport, but recently we've seen the trend reverse a bit due to the refugee-scare. Hopefully one day everything will be open for anybody.

But just hypothetically, if I want to grab a bike, ride to some isolated forest in France, build a cabin and live the hermit life, I can not to that. I'd be forcefully removed and placed back into my designated space. And force really is the only thing that gives basis to the claim of land. Seems kinda weird. Animals don't care and just move where ever they want to.

<comment><USER4> > _Animals don 't care and just move where ever they want to._

A very very high fraction of animals are territorial and will fight to the death over land claims. You can see this in your back yard if you have squirrels or bird nests.

> _But just hypothetically, if I want to grab a bike, ride to some isolated > forest in France, build a cabin and live the hermit life, I can not to > that._

This is actually a result of fairness on the part of the French government - you are a "nice person" and presumably would not ruin the environment for anybody else if you did that, but if it were legal to show up and make houses in French forests it would only be a matter of time before unscrupulous individuals began to show up and clear-cut the forest, overtaxing it and turning it into an unregulated slum city. Indeed if everyone were nice there would be no need for laws or governments at all.

<comment><USER5> This is obviously correct but also worth noting there is a middle ground. As evidenced by freedom of movement schemes within ASEAN, EU etc. So approaching the ideal of the OP but in a pragmatic way.

<comment><USER6> Well, Schengen grants me freedom of movement to roam to France and live there! So that middle ground does exist.

We are just slowly working toward more homogeneous soceties among which freedom of movement can be allowed - but currently, if we eliminate all borders tomorrow, it would be quite chaotic. What we first need to address are the struggles that make millions of people want to leave their home country, so they can be happy there, and there is no mass exodus from anywhere.

</comment></comment></comment></comment><comment><USER7> Went down a rabbit hole on this one, and though this was an interesting related chart: [https://www.henleypassportindex.com/passport- index](https://www.henleypassportindex.com/passport-index) It shows which countries have the best passports as far as access goes.

Edit: Add some data from these countries

Countries from the Article:

-Austria 186

-Cyprus 171

-Malta 182

-Turkey 111

-Vanuatu 129

-Grenada 141

-St. Kitts and Nevis 151

-Saint Lucia 142

-Dominica 136

-Antigua and Barbuda 149

For reference:

-United Kingdom 186

-United States of America 186

There does not appear to be a correlation between access and price. Though the most access is the most expensive.

<comment><USER8> What would be particularly interesting is intersections for folks who actually do buy multiple passports. If I had a US passport plus a Maltese passport, does that score some higher number of access by allowing you to use the right passport at the right border, or is it still 186?

I hold dual citizenship and I move a lot more easily through many borders than my single citizenship wife does by picking the appropriate passport for that particular entry. No, I didn't buy it.

<comment><USER9> Using their tool ([https://www.henleypassportindex.com/compare- passport](https://www.henleypassportindex.com/compare-passport)) it looks like if you have a US Passport and add a Malta/Austria Passport you add Brazil, Venezuela, and Iran to your visa free travel.

Cuba if you add Antigua and Barbuda

So it'd be 189.

</comment></comment></comment><comment><USER10> Odd that neither Australia nor NZ figure on the list since both do this (passport for cash, ie citizenship pathways for entrepreneurs) and both are heavily used (China) and both are occasionally pointed to (Peter Thiel?)

<comment><USER11> The list would be totally different if the question was where could you get permanent residency for cash - I would guess the US would be at the top of the list along with Singapore, Australia, Cyprus, Canada, and Switzerland (who I think used to let super rich people negotiate their own tax rate)

<comment><USER12> Well, the list does not tell you which income you pay taxes on.

The US is unusual (perhaps unique) in that most rich countries don't ask you to pay taxes on your worldwide income.

So if you have a lot of passive income -- almost the definition of rich -- then you would prefer England or Canada over the US.

Someone might make a comparison of London and Vancouver real estate but there are so many other factors that I am not sure that is useful, but it might be indicative.

<comment><USER11> The article discusses where you can get Citizenship for cash, the OP is addressing Residency for cash (which can lead to citizenship eventually) - those are two different lists.

One's desire to obtain Citizenship may have a very different set of motivations than one's desire to obtain Residency.

<comment><USER12> I agree with your basic point that the list is aimed at purchasing citizenship outright and would look different if you included countries with residency requirements.

I was just pointing out that the US would not top the list if it did.

</comment></comment></comment></comment></comment><comment><USER13> So I'm going to rant about taxes because this is what the underlying issue is: the ultra-wealthy increasingly not contributing to the societies that made their wealth possible and continue to make it possible.

I'm reminded of the talk about the tax cuts passed last year. One of the reasons given for cutting the corporate tax rate is double taxation (paying corporate taxes then taxes on dividends). Australia has had a system for years that solves this problem.

The concept is dividend franking. What this means is that if a company pays 30% corporate taxes on $1 and then passes you the remaining $0.70 as a dividend, you're actually getting two things:

\- Income of $1

\- Credit for $0.30 tax paid

If you're an offshore investor that tax credit gains you nothing. You don't need to file a tax return. You've paid $0.30 in taxes.

If you're resident then if your marginal rate of tax is lower than 30% you'll get a refund on the difference. If it's 30%, no difference. If it's more than 30% you'll pay a little more.

If the US/EU adopted such a system and also applied it in some form to capital gains a lot of these problems would simply go away. By this I mean that some form of withholding taxes are retained from capital gains that you get credit for in your taxes. This is a little trickier than dividends because you have to work out a cost basis but this is a solvable problem.

Then you combine that with:

\- Revenue apportionment of profit. If you earn x% of your revenue in country A then country A taxes x% of your profit; and

\- Loans taken out in country A for $x when an entity has untaxed profits in country B is the same as repatriating $x.

Then you have a much improved situation (IMHO). It also means things like buying citizenship, at least for tax purposes, largely goes away so who cares?

Also, other than outright citizenship there are a number of so-called golden visa programs that give you a path to citizenship but are often much cheaper.

<comment><USER11> Actually there is not much of tax benefit to being a citizen most places (vs resident) - meaning you can accomplish most tax avoidance without actually becoming a citizen

</comment></comment><comment><USER14> The other day I logged into Bank of America (where I used to have a checking account but now just keep a couple of credit cards) for the first time in several months and a popup comes up asking if I have dual nationality. Really guys? KYC is getting a little out of hand here....

<comment><USER15> I noticed that too. I thought it was an ominous development.

<comment><USER14> I happen to have dual nationality with Pakistan (a situation I chose a few years back and not without some regrets now), so I answered accordingly. But what on earth is BoA acting as a front for ICE now for I can't imagine.

<comment><USER15> Well, here are two clues:

[https://www.washingtonpost.com/opinions/citizenship- shouldnt...](https://www.washingtonpost.com/opinions/citizenship-shouldnt-be- a-birthright/2018/07/18/7d0e2998-8912-11e8-85ae-511bc1146b0b_story.html)

[https://www.npr.org/2018/07/04/625980910/white-house- launche...](https://www.npr.org/2018/07/04/625980910/white-house-launches- effort-to-take-citizenship-from-those-who-lied-to-get-it)

I think the Trump administration is quietly launching a strategy to strip a large number of people of their citizenship.

<comment><USER14> I was incontrovertibly born here, so they can throw at me what they like. But my mother, like many people born in South Asia, finds it hard to obtain official birth documentation. When she naturalized she had to have her mother swear in an affidavit as to her birthplace and birthdate.

<comment><USER15> You shouldn't be too complacent. If the "subject to the jurisdiction" argument gains traction (and it might) they could argue that your mother's citizenship is invalid, and that therefore so is yours.

<comment><USER14> She was a legal permanent resident by virtue of marriage to a natural born citizen at the time of my birth, so the question of whether her naturalization is invalid or not should be irrelevant for my case, since it occurred some years later.

<comment><USER15> It _should_ be irrelevant, but it may not be if the anti-birthright- citizenship argument carries the day. If that argument prevails, all kinds of claims to citizenship will unravel, which is exactly what the people advancing the argument hope to achieve.

If you have dark skin you should be particularly worried.

<comment><USER14> As Aasif Mandvi put it, Reverend Al speaks for me, but just.

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER16> The best things in life are free, I'm working on my fourth, with no money down. There are always fees though.

There are surprising ways to get residency and citizenship from all sorts of countries, usually with a commitment of a bit over 5 years.

<comment><USER17> Can you share a little bit more? What passports are you talking about? And also, do you have a specific reason motivating this project?

<comment><USER16> I'm not going to list them for privacy reasons, but they include US and EU, which in my mind are the most powerful for entrepreneurs, especially as a combination.

But you do need some luck and other features. A degree helps a lot, although I don't have one.

I got the US one via the green card lottery, and although that might seem like crazy luck, if you live in certain countries your odds are surprisingly high. I calculated mine where 1 in 10. You just keep on applying.

The EU has pretty amazing visas available if you look carefully (being proficient at the language that Google Translate claims is English is helpful). For instance you can live in several EU countries just by being self-employed. You can then use that to get citizenship over time and live almost anywhere in Europe and even in some Caribbean countries.

Places like Australia (although they're tightening this up) allow you to move there if you're young, English speaking and have the right job or degree (for instance, if you can cook!). Once you're in often there is no requirement to actually work, so you can work on your own project while you pass 4 years to claim citizenship. Then you leave. But you might not want to.

Motivations? Besides flexibility for business purposes and low cost or free high quality health care, I'd say this: the world is becoming a more dangerous place, and being able to escape somewhere safe is comforting.

<comment><USER17> OK, I hold myself both a US and EU passport and I agree with your overall reasoning. I was just surprised by the will to get 4 passports. I feel like once you have US and EU you're pretty much covered.

<comment><USER16> Australia/New Zealand is a very nice to "get away from it all" but the real challenge for me is something nice in Asia.

I'm not really seeking these out they tend just to happen.

</comment></comment></comment></comment></comment><comment><USER18> Among the people with the motivation to get a safe haven and the money to spend on it would be drug king pins and wealthy ISIL funders. I hope they at least perform lengthy background checks on these people.

<comment><USER19> Most of the drug king pins with records are serving time. Background checks on the ones without a record are not effective.

<comment><USER18> These governments could also maybe ask where the money to buy the passport comes from. Then you could check if those investments have any ties to known drug traffickers. That should certainly raise some red flags at least.

Same thing with ISIL funders, ask the person to explain where the wealth comes from and require that the business has to have been audited by the local authorities. It's not perfect, but then at least someone might look into suspicious transactions to known terrorists.

</comment></comment></comment><comment><USER20> "I got 5 passports, I'm never going to jail" ~Jay-Z

</comment><comment><USER21> About 5 years ago I took vacation at St Kitts // Nevis and, somehow, locally learned about the "invest for citizenship" exchange deal they had. Somehow again I was surprised to find them on this list, but this time with a numerical dollar value and how long it's been in action.

The romantic side of me has considered it once or twice had I the disposable liquid cash for it.

<comment><USER22> "Exchange deal" seems like a euphemism for what's going on there: [https://www.theguardian.com/news/2018/jul/12/nevis-how- the-w...](https://www.theguardian.com/news/2018/jul/12/nevis-how-the-worlds- most-secretive-offshore-haven-refuses-to-clean-up)

</comment></comment><comment><USER23> Are there any additional benefits other than the collector value? Can you keep your money in Antigua and Barbuda or Vanuatu to avoid enough taxes that the deal becomes a net positive? Are the banks there reliable enough that the risk is low and you can be confident it's going to work out?

<comment><USER24> Travelling would be the first one that comes to mind. If you're from a country low on visa restriction index ([https://en.wikipedia.org/wiki/Travel_visa#Visa_restrictions](https://en.wikipedia.org/wiki/Travel_visa#Visa_restrictions)) a passport like this could ease your travels significantly.

<comment><USER25> Once you are a high net worth individual, I don't think getting visas would be difficult. My best bet is still to get tax break.

<comment><USER24> There's still much less hassle, and time necessary.

</comment></comment></comment></comment><comment><USER12> Related studies I would like to see:

1\. Which passport gets you access to the most high paying jobs

2\. Which passport has the best low cost education

3\. Which passport has the best low-cost healthcare

4\. Which passport gives you access to cities with dense experiences (I'll let HN assist me with rounding out what that means)

<comment><USER26> Not really related. If you're paying the prices listed in the article none of those listed are of consequence

<comment><USER12> You're looking at the top of the list, and I'm looking at the bottom.

</comment></comment></comment><comment><USER27> So I'll ask the obvious question: Why does Austria ask for $24M for citizenship instead of just denying it?

<comment><USER28> Why would you waste an opportunity to gain $24M? What would be the point of denying it?

<comment><USER29> A country is NOT a business, and there's international treaties and whatnot to consider - what if a terrorist were to buy their way into an Austrian citizenship? What if a wanted US criminal escapes to Austria and hides behind their Austrian citizenship?

There's more factors here than just money.

<comment><USER30> > what if a terrorist were to buy their way into an Austrian citizenship?

Well it would probably work for a short while but if the terrorist matters enough (any terrorist that can come up with 24M probably does) back room politics would happen, said terrorist would wind up being extradited and Austria would get to keep the 24M and whatever they negotiated from the nation the terrorist is being extradited to.

</comment></comment></comment></comment><comment><USER31> Or just repatriate to wherever your (or your spouse's) great grandparents came from for free.

<comment><USER32> That doesn't always work. Some places only care about parents or grandparents, others (like USA) require the person spend a number of contiguous years in the country in order to sponsor family. I have a grandparent who was born in the USA but never lived there long enough to sponsor family.

<comment><USER31> In most places you would need your parents to file their paperwork first, based on their parents or grandparents. I'm trying to get my mother-in-law to repatriate her German citizenship right now so we can do it.

</comment></comment></comment><comment><USER33> You could also just pay someone WAYYYYY less than 100k to marry you for citizenship no?

<comment><USER34> I've seen people go through this process (without money involved, to be clear, they were genuinely trying to live together) in both Canada and the US and it's nowhere near as simple or guaranteed as people think. Maybe it is in some countries, but I'd expect many 'desirable' countries are actively trying to filter out people who marry specifically for citizenship.

<comment><USER17> Having gone through this process in the US myself, I won't dispute the "not simple" part, but how is it not guaranteed? As long as the marriage is done in good faith why would the permanent residency - and then citizenship - <USER2> denied?

There is no CAP for "green cards through marriage" so no waiting list, and the residency period to transition to citizenship is shorter (3 years) than the standard (5 years I believe).

<comment><USER34> Your question has the answer in it: because it can be denied on grounds of not being in good faith. GP post was talking about literally paying someone for marriage to obtain citizenship, literally the opposite of a good faith marriage in terms of this process.

People think it's a rubber stamp, but from what I've seen it's an invasive process where they poke around all sorts of aspects of your personal life to ascertain how 'good faith' your marriage is.

<comment><USER17> Sure, the GP was talking about marriage fraud, but I was under the impression that the post I was replying too was making a general statement that GC through marriage in general was not guaranteed. My bad for misunderstanding.

My XP is only one data point of course, but the process was not invasive at all. We had to provide some documentation (e.g. statements of shared bank account, utility bills with our names), go through a 30-ish minute interview where we had to explain how we met, how we got engage, etc and that was it. Now, maybe when the USCIS suspects fraud they start digging a little more and it gets painful.

<comment><USER34> The people I know had friends interviewed and it took quite a long time (a couple years at least) of that sort of thing for whatever reason. It still took quite a few years for even permanent residence, afaik citizenship was never even obtained.

I don't doubt that the experiences vary. But the entire _point_ of my reply was that you can't just buy into citizenship with marriage because they will deny you if they find out you did that, ergo it is not guaranteed.

</comment></comment></comment></comment></comment></comment><comment><USER35> Turkey? Wondering why would someone want a Turkish passport, especially now?

<comment><USER36> Potentially a future EU member?

<comment><USER37> Ha. In like 20-30 years, assuming that the entire political course of the country does a 180 degree spin and stays on it. It would be faster, cheaper, and easier, to just live in any EU country for 5 years and get the passport that way.</comment></comment></comment>