June 23, 2011
Scala and Types (from http://news.ycombinator.com/item?id=2682900)
PaulHoule: That brings us to point (1) of his article. He asks us to make a large investment in learning a language that might pay off in the future... might.
PaulHoule: My understanding of Scala is quite imperfect but the more I've learned the more it seems that it's got pretty facades built over weak wood. Rather than being a 'scalable language' it comes across like a fake town that was built as a set for a Western. Look at any beautiful concise code sample that they try to seduce you with and you find that any small change requires tripling the code size. Look at the chapter in the book on DSLs and the take-away is "don't try to build internal DSLs".
PaulHoule: Be it looking at the profiler running on on a Scala program that uses actors or finding that I never quite seem to get away with not having to declare types explicitly, I have a facepalm event every hour or so working with Scala.
PaulHoule: In my case, (2) has nothing to do with it. I'm quite familiar with functional programming, both in languages that support it well and languages that don't. These days even my PHP looks like LISP.
PaulHoule: (3) is certainly true, and I think it has something to do with the cultural difference that @speckledjim points out.
PaulHoule: Anyone who's got to work with Scala will definitely confront (4); if you're working in Java or PHP or some other commercially viable language you can probably solve a high fraction of problems by using Google and Stack Overflow.
PaulHoule: If you're programming in Scala you'll have a lot more success understanding the fundamentals of the language. If, for instance, you need to access Scala objects from Java (particularly the super-prevalent ones like Option and List) you'll find that cookbook-style documentation is 100% AWOL. Go look at the scaladocs for Option and List, however, and you'll be calling methods on them in no time from Java.
PaulHoule: If you insist on working with Scala, get a book and read it all the way through from the beginning, skipping forward when you don't understand something.
fogus: Which book do you mean? Also, do you mind elaborating on why one should avoid building DSLs with Scala? In my own experience [1] I've found it extremely nice for internal DSLs.
troutwine: Presumably he means Ordersky's Programming Scala. While it is possibly one of the better Scala books available it is downright bad, having committed the doorstop producing sin of confusing a language tutorial with a reference with a thesis defense. The second edition of the text is all over the place, providing little in the way of even trivial program examples and maintaining shockingly conservative advice from the first edition, written for the language in its state a few versions back.
troutwine: The assessment that Scala is a pretty structure built of weak wood is not too far off, at this point. Compared to other strongly functional languages--Haskell and ML, say--the type system is shoddy and limited. In part this is a frustration of maintaining objects on Java's terms, but also defects in the JVM: type erasure is a hair-shirt that neither of languages I mentioned previously have to wear. You can somewhat avoid the loss of types with manifest hacks, but it's shoddy business. Often you can't; note that Akka has a distinctly dynamic feel, being that certain messaging functions--!! and !!!--must return an Option[Any] even when the original message is well-typed. The system loses the type information at runtime!
troutwine: Compilation speed is also an agrivation. It's a slower process than Haskell--not zippy to begin with--and comes with less result, to boot. All that said, I tentatively like Scala, especially if a project is required to run on the JVM. I find it to be an especially pragmatic language, if unbeautiful and not something I intend to use for long-term, exploration coding. A fine choice for a language to be used in anger, let's say, if the memory usage of the JVM is of no concern.
Peaker: If I understand "type erasure" correctly, Haskell and ML both do have type erasure. In Haskell, using typeclasses like Typeable, you get the power of keeping types in runtime, but the types are actually erased.
troutwine: Oh, sure. Sometimes types disappear at compile-time and aren't needed during program execution: the theorem is already proven so why should the runtime system carry around the baggage? Unless we're talking past one another, the Scala problem is rather worse: start passing around Seq[Seq[Int]]'s through your code and the compiler will be unable to ensure that it's always a Seq[Int] stuffed in there; the compiler comes with warning flags, but it's rather a bother and decidedly more dynamic.
troutwine: You are quite correct, almost all strongly typed languages perform some type erasure for efficiency purposes. The problem, as I see it with Scala, is rooted in defect in the JVM; the system looses type information and cannot verify at compile-time that all your types will be correct. Please correct me if I'm wrong or have misunderstood you.
Peaker: I don't know Scala -- but it sounds like a compile-time type-verification problem more than a type erasure problem.
Peaker: When Haskell targets x86, the x86 opcodes surely don't help Haskell verify that [[Int]] really has [Int]s in there, but it's not necessary because it is proven at compile-time. So I am a bit confused why Scala needs the JVM's help.
troutwine: Consider that Haskell does its compilation step once; the types and their parameters are discarded and machine code is generated up front. (More correctly, LLVM IR is generated and combined with the Run Time System into a binary.) In Scala, and Java before it, compilation happens during program execution: you cannot discard types because the compilation step is never over. Ordersky's previous work on Pizza ensured that, however, that type parameters _were_ lost; rather than modify the JVM to support generics it proved to be more expedient with regard to backward compatibility just to strip them out. Pre-generics binary code could co-exist with post-generics because they compiled down to the same bytecode. Hence the complaint that in Java Array[Int] and Array[String] generates two special purpose, 'parameterized' Array structures in memory. Mostly the Java compiler can be clever and produce relatively only what is needed during execution, but the PermGem exception happens because, well, it's a hack.
troutwine: Now, consider the difficulty of Scala wherein it's possible to represent a compound type. Erasure ensures that only the first parameter in the chain is generated in the type-erasure step, destroying the meaning of the union. There are kludgy ways around this--wrapping, bundling up manifests--but in the end the JVM does not allow the transmission of necessary information efficiently. Manifests serve the purpose of maintaining parameter information at runtime, but do so at the expense of code cache space and stress system resources. PermGem exceptions are much more common, in my experience, when doing Scala work as compared to Java.
troutwine: The shorter answer to your question is the JIT nature of Java combined with a byte-code designed not to maintain the information needed to generate all possibilities of machine code on demand. LLVM IR maintains such information for Haskell--when targeting machine code directly I believe this is achieved by static polymorphic compilation, but I could be wrong; Stack Overflow time?--and the CLR does the same for C# and friends. It's a JVM problem entirely. The JVM promises to perform any and all compilation but is unable to accept all the information needed to do so effectively.
August 14, 2009
Muslim Dress in France: Misguided Equality

I had a brief conversation with a fellow on Reddit recently in the comments on an article in the Sydney Morning Herald. The French, citing unusually strict sanitation rules for their public swimming pools, have banned the use of so-called Burqinis, a portmanteau of Burqa and Bikini. The French have been particularly stringent in maintaining the secular nature of their republic, banning the hijab and other religious symbols from schools in 2004. Adding another dimension, the French state has also framed the restriction of dress in terms of individual right. President Sarkozy stated on June 22 that

The problem of the burqa is not a religious problem, it’s a problem of liberty and women’s dignity. It’s not a religious symbol, but a sign of subservience and debasement. I want to say solemnly, the burqa is not welcome in France. In our country, we can’t accept women prisoners behind a screen, cut off from all social life, deprived of all identity. That’s not our idea of freedom.

Which leaves us with several distinctions: The hijab, a head scarf which many Abrahamic religions wear a variation of for modesty purposes, is a religious symbol and, as such, is banned from schools. Presumably male Jewish children are restricted from wearing the yarmulke as well. The burqa is a tool for oppression, not a religious symbol and, as such, should be banned outright. The burqini is merely a sanitation hazard. This is reasonable enough. However, using this classification scheme, what is a burqa that is appreciated by the wearer? Reddit user Paqza writes

On of my friends who is fairly liberal on most things recently converted to Islam and wore a burqa while teaching in Yemen. She says that surprisingly, she really appreciated the experience because she actually noticed that people started appreciating her more for her intellect and less for her body.

I took the surprise felt by Paqza’s friend to imply that she did not normally wear a burqa in her home country and did so in Yemen to adhere to the local, more strict religious custom. She enjoyed the dress as her intellectual identity was no longer obscured by her physical appearance, the former she values equally or more so than the later. This, using the French scheme, would make the woman’s physical appearance, in a not-trivial regard, a “screen” that deprives the woman of her intellectual identity and her physical appearance a “debasement”. Though I imagine the woman’s identity is roughly composed of equal parts between the two it is interesting that the French scheme removes this choice.

Attacking a firm distinction, presumably in the West, that Paqza did not strong imply insomniac84 replied

Yes, because as a woman no one cares about your intellect if you don’t wear a burqa.

He goes on to say

She had no chance to be respected for her intellect without wearing the covering. That’s the culture. So it is no surprise when she covered up she finally should be looked at as a human in that country. That is how the religious country works.

Here insomniac84 is refuting my earlier conclusion. In going to Yemen, he asserts, she wore the burqa under duress by the culture at large. The Britannica notes a variety of female dress custom, though they are invariably modest. I tend to doubt insomniac84’s assertion that she was forced to wear the burqa, though I have no conclusive cultural evidence to the contrary. He continues

Now when muslims move to a non religious country, they too should follow local customs and dress. It should be a two way street, but there religious fanaticals offer no respect to anything that isn’t their religion. Even if they moved to a different country. Instead they try to push their oppressionist beliefs on others no matter where they go.

A message of cultural assimilation, an argument that fails almost entirely. How does one define local dress and why should it necessarily be adhered to? Western women, by custom, once wore long, concealing dresses for the purposes of modesty. They no longer do, however, choosing to wear a wide variety of clothing. Religious groups in the US still advocate very modest dresses for women. Is this oppression? I hardly think so. Yet such groups, following insomniac84’s line of reasoning, are outside of the cultural norm and, so, should dress in a normal fashion. Perhaps the key is the pushing of “oppressionist beliefs on others”? This does not hold either. Paqza never stated that his friend now insisted that all women should wear the burqa, or, indeed, that she continued to do so outside of Yemen. Similarly, I have read nowhere that French Muslims are lobbying to enforce strict dress on the country at large. In fact, the woman in the article which spawned this discussion in the first place was a French convert to Islam. It is not at all unlikely that she chose to adhere to a more traditional Muslim dress code.

Taking issue with the claim of cultural imposition Reliant replied

Should Scots be prohibited from wearing kilts outside of Scotland because that would be forcing their culture on others?

hiscifi quickly replied

no but should they be forced to wear kilts regardless of whether they want to?

Reliant’s rejoinder

Forced how and by whom? Burqas aren’t worn by all Muslim women. (…) What if inside a Scottish cultural group in North America, when they have a family party, all the men in their family must wear a kilt or get disowned. Is that enough to ban kilts?

At this point I jumped in. Though I basically agreed with him I felt that his analogy was flawed. I told him so

Expand family out to include several million people and reword disowned to be “violent reprisal” than, yes, perhaps. The situations simply aren’t analogous. However, such an outright ban does negatively affect those that would choose, of their own free will, to wear such a traditional garb.

The conversation continues on from here, but the key issue, to my mind, is this: How does society at large protect the rights of individuals living unwillingly in restrictive communities without trampling the rights of those that choose to live in such communities? The problem of the burqa, burqini or hijab are not so much the clothes themselves as what they may represent. To ban them outright, as Reliant later points out, is to shuffle this problem under the rug. The basic coercion still exists but it is merely hidden away from public view. Indeed, the outright ban of traditional clothing is equally a coercion of dress for those women that would choose to wear such clothing but may not.

Proscribed fashions in clothing, hair, activity or diet are not, in and of themselves, worthy of legislation. Instead, it is the cultural assumption that one group of people may dictate an individual’s presentation through force that is the actual problem. Reliant sums it up nicely

[I]f the victim isn’t willing to help, how far should the government go to protect someone for their own sake? If a woman is married to someone who is willing to threaten physical violence over the wearing of a headscarf, what other things that would the husband threaten physical violence over? Even if you ban it, the problem doesn’t go away, it only hides it from being seen.

5:03pm  |   URL: http://tmblr.co/ZzgRWy9j_cB
Filed under: dress culture discussion