America's misguided culture of overwork - <AUTHOR> http://www.salon.com/books/feature/2010/08/25/german_usa_working_life_ext2010/index.html <comment><USER4> My personal experience with Germans is that they are hard workers for several hours, then they take off and play. During the time they are working they are focused on getting work done.

Americans will put in long hours, but then during the course of the day will play in the form of checking personal email, talking around the water cooler, etc.

You can cross ref. this with NASA's finding that programmers who were only allowed to work 5 days a week of 8 hour days were as productive and had less bugs in their code than those allowed to work more hours.

<comment><USER5> My experience echoes this. I really believe there is a fixed limit to the amount of work one can do and once you cross that line, you just end up goofing off or procrastinating. And it's nowhere near 40 hours per week. I would say it's more like 20-30.

The 40 hour work week is standard because Henry Ford's productivity studies found that for repetitive, manual labour, that was the maximum amount of hours one could work before a drastic reduction in productivity. That bar was set nearly 100 years ago and yet we still follow it even though work has drastically changed.

I never understand people who work insane hours. They may be at work for X hours per day but I really doubt they are working all that time.

<comment><USER6> I saw a PBS documentary sometime in the early 90's about the Labor Movement in the US. Just after getting the 40 hour work week, they pushed for 32 hours because it was found to be optimal. Industrialists fought harder against that one so Congress felt it was a worthy compromise to leave at 40. I'd love to find the study the Labor Movement based its conclusion on.

My own experience is that I'm maximally focused for 6 hours each day but it's split into 2-3 hour bursts.

<comment><USER7> I have the same experience as a mathematics grad student. After two or three hours I run out of focus and need to go for a walk + food.

<comment><USER6> I noticed the same thing when I was a math undergrad. While working on proofs for Abstract Algebra and Real Analysis, I couldn't go more than a couple of hours.

</comment></comment></comment></comment></comment><comment><USER8> _"How did Germany become such a great place to work in the first place? The Allies did it."_

What? I'm pretty sure the European labour movement and the Social Democrats wouldn't agree with that answer. On a list of possible explanations, I think "You can thank the Americans for it" would rank rather low.

<comment><USER9> Maybe not so much in this specific instance, but Germany's economic and political structure (decentralisation of power and money) was a direct result of the occupation by the Allies, who wanted to avoid a strong central government. America was hugely influential in 1945-70.

<comment><USER10> But the Dutch, French, Scandinavian, and others aren't, and the those systems is very comparable to that of Germany. Many of the ideas originate from far before WWII, and had a strong presence (and development) in Europe since events such as the French revolution.

It's America-centrism to think that all welfare and modernism is brought to the world by the USA. One typical anecdote a former exchange student told me, that some high school kids in the USA believed (this was at the end of the nineties) that European countries do not have their own radio channels ;). Go educate yourself, the average Western-European citizen has more luxury, more free time, and better health-care than the average citizen of the United States (I know, I have visited the US often).

The primary advantage of the US is that it is far easier to set up a company, and make it really big. If you make it, you will be rich and wealthy. If you fail, you will hit rock bottom. It is a consequence of the system, wages, taxing, etc.

<comment><USER11> _Go educate yourself, the average Western-European citizen has more luxury, more free time, and better health-care than the average citizen of the United States (I know, I have visited the US often)._

Help me educate myself. Provide some evidence.

<comment><USER12> Of those three areas, only the "more free time" element is easy to compare:

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

From those statistics it does look like the average citizen of the United States probably does work more hours in a year than the average citizen of the EU.

[Edited to remove the comment about "but not by a huge factor"]

<comment><USER13> [http://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Yea...](http://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Yearly_working_time_2004.jpg/400px- Yearly_working_time_2004.jpg)

I'm surprised that what are generally considered the richest countries are all at the bottom: Netherlands, Sweden, Norway, France, Germany, etc. The difference in working hours between those and the US is huge: 1307 - <USER2> hours/year compared to 1777 hours/year.

<comment><USER14> It is not as simple as that. There are many countries in which the official work day is less than the real work day. As an example, in Japan no-one leaves before the boss leaves (so it can be longer than the official time).

Also, in some countries there are many people working for themselves (such as in small businesses). These people generally work more than the official time.

I had a family member work for 14 hours a week (10 hours saturday and sunday) while starting their own business (this went on for two years).

Small business owners break the law a lot and work more than the allotted time.

</comment></comment></comment></comment></comment></comment></comment><comment><USER15> I've worked in both countries and I noticed at least one explanation for the productivity difference that isn't mentioned in the article. If a German is at risk of missing a deadline on a project he will put in a lot of extra hours to avoid that. An American who already puts in way more hours has much less time and energy left to make up for unforeseen circumstances. So the increase in flexibility pays off by avoiding rescheduling dependent projects. Perhaps this flexibility may have other benefits too, such as that people have more time to intellectually enrich themselves in ways that benefit the company.

<comment><USER16> Can't agree more.

</comment></comment><comment><USER17> This guy has lots of facts wrong - makes you wonder about his accuracy in research:

\- no federally mandated six weeks of vacation time (though 4-5 weeks are the norm, even in private sector)

\- University tuition has been introduced recently (though still low, but will rise as obvious source of gov revenue)

\- Free nursing care / child care for a small percentage of toddlers only

\- No labor minister of that name (he is undersecretary) etc.

<comment><USER18> Vacations norm is more 5 to 6 weeks with 38h to 41h work week. That is, for all the people I know in Germany. (I know nobody with only 4 weeks). Please note that these are paid holidays, you have a lot of days off too (Christmas, etc.)

The University tuition is about €500/year.

Nursing/Day care for the kids (we have 3.5 and 1.5 year old kids) is from free to €200/€500 per month for both of them (it depends of your income and where you live).

For the title "minister" or alike, this is always a translation issue, it is always hard to map the name from one country to another because the same name may mean something different (Prime Minister in UK and France for example).

<comment><USER6> I'm employed at a university in the US and have what we consider a "cushy" job: i.e. good benefits and a short work week. Just for comparison, here's what my employer offers.

vacation = 2 weeks

personal time = 6 days (sick time is considered personal time)

holidays = 7

We have also time off that I don't know how to categorize. It's specific to universities.

university shutdown between Christmas and New Year's = 7 days

Memorial Day until Labor Day we leave at 1pm on Friday, assuming no critical work needs to be completed.

University tuition ranges and often includes housing, which is necessary in less urban areas. $1000/class would be on the low end.

Day care for our 4.5 year old is about $250/week.

My work week is 40 hours but we're strongly encouraged to take a 1 hour lunch. However, with the exception of one other person in my social circle, everyone else works 45+ hours weekly.

EDIT: Applied line breaks again.

<comment><USER19> "University tuition ranges and often includes housing, which is necessary in less urban areas."

Really? I'd think campus housing would be more necessary in urban areas, just to provide subsidized living space in often expensive areas. I go to a rural university, and there are more than enough apartments around--just living by myself, I'm paying less than half for a studio apartment than I would for a bed in a dorm room.

<comment><USER6> My thought pattern was more along the line of urban areas have plenty of apartments available off campus. Rent fluctuates according to the local market: my own city is a steal for students right now. Some markets are always ridiculously high, e.g. NYC and Boston. In less urban areas where land is available, universities can easily build dormitories. Of course, I haven't seen more than a handful of universities so I'll admit to a small sample size.

<comment><USER19> In less urban areas where land is available, developers can easily build apartments--but in urban areas where land is unavailable, my theory was that students just increase demand on the existing housing market with supply less able to react.

Here in Pullman, Washington, student housing is cheap and readily available just because there's so much room to expand. There's always a wheat field you can turn into an apartment complex somewhere.

<comment><USER6> I can see your scenario happening. Around me, the housing market crashed just after some large condo and apartment building projects got underway. The developers dropped prices/rents, which caused the owners of smaller, older apartment buildings to drop rents by as much as 50%.

Developing in non-urban areas would be really subject to local zoning.

In any event, remove housing from the university cost - e.g. a student living at home - and you're still looking at a low of $10K per year. ($1K/class * 5 classes/semester * 2 semesters) That's not accounting for probably another $300 in miscellaneous fees. Factor in books and it could easily add another $500/semester.

You can probably find some scenarios in which the cost is lower, but $10K is really "bargain basement" nowadays in the US.

<comment><USER19> Yes, $10K per year is in-state tuition at my school.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER20> I don't know much about other industries. But in software, much of the 'long hours' seems like the result of keeping up appearances, not actual necessity. In my office now, I am sitting here posting to Hacker News. My sysadmins are playing foosball. They'll probably then go get lunch for an hour. Then come back, read some websites for an hour. Punch out a couple tickets. Play foosball. Go to some meetings. Then around 6pm people will start freaking out and stay until 10 or 11 scrambling to get the work done they were supposed to do all day.

In contrast, a startup I once worked for grew large enough to have an office in Germany. I went to work there one summer. The Germans simply didn't fuck around. They'd come in by like 8 am, crush the problems, crank out features and then go home. The Germans maybe weren't as "fun" as their US counterparts, but they were an order of magnitude more efficient.

I don't know what it is, but Germans seem to have a cold, efficient "Terminator" relationship to work. Americans have a dramatic bi-polar relationship to work, where they waste a lot of time when they are working and then worry and complain about their jobs are when they are not working.

</comment><comment><USER21> It feels funny that Germany is being marked as the prototypical socialist country. We don't think of us like that.

It seems even in the US the state is paying for things (streets, school?), so the US is also socialist? It seems to me that by the definition that most US commentators seem to use, any country with taxes is socialist.

As for the health insurance, note that it is only mandatory for employed people. If you are a freelancer or business owner/entrepreneur, you can drop out of the social insurance system for the most parts (except if the government decides to use taxes to compensate for troubles with the pension plans, which is outrageous to me). In fact, it is a problem to get into the social insurance system if you are not employed.

While health insurance is expensive here, I don't think it makes us into a socialist country. In the real socialist and communist countries you were supposed to give up everything for the benefit of the state, and your idea of fun free time was hopefully voluntary farm work.

<comment><USER22> Many Americans don't distinguish between 'socialist' and 'social democracy', since there hasn't been a strong social democratic tradition in America for generations. You should just swap out the two terms, and then (hopefully) the conversation will feel a bit less weird.

</comment></comment><comment><USER23> This article is pure speculative narrative.

That is, whereas most essays make a thesis, then present evidence and arguments to support that thesis, this article presents a whole story spun out of thin air, involving FDR, national health insurance, vacations, the Chinese.

As such, it presents an interesting problem. You could argue with some detail --- such as the role Germany plays as a competitive partner in China -- and still it would have much of nothing to do with the rest of the essay. The thing is so loosely coupled it's impervious to criticism. I'm not sure whether to be impressed or disgusted.

I found this to be more of the same fairy tale we Americans have been telling ourselves for decades -- if only we were the Europeans. Things would be so much better. While Germans are doing some great things, we will never be Germany. Or Norway. Or Sweden. Personally I'd like to move beyond that and talk about the real country we live in.

<comment><USER24> _"This article is pure speculative narrative. That is, whereas most essays make a thesis, then present evidence and arguments to support that thesis, this article presents a whole story spun out of thin air, involving FDR, national health insurance, vacations, the Chinese."_

Huh. Maybe we're being A/B tested, because the article that _I_ just read began with a clear thesis ( _"European social democracy – particularly Germany's – offers some tantalizing solutions to our overworked age"_ ), provided multiple lines of evidence and arguments to support that thesis, and didn't mention the "FDR" or "the Chinese" at all (it mentions, _China_ , at the very end...but only to say that China isn't our enemy). If the article that _you_ read is speculative and theoretical...well, perhaps you've got something from the Cato institute stuck in your browser cache?

It's also pretty interesting that you would lead with that statement, when your counter-argument is an assertion: _"we will never be Germany"_. Maybe you're right, but I'm missing the part of your comment where you provide evidence and arguments to support your thesis -- or even an argument as to why we need to be Germany to adopt some of their ideas. Must be the A/B testing.

<comment><USER25> _"You can pull out these GDP per capita statistics and say that people in Mississippi are vastly wealthier than people in Frankfurt and Hamburg. That can't be true. Just spend two months in Hamburg and spend two months in Tupelo, Mississippi. There's something wrong if the statistics are telling you that the people in Tupelo are three times wealthier than the people in Germany."_

I stopped reading after this thinking along the same lines as the OP. I'm still not fully awake but this doesn't seem like a good argument, although to be fair you didn't say the arguments were good.

<comment><USER26> GDP is a terrible measure of a population's wealth.

As a famous economist said - "the ideal GDP is a chain-smoking terminal cancer patient going through an expensive divorce whose car is totalled in a 20-car pileup"

</comment></comment></comment></comment><comment><USER27> It's an interesting topic, and quite complex. In my line of work (high level tech support), measuring productivity is relatively straightforward, and the European team with its 30 days of holidays and no overtime at all beats the US team in average output per year easily. Both lose out to the Indians, whom I admire a lot for the pure raw effort.

On the other hand, I've heard local startups complain about the difficulty of finding people that are willing to put in the hours that you'd need in a startup.

<comment><USER28> Do startups really need these hours? Or do they only think they need them? It's not the hours that count, it's the output.

For example, I can work 60 or 80 hours a week instead of 40, but it doesn't really make a difference because the effective output will stay more or less the same. Without sufficient leisure time I'm just slower and I'll make errors when working.

In addition, with progressive systems it doesn't even make sense to work that much. 20 hours more a week reduces my leisure time to effectively zero. On the other hand, even if this additional hours were paid, the effective difference would be minimal, due to the high taxes I'd have to pay for them.

<comment><USER12> I'm interested that this question has got so many votes without any replies.

In my view there are times in start-ups (I've been involved in two, once as a co-founder) there are times when you do have to go that extra mile (or ten), but I don't think coding is the area where this is really obvious.

For example, if there are a handful of people in the company and you try and get VC investment that takes a _huge_ amount of effort so you end up having coding time round about other tasks. So even though your total code output doesn't go up that much you end up doing piles of other stuff (e.g. planning for a major deployment at a customer) thay someone technical has to do but which _isn't_ coding. Something has got to give - so you work longer hours, not because you want to, but because you have to.

Looking back do I think expecting employees to work crazy hours makes them any more productive as developers - absolutely not. But as a founder/exec you _have_ to do it.

</comment></comment></comment><comment> mike-cardwell I'm surprised wealth distribution wasn't mentioned in the stuff about GDP comparison. I'm no Economist but I was under the impression that wealth is distributed more evenly in European countries than in the US. We have rich people here in Europe but the US seems to have lots of _insanely_ rich people and lots of poor people to go with it...

<comment><USER12> Norway is an interesting example - one of the highest per capita GDP figures but unusual in that the distribution of incomes is very narrow e.g.

[http://news.bbc.co.uk/1/hi/programmes/from_our_own_correspon...](http://news.bbc.co.uk/1/hi/programmes/from_our_own_correspondent/4223148.stm)

<comment><USER22> Norway is a very lovely country but I doubt there's a sustainable model there for the rest of the world to follow, since we all can't become the world's third-largest exporter of oil.

<comment><USER12> I think Norway is interesting because they have such a narrow distribution of wealth even though they have vast riches from oil, not because of those riches.

Edit: The Norwegian Sovereign Wealth Fund apparently owns 1% of global equities! [http://en.wikipedia.org/wiki/Government_Pension_Fund_of_Norw...](http://en.wikipedia.org/wiki/Government_Pension_Fund_of_Norway)

<comment><USER22> Well, if I remember correctly (I'm no expert on recent Norwegian history), Norway had a tradition of social democracy for a couple of decades before it discovered its oil reserves. I suspect they also had a high degree of income equality, even back then.

I'm only arguing that today their social democracy continues to do well - <USER3> isn't under the same pressure of other European states' - because of their wealth.

<comment><USER20> Norway was also one of, if not the poorest country in Europe until the oil boom. They did indeed have a high degree of income equality - nobody had any money. Culturally, this, along with the harsh environment meant that Norwegians already had learned to live collectively and save whatever they had.

</comment></comment></comment></comment></comment></comment><comment><USER9> Hmm, I enjoy hearing all the praise heap onto us (Germany) latetly. There was a time when Germany was called the sick, fat old man of Europe, too inflexible and and stubborn to able to adjust to a changing environment.

I'm sure once the growth lessens the tone will change again - I'll enjoy it as long as it lasts.

<comment><USER17> Which growth are you referring to? Growth has overall been dismal at best.

<comment><USER9> 2.2% economic growth in the last quarter; higher than anything since reunification.

[http://www.guardian.co.uk/business/2010/aug/13/german- econom...](http://www.guardian.co.uk/business/2010/aug/13/german-economy- fastest-growth-ever)

<comment><USER17> Guess my irony didn't show. Compared to the US and Asia and even EU-growth, Germany has not performed ahead of the pack at all, growth-wise. It has trailed behind US growth for years.

<comment><USER29> As a London based person, the 'suddeness' of the interest in Deutsche strategy is palpable.

Last years 'sick man' is now the healthiest man on the block:: IF the Keynsian stimulation favoured by America does not work.

Further, there are mounting concerns (valid or not) that China may not be the saviour some hoped. If that transpires, the situation will be bleak indeed for the indebted US and good for the 'austere' Germans. This may feel like being the 'best' survivors of a nuclear war however.

I think people are gently probing which entities will be the big players in the next few years and are trying to copy plays from their playbook.

<comment><USER30> These press articles (and maybe even the underlying Economic studies) are just nonsense. E.g., Ireland used to be the magic model for all of Europe with huge GDP growth, now they are completely broke. Same for the Baltic states to a lesser degree.

One year, it's all fairy dust and unicorns, the next year doom and gloom. Seen from some distance, this sounds a lot like people who have no clue at all making long term predictions based only on what they see right now.

Which again confirms my suspicion that Economy as a science at least on that level doesn't hold much water. The predictions might as well be random.

<comment><USER31> No real scientiest talk like these press articles. Economic models can only simulate a few variables. Unfortunately economic development depends on almost infinate number of variables.

I know: I know nothing :)

</comment></comment></comment></comment></comment></comment></comment><comment><USER32> From the artice: "Germany has the highest degree of worker control on the planet since the collapse of the Soviet Union." As if the Soviet union was a workers' paradise. There was lots of party control, but certainly not worker control.

<comment><USER33> Yes, comparing European 'socialism' to Soviet/Chinese style socialism ('communism') is so myopic that it has become a litmus test to detect writers who have at least a basic understanding of American/European system comparisons. Someone who sees 'socialism' and interprets it American-style, and thinks that Europe is that, starts out so wrong that anything based on those assumptions is tainted.

</comment></comment><comment><USER34> I believe the author is wrong about GDP contribution of free tuition:

 _"You know, it's 50,000 dollars for tuition at NYU and it's zero at Humboldt University in Berlin. So NYU adds catastrophic amounts of GDP per capita and Humboldt adds nothing."_

Granted, there are several approaches to calculating GDP but none of them ignores the government spending.

<comment><USER35> Ah, but does it cost the government of Germany 50,000 dollars for a years tuition?

<comment><USER34> Probably less but not zero as the author states.

</comment></comment></comment><comment><USER36> I've always found these America vs Europe comparisons to to be rather poor. We're so much bigger and more diverse and our problems are on such a larger scale that its hard for me to rationalize we are still talking apples to apples. I cant help but laugh when i see these "quality of life" indexes that compare Norway, one of the most xenophobic/racist/elitist nations with a population half that of Manhattan, to the US.

While it's easy to point out how much nicer life is in Europe, i worry that people forget how much of that lifestyle is fueled by American growth/consumption. In Greece we have an expression, when America sneezes, the world catches a cold. If America slows down, the European lifestyle, which is already in decline given its unsustainability, is going to completely disappear.

To me, an unsustainable system of life/rule/govt etc is bad by definition, regardless of whether or not it works "for now". European companies are falling behind their American counterparts in many of the next generation industries. The Chinese are lining up to trounce them further. It's going to get really bad unless they make some serious changes.

Just my perspective, not that it's worth much.

<comment><USER37> _Norway, one of the most xenophobic/racist/elitist nations_

for me this is a pretty severe accusation. don't know on which _data_ you are basing that on ...

 _European companies are falling behind their American counterparts in many of the next generation industries._

well, do they? do all of them? which industries? which companies? looking at _green technology_ i.e., Europe (especially Germany) is in a very good position for the future. and this is one of the most promising industries ...

</comment></comment><comment><USER38> A German here living in the US for about 10 years...

I found that I my line of work (software engineering), this is not generally true. I used to work more daily hours when I was still in Germany, and there was a culture of "You have to be in the office, otherwise we cannot verify that you are actually working".

Here I work from home when I like, work odd hours, work few hours (as long as I work focused during the hours I do work), and I am generally trusted to get my work done.

</comment><comment><USER22> I'm starting to think there's something to the idea of a national culture - nothing genetic, but a set of high-level assumptions and attitudes about life that inform the vast majority of people in a region, across the political spectrum. I've personally run into vast differences in attitudes about privacy and government between Americans and Germans, and I've been thinking a lot lately about Heinrich's 'WEIRD' paper (which finds differences between Americans and other Western nations - and Western nations and the rest of the world - on psychological tests.)

I suspect that because of certain prevalent American values (autonomy, distrust of authority, a bit of the Horatio Alger myth) they've naturally optimized to the work environment best suited to them. I further suspect that America could only switch to a German system very, very gradually. The country's just not currently suited for social democracy - they'd be terrible at it.

</comment><comment><USER39> Whenever a recession hits a country everbody doubts their system. They look for other countries which are growing at the moment and try to emulate their success.

I still remember the time when the japanese were strong and everybody (europeans and americans) tried to become japanese, use their culture and work ethic.

In a decade or two, the american will forget the recession and wonder about wierd articles like this one.

<comment><USER40> Nice job putting that song in my head, hero.

"...turning Japanese, I think I'm turning Japanese, I really think so..."

</comment></comment><comment><USER41> standard offers i've come across in contracts is 2 free days per working month here, however 20 days is minimum by law not counting holidays. i've lived both in the US and EU, and while i feel there is more freedom in the US, the problem is as soon as you start working you can't enjoy them cause you're working 40+ hours per week and barely have any vacation.

<comment><USER42> Only working 10/11 days per month - 8 in February? Where is this?

<comment><USER43> 20 (work-) days per year, not month.

<comment><USER42> Right, that makes sense now.

</comment></comment></comment></comment><comment><USER44> "free university tuition" -> Not true anymore, it's more like 300-600 Euros per semester. Still not much compared to the US but enough for german students to protest and public banks to create state-sponsored student loans. This type of loan for students was unknown before in Germany.

<comment><USER33> Are there state-provided student loans in Germany? Here in the Netherlands there have been for years (decades maybe? - I'm an immigrant here, my knowledge only goes back 15 years or so ;) )

<comment><USER27> Yes, although the rules change frequently. For me it was an interest free loan of which I had to pay back only 50%.

</comment></comment></comment><comment><USER45> > _You know, it's 50,000 dollars for tuition at NYU and it's zero at Humboldt > University in Berlin. So NYU adds catastrophic amounts of GDP per capita and > Humboldt adds nothing_

GDP = private consumption + gross investment + government spending + (exports − imports)

So unless the government is managing not to pay the professors or pay any other money to make Humboldt happen, Humboldt is adding to the GDP, just as government spending rather than consumer spending.

Now, it may not cost the government $50k/student. But it doesn't cost them 0 either.

</comment><comment><USER46> i could swear that in the early/mid 90's, the story was that germans were more awesome because they worked longer hours than we did. now we're not awesome because we work longer hours. am i misremembering the articles, or have we indeed always been at war with eurasia?

</comment><comment><USER47> Maybe the US is the most powerful country in the world _because_ its people work hard in a high productivity system.

America is an exception. But perhaps it is "out of sync" with the world in the same way Google is out of sync with your average software corp.

</comment><comment><USER48> Our government could provide us with all the embellishments that the major European Democracies enjoy. Unfortunately, a big chuck of our tax dollars supports our Empire (wars and a enormous military)

</comment><comment><USER49> Well, this is as far as I could read.

 _Despite the numbers, social democracy really does work_...

Yes, numbers, those pesky axioms that just won't obey when we legislate away the laws of physics.

Oh. My.

</comment><comment><USER50> How about moving to Sweden? We have 4G (the real LTE-kind) in the three largest cities now, and even better social safety net than Germany. ;)

<comment><USER51> Isn't it incredibly difficult for non-EU citizens to move to Sweden to work/live?

<comment><USER52> No, not as far as I know from the people I know that are in that situation. Of course there are some things you have to deal with, but they are more than bearable.

</comment></comment></comment><comment><USER53> The Xenophobe's Guide to the Germans <http://www.ovalbooks.com/xeno/Germans.html></comment>


Haskell Typeclasses vs. C++ Classes - <AUTHOR> http://www.michaelburge.us/2017/10/15/haskell-typeclasses-vs-cpp-classes.html <comment><USER2> Very detailed and informative!

For onlookers, I'd note that Haskell typeclasses are something of a trap for beginners who think they are the way to accomplish object-like coding in Haskell.

Actually, records with functions (closures) inside is usually a better choice: simpler, more flexible, more straightforward.

Of course the resemblance between a vtable and a record of functions is very obvious!

<comment><USER3> > they are the way to accomplish object-like coding in Haskell. > Actually, > records with functions (closures) inside is usually a better choice:

The better choice would be to use Haskell as it was intended to be used.

<comment><USER2> And that doesn't include first class functions inside of data structures? :)

<comment><USER3> I was just responding to "object-like coding," which i took to mean "using the OO paradigm in haskell." sorry if that's not what you meant.

</comment></comment></comment></comment><comment><USER4> The closest thing to Typeclasses in C++ are concepts, i.e. the set of semantic and syntactic requirements on template parameters.

As of C++17, concepts are not yet an actual language construct but are enforced by convention and normally only checked at template instantiation time (as opposed to definition time), although there are techniques that can be used to simulate more formal checking (archetypes, enableif, etc.).

<comment><USER5> They've been voted into C++20! The wait may finally be over (in a few more years) :-)

<comment><USER4> That's excellent, I missed the news.

Unfortunately concepts lite are not capable of type checking declarations, but it is still an improvement.

</comment></comment></comment><comment><USER6> It may even be fair to say that Haskell's typeclasses make it more like an object-oriented programming language. They have things like properties and multiple inheritance. Even Wadler has a section leading with "Object-oriented programming." in his paper on parametric polymorphism:

[https://people.csail.mit.edu/dnj/teaching/6898/papers/wadler...](https://people.csail.mit.edu/dnj/teaching/6898/papers/wadler88.pdf) (page 3)

<comment><USER7> _Polymorphism_ — If you understand by OOP the single-dispatching made at runtime, then type classes are different because type classes are solved at compile time, the "vtable" (the dictionary of functions) being passed around isn't virtual and is provided per type, not per instance.

 _Encapsulation_ — If you understand by OOP the encapsulation of data, then no, type classes have no such thing.

 _Inheritance_ — type classes don't have inheritance. What they have are constraints (e.g. you can implement typeclass X for type T if a typeclass implementation Y also exists for T). So you can say for example that _MonadError_ can be implemented only for types already implementing _Monad_. That's not inheritance, but _composition_.

Most importantly perhaps and something that doesn't clearly follow from the above is that OOP as implemented in popular languages, including C++, gives you _subtyping_ , whereas type classes do not.

This has important ramifications. For example _downcasting_ isn't possible. And you no longer have the "liskov substitution principle". And subtyping is actually incompatible with Hindley-Milner type inference.

Also in actual usage the differences can be quite big — for example, if you view type classes as "restrictions" on what a type can do (like OOP interfaces are), you no longer need to add these restrictions on the types themselves, but on the operations, where you actually need them, while the data structure definition can remain free of such restrictions.

This is called " _constrained parametric polymorphism_ " btw. Which can't be achieved in most OOP languages that I know of, except for Scala and that's because Scala has "implicit parameters" which are equivalent to Haskell's type classes.

At the end of the day, what a type class gives you is a way to transform a type name into a meaningful value. Imagine having a function like ...

         f: T => A

But the T param is a type name. That's what type classes give you, whereas OOP does not.

<comment><USER8> > type classes are different because type classes are solved at compile time

        data Nested a = Nest a (Nested [a]) | Done deriving Show

        build :: Int -> a -> Nested a
        build 0 a = Done
        build i a = Nest a $ build (i- 1) [a]

        main = do
            i <- readLn
            print (build i i)

if you build a value of Nested at runtime then it is impossible to do static dispatch and the dictionary has to be constructed at runtime as well.

Sorry that I mistyped the example at first. If you run this version:

        > main
        23
        Nest 23 (Nest [23] (Nest [[23]] (Nest [[[23]]] (Nest [[[[23]]]] (Nest [[[[[23]]]]] (Nest [[[[[[23]]]]]] (Nest [[[[[[[23]]]]]]] (Nest [[[[[[[[23]]]]]]]] (Nest [[[[[[[[[23]]]]]]]]] (Nest [[[[[[[[[[23]]]]]]]]]] (Nest [[[[[[[[[[[23]]]]]]]]]]] (Nest [[[[[[[[[[[[23]]]]]]]]]]]] (Nest [[[[[[[[[[[[[23]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[23]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[23]]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[[23]]]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[[[23]]]]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[[[[23]]]]]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[[[[[23]]]]]]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[[[[[[23]]]]]]]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[[[[[[[23]]]]]]]]]]]]]]]]]]]]] (Nest [[[[[[[[[[[[[[[[[[[[[[23]]]]]]]]]]]]]]]]]]]]]] Done))))))))))))))))))))))

The innermost Nested has type `Nest [[[[[[[[[[[[[[[[[[[[[[Int]]]]]]]]]]]]]]]]]]]]]]` which wasn't known at compile time so the show instance has to be constructed at runtime. This is called polymorphic recursion.

<comment><USER9> Technically, one might argue that i doesn't store a vtable, but only a reference to a type, which stores a vtable determined at runtime.

I'd say the difference is minor to non-existent.

<comment><USER7> "i" does not store a reference to a type. Values in Haskell aren't tagged with their type like in OOP.

There is no "isInstanceOf" check in Haskell.

</comment></comment></comment></comment></comment><comment><USER10> I kinda wish the Haskell designers hadn't gone with the term "typeclass", as it's incredibly misleading.

Typeclasses have a lot more cognitive similarity to Go-style interfaces or Smalltalk protocols than they do to OOP-style classes, and that fact can be enormously confusing to newcomers (which, at times, seems to be the Haskell raison d'etre).

<comment><USER11> Well this stuff happened in '88: [http://homepages.inf.ed.ac.uk/wadler/papers/class- letter/cla...](http://homepages.inf.ed.ac.uk/wadler/papers/class-letter/class- letter.txt) \--- they possibly didn't expect OOP and "classes" (Stroustrup '79) to become _quite so very ubiquitous_ as they did in the 90s.

<comment><USER10> You... don't really think Stroustrup invented the term "class", do you? :)

<comment><USER11> Of course not but that sort of meaning for the term class was GP's point here

<comment><USER10> And my point is that that usage of the term predates Stroustrup by 10 solid years.

By the time Haskell was first released, OOP was either already available in popular languages (Smalltalk, Object Pascal) or being introduced into existing languages (Objective C, C++, Lisp).

In hindsight it would appear there was no reason _not_ to see that OOP was gaining in popularity, that the term "class" was already in use, and that overloading it would be confusing.

That said, in the end, all my original post was lamenting is that it's a shame that Haskell terminology went the way it did... it's just yet another aspect of the language that creates confusion among newcomers, and it already has enough of that already! :)

<comment><USER12> I don't think the creators of Haskell were concerned even slightly with trying to fit in with trends in imperative languages. They were doing their own thing (or at least, trying to make a research-friendly version of David Turner's commercial language Miranda).

<comment><USER10> Your explanation does not justify the choice. They were tasked with communicating with other academics who were already using the term "class" in the field of programming language research.

<comment><USER13> To be blunt, it doesn't need to be justified. Should I call cars horseless carriages simply because that was the original term? Have you seen how bad the situation is in mathematics where the exact same concept has multiple names? This isn't a unique thing to have happen. Nor one to fret this much over.

The haskell committee were concerned with conveying knowledge amongst functional programming researchers. The use of class in similar but unrelated fields doesn't mean everyone need use it.

<comment><USER14> If you call a fish a "car" don't be surprised when people get confused and think that choice of name was ill-advised. Car is already in use, don't use car to describe a fish, it's not difficult. When a word has an accepted meaning, using that word to convey an entirely different meaning where you could easily choose something else is ridiculous. It is right to criticise anyone who does something so silly.

Or you can think I'm just flying the mountain with ice cream windows if you like.

<comment><USER12> It depends whether you care about catering to a general audience.

Lisp got away with an entirely different meaning for "car" for a pretty long time!

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER15> To me, type-classes are used like a less flexible form of duck typing. I would really like to see a more flexible strongly typed duck-typing than type- classes. I think that a sufficiently advanced IDE could auto-generate, from an expression, a "duck-type" for each untyped object used. For example, if you have the expression:

        (given) g :: Int -> String
        function a =
         let
          l = (f a)
         in
          g l

Would it be possible to generate the duct-type

"function :: (a which has a method f :: a -> Int) -> String"

Now you're not saying that a has to belong to a typeclass, you are saying that a has a duck-type of any value with a method f :: a -> Int.

<comment> default-kramer I think OCaml does what you are looking for. See the example on [https://en.wikipedia.org/wiki/Structural_type_system](https://en.wikipedia.org/wiki/Structural_type_system), which features OCaml.

<comment><USER15> Thanks, looks interesting. One of the things I've always wondered about with this approach is, how do you then show the "duck type"s in a succinct and human readable way.

This is pretty succinct, but I'd have to say that it is not obvious what the syntax means:

         val y : < get_x : int; set_x : int -> unit > = <obj>

Perhaps the example was poorly chosen, what is "unit"?

<comment><USER16> Unit is a type that has exactly one value, (). It's often used like `void` is used in C-like languages.

So this:

        val y : < get_x : int; set_x : int -> unit >

means an object that has a get_x method that returns an int, and a set_x method that takes an int and returns unit (void).</comment></comment></comment></comment>