400 Years of Equator Hazings: Surviving the Wrath of King Neptune's Court - <AUTHOR> http://www.collectorsweekly.com/articles/400-years-of-equator-hazings/ <comment><USER2> In the U.S. Navy, the line-crossing initiation is voluntary, or at least it was when I was in, but it's kind of expected. One of my roommates aboard the USS Enterprise (the aircraft carrier) was an older warrant officer; he'd become a trusty shellback as an enlisted man, but when he got his warrant, the record was misplaced. So when we crossed the line, he went through the initiation again, with the rest of us slimy pollywogs, so that it'd be in his records again. He was a good sport about it.

<comment><USER3> In the USN now, it's completely voluntary and there are very strict rules on what can occur during the ceremony. And probably close to 100% of the senior officers in the Navy are (at least privately) completely supportive of the new policy; the old initiation rituals were definitely illegal and were a constant source of concern for Navy leadership.

In a crew of hundreds, there will always be a handful of honest-to-god sadists who would delight in the chance to pour hot sauce on wogs' genitals and make them crawl on hot non-skidded decks. So one trick the ships do now is to have a all-hands call to announce the ground rules, secretly note the names of everybody who complains about it being too lenient and then make sure that those guys are standing watch during the ceremony.

P.S. Shellback since 1998...

<comment><USER4> About what percentage of wogs choose to go through initiation these days? Does it carry any cachet if they do vs. not?

</comment></comment></comment><comment><USER5> Great story. Having undergone the hazing on a Dutch merchant ship, what stands out to me is how similar the rituals are across countries.

I had almost the exact same experience as the author, only including head shaving.

P.S. Here is my certificate: [http://imgur.com/TPcQ2zu](http://imgur.com/TPcQ2zu). I always take it with me on board, don't feel a particular need to do it again.

</comment><comment><USER6> I crossed a few times as a passenger on a boat in the Galapagos Islands. One of the Australian passengers made mention of it, but the Ecuadorian crew acted like they knew nothing about it. Kind of disappointed nothing was made out of it.

That was also the time I drank the Vice Governor of Bermuda under the table. He, being a vain Scotsman, thought Americans knew nothing about whisky. I, being one who is not culturally retarded in the ways of the booze arts, correctly named the scotch in his flask as Lagavulin 16 year, and it was downhill from there. The Canadians wisely ducked out before we emptied that flask and the boat of wine and beer. The Scotsman called out sick for our morning tours. I was apparently still drunk by that point, because I felt great until about an hour into our second snorkeling trip. Thankfully, cold Pacific Ocean water and exercise are pretty good hangover cures.

</comment><comment><USER7> Crap like this makes me glad I was in the Army.

</comment><comment><USER8> Wog ratio on HN... probably north of 98%

<comment><USER2> It's north of 98% everywhere, I'd think.

<comment><USER9> Probably not in Indonesia, Ecuador, or Somalia?

</comment></comment></comment><comment><USER10> I did some research on this recently, as part of a broader story on hazing rituals in the military. It's fascinating stuff. As a Marine, I've experienced and/or witnessed a fair amount of hazing. It's amazing how defensive people are about these traditions.

</comment><comment><USER11> Living in Singapore, which is just north of the Equator, I have no idea if the local Navy does this since crossing the equator must be a common occurrence.

I would suspect the Indonesian navy doesn't as the country straddles the equator.

</comment><comment><USER12> Tangent: Sturgil Simpson has a great song about some of this called Sea Stories.</comment>


Feedback welcome:  Current project - Salesforce.com Cloud Backup - <AUTHOR> http://www.datatrailer.com

<comment><AUTHOR> We use CouchDB and Python to backup your salesforce.com data which allows us to capture all your history and then when you're ready to take a local mirror, we can just use the CouchDB mirror function to send you all the data on an ongoing basis. Uses rackspace and a pile of open source / free software.</comment>


19 Indian teen students commit suicide after software error botches exam results - <AUTHOR> https://www.firstpost.com/india/19-telangana-students-commit-suicide-in-a-week-after-goof-ups-in-intermediate-exam-results-parents-blame-software-firm-6518571.html <comment><AUTHOR> See the Reddit thread [0] to learn about the pressure on students here in India. The society is the problem, the software but was the catalyst.

That said, as an Indian student myself, I see this situation improving, albeit slowly.

[0]: [https://www.reddit.com/r/worldnews/comments/bi8lrw/19_teenag...](https://www.reddit.com/r/worldnews/comments/bi8lrw/19_teenage_indian_students_commit_suicide_after/)

</comment><comment><USER2> the stakes for passing a stupid test should never, ever, be this high...

<comment><USER3> A friend of mine had a similar scare while studying in europe: missing points, meaning potentially an extra semester, risking the visa and a chance on a masters degree.</comment></comment>


Ask HN: What would you make if you had 1000 hours? - <AUTHOR> I'm just thinking about it. I used git-hours to sum of the parts of a project I worked on and calculated it worked out to over 1000 hours, which roughly correlated with my own estimate of how much I'd put into it.<p>I'm wondering. If you had 1000 hours, what would you build? <comment><USER2> A rube-goldberg machine who's only purpose would be to increment time only as I worked on it. The method of incrementation however would become increasingly complex and confusing... Seriously though, I'd try to come up with an app that would put the power of information into the hands of regular non-technical people. The "power of information" could be a very simple concept using public information with a simple web-based interface, for instance: a dynamic map of all board members of all US companies and their memberships on other boards. This could be expanded easily in a second stage to shed light on campaign contributions. Maybe data-retrieval exists for this but perhaps not as compelling as I'm imagining it.

</comment><comment><USER3> Probably nothing. I usually dream of having weekends for myself but when I do, I don't do anything with them. It's pretty depressing.

</comment><comment><USER4> A contraption let lets you record your dreams so you can play them back. I'm always dreaming of great ideas but when I wake up I totally forget them

</comment><comment><USER5> Cool question. I've always wanted to record an album, I'd do that. Music, vocals, mixing, mastering, prepare some visuals to go with it. Invite some other people to join in where they could.

</comment><comment><USER6> I'm into amateur electronics and I'd love to build a programmable automatic cocktail mixer/dispenser.

Alternatively a small 4 wheeled robot to tinker with.

<comment><AUTHOR> that would be cool

like 3d printer for cocktails

</comment></comment><comment><USER7> I niche product I know would generate some money, but just don't have the time or energy right now.

</comment><comment><USER8> An HN post that displayed __* correctly.

</comment><comment><USER9> Another house

<comment><USER10> I like this. I dream of quitting my job, buying land, building a house, and starting a small farm.

I'm just so tired of the BS in corporate life.

</comment></comment><comment><USER2> Depression.</comment>


China is winning the global tech race - <AUTHOR> https://www.ft.com/content/3530f178-6e50-11e8-8863-a9bb262c5f53 <comment><USER2> I know this article is more about tech companies, but China is winning everywhere. They have started a very ambitious OBOR to connect Europe, Africa and Asia. The Chinese investments in Europe is just mind boggling [0] and the infrastructure projects by the Chinese Govt are spread across the whole Asia, Africa and Europe.

Unlike the USA which offers support and aid by offering money to other countries, the Chinese loan tons of money to build infrastructure and it is so much that the small countries will not be able to pay and literally submit to the Chinese. [1]

[0] - [https://www.bloomberg.com/graphics/2018-china-business-in- eu...](https://www.bloomberg.com/graphics/2018-china-business-in-europe/) [1] - [https://www.nytimes.com/2017/12/12/world/asia/sri-lanka- chin...](https://www.nytimes.com/2017/12/12/world/asia/sri-lanka-china- port.html)

<comment><USER3> > Unlike the USA which offers support and aid by offering money to other > countries

how is the chinese doing any different than what the USA did/might've done with foreign aid and other strings attached loans? In the end, it's a form of empire building.

<comment><USER4> That's a breathtakingly ignorant assertion. The "strings attached" to U.S. foreign aid are there to benefit the country being helped, not the U.S. They are things like economic reforms and measures to limit corruption. There is definitely an ideology behind it, and its paternalistic, but it's not empire building. It's more like evangelical Christianity--the belief that we can uplift people not only by giving aid, but by teaching them to live and govern themselves like we do.

(Source: my dad spent his career doing USAID work; grew up surrounded by USAID, World Bank, etc., folks.)

<comment><USER5> No need to call others' opinions ignorant when you have another one. Here's a good book dealing with foreign aids, among other things:

[https://www.amazon.com/Dictators-Handbook-Behavior-Almost- Po...](https://www.amazon.com/Dictators-Handbook-Behavior-Almost- Politics/dp/1610391845/)

<comment><USER4> I use "ignorant" quite deliberately; the opinion of U.S. foreign aid as having strings attached to benefit the U.S. is literally ignorant of what U.S. foreign aid projects and funding look like.

I haven't read the book, but de Mesquita is addressing something different, the fact that foreign aid can enable bad leaders to stay in power by giving them a flow of benefits they can use to reward cronies and placate the populace: [https://www.nytimes.com/2011/06/10/opinion/10DeMesquita.html](https://www.nytimes.com/2011/06/10/opinion/10DeMesquita.html). That may well be true, but it's a criticism of foreign aid in general; note that de Mesquita is associate with the Hoover Institution, which believes that government-to-government foreign aid is inherently misguided: [https://www.hoover.org/research/better-approach-foreign- aid](https://www.hoover.org/research/better-approach-foreign-aid).

De Mesquita does not contend that U.S. foreign aid is a form of "empire building" intended to make recipient countries dependent on the U.S. or confer direct economic benefits to the U.S. (Even if the U.S. is driven by the possibility of _indirect benefit_ from having more capitalistic countries on the world stage, along with a stable world order, that is something quite different from seeking an "empire").

<comment><USER5> IIRC, he claims that foreign aids directly help autocratic rulers stay in place, by giving them means to pay off their vital support. So he says that it clearly prevents uplifting people or teaching them democracy, since they are the first victims of dictatorship.

<comment><USER4> I'd go even further than that and say that foreign aid helps keep badly-run democratic governments stay in place ( _e.g._ in Bangladesh). Being skeptical about whether foreign aid achieves the desired effect is very different than saying that the U.S. provides foreign aid for purposes of "empire building."

</comment></comment></comment></comment></comment></comment></comment><comment><USER6> According to the article, China is winning because it has more unicorns than others in > 10 billion: 11 are Chinese vs 6 are American. This is just VC pumping its own game.

Massively overvalued Chinese startups fueled by unsustainable shadow debt taking isn't a recipe for success.

"China's campaign against its US$10 trillion shadow banking industry has choked off refinancing for the weaker borrowers". let that sink in......10 Trillion debt that needs to be unwound in China, mostly corporate debt.

"Chinese corporate debt to GDP ratio is already very high by international standards – at 168 per cent in 2017 – and is expected to start rising again as nominal GDP growth declines towards the 8 per cent from an unusually high rate of over 11 per cent in 2017, Fitch said. Further payment problems are likely in a market that has already seen at least 14 corporate bond defaults this year"

[http://www.scmp.com/news/china/economy/article/2149108/curbi...](http://www.scmp.com/news/china/economy/article/2149108/curbing- chinas-corporate-debt-could-hit-economic-growth-report)

Also, this is happening in times of economic slowdown in China, due to trade wars, tariff from US, reshoring of manufacturing back to US, declining FDI, etc.

"China's economic growth slows to multi-decade lows across industrial, infrastructure and retail"

[http://www.abc.net.au/news/2018-06-14/china-growth- stumbles-...](http://www.abc.net.au/news/2018-06-14/china-growth-stumbles-on- weaker-industrial-production-and-inves/9870214)

"Two-thirds of the 21 tech IPOs in the past year are below their issue price, with shares down an average of about 20 per cent through Friday. Leading the wipe out are online financing platforms Qudian Inc and PPDai Group Inc, which plummeted 55 per cent and 48 per cent respectively, while search engine Sogou Inc has tanked 27 per cent."

[http://www.scmp.com/tech/article/2146122/struggling- chinese-...](http://www.scmp.com/tech/article/2146122/struggling-chinese-tech- debuts-dont-bode-well-unicorn-ipos)

<comment><USER3> > unsustainable shadow debt

i keep hearing this term, but what does shadow debt mean?

<comment> rm_-rf_slash Unregulated unofficial loans. They have played a major role in developing China's economy outside of the rigidly regulated financial sector. However their total value and creditworthiness is not entirely known. The Chinese government doesn't want to shut down the shadow debt markets wholesale, because of their outsize influence on the economy, but for the same reason they don't want shadow lending to get too out of hand either. If there is a credit crunch or economic contraction, it will be harder to manage the consequences of unofficial debt than official debt.

</comment></comment></comment><comment><USER7> TFA is blocked. Does it talk about protectionism, cronyism, poor IP enforcement, restrictions on foreign media and communication companies, or forced technology transfer from foreign firms as a condition of doing business in China? These aren't the only factors behind China's rise as a tech superpower, but without them China wouldn't be where it is today.

<comment><USER8> So like most other countries that are now pointing their fingers?

[http://theconversation.com/trumps-protectionism-continues- lo...](http://theconversation.com/trumps-protectionism-continues-long-history- of-us-rejection-of-free-trade-91190)

[http://foreignpolicy.com/2012/12/06/we-were-pirates- too/](http://foreignpolicy.com/2012/12/06/we-were-pirates-too/)

[http://www.spiegel.de/international/zeitgeist/no- copyright-l...](http://www.spiegel.de/international/zeitgeist/no-copyright- law-the-real-reason-for-germany-s-industrial-expansion-a-710976.html)

<comment><USER9> Do these other countries continue to enjoy WTO Developing Nation Status, which enables a lot of the unfair advantages China enjoys as pointed out by the grandparent comment?

[https://www.wto.org/english/tratop_e/devel_e/dev_special_dif...](https://www.wto.org/english/tratop_e/devel_e/dev_special_differential_provisions_e.htm#legal_provisions)

Pointing out the historic cheating of now first world countries is fair if questionably relevant, pointing out Donald Trump's raising of tariffs as hypocrisy (I assume) is down right silly, especially in the context of this conversation.

<comment><USER8> > _Do these other countries continue to enjoy WTO Developing Nation Status, > which enables a lot of the unfair advantages China enjoys as pointed out by > the grandparent comment?_

No -- they don't need it as much, as they already climbed the lax- IP/protectionism ladder for centuries to get high.

Now they insist nobody currently lower than them should use the ladder.

<comment><USER9> Taking your last sentence literally, is that actually your honest assessment of this dispute, in its entirety?

<comment><USER8> My actually assessment of this dispute is even worse.

<comment><USER9> "Now they insist nobody currently lower than them should use the ladder."

How might you know this though? No one has said anything out loud even remotely comparable to this, so how might have you formed this conclusion? What information source are you using?

I'd be quite interested to hear your actual full assessment if you have the time.

<comment><USER8> > _How might you know this though? No one has said anything out loud even > remotely comparable to this, so how might have you formed this conclusion? > What information source are you using?_

Are you kidding me? The party line from western politicians, establishment media (NYT, Economist, and so on), and establishment (read "state sponsored") think tanks, are exactly that: "Do as we say, not as we did".

<comment><USER9> I have a feeling you're not aware of the human mind's capabilities as it relates to realtime classification, association, translation of sentences into far more detailed and colorful ideas.

Let's test this theory: post the most compelling _actual_ evidence you have that backs up the claim:

"Now they insist _nobody_ currently lower than them should use the ladder."

<comment><USER9> Is a downvote considered compelling evidence now?

Something to as yourself in private: why do you believe what you believe, with such conviction, if you are not able to defend it intellectually?

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER10> Interesting article by Michael Moritz of Sequoia Capital.

China is taking the lead.

"All lists of private companies contain degrees of subjectivity and error, but the Wikipedia ranking of unicorn start-ups by value offers a peek into the future. For westerners, it should be disconcerting. Of the top 50 entries, 26 are Chinese and 16 are American. There are none from Europe. The Chinese also dominate the proportion of the most valuable of these companies. Of the top 20 with an estimated market value of over $10bn, 11 are Chinese, six are American and two are Indian. "

<comment><USER11> Europe needs to build its own tech ecosystem instead of being a resource hub and market for US companies. There were some sense in the French driving Peugeot, the Germans VW and the Americans Ford, instead of all driving a generic car from a distant silicon valley company far away from local market and value chain.

<comment><USER12> I don't really understand how Europe has struggled so much. Is it due to a lack of investors? Brain drain or some comparative lack of talent (I doubt it)? Regulations (also doubt it)? Cultural differences? Difficult domestic market?

<comment><USER13> Probably a combination of all three. The US and China have the benefit of a comparatively gargantuan native population that all speak the same language and enjoy similar tasting kool-aid that you can immediately market to. A business in SF can reach people NYC, Florida, etc. Combine that with somewhat lax customer rights laws (however you may view it), and you have recipes for some explosive growth.

I've also heard that European investors are notoriously conservative in their strategies and don't take the risks that the US does. Japan is also faltering in this department for that reason. Without the pools of money to draw from, if you cannot gamble then you cannot win, essentially.

<comment><USER14> > Probably a combination of all three. The US and China have the benefit of a > comparatively gargantuan native population that all speak the same language

As odd as it sounds, my understanding is that China's Han population _doesn 't_ all speak the same language, but they (for the most part) _read /write_ the same language. They call the variations in spoken language "dialects," but many of them are mutually unintelligible. I think the situation is the similar to a hypothetical one where the Romance countries (e.g. France, Spain, Italy, etc.) speak their respective modern languages, but continue to write exclusively in Latin.

Just a small unimportant quibble that doesn't negate your larger point.

<comment><USER15> Still, the difference is size. In China, 20 million people speaking the same language is a city. In Europe, it's a country.

</comment></comment></comment></comment></comment></comment><comment><USER16> The bigger China grows the more important IP and patents will become thus making it like all the rest. India will be the next giant to be exploited.

</comment><comment><USER17> Meanwhile ZTE goes bust if it can't buy American chips. I dont see any Chinese tech that is unique.

<comment><USER18> Do you mean Qualcomm chips and smartphone tech that practically every runs every smartphone in the world? I can see how that would impact ZTE's smartphone business...

[https://en.wikipedia.org/wiki/Qualcomm#History](https://en.wikipedia.org/wiki/Qualcomm#History)

<comment><USER19> Completely OT, but I just realized that Qualcomm the chip company and Qualcomm the email software company are one and the same. Don't know why I never made that connection before.

</comment></comment></comment><comment><USER20> I wonder if the reason for this is mainly due to how much leeway you have as long as you use your technology for the benefit of the ruling party. Isn't it much easier to work on things like harvesting personal information if you don't have GDPR breathing down your neck? Hell the government might even help your tech startup with basically unlimited cash as long as you help them with your tech.

<comment><USER21> > _as long as you use your technology for the benefit of the ruling party_

The dark side of this leeway are demands for patronage from middle-level bureaucrats.

</comment></comment><comment><USER22> I believe China is too unbalanced in their IP protection in order to 'win the tech race'. They either have a monopoly that controls the market via Chinese gov, or there are no rules at all and everyone will backstab you. I believe that these conditions are unfavorable for true technological innovation.

</comment><comment><USER23> Paywalled. I can't read this.

<comment><USER24> maybe:

try via twitter link ( [https://twitter.com/FT/status/1008323779360157696](https://twitter.com/FT/status/1008323779360157696) ) - and open in a new incognito window.

</comment></comment><comment><USER25> They are winning more than the global tech race.. :(

</comment><comment><USER18> I think most people voting / commenting are not actually able to read the article due to paywall. Adding the text so discussion is more substantial. @HN not sure if this goes against any rules, my feelings won't be hurt if the below is removed.

 _Cast your eyes down the list of the world's most valuable private technology companies and you might be put in mind of the 2008 Beijing Olympics. That's when China ran away with most of the gold medals — even though the west focused on the accomplishments of the US swimmer Michael Phelps. The same trend is evident in the list of technology "unicorns" worth $1bn or more. Uber, Airbnb and SpaceX may be hogging the limelight, but the undisputed gold medal leaders are the Chinese.

All lists of private companies contain degrees of subjectivity and error, but the Wikipedia ranking of unicorn start-ups by value offers a peek into the future. For westerners, it should be disconcerting. Of the top 50 entries, 26 are Chinese and 16 are American. There are none from Europe. The Chinese also dominate the proportion of the most valuable of these companies. Of the top 20 with an estimated market value of over $10bn, 11 are Chinese, six are American and two are Indian.

Topping the list with an estimated value of $150bn is Ant Financial, the financial services spin off from Alibaba. Its value rests on the opportunities investors believe lie ahead in China and, increasingly, in south-east Asia.

Many California-based technology investment bankers — eager to haul in trophy initial public offerings — are now romancing more companies in China than at home. Smartphone maker Xiaomi has already filed to float in Hong Kong, which must be disquieting for the US exchanges. Ride-hailing app Didi Chuxing and Meituan are among the bankers' other targets.

The growth rates of leading public technology companies underline the same trends. For the year ending March 2018, the top five US companies grew at a 26 per cent median clip, while the top five Chinese entities jumped 33 per cent.

The US companies are generally larger, but Chinese companies are narrowing the gap. As 2016 dawned, the top five Chinese companies were worth one-quarter of their US counterparts. By the end of March 2018 this had risen to one-third. Right now, Facebook, the fifth most valuable US tech group, is just ahead of Alibaba, with Tencent not far behind. No wonder that Chinese youngsters looking for role models evoke the names of Jack Ma, Pony Ma, Lei Jun (founders of Alibaba, Tencent and Xiaomi) more than they do Amazon's Jeff Bezos, Facebook's Mark Zuckerberg, or the late Steve Jobs of Apple.

Chinese internet companies also stand out because they are purchasing stakes in many of the more interesting, younger private technology companies. It is somewhat akin to real estate companies snapping up the best beach-front property.

Most Chinese activity is outside the US, with Tencent and Alibaba building vast constellations of satellites. Tencent has more than 600 investments, while Alibaba has around 400 — totals that almost make Japan's SoftBank look like a penny-pinching slowpoke.

Critics of this approach may gripe that it is undisciplined, but the admirers argue that these investments are somewhat akin to Chinese premier Xi Jinping's ambitious and far-reaching Belt and Road Initiative. The only US company that comes close is Google, which since the start of 2017 has made more than 100 investments, although they are heavily concentrated in the US. It has also purchased more than 80 companies outright since 2014.

Another transpacific difference involves the use of cash. Between 2015 and 2017, the five biggest US tech groups (especially Apple and Microsoft) spent $228bn on stock buybacks and dividends, Bloomberg data shows. During the same period, the top five Chinese tech companies spent just $10.7bn and ploughed the rest of their excess cash into investments that broaden their footprint and influence.

It's hard to escape the view that the Chinese groups are — like all of us — creatures of their heritage. They are using their investments as one way to help fulfil the ancient Chinese definition of the Middle Kingdom — as the centre around which all else revolves.

The writer is a partner of Sequoia Capital. The views expressed are his own and he may own shares in companies mentioned_

</comment><comment><USER26> This is propaganda. China is mostly an uneducated factory nation who will be crushed by automation. Articles like this are great for clicks on a website.

Edit: which Chinese tech companies are actually dominant? All of them are copies of American tech companies propped up by their government. Where is the market penetration into the USA? Where is the competition? There is none.

<comment><USER18> Author is Sequoia's Michael Moritz who has a decent amount of credibility here. I think his last few articles on China have been more around warning US tech companies not to get complacent, rather than trying to convince people that China is a tech holy land.

As for the part about being an uneducated factory nation, the latest PISA findings from 2015 would have China scoring higher than the US on math (10th vs. 25th) and science (6th vs. 40th), but slightly lower than the US on reading (27th vs. 24th).

<comment><USER3> > Sequoia's Michael Moritz who has a decent amount of credibility

but you have to also think whether he's biased in wanting to push the view that the next big tech hub is in China, because he's invested in the region. Making the hype machine so that when time comes to exit, there's plenty of doofus who will believe the hype and buy into the market.

it's very hard to know what to believe, and even more effort to do research. Most people won't be doing it, so it's an effective method to generate hype.

<comment><USER27> > but you have to also think whether he's biased in wanting to push the view > that the next big tech hub is in China, because he's invested in the region.

He puts his money where his mouth is. I made another comment here that it was refreshing as it didn't predict the collapse of China which has been peddled for the past few decades by so-called experts - they could peddle any view they want with no financial repercussion.

Secondly, even if Moritz was biased and published this article for his own gains, it's not as if we (foreigners) have easy access to invest in the region.

> it's very hard to know what to believe, and even more effort to do research. > Most people won't be doing it, so it's an effective method to generate hype.

I heartily agree with you here, but you have to admit for every article like this, there are 10x more about the imminent demise of China, so I don't buy the argument that this article's hype will override 'collapse' articles which generate much more clicks.</comment></comment></comment></comment>


Can ARM Kill Intel? - <AUTHOR> http://www.electronicsweekly.com/blogs/david-manners-semiconductor-blog/2010/11/can-arm-kill-intel.html <comment><USER2> Amateurs discuss tactics, professionals discuss logistics.

Intel has so much FAB capacity that they can't easily be killed even by superior competing products.

<comment><USER3> They also usually have the smallest process technology of the time. If necessary, Intel could fab ARM chips and dominate the ARM market from the inside.

<comment><USER4> Precisely what I was thinking. Does anyone know if there is a reason Intel hasn't just acquired ARM? I assume Intel believes that they might still be able to compete and win in the market, but that seems to be less true every day.

(I assume the answer is that it would raise a bunch of anti-trust flags everywhere, but I'm not positive about that.)

<comment><USER5> > Does anyone know if there is a reason Intel hasn't just acquired ARM?

Intel had an ARM license and got rid of it, which suggests that Intel doesn't think that ARM is worth the trouble.

<comment><USER6> If Intel got rid of its ARM license, how do they build all these?

[http://www.intel.com/design/iio/index.htm?iid=ipp_embed+proc...](http://www.intel.com/design/iio/index.htm?iid=ipp_embed+proc_io)

Intel makes several 'families' of ARM (Xscale) based parts: IXP, IXC, IOP, PXA and CE. Intel sold the PXA family to Marvell Technology Group in June 2006.

The simple fact is that Intel still holds an ARM license even after the sale of the PXA family to Marvell.

<comment><USER5> > If Intel got rid of its ARM license, how do they build all these?

You're right - I misread what happened with StrongArm.

</comment></comment></comment></comment></comment></comment><comment><USER7> In the last 2 years we have seen many ARM netbooks prototypes showing better battery performance and cheaper price than Intel netbooks. But I still can't buy an ARM netbook. Where are they? What is holding them back?

<comment><USER8> Lack of an operating system with mass-market appeal in the netbook space, as far as I can tell.

<comment><USER9> I assume the Windows OEM prices have been tuned so that it's more expensive to develop and manufacture ARM-based netbooks that run Linux than it is to stick with x86 for the current generation.

Also, the processor is not responsible for a huge part of the power consumed on a netbook. Disk, screen and memory seem to be a big part. If you make a netbook that can run Gnome and Firefox decently, it will have a hard-drive (or SSD) and a couple gigabytes of memory. The LCD is the same.

<comment><USER10> If you sell an ARM powered netbook that means no windows. So you can wave goodbye to being able to use OEM copies of windows on any other products that you make.

So anyone like Asus or Acer that have a PC business and launch a non-windows netbook soon learn the error of their ways.

<comment><USER9> They can sell one line of Windows-proof highly capable, futuristic computers while keeping and developing their legacy-ish, kludgy, virus-infested, Windows-bundled, 8080-descendant-based inefficient lines.

Of course, Microsoft will probably find a way to increase their OEM pricing, specially if the Windows-proof line ends up making a dent on the Windows- bundled lines. And they don't even need to increase, say, Asus's licensing prices. All they have to do is to lower Acer's.

<comment><USER10> MSFT tend not to increase pricing they tend to say - ship even one computer without Windows and you wont be buying OEM Windows for any of your other machines.

<comment><USER11> They've gotten in rather a lot of trouble for doing that in the past. Do you have any evidence that they have been doing it since the emergence of the netbook market?

<comment><USER9> > Do you have any evidence that they have been doing it since the emergence of > the netbook market?

The Windows-based netbook market?

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER12> I prefer to think of this in a Christiansen disruptive technology context. Technologies grow upmarket beyond the needs of its user base and create a disruptive opportunity for downmarket technologies.

I recently made a comment about this on an Intel blog article (SC10: Jeff's Notebook - Innovation and Disruption: How a Successful Company can be gone in 10 Years): <http://intel.ly/dZAxKk>

</comment><comment><USER13> "People in the mobile phone architecture do not buy microprocessors," says Hauser, "so, if you sell microprocessors you have the wrong model. They license them."

Someone is building them. In iPhone's case its Samsung. The phone's Apple- designed A4 processor, which was built by Samsung, costs $10.75 each. Most of that is going to Samsung, part of that goes to ARM. The ASP of ARM 10-20x lower than that of Intel.

<comment><USER6> Someone seems to have forgotten that ARM means "Advanced RISC Machines, Ltd" and that Acorn, Apple and VLSI were partners in A(dvanced) R(isc) M(achines).

Of the three (Acorn, Apple and VLSI), only Apple is really still around. Apple must already have significant equity position in ARM being a founder.

VLSI was bought by Philips Semi, which was later spun out as NXT. NXT is a user/licensee of the ARM architecture but not even the biggest one by a long shot.

Intel's revenue from ARM (and yes, they still make some Xscale parts) is probably bigger than all of NXT's revenue.

Acorn went belly-up as a going concern in 2000 with the remains bought by Morgan Stanley.

The ARM "JV" IPOed (as ARM Holdings).

In any case, I doubt that Apple pays much, if anything for its ARM license.

And I doubt we really know what Apple pays for A4 parts.

</comment></comment><comment><USER14> In the server markets, you look at performance per watt and performance per rack unit and ease of setup - for general purpose computation, Intel still dominates those metrics. (with some exceptions [1]). Being ahead in fab technology, it can take the performance hits due to the legacy x86 architecture.

You can replace 1 beefy server with 8 small nodes, but you can not replace the convenience of administering that one server.

Also, retargeting performance-sensitive JITs/compilers/maths libraries such as GCC, LLVM, Java, V8, *BLAS is no small feat either - x86 gets support first, because it is the market leader, and also gets tuned the most, since it's the oldest backend. A feedback loop that's hard to break, so don't expect Intel to go out of business any time soon.

[1] <http://www.cs.cmu.edu/~fawnproj/>

</comment><comment><USER15> I don't see how intel is even a target. PowerPC owns gaming. There are still tons of MIPS chips in networking applications as well as some other verticals. ARM owns phones, largely because every phone has a custom chip in it. It's not clear if it will grow beyond that.

Why not suggest ARM will defeat PowerPC or MIPS? That sort of seems plausible, Intel is so insanely good at what they do and they backed out of ARM a few years ago. I can't imagine they did that without understanding how they'd compete.

<comment><USER16> i think you're talking about console gaming perhaps, xbox and wii use powerpc variants, but ps3 uses the cell processor and nds uses an arm processor. in terms of mobile gaming, powerpc is nowhere to be found, this is owned by arm. in terms of pc gaming, intel and their we're-not-totally-a-monopoly division, amd, own that realm. though arm is starting to make inroads into low powered servers so it'd be interesting to see where this goes in the long run.

<comment><USER17> Cell is a PowerPC variant.

<http://en.wikipedia.org/wiki/Cell_(microprocessor)>

</comment></comment></comment><comment><USER18> ARM is not really friendly with competitors especially those not paying the high license fee. Do you remember the nnARM project at OpenCores? this has been removed on request by ARM limited. If ARM wants to "own the market", they should allow in some ways competitors to build compatible CPUs.

<comment><USER9> > they should allow in some ways competitors to build compatible CPUs.

They allow you, or anyone, to build compatible CPUs. You just have to pay for the privilege.

</comment></comment><comment><USER19> I wouldn't be surprised if Apple will make Mac OS 11 run on ARM only.

<comment><USER20> Not while anyone wants to run Windows in a VM, they won't.

<comment><USER21> You can bet Microsoft will make Windows 8 ARM compatible. They don't want to lose the tablet market and since Intel is having such a hard time getting into that market, they can't simply rely on them.

And if you're going to suggest WP7 for tablets, don't. Microsoft will only do that in worst case scenario if Windows 8 will prove to not be good enough for tablets. They don't want to get $10 per license when they could get $50, and that's especially true if touch/mobile computing will replace desktop computing.

<comment><USER11> The way Microsoft has handled the mobile market for the past 15 years, it seems likely that they'll go through at least two or three more mobile operating systems before the market can decide whether x86 belongs in handheld devices.

</comment></comment></comment></comment><comment><USER16> from the article, "stifled innovation", "monopoly", i wonder how true that is, where would we be if any of this was true, would we have a more awesome chip in our laptops today?

i'm pretty excited about gpu's, but they're only good for parallel instruction processing, some tasks still require the usage of a highly spec'd cpu.

whatever happened to transmeta?

</comment><comment><USER22> Has ARM's design licensing model ever been demonstrated in the high end (server/workstation) CPU market? It seems to me that the amount of engineering expertise required to push that sort of high performance, fully custom design through to fabrication would make it difficult.

<comment><USER23> Isn't that how SPARC worked? Of course, you can argue it failed after a while... <https://secure.wikimedia.org/wikipedia/en/wiki/SPARC>

</comment></comment><comment><USER24> Intel builds ARM processors. This article sucks.

<comment><USER25> Sources?

<comment> a-priori More accurately, they _did_ build ARM chips -- the XScale line. But they sold that division to Marvell in 2006, although they still retain an ARM license.

<http://en.wikipedia.org/wiki/XScale>

<comment><USER6> Even more accurately, they still DO build ARM chips. They only sold the PXA processors to Marvell.

Could you maybe _read_ the Wikipedia article next time?

<comment> a-priori I appreciate the correction... but there's no need to be nasty.

</comment></comment></comment></comment></comment><comment><USER26> ARM could probably kill x86 given some time, if that was what the writer implied - and let's just wait a few years and see how things currently brewing will develop before we start shooting off our downvotes, shall we? I am willing to bet that an often-blamed-for-being-fruity computer manufacturer will shortly migrate from x86 to ARM. Just wait.

Killing Intel themselves, though, just won't happen. If anyone can dominate the CPU market wielding ARM in their hand (haha!), it's Intel. The rest of the world has a good few years to go before catching up to their level in terms of manufacturing.</comment>


Deep work in practice: reimagining my workflow for radically less distraction - <AUTHOR> https://alexdenning.com/deep-work-in-practice/ <comment><USER2> I recently had to go through the process of "re-learning how to work." I didn't realize how bad I was at deep work, as the article references it as, until I quit my job and set out on my own full-time.

I found that I was replacing the normal interruptions of the office - meetings, email, phone calls, lunch; with getting distracted on social media, general reading, checking alerts, etc. It was like my brain was conditioned to expect a distraction and thus made me seek it out.

It took some effort, but making sure I am organized for the week has really helped as I know what I need to get done. Also, I've now been able to use my "distracted level" as a litmus test of how organized I am. I know when I'm not focused as much as I should, I need to spend some time on my planning.

edit: grammar

<comment><USER3> whew! you're nailing it, good thing you're not taking silly breaks like going on hacker news and posting comments instead of working!

<comment><USER4> Deep work is not only about spending maximum time on what you really want to do. It more on how you get the maximum efficiency out of it.

And oh yes, "deliberate distraction" is highly recommended while doing deep work. So there is nothing wrong posting comments related to deep work on HN. :)

</comment></comment></comment><comment><USER5> I think self-control should be valued higher than self-restriction. With self- restriction I mean blocking bookmarks (hindering you), not muting the phone (removing outside distractions). To me this self-improvement through shedding responsibility is scary. It's the same for fitness tracker that tell you when to do. (I have to admit there is some grey area in between though. Some habit forming can be beneficial ((e.g. _allways_ riding the bike to work))

Personally I like small breaks between the tasks, but only if I change work contexts anyways. Do people really have a problem just riding the flow and not heading off to hackernews mid-task (honest question)?

edit: here I especially don't get the "pomodoro" technique where you are interrupted by your own alarm every 20 min.

Btw: noisy music works wonders for me sometimes (other times it's Bach I admit, but even than: loud Bach)

<comment><USER6> It's a nice sentiment, but the products/sites/apps that aim to suck our attention are designed to exploit human weaknesses via dopamine release, variable reward etc. (see the book Hooked), making it exceedingly difficult and potentially expending your finite store of willpower on things you could much more easily avoid altogether.

Personally, cultivating the self-control to avoid checking facebook.com is less interesting to me than editing my hosts files to block it, and using my willpower for more rewarding tasks (exercise, learning piano etc.)

With that, I'm turning my block back on HN :)

<comment><USER5> I kinda block my facebook newsfeed via CSS, but just to be able to access chat without having to read the feed if I don't want to (remaining just one click away from toggling it back on). (you can also do that my typing an invalid url and setting it as your facebook bookmark, e.g. [https://www.facebook.com/asdfgwhatever](https://www.facebook.com/asdfgwhatever) )

<comment><AUTHOR> News Feed Eradicator is really good for this. You can also use messenger.com to access chat without any other notifications - [https://chrome.google.com/webstore/detail/news-feed- eradicat...](https://chrome.google.com/webstore/detail/news-feed-eradicator- for/fjcldmjmjhkklehbacihaiopjklihlgg)

<comment><USER5> oh thanks, the web version looks good. I just tried the windows metro app and it failed to notify on new messages all the time...

</comment></comment></comment></comment></comment><comment><USER7> A key skill in focusing on something is _realizing_ when you have become distracted and bringing your attention back to the task at hand. The sooner you do this, the better. Usually we tend to get carried away by stimuli and become "lost" for long times at stretch. This not only eats up time, but also consumes mental energy that we could have otherwise used for productive work.

I have been successfully using meditation as a "model problem" to train my ability to become aware when I have become distracted and bring my attention back to the object of focus. A classic analogy of mindfulness meditation is that of an elephant (your mind) tied to a post (your breath or whatever is the object of your focus) through the rope of mindfulness. When the elephant strays, the rope pulls it back to the post.

While there seems to be some scientific evidence that meditation does indeed improve your ability to concentrate on any general task, my own conviction arises from seeing first hand the similarity between countering distracting stimuli during meditation and during general work.

</comment><comment><USER8> Since February 2016, I started working with a timer.

I have an agreement with myself that if a timer on my phone is set for 15, 30, 60, 120, 180 minutes, I should work non-stop without any distractions (no food, no music, nothing except my work).

Since then, it's much more easier for me to work really hard and be very focused.

If I'm too lazy to set timer for 3 hours, then I set for 15 minutes. It's easy to convince yourself to work hard during 15 minutes. Then I usually become warmed up a bit and set a new timer for 30 minutes, then for 60 etc.

I also keep track of how much time I spend daily. For example, in October, I worked purely on algorithms like this:

01.10.2016 4

02.10.2016 6

03.10.2016 1.75 2

04.10.2016 2 0.75

05.10.2016 0.5

10.10.2016 0.5

11.10.2016 0.5

12.10.2016 1

13.10.2016 0.5 1

14.10.2016 1.5

15.10.2016 1 2.5

16.10.2016 0.25 2 2.5

17.10.2016 1.25

18.10.2016 0.5

Numbers are hours. I.e. 0.5 = 30 minutes. Several numbers mean that I had pause/time gap in between.

Algorithms/math and problem solving olympiad problems require a lot of really hard work. With a timer, I'm working much more effectively like I never did before.

P.S. Why timer on a phone instead of a computer? Well, it's easier for me to just click and close window on the computer. If timer rings on phone, I have to get up and walk to the phone (I intentionally put it on the next table).

By the way, it's very good to keep a journal because overtime your collected data about yourself become valuable. For example, I plan to draw a graph with moving average, so I would see overall picture how dedicated I'm. If you don't have such data, it's easy to fall into trap convincing yourself how good you are (like I did before).

</comment><comment><USER9> The irony of Hacker News articles on productivity and focus is not lost on me.

</comment><comment><USER10> I tend to fall into the distraction trap for days/weeks at a time. It's hard to notice until you take a step back and realize how little was accomplished over a given time period.

"This is all a lot easier if you're working on interesting and important things." Definitely one of the more important points made at the end of the article and, unfortunately, not always something within our control.

I was recently reading about learning theories (during a period of distraction) and noticed a possible relationship between Vygotsky's Zones of Proximal Development [1] and distraction. There must be a point of inflection between "completely distracted" and "deep working focus" where we feel compelled to switch off a current task or procrastinate. Maybe a similar scaffolding approach can be used to ease you back on task.

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

</comment><comment><USER11> My experience is pretty similar to the author's. The number of distractions that exist in my life have been pretty constant since I started using dial-up BBSes in the early 90s. I could chat with friends instantly, download games/porn, war-dial and find new systems to (unlawfully) play with.

However, when I was away from my computer I was less distracted and could get a lot of (high school) work done. Cell phones are pretty much the only technology that has made distraction ever-present. That giant box with the 12-lb keyboard that used to sit on my desk at home is now shrunk down and within arm's reach at all times. It does pose a problem.

Also, the modern office is a place of distraction; especially open-format offices. I work in one of these and I generally avoid coming into the office if I have some detailed work I have to do. Managers don't seem to realize what an awful place those types of offices are for actually getting work done. High ceilings that bounce noise, inconsistent temperatures, seeing frequent movement out of the corner of your eye, people goofing off two rows away.

I've already picked up some of the behaviors the author details. I don't use social media (except LinkedIn, very infrequently). I silence my phone while working. I take breaks every 90-120 minutes. I keep a calendar of all my appointments and meetings, in and outside of work.

One other suggestion I think is good: have a "work" computer and a "play" computer/device. If you have a work laptop, then this is pretty easily done. I equate this to the advice given about beds. Beds are only for sleeping and sex. Don't study in a bed, don't eat in a bed, don't work in a bed. I find when I'm in front of my "work" machine, that I'm more naturally prone to doing "work" things and not "play" things.

</comment><comment><USER12> This is the first I've heard the term "deep work". Is this a more common term or something coined recently?

<comment><USER13> I feel like the hype around deep learning is slowly spreading to all "deep [Noun Phrase]" phrases.

<comment><USER14> It's pretty unrelated to deep learning.

<comment><USER13> That's my point....

Remember how in the late '90s, everything was e-/i-/cyber, even things that were only tangentially related to computers or networking? It feels like that.

Today, I've seen posts and ads for "deep work", "deep analytics", "deep thinking", (not using anything recognizable as deep learning), and a few other things. Most of these are more-or-less idiomatic, but I think they would have been called something else 5 or 10 years ago.

<comment><USER14> I can't really speculate on what might have happened 5 or 10 years ago, but I've read the book and have been following Cal Newport for a while (I read his previous book too) and it doesn't strike me as an attempt to capitalize on the "deep learning" trend.

I mean, it's not even tangentially related other than that the author happens to be a computer science professor (who works on distributed systems, not AI).

</comment></comment></comment></comment></comment><comment><USER15> Recently, I have been working on something exactly similar - An app to schedule your day: [https://github.com/mitul45/ta- calendar](https://github.com/mitul45/ta-calendar)

Check it out and let me know what you guys think!

<comment><USER16> Looks good! I built a similar free app for iOS: [http://longdayapp.com](http://longdayapp.com)

</comment></comment><comment><USER17> These are tricks and "hacks," which are certainly useful. But they are only band-aid fixes. The external environment will continually evolve to find new ways to blast stimuli at you. The only real defense is training your mind.

<comment><AUTHOR> Absolutely. I try and address this in the post when discussing the Pomodoro Technique, which is probably the most frequently cited "band-aid fix". But – these band aid fixes are a decent way of starting to train yourself to resist distraction, so aren't to be immediately dismissed.

</comment></comment><comment><USER18> Like what people are saying about mindfulness. Ideally, we can notice ourselves drift and self-correct at that moment.

Also think fear plays a role. Hard work can be scary. This video on procrastination from School of Life comes to mind [https://www.youtube.com/watch?v=3QetfnYgjRE](https://www.youtube.com/watch?v=3QetfnYgjRE)

Personal favorite tip: Breaking things into bite-sized tasks! I have a whiteboard for just this purpose.

Timewarp is going to help me. Set some wormholes up with quotes like "Stop playing the slot machines"

</comment><comment> J-dawg I only heard the term "deep work" yesterday, listening to Cal Newport on James Altucher's podcast.

It's a pretty good introduction and he talks about his own approach to work. He's also a professor of computer science!

They talk about his other book first (also interesting), so you need to skip a little way ahead for the deep work stuff.

[https://itunes.apple.com/gb/podcast/the-james-altucher- show/...](https://itunes.apple.com/gb/podcast/the-james-altucher- show/id794030859?mt=2&i=375568891)

[http://www.jamesaltucher.com/2016/09/cal- newport/](http://www.jamesaltucher.com/2016/09/cal-newport/)

</comment><comment><USER19> For macOS users, there is a very lightweight app called, appropriately enough, SelfControl [1]. Add the domains you'd like to block to the blacklist, then set the amount of time you'd like them blocked.

Another thing that helps me focus is Chrome's user profiles (and the main reason I haven't migrated to Safari). I maintain both 'Work' and 'Play' profiles -- that separation helps limit the urge to cycle through my bookmark bar.

[1] [https://selfcontrolapp.com/](https://selfcontrolapp.com/)

</comment><comment> awinter-py He uses 'decline in productivity' as evidence. Output per hour is measured in dollars, not %. I think he's giving us productivity growth. This is the wrong stat to use.

</comment><comment><USER20> Just realised I was reading this article whilst listening to a TED talk in a different tab. I guess he has a point here.

</comment><comment><USER21> My takeout from this: positive unknowns are addictive to your brain. Everytime you checkout a website too often you're mostly like a kid before christmas. For a second it defused my own behavior pattern, I may be able to stop losing hours of void refresh per day.

</comment><comment><USER22> I find that I am actually more productive with constant stream of minor distractions. Although I do find real work distractions to be more effective, e.g. background conversation, people walking by.

</comment><comment><USER23> Add to the list of distractions: work situations that have a policy requiring a developer to keep a chat or messaging app open and monitored while working, either at the office or at home.

</comment><comment><USER24> Installed SelfControl app for Mac, and blocked every website that doesn't contribute to my work for two 4 hour periods during the work day. The first few days it's AMAZING how many instinctual visits to those blocked sites I made. After a couple days I stopped with the distraction and it actually helped me concentrate on my work.</comment>


Is Apple About To Cut Out the Carriers? (with its own Sim card) - <AUTHOR> http://gigaom.com/2010/10/27/is-apple-about-to-cut-out-the-carriers/ <comment><USER2> this seems more like apple kowtowing to the carriers rather than cutting them out. this would allow you to use your phone only on apple-approved carriers...</comment>


Show HN: NeedProgrammer: Programming jobs near you - <AUTHOR> https://needprogrammer.com/#/home/map <comment><USER2> You need to fix your open graph tags, screenshot here: [http://imgur.com/VUcH5ot](http://imgur.com/VUcH5ot)

<comment><AUTHOR> Thanks for the heads up!</comment></comment>


Using attrs for everything in Python - <AUTHOR> https://glyph.twistedmatrix.com/2016/08/attrs.html <comment><USER2> While the conciseness of attrs is nice, it's not very readable.

This:

        class Point3D(object):
            def __init__(self, x, y, z):
                self.x = x
                self.y = y
                self.z = z

...is much easier to read than this:

        import attr
        @attr.s
        class Point3D(object):
            x = attr.ib()
            y = attr.ib()
            z = attr.ib()

Readability is what I love about Python. I don't think the conciseness of attrs is worth the loss in readability.

<comment><USER3> Also, read the post and looked over the docs, and don't see any explanation of what `.s` and `.ib` is supposed to mean (though I can figure out from context). Does anyone know what the letters stand for? Struct and instance b…???

<comment><USER4> > They are a _concise_ and highly _readable_ way to write attrs and attrib > with an explicit namespace.

> For those who can't swallow that API at all, attrs comes with serious > business aliases: attr.attrs and attr.attrib.

I'm definitely in the can't swallow camp. There's no precedent for using attribute namespaces to name things with half the name on one side and half the name on the other side, so who the hell does this project think it is to start doing it? :) Seriously though I'm pretty sure I hate it.

And I'm having trouble liking the "proper" names. So we use a class decorator "@attrs" to declare "this class is going to use class attributes to declare available instance attributes slots, a bit like django or schematics fields". Maybe it would have been better to call it "@attrs.model" since it is essentially a model definition in the terminology of other data modeling projects?

<comment><USER5> If you use `import ... as ...`, you can rename them to nicer names (full gist at [0]):

        from attr import (
            s as AttributedModel,
            ib as attribute,
        )

        @AttributedModel
        class Bar(object):
            x = attribute()
            y = attribute()

0: [https://gist.github.com/gknoy/6e884fce3edda08a1566823fec37ba...](https://gist.github.com/gknoy/6e884fce3edda08a1566823fec37ba70)

</comment></comment></comment></comment><comment><USER6> It feels a bit hampered by "bad" design decisions to me

I think its safe to say that the current view of what decorators do is, a) filter things going to functions (so they error, or hit a cache), or b) register a function with another library (e.g. flask path decorator)

This library does a lot more than that, so it seems that maybe a metaclass (which exists to mutate the class's creation) would be more appropriate?

This seems to act as a __init__ replacement, but it would be cool to act as a __init__ assistant (in other words, run the attr.s __init__, then run the user defined __init__)

The ordering of attrs matters a bit more than one would expect, not only does it define the attribute order for creating a new instance, it also defines the order of attributes when sorting against other classes. You would not want a id=attr.ib() at the top of the class definition, where it most makes sense!

The ordering of attrs is done through the .ib() call itself (which gives itself a number, and increments a global counter). This is a way of doing it, and practically might be the best way (it won't lead to any inconsistencies within a class), but it still feels weird

I personally won't use it, but I might make a competitor to it for personal use

<comment><USER7> Your view of what decorators doesn't seem to reflect the usage I've experienced writing Python professionally over the last 10 years.

Decorators take an object and return a object (by convention a callable, although this isn't enforced in the slightest). Maybe they modify a function or method signature, maybe it produces an unrelated object, or maybe one augments the object by adding side effects like caching or logging.

There is a special syntax (@) legal for classes, functions, and methods that provides a shortcut for the common pattern of:

        def decorator(): ...
        def foo(): ...
        foo = decorator(foo)

such that we can say:

        @decorator
        def foo(): ...

Things I've seen decorators do:

        * add logging
        * add tracing
        * enable type validation
        * register functions/objects for various reasons
        * produce full objects out of functions
        * swap out implementations for global functions/vars
        * change output formats to json/xml/yaml
        * take a class, inspect a database schema and bind various internal attributes to update items in a row for that schema (somewhat common in ORMs)

I don't see this attrs library as any more egregious than other uses. In particular, I don't see why mutating a type via a metaclass is preferable to using a decorator. I can offer that decorators generating objects compose _much_ better than metaclasses do (at least they have in python 2.x, I haven't had a chance to use 3 professionally).

<comment><USER6> I know how decorators work and you might be missing the point I was making by a fair mile

The following don't mutate the mental map of how the function works, its "this function is still what I typed": "add logging" "add tracing" "register functions/objects for various reasons"

The following act as a filtering role, the inside isn't "changed", the mental map becomes "This function will operate within this feature in some way, but otherwise is still what I typed": "enable type validation" "change output formats to json/xml/yaml" "swap out implementations for global functions/vars" (assuming the implementations are comparable)

The following is "What I've typed is not a proper representation, and some things may act differently than usual" e.g. things that can take lists can no longer, due to needing to be serializable (and the least common decorator case):

"take a class, inspect a database schema and bind various internal attributes to update items in a row for that schema (somewhat common in ORMs)"

(and that is usually implemented via a subclassing of a Model class, which then in turn can implement a metaclass, to get the full mutate-class-on- creation funs, iirc)

\- - -

> In particular, I don't see why mutating a type via a metaclass is preferable > to using a decorator.

Its not a technical topic, its a semantics topic. while both can do whatever silliness they want, decorators are usually reserved for incidental tasks on the side, and wrapping the original function in some light filtering. Metaclasses are expected to do mutation to the class (hence requiring a metaclass), so semantically a subclass or metaclass would be more appropriate to use for this task, compared to a decorator (from the standard library, Enums come to mind as an example for this)

<comment><USER8> Just a data point: MacroPy uses the decorator syntax for "case" classes that produce objects with a similar behavior to "attr.s" generated objects [https://github.com/lihaoyi/macropy](https://github.com/lihaoyi/macropy)

<comment><USER9> A few weeks ago, someone posted an article where the author showed how they could "inline" functions by playing with the AST. That was done to increase performance for the case of very simple functions along the lines of:

        def mul_by_pi(x):
            return x * 3.14

(I'm sure there are better examples, but that was the idea). I've seen production code where methods and functions are used to provide bitmasking with a class-dependent mask, for example (where the mask is a const, not an attribute), which would benefit from inlining.

From what I've seen, it seems MacroPy could do that, but it's not a direct example anywhere, and it seems they haven't tested it. Has it been done before?

My other problem is that the client is extremely averse of adding any new dependency (which is understandable), but I might be able to convince them if I can show a significant speedup on inlined code. The previous post I mentioned isn't a viable alternative because only "toy code" (as the author said) was provided, and in my team we aren't knowledgable enough in AST handling to feel comfortable hacking it together, but a more mature project like MacroPy definitely looks viable.

</comment></comment></comment></comment></comment><comment><USER10> If you just want an object that stores a few attributes and you don't want to define a namedtuple, you can use types.SimpleNamespace in Python >= 3.3: [https://docs.python.org/3.5/library/types.html#types.SimpleN...](https://docs.python.org/3.5/library/types.html#types.SimpleNamespace)

It's a pretty unknown feature from the stdlib, but sometimes very useful.

</comment><comment><USER11> Would there be any value to allowing a convention for the __init__() method that allows direct assignment of arguments to attributes? For example, replacing the following:

        class Point3D(object):
            def __init__(self, x, y, z):
                self.x = x
                self.y = y
                self.z = z

with:

        class Point3D(object):
            def __init__(self, self.x, self.y, self.z):
                # Other initialization work

It seems __init__ could be made to parse the list of parameters, and for any self.foo that's not defined, assign the corresponding argument to that attribute. But I have no experience in language design. Is there a reason this wouldn't work?

<comment><USER12> you can just do

      class B:
          def __init__(self, a, b, c):
              self.__dict__.update(locals())

<comment><USER13> That makes B.self a field too, which you probably don't want.

<comment><USER14> Especially because that creates a circular reference and annoys the garbage collector.

</comment></comment></comment></comment><comment><USER15> "Another place you probably should be defining an object is when you have a bag of related data that needs its relationships, invariants, and behavior explained. Python makes it soooo easy to just define a tuple or a list."

Yes, and defining a tuple or a list is often better than a small object because of Python's problems with serializing (pickling) objects. If you're doing anything with data, anything functional, anything with multiprocessing, anything with distributed programming -- you want to avoid using objects as small bags of data. (Namedtuples should have been a way to improve this, but they are implemented as a class, so they have serialization issues too.)

Lists of data can be serialized easily. Lists of objects cannot. dill tried really really hard to fix this, but the problems that remain are problems created by the Python language spec.

<comment><USER16> None of this is a problem with attrs. Serialize however you like.

        >>> import attr
        >>>
        >>> @attr.s
        ... class Thing(object):
        ...     a = attr.ib()
        ...     b = attr.ib()
        ...
        ...
        >>> @attr.s
        ... class Many(object):
        ...     things = attr.ib()
        ...
        ...
        >>> many = Many([Thing(1, 2), Thing(3, 4)])
        >>> many
        Many(things=[Thing(a=1, b=2), Thing(a=3, b=4)])
        >>> attr.asdict(many)
        {'things': [{'a': 1, 'b': 2}, {'a': 3, 'b': 4}]}
        >>> import pickle
        >>> pickle.dumps(many)
        "ccopy_reg\n_reconstructor\np0\n(c__main__\nMany\np1\nc__builtin__\nobject\np2\n
        Ntp3\nRp4\n(dp5\nS'things'\np6\n(lp7\ng0\n(c__main__\nThing\np8\ng2\nNtp9\nRp10\
        n(dp11\nS'a'\np12\nI1\nsS'b'\np13\nI2\nsbag0\n(g8\ng2\nNtp14\nRp15\n(dp16\ng12\n
        I3\nsg13\nI4\nsbasb."
        >>> import json
        >>> json.dumps(attr.asdict(many))
        '{"things": [{"a": 1, "b": 2}, {"a": 3, "b": 4}]}'
        >>>

<comment><USER17> ...how does it do that?

You call attr.asdict() and it searches the attribute values, including inside lists, for more attr objects to convert into dict values?

What kinds of values does it search through? The documentation doesn't say, it just gives an example where it works inside a list for some reason.

<comment><USER14> Why would it need to recurse? The method probably just returns a copy of the instance's __dict__. Maybe updating it with the __slots__ and their values.

<comment><USER17> It would need to recurse because you want something you can encode in JSON, not a dictionary containing a list containing miscellaneous instances.

We have an example there of an 'attrs' instance, containing a list containing 'attrs' instances, and _all_ of the instances turn into dictionaries.

</comment></comment></comment></comment></comment><comment><USER18> This is how I develop in Python. I do not use this helper library (and will certainly look into it), but definitely wish that more Python hackers built software in this way. Passing plain-old classes around that are very small and close to their domain is hugely valuable. Adding convenience methods or synthetic properties with a @property decorator is also hugely important. It lends itself to a very nice DSL where, for example, you can have image.png where the png property is a literal PNG representation of the image.

</comment><comment><USER19> Haven't finished reading yet but I just wanted to say that this _really_ resonates with me...

> You know what? I'm done. 20 lines of code so far and we don't even have a > class that does anything; the hard part of this problem was supposed to be > the quaternion solver, not "make a data structure which can be printed and > compared".

YES. I don't know much about attrs, but if it helps solve this, I'm in.

</comment><comment><USER20> The problem with constructs like this one is that it looks nice at first glance, but adds a cognitive load to an ecosystem that already has about "20 ways to do it" for every single problem.

Python is beginning to rival C++ in that respect.

<comment><USER21> Please don't tell the C++ community that! We really don't want to encourage them.

To someone who uses Python every day, the extra cognitive load of `attr` is more than made up for by all the boilerplate it eliminates. But for beginners, behind-the-scenes magic is a real turn off.

I think that making `attr` an optional library is a fair compromise, but perhaps it would be a good idea to add a note to the library reminding the programmer not to use it if the code is likely end up in the hands of novices.

<comment><USER22> >To someone who uses Python every day, the extra cognitive load of `attr` is more than made up for by all the boilerplate it eliminates.

That's funny because the first thought I had when reading this was "this does not eliminate nearly enough boilerplate to justify using that much magic".

>But for beginners, behind-the-scenes magic is a real turn off.

It's a turn off for beginners and experts but a turn on for intermediates.

</comment></comment></comment><comment><USER23> While I do see the usefulness for the specific example, and while it does seem to reduce boilerplate which is really nice, how useful it is outside of the Point3D example? For example, how often do you actually gt/lt comparisons between classes, or equate classes when they're not mathematical constructs like this? And if you add an attribute that shouldn't be used in repr or comparison, you have to explicitly say that in the attribute declaration, meaning it's would be much less clear what's going on down the road -- as in it won't be apparent how the comparison works or why this is being printed the way it is -- which I don't like in a language like Python. It almost seems like you're trading language level boilerplate for this library's boilerplate, and while it may be less with this library it obfuscates what's going on at the expense of more explicit code.

I can kind of understand something like this in Ruby, as it kind of encourages this (and it also has nicer class string-ification by default), but in Python I'd rather have all of my logic be explicitly stated out at the expense of less boilerplate. Also how often do you really need to overwrite those gt/lt methods in production code? If I saw that, rather than an explicit e.g. `.gt` method, I'd consider that a code smell.

</comment><comment><USER24> In the end, this is about defining a typed structure. "@attr" plus validator constraints is effectively a typed structure.

Python got further with minimal declarations than any other mainstream language. Yet there's a demand for typed variables. This is going into future Python, although in a strange and clunky way, because types don't fit the syntax.

We seem to be converging on a consensus on when to declare types. The breakthrough was "auto", in C/C++, which declares a variable as the type of the value to which it is initialized. This is the default in Go and Rust. Function formal parameters and structure slots have explicit type declarations, while local variables are usually implicitly typed.

Python seems to be moving in this direction, but from the no-type-declarations direction. Unfortunately, because the language itself doesn't do this well, it's being kludged through decorator macros.

<comment><USER25> The latest version does allow you to decorate variables with types... Not sure its doing anything with them yet.

<comment><USER24> It's not. See [1]. The retrofitting of type declarations to Python is taking a very strange path.

(Evil interpretation: this is an effort by Python's little tin god to sabotage PyPy. Type information is a huge win for a compiler; it can now generate hard code for a specific type. It doesn't help CPython much, since inside CPython everything is a CObject. With type information, one could write things like NumPy, with its arrays of uniform type and functions which operate on them, in Python. The PyPy compiler could then generate efficient code for them. This would make PyPy the primary Python compiler. But if type annotation isn't enforced in CPython, code won't port reliably to a compiler which enforces it.)

[1] [https://www.python.org/dev/peps/pep-0484/](https://www.python.org/dev/peps/pep-0484/)

<comment><USER26> How is this "sabotaging" PyPy? Also, even with type declarations, I'm not sure you could get Numpy-esque performance, given that Numpy doesn't have to dereference every element in the array.

<comment><USER24> If the compiler knows a Python array is uniformly of type float, it can, and should, use a dense array of floats to represent it.

<comment><USER26> Is this safe in all cases? What about complex types? Specifically if you assign a variable to an element in the array, and then replace the element in the array? You'd have to take care not to update the value of the variable.

<comment><USER24> Assigning a variable to a destination declared to be an incompatible type should produce an error at compile time if possible, and at at run time otherwise. That's what type declarations are all about.

<comment><USER26> I think you misunderstand. Here's an example:

``` foos = [Foo(a=0), Foo(a=1)] f0 = foos[0] foos[0] = Foo(a=2)

print(f0.a) # 0 print(foos[0].a) # 2 ```

`foos` is a list of type `Foo`, but it still can't be safely made into a dense list (at least not naively).

<comment><USER27> You are right. Array elements need to have value semantics to do complete unboxing. But for NumPy-like use cases, they do.

It should be noted that PyPy _already_ does unboxing Animats suggested, without any type annotation. At least for 4 years. It is not theoretical. [https://morepypy.blogspot.com/2011/10/more-compact-lists- wit...](https://morepypy.blogspot.com/2011/10/more-compact-lists-with-list- strategies.html)

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER28> This seems nice, but other than easy destructuring of functions that return long tuples (which really should return dicts), I cannot figure out a good use case for it over using a dictionary.

I am keen to hear others' opinions.

<comment><USER4> You'd have to expand more on your proposal for using a dictionary for people to be able to reply. The article was full of use cases, so why not address those rather than simply state that you can't think of any?

When you say use a dictionary, do you mean subclass `dict`? One of the aims of the project is to constrain the available instance attributes, as in a normal class. How would your dict proposal do that?

<comment><USER28> In that case, I'd just deal with the overhead of a normal class. More boilerplate, of course, but I'd have more control over the class.

As to the use cases, I was not really buying into them other than the nice destructuring example, which is actually very nice one.

<comment><USER29> I think the point is that this _is_ basically a normal class, but one with the boilerplate already written for you. If you don't mind boilerplate, this library does nothing for you. If you don't want to write classes and think dicts are good enough, this library does nothing for you.

If you do want to have classes but don't want the boilerplate that comes with making a basic-but-full-featured class, then that's where this library comes in.

</comment></comment></comment></comment><comment><USER30> Hmm, IDK.

Stuff like @attr.ib is kind of cute looking. (This not being a good thing).

Though in reality, I'd probably want more explicit methods. If you are using something like Django REST framework, you can validate with the serializer. And sometimes you want to validate (often) the combination of variables and how they interact.

Kind of feels a little non-pythonic to me. Clever, but the ways it is changing things are stuff you have to unroll if the behavior grows, versus stuff you just add to.

<comment><USER31> From the docs:

(If you don't like the playful attr.s and attr.ib, you can also use their no- nonsense aliases attr.attributes and attr.attr).

<comment><USER32> I would consider that a negative.

> There should be one-- and preferably only one --obvious way to do it.

Whats going to happen when all professional code is using `attr.attributes` but all the documentation uses `attr.s`?

Anyway its a minor point. I personally think it is a poor decision when a programmer decides to be cute than clear.

</comment></comment></comment><comment><USER33> [https://xkcd.com/927/](https://xkcd.com/927/) comes to mind when I read this.

</comment><comment><USER34>
      I love Python; it's been my primary programming language for
      10+ years and despite a number of interesting developments in
      the interim I have no plans to switch to anything else.

"interesting" and "developments" are referred to as haskell and rust respectively in the original post.

"A History of Haskell: Being Lazy with Class" [0] by Paul Hudak _et al_ suggests that it emerged before 1990. See [http://haskell.cs.yale.edu/wp- content/uploads/2011/02/histor...](http://haskell.cs.yale.edu/wp- content/uploads/2011/02/history.pdf#page=7) the page in the report showing Haskell timeline.

[0] [http://haskell.cs.yale.edu/wp- content/uploads/2011/02/histor...](http://haskell.cs.yale.edu/wp- content/uploads/2011/02/history.pdf)

</comment><comment><USER35> For lightweight containers that improve on the built-in namedtuples consider using the excellent _boltons_ library's _namedutils_ : [http://boltons.readthedocs.io/en/latest/namedutils.html](http://boltons.readthedocs.io/en/latest/namedutils.html)

</comment><comment><USER36> This feels a little bit like Lombok in the Java world. Can anybody with experience with both comment on that?

We use Lombok a fair amount within our code to abstract away a lot of the class setup, which has been nice. But as I move more towards the Python world, I'm interested to see how attr fits in.

<comment><USER37> Lombok is kinda bigger commitment than attrs, because it interfaces with Java compiler internals (last time I used it, it was only possible to compile with sun/oracle jdk).

attrs seems lesser risk IMO, it's just a plain Python library, no other deps.

If you like Lombok, I'd expect you'll love attrs. :)

</comment></comment><comment><USER4> How does this compare to schematics? It avoids inheritance, whereas in schematics and similar projects you'd have to inherit from their `Model` class (and thus acquire methods you might not want).

<comment><USER38> Schematics looks a bit like a less elegant version of schema. It does seem more focused on validation than attrs, I agree.

<comment><USER39> Schema [1] does not appear to have any support for object initialization.

[1] [https://pypi.python.org/pypi/schema/0.6.2](https://pypi.python.org/pypi/schema/0.6.2)

</comment></comment></comment><comment><USER40> The short names confuse me a bit on this.

<comment><USER41> [http://attrs.readthedocs.io/en/latest/overview.html#on- the-a...](http://attrs.readthedocs.io/en/latest/overview.html#on-the-attr-s- and-attr-ib-names)

<comment><USER37> Hello, Hynek! Thanks for attrs, wonderful library!

I'd suggest to market the "serious business aliases" more prominently. It's not about aesthetics, but expectations: people like me are immediately puzzled by "attr.ib()", thinking "why ib?".

The reason is because after reading a lot of Python code, our brain is already trained to recognize attributes and method names after the dot.

Also, it's a reasonable expectation to be able to import a function or submodule and the code still make sense, but this won't make sense:

      from attr import s, ib

      @s
      class Thing(object):
          x = ib()

I understand it looks such a small thing for you and others already used to this DSL, and also that it's not the most important technical aspect of the library. However, I do think it's an important human aspect of it.

I have the feeling that by making the "no non-sense" alternative more prominent in the examples and documentation, it would reduce cognition steps for newbie users and maybe make your own life easier by not having to explain and paste this link every time someone finds it odd (which will probably continue to happen).

Cheers!

<comment><USER41> Hello, thank you for the rare nice words in this thread!

I got a bit hit by surprise by the submission of this article to HN (it's like two weeks old now) so it caught me a bit off guard close before a new release and there's some inconsistency between the GitHub README and the docs on RTD.

The version that's on PyPI now <[https://pypi.org/project/attrs/>](https://pypi.org/project/attrs/>) has it as the _first_ sentence after the first code sample anyone ever sees (and people still complained because the just don't read :() and the new version <[https://attrs.readthedocs.io/en/latest/>](https://attrs.readthedocs.io/en/latest/>) has a whole section around the example explaining attrs' scope and ib/s: <[https://attrs.readthedocs.io/en/latest/overview.html>](https://attrs.readthedocs.io/en/latest/overview.html>) (the new version also adds and promotes aliases that make more sense but that's beyond the point).

I feel like I've _really_ done my due here and I'll have to accept that I can't make everyone happy. :|

</comment></comment></comment></comment><comment><USER42> I can't find it at the moment but wasn't there another solution to this problem where you could just populate an object at will (like matlab's struct for instance)? IIRC it was dict-based and allowed something like

        foo = SomePythonWizardry()
        foo.x = 1
        foo.a.b = 2
        print( foo ) #yields e.g. foo.x = 1, foo.a.b = 2

Or am I just dreaming? It would be all the goodness and none of the weird syntax.

<comment><USER13> You're probably thinking of jsobject¹:

        from jsobject import Object
        foo = Object()
        foo.x = 1
        foo.a = {}  # foo.a.b will fail without this line
        foo.a.b = 2
        print(foo)  # prints: {'a': {'b': 2}, 'x': 1}

¹ [https://pypi.python.org/pypi/jsobject/](https://pypi.python.org/pypi/jsobject/)

</comment></comment><comment><USER39> Added to the Python OOP catalog: [https://github.com/metaperl/python- oop](https://github.com/metaperl/python-oop)

</comment><comment><USER43> attrs seems to be all over the place, but I find Schematics ([http://schematics.readthedocs.io/en/latest/](http://schematics.readthedocs.io/en/latest/)) much better designed and more powerful.

<comment><USER39> Yes, Schematics is impressive. Thank you, I added it to my list of Python OOP extensions [1]. I wonder why you need to supply a dictionary to the object instead of keyword pairs.

[1] [https://github.com/metaperl/python- oop](https://github.com/metaperl/python-oop)

<comment><USER43> > I wonder why you need to supply a dictionary to the object instead of > keyword pairs.

My understanding is that the main reason is to make constructors more flexible, with arguments like _raw_data_, _trusted_data_ etc. But it is trivial to write a simple helper function that would accept keyword pairs and build a model instance.

</comment></comment></comment><comment><USER44> This is wonderful and cute as hell and please PLEASE don't ever use it in production code. ;-)

<comment><USER16> Why not? It's aggressively tested and benchmarked to ensure its correct and its performance impact is as close to zero as possible. (It's pretty close.)

<comment><USER44> tl;dr: I don't like metaprogramming.

\----

Both of those things are very good, even great, but they don't speak to the issue: It's [bad] magic.

In this case, it does at module-load-time what should have been done previously at build-time. (And yes, I know Python normally doesn't have build- time the way e.g. C does.)

I'm working on a large production codebase right now where several of the cowboy-coders here have added all sorts of crazy metaprogramming and it's a PITA.

Let me tell you a story. We had a class decorator that introspected the attributes of the class and added "constants" to the _enclosing module_ providing named string values for each of the class's attributes. It lets us access dict versions of these objects (they're data models) like foo_as_dict[foo_module.SOME_ATTR_NAME_BUT_IN_CAPS] ...

Good luck finding foo_module.SOME_ATTR_NAME_BUT_IN_CAPS in foo_module.py though, because it's not there. (and notice that if the model field name changes ALL of your uses of the "constant" have to be refactored to the new name too, so it's not really as helpful as it might seem in the first place.)

And now every new developer has to ask, "Where are these coming from?" and we get to point out the magic extra-clever decorator. (Try to imagine the horrible wonderful "voodoo" that decorator encompasses... Imagine the innocent newbie encountering it.)

We have a "service builder" thing that takes a bunch of arguments and build a web service object _in memory_ at module-load time. No source for any of that machinery. A bug in the service gives you a traceback running through a bunch of weird generic meta-code.

Did I mention the guy who originally wrote it bailed to a new job a month after he finished it? No one else knows how it works. We can read the code and reverse engineer it, of curse, but that's kind of B.S., no? A junior dev could debug the real service code if it existed, but the meta-code that generates the services is another challenge (that they shouldn't have and the company shouldn't have to pay them to overcome.)

We had unittest that read a JSON file and built a test suite _in memory_ to run a bunch of other tests. They finally let me re-write _that_ to a build- time script that scans the exact same JSON files and emit plain-vanilla unittest modules, that then can be run as normal, and the dev/user can look at the actual code of the test, rather than the meta-code of the test-builder.

The same problem applies to this attr package.

If you're trying to trace into or debug code that uses attr you've got to know attr at least enough to be able to follow what it's doing. It's an _in-joke_. ;-)

(P.S. I'm a big fan dude. Nice to interact with you. All respect.)

<comment><USER16> The same problem does not apply.

I understand that spooky action-at-a-distance magic can really ruin a codebase's maintainability. But what you've developed here is not a judicious appreciation of its danger and its power, but a blanket aversion to both its risks and its benefits.

An apt metaphor would be, let's say: toast. If you try to make some toast, but accidentally burn your house down, it's understandable that you might want to have your bread un-toasted for a while. But it doesn't make sense to switch your diet to be entirely raw as a result, especially if you eat a lot of chicken.

In python, metaprogramming is like fire. People who haven't seen it before are fascinated before it, and try to touch it. This always goes badly. But that doesn't mean it's useless or we shouldn't have it. There are many things it's good for, if it's carefully and thoughtfully applied.

attrs goes out of its way to avoid any behind-the-scenes effects. It even generates Python code, rather than using setattr(), so that if any error happens in the constructor, you can step through it normally in the debugger, and see it in the traceback. Its semantics are clear and direct. It doesn't have these problems.

<comment><USER44> I like toast, and a toaster is better than a folded wire clothes hanger perched over the stove burner, but this robot toast-o-matic is too fancy for my kitchen at work. We gotta toast that toast and ain't nobody got time to debug some fancy toaster.

:-) Metaphors. Heh.

Let me reiterate the first part of my statement above, to wit: "this is wonderful and cute as hell".

I like it.

I could _use_ it if it generated complete code for the classes you define. That would actually put to rest my "metaprogramming BAD" problem in this case.

Tucking __init__ source in linecache for the debugger is neat but it's also more magic. You might wind up stepping through code that doesn't exist in any file. Is this wonderful hacky weirdness mentioned in the docs? I didn't see it.

And what about __repr__? No precomputed string template?

Don't imagine that I'm crouching in the dirt tentatively reaching out to the monolith of metaprogramming. I'm into it. I read GvR's "The Killing Joke" for _fun_. But he called it that for a reason. :-)

I still recall a junior dev slamming into a wall trying to extend a Django HTML form widget. The reason? The cowboys over at Django made it with a metaclass.

We should look at a problem and think, "What's the simplest thing that will work?" Or, more to the point, "Does _this_ problem require metaprogramming to solve?" ("or am I just showing off?" could be the rest of that question...)

HTML form widgets don't require metaclasses. The problem attrs solves doesn't require metaprogramming. It's a simple DSL for data models. Right? Riiiight?

If attrs took in a spec (as Python code or whatever) and emitted all your boilerplate, ready to go, I would love it so much. You would get all of the benefits without any of the downside. I know that's boring and not sexy or fun, but I just want to get this bug fixed and ship it and get on with my life. I'll play with attrs at home, on my own time, but I'm sick of magic at work.

(Damn, am I really that old? heh)</comment></comment></comment></comment></comment>


Named tuple for C++ - <AUTHOR> http://vitiy.info/named-tuple-for-cplusplus/ <comment><USER2> Yup. I reached the same idea a while ago. I didn't use a hash for the fields though. If you think about it, you don't need a hash function at all. A hash function actually slows down compile times! At compile time, you just resolve all the names to offsets in the tuple (simpler, and the added benefit of no hash collisions). I created a "Symbol" type for string constexpr's and used a user defined literal for them.

It seems to me like Boost.Hana is the natural way to do it.

<comment><USER3> So you effectively make an enum out of the names in the tuple. That way you can even use the enum to use as the index into the get<> function calls.

<comment><USER2> Yes, that is one way of looking at it, though enums don't use string constants.

</comment></comment></comment><comment><USER4> WTF? Just use a struct. And interop with existing tuples; maybe conversion constructor and operator cast. 10 lines everybody can understand, not some crazy shit.

<comment><USER5> Indeed, a structure _is_ a named tuple. I think there's a subset of C++ users who pride themselves on creating massively complex solutions, as if they're trying to use as much of the features of the language as they can, instead of going for the simple, straightforward solution. AFAIK std::tuple does compile into the same code as if you declared a struct yourself, but I'd like to see what this convoluted solution compiles to... if I'm reading it correctly, this turns into an _O(n)_ structure member access!?

 _What if You by mistake switch 'GPA' and 'grade' inside your function? Nothing will happen to inform You that something went wrong._

I don't know if there's a specific name for it, but "what if you did X" arguments like this fail to convince me.

<comment><USER6> That variadic expansion happens at compile time, so it's still O(1) access. In my experience, the effects of something like this won't be immediately visible. You might start to notice compile times creeping up as the project grows. YMMV.

</comment></comment></comment><comment><USER7> I don't know C++, so sorry if this is a dumb question: what's the difference between a tuple with named fields and a struct?

<comment><USER8> You can do metaprogramming things like iterate over the fields of a tuple or unpack it into the arguments of a function, but you can't with a struct (without manually defining an array of fields).

</comment></comment><comment><USER9> Looks very nice. The nice thing about tuples is they can be manipulated generically to do some really cool stuff like destructuring and pattern matching, serialization, remote marshalling, etc. Making them easier to use is a win for all.

</comment><comment><USER10> I always shy away from clever solutions that involve semantics that's not obvious to the reader. If something using this code lends on your lap you are going to spend hours tracking its source, figuring out what the author was trying to say, etc.

I know, I've been there. Making my coworkers' lives harder than it needed to be with clever template magic didn't help anyone. I ripped that code out soon after.

But if the code like this is well contained, and is there to solve a very specific problem that maintainers will be able to handle, then go for it.

</comment><comment><USER11> The std::tie function can also solve this problem in most situations, if you are stuck with C++ 11.

<comment><USER2> Not really. You don't get the names of your fields from std::tie.

std::tie is more of a way to map non-named tuples to and from other data structures.

</comment></comment><comment><USER12> Just use two parallel containers: one for names, and one for values. It is dead simple to check that they have the same size and iterate over both simultaneously where needed. And the best part is, for code that does not actually require both pieces of information, you can pass one of the lists and pretend that the other does not exist. Code that only knows how to visit values only has to deal with values and not weird hybrid name/value elements.

Seriously, _always_ try the simpler thing first. Do not go deeper into templates and special syntax before seeing if any other construct will do the job.

<comment><USER13> Is this only appropriate for the case where we want to iterate over all the elements? Don't we lose the O(1) access using a name? I'm assuming you're making 2 arrays.

<comment><USER12> Yes. My point is to consider what is actually required before making complex structures. It is often perfectly acceptable to combine two existing types and handle what few interactions they actually have.

</comment></comment></comment><comment><USER14> From article:

> A lot of you now are thinking about making custom struct with named fields, > than and passing typed result as this struct. This is good solution and > there are a lot of cases when this will be actually better, but … this is > not so simple. But what if you know that this temporary structure is rather > limited in size and will be used just 'here' to pass results...

I'd still use a custom struct with named fields. I don't see the above being anywhere close to justifying the additional complexity.

</comment><comment><USER15> Why does this require C++14?</comment>


Frolicsome Engines: The Long Prehistory of Artificial Intelligence - <AUTHOR> http://publicdomainreview.org/2016/05/04/frolicsome-engines-the-long-prehistory-of-artificial-intelligence/ <comment></comment>