9,267 reputation
63986
bio website
location
age
visits member for 3 years, 9 months
seen 1 hour ago

0x2B | ~0x2B


Jan
24
comment Why do mainstream OO languages not have immutability on class-level built-in?
@Philipp: What do you mean by whole class? Are you referring to the possibility to change a class at runtime, e.g. adding new methods?
Jan
24
comment Why do mainstream OO languages not have immutability on class-level built-in?
"If you dig deep enough, every programming language mutates state under the hood, because that's how the processor instructions are designed.": If a programming language does not allow mutation, the fact that its implementation does use mutation is irrelevant for the programmer.
Jan
24
reviewed Leave Open Why do mainstream OO languages not have immutability on class-level built-in?
Jan
24
comment Situations when O(n^2) better than O(n*log(n))
@Useless: This does change the fact that the above statement is incorrect.
Jan
24
comment Situations when O(n^2) better than O(n*log(n))
"Quicksort has (if naivelly implemented) square complexity": quicksort has worst-case complexity O(n^2), no matter how it is implemented.
Jan
24
reviewed Leave Open Attributes of an Ethical Programmer?
Jan
21
comment Scala and exception handling
You probably know Robert Harper better than I do. I only read the book I cited and I find it a very good reading. Of course he has his own views, which I cannot judge, since I am not an expert in FP, even though I like the subject a lot.
Jan
21
comment Scala and exception handling
@Doval: ;-) I somehow remembered you were an SML fan. True, Java's checked exceptions are a nice alternative. But again, once you decide that something is an error, I think you should model it with an exception. If it is a 0-1 result, I think it should be an option.
Jan
21
comment Scala and exception handling
Nice answer (+1), especially for explaining that monadic types like Option are a good substitute for options. I often see exception as a jump into the void, in the hope you land somewhere. Options are rather taking an escape door into a tunnel that guides you out to a safe place. You might want to mention continuations (also supported by Scala) as yet another way of dealing with failure, see e.g. Chapter 29 of cs.cmu.edu/~rwh/smlbook/book.pdf.
Jan
21
comment Scala and exception handling
Citing from that book: "In general, if efficiency is paramount, we tend to prefer exceptions if failure is a rarity, and to prefer options if failure is relatively common. If, on the other hand, static checking is paramount, then it is advantageous to use options since the type checker will enforce the requirement that the programmer check for failure, rather than having the error arise only at run-time."
Jan
21
comment Scala and exception handling
@Doval: Sure, what you consider an error and what you consider a normal negative result depends on the context, but this does not mean you shouldn't make this distinction and use different constructs. BTW, IMO a very interesting reading can be found in Chapter 29 of cs.cmu.edu/~rwh/smlbook/book.pdf
Jan
21
reviewed Leave Open Does Clojure borrow concurrency ideas from Haskell?
Jan
21
reviewed Leave Open Which language has most advanced support for proof based programming?
Jan
21
comment Scala and exception handling
I disagree that options are used for error handling: When I look for a number with a certain property and I find no number, it does not mean I have an error. My computation simply terminates and gives a correct answer: None. On the contrary, I would say that languages that do not have an option type encourage the use of exception to model an optional result, which is conceptually wrong. Exceptions are for errors, not for expected results.
Jan
21
comment Scala and exception handling
I would add that exceptions should be used, as the word says, to handle exceptional situations, i.e. errors, not to build the normal flow of control. That's why a function that might not return any result should have a result type Option instead of modeling the no-result-found situation by throwing an exception.
Jan
20
comment Does Object Orientation require the concept of inheritance?
There are many different notions attached to the term object-oriented. See e.g. community.schemewiki.org/?object-oriented-programming
Jan
20
comment Most efficient way to generate all descendents of all nodes in a tree
You can simulate recursion using a loop and a stack, is this allowed for your solution?
Jan
19
comment Understanding the difference between mutable and immutable classes
"An immutable class is immutable, as in, it is not mutable.": To be precise, one should say that instances of that class can be / cannot be changed. Mutability refers to instances, not the the class itself.
Jan
19
comment When does pair programming work? When to avoid it?
@AndresF.: I agree with you. "Partial pair programming" or, using less fashionable words, "discussing some difficult problem together when needed" is a very reasonable approach, used not only for programming, but also when learning at school, etc. However, I do not consider this practice a silver bullet that should be used all the time.
Jan
19
comment When does pair programming work? When to avoid it?
@DaveO.: I can only do simple things using pair-programming. For complex tasks I need to think, and pair-programming is just a source of distraction (see Will Sargent's answer). I still find it very useful to discuss complex problems with colleagues, but this is different from writing the whole code together.