okmjuhb | 15 years ago | on: Ask HN: What is a monad?
okmjuhb's comments
okmjuhb | 15 years ago | on: The Day I Bought $15,000 From the US Mint
I guess if ignorance of the way he's hurting people counts as "not cheating them" this is true.
He gets the airline miles because the US mint takes in between a 1% and 3% loss on the transaction to pay the credit card company. They also lose money when they ship him the coins for free. The reason the US mint is willing to do this is because coins are so much cheaper for them in the long run than bills, once they go into circulation; they're paying this guy and UPS a fee for helping them put dollar coins into circulation. This guy is taking that fee, but not putting the coins into circulation. Its not like the money in his rewards account appeared out of nowhere.
okmjuhb | 15 years ago | on: Java is Pass-by-Value, Dammit
The Java code you give isn't an example of passing by reference because, while you can change the value that x points to in Java, you can't change x to point to something different. No java function can change its arguments; the example you gave has the java function changing something that its argument points to.
Your argument that Java people can call language features the same name as distinct language features is: a. dumb, because it's just "words mean whatever anyone wants them to mean", and b. doesn't come anywhere close to applying here; the quotation at the end of my last response: "there is exactly one parameter passing mode in Java - pass by value" is a direct quote from 'The Java Programming Language'. The authors of Java disagree with you.
More from them: "All parameters to methods are passed 'by value'. In other words, values of parameter variables in a method are copies of the values the invoker specified as arguments. If you pass a double to a method, its parameter is a copy of whatever value was being passed as an argument, and the method can change its parameter's value without affecting values in the code that invoked the method.
...
You should note that when the parameter is an object reference, it is the object reference - not the object itself - that is passed "by value." Thus, you can change which object a parameter refers to inside the method without affecting the reference that was passed. But if you change any fields of the object or invoke methods that change the object's state, the object is changed for every part of the program that holds a reference to it.
...
Some people will say incorrectly that objects are passed "by reference." In programming language design, the term pass by reference properly means that when an argument is passed to a function, the invoked function gets a reference to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory.
...
The Java programming language does not pass objects by reference; it passes object references by value. Because two copies of the same reference refer to the same actual object, changes made through one reference variable are visible through the other. There is exactly one parameter passing mode - pass-by-value - and that helps keep things simple."
Your last few paragraphs are beside the point; the question is not about which languages offer which levels of abstraction; the point is that different abstractions have different names and Java doesn't offer the abstraction named "pass by reference".
okmjuhb | 15 years ago | on: Java is Pass-by-Value, Dammit
This is silly; "pointer" and "reference" both had meanings before Java came along. If Java called pointers "names" instead of "references" it wouldn't mean that its function call semantics were pass-by-name either. And besides; if your argument is that we should use the Java terminology to describe all the aspects of Java under discussion, the fact that the all the Java designers make explicit that the function call semantics pass references as values, not objects as values.
"And your example fails to compare apples to apples. In Java Integer is an object, but int is not. You are confusing Java things with C++ things."
The argument applies if you use int in place of Integer just the same; or if you make a C++ Integer wrapper class analogous to the Java one. Any comparison here will of course be apples to oranges because C++ supports pass by reference and Java does not. The swap function is impossible to write in Java because it requires allowing called functions to change the values viewed in the caller, which is almost the definition of passing arguments by value.
"As you can see, Java is not C++, and so your C++ terms and definitions do not apply here. Thank you for playing. Move along."
Leaving aside the childish and insulting tone, the definition of "pass by reference" has nothing to do with C++; if the code were in perl it would still be pass by reference, because "pass by reference" has a meaning that exists outside of any particular programming language and describes a concept. Java function calls are not part of that concept; "there is exactly one parameter passing mode in Java - pass by value".
okmjuhb | 15 years ago | on: Java is Pass-by-Value, Dammit
The real problem is that Java created needless confusion by calling its pointers references for purely marketing reasons.
okmjuhb | 15 years ago | on: Ask HN: Favorite pointer tricks in C?
okmjuhb | 15 years ago | on: Rare Star Trek: The Next Generation Pictures
okmjuhb | 15 years ago | on: How Duff's Device Works
okmjuhb | 15 years ago | on: Ask HN: Help, Investor wants money back in 7 days "Or else"
Under no circumstances should you make threats like this without talking to a lawyer.
okmjuhb | 15 years ago | on: Why Python?
okmjuhb | 15 years ago | on: Ask HN: Learning advanced math
Axler is a good choice for linear algebra. Dummit and Foote is the standard choice for algebra generally. I'm of the opinion that we should teach algebra before linear algebra in general, but this seems like a minority view.
okmjuhb | 15 years ago | on: Easy Ways to Fail a Ph.D.
okmjuhb | 15 years ago | on: Learning to write a compiler
These tools mean that "learning to write a compiler" can take several different paths; on the one hand, we could learn about how each of these tools work (e.g. "how to write a parser generator", "machine-independent optimizations", "code generation", etc.). This is the approach taken by the dragon book. This gives the background theory and mathematics behind compiler-writing (and will likely be something people need to know if they want to write for instance an LLVM optimization pass). The problem with this is that, because of the trends mentioned above, it has little to do with the day-to-day of actual compiler writing and language experimentation (this is only somewhat true, since most "real" compilers will have a custom-written frontend and at least a little bit of knowledge about the target architecture).
The other approach is to use pre-written tools, to focus on language design decisions and applications. To be honest I'm not familiar with any resources that do this particularly well. This is the approach taken by most of the "we're going to build a compiler!" websites mentioned on the Stack Overflow post. This approach is probably more useful for most of the people who want to "write a compiler", but it leaves people with a very shallow knowledge of what's happening beneath the surface of the APIs they use.
I don't mean to imply that one of these approaches is "better" than the other (and indeed, the second requires a little bit of the first - it's difficult to debug an automatically generated parser without knowing at least a little bit of the theory), but it's important to know which approach you're aiming for, and trying to optimize based on that goal. Going to the Dragon book as a "how-to" is a disaster waiting to happen.
okmjuhb | 15 years ago | on: Art of Computer Programming, Volumes 1-4A Boxed Set
okmjuhb | 15 years ago | on: Art of Computer Programming, Volumes 1-4A Boxed Set
okmjuhb | 15 years ago | on: Futurama Writer Created And Proved A Brand New Math Theorem Just For Episode
You don't really need much math background to understand the proof. At the top, where he writes pi = (top line of numbers, bottom line of numbers), he means the permutation that sends the first element to the second place, the second element to the third place, and so on.
If you think about it, every permutation can be split into cycles of this form (a -> b, b-> c, c->d, ..., e->a). One of these cycles, that's of length K, is called a "K-Cycle".
I think that's the only terminology you need to follow the proof.
okmjuhb | 15 years ago
There's some roman paintings here: http://www.art-and-archaeology.com/roman/painting.html if anyone's interested.
okmjuhb | 15 years ago | on: The case for getting rid of tenure.
>Imagine you ran a restaurant. A very prestigious, exclusive restaurant. To attract top talent, you guarantee all cooks and waiters job security for life. Not only that, because you value honesty and candor, you allow them to say anything they want about you and your cuisine, publicly and without fear of retribution. The only catch is that all cooks or waiters would have to start out as dishwashers or busboys, for at least 10 years, when none of these protections would apply. It sounds absurd in the context of the food-service industry—for both you and your staff.
Except that the reason this is crazy is that dishwashing and bussing tables have little to do with cooking, and that the goal of a restaurant is to make money. A much better example would be one in which the goal of a restaurant is to produce new and exciting foods, and where all head chefs have to start out as a station chef and prove themselves there, first. This system would actually make a lot of sense then.
The article then goes on to blame tenured faculty salaries for increasing costs of tuition; never mind that academic faculty salaries have either just kept up with inflation or fallen behind it for the past 30 years, that in fact administrative salaries have ballooned during that same period, and that the fraction of tenured faculty has dropped substantially. Some of the numbers they give are at first glance highly suspect (35 years of professorship costing $12 million means, not adjusting for inflation or the opportunity cost of money, that a professor costs a little more than 340 thousand dollars a year over her lifespan - a number that seems hard to justify).
The argument about affecting teaching and interdisciplinary study is a red herring - if we put too much weight on (e.g.) publishing as opposed to teaching in deciding whom to give tenure, there's no reason we won't do so when we're hiring for our renewable 7-year contracts or whatever alternative system is implemented. The problem is academic priorities, not tenure. (Though I'm not taking a stand on whether or not teaching is valued too much or too little as it is, and likewise with interdisciplinary studies).
The arguments that tenure hurts intellectual freedom for those without it is ok, but it also misses the point of tenure. Tenure makes it difficult for political decisions to dictate research directions. Tenured medical ethicists can write honestly about abortion without worrying that in 10 years the social tides may have shifted and they suddenly have to defend their jobs because of something a TV news pundit dug up on them. The article is somewhat correct in that young researchers might be afraid of saying inflammatory things because it could hurt their chances of getting tenure later, but there's no reason any alternative system is necessarily better in this regard.
>Critics say that tenure hurts students by making professors lazy. Course loads vary widely from school to school: At some public universities, professors teach nine or 10 courses. At smaller schools, they teach as few as one or two, totaling as few as 140 classroom hours a year. If you can't be fired, what's to stop you from refusing to teach an extra course? "I honestly don't know what a lot of academics do a lot of the time," says Taylor.
This is particularly infuriating. The article makes it seem as though Taylor is an academic faculty member, so it baffles me that he doesn't know any better. Teaching even one course is a pretty substantial amount of work. Doing it while trying to get grants and do research requires a tremendous amount of effort. The professor's I've known are, to a person, among the most dedicated and hardworking people I've ever met.
>But the clincher for the anti-tenure argument may come from the very people it is supposed to benefit: academics. Specifically, young academics. Consider the career path of an aspiring full-time tenured professor: Four years of college, six years getting a doctorate, four to six years as a post-doc, and then six years on the tenure track. By the time you come up for tenure, you're 40. For men, the timeline is inconvenient. But for women who want to have children, it's just about unworkable.
This is perhaps my favorite paragraph in the article, and it by itself might be enough to justify some of the proposed fixes. The alternatives to the current system, the "modifications to tenure", are all interesting ideas that I'd like to see explored more fully. I wish that there were more to them than a few throwaway sentences in the second-to-last paragraph of the article.
okmjuhb | 15 years ago | on: Threads (in Ruby): Enough Already
okmjuhb | 15 years ago | on: C++0x (upcoming C++ standard, includes lambda functions)
The compiler already deals with this issue with the ?: operator. It's a readability and maintenance problem there, too. It'd be easy to do; the language designers chose not to.
So the code (quoting from samstoke's hello world):
would get translated to: Note that this makes the order of operations explicit, and that no World needs to be modified. Note also that now main has to take and return one of these World objects, so that a World needs to be threaded through all computations that will interact with the World (just like IO actions can only be executed from within other IO actions).A monad lets you thread implicit state through a computation.