9,528 reputation
12141
bio website
location
age
visits member for 3 years, 8 months
seen 3 hours ago

Jun
6
comment is it valid that a state machine can have more than one possible state for some transition?
How do you decide which transition to follow?
Jun
5
comment Writing a method to 'transform' an immutable object: how should I approach this?
Mutating the color under the rendering system's feet from another thread seems neither good style nor particularly robust.
Jun
5
comment Any patent issue if I want to call my classes “signal/slot” as in Qt?
Names shouldn't fall under patent law, at most it's a trademark. Then again, considering the current state of the patent system...
Jun
4
comment Are there advantages for using recursion over iteration - other than sometimes readability and elegance?
@JohnR.Strohm You already sung the praise of TCO to me in another comment thread, and I already told you why that's not the whole truth. Aside from the obvious objection that not all calls are in tail position, let me repeat that a large number of major language translators (which, in total, account for a significant chunk of all program executions these days) do not implement TCO, and some more only do so in very narrow circumstances that can't be relied upon. Whether you regard this as "brain damaged" or not it solely your problem and doesn't change the fact.
Jun
3
comment Significant amount of the time, I can't think of a reason to have an object instead of a static class. Do objects have more benefits than I think?
@Prog A file system as a whole doesn't make a lot of sense as an object in most circumstances. There is only one, and its state is necessarily global anyway. And in fact, even the Java libraries seem to not represent the filesystem as object. Is the file system object perhaps a straw man?
Jun
3
comment Significant amount of the time, I can't think of a reason to have an object instead of a static class. Do objects have more benefits than I think?
@Prog That is even broader and vaguer than I feared. Like, yeah, not everything needs to be an object. Now what?
Jun
3
comment Significant amount of the time, I can't think of a reason to have an object instead of a static class. Do objects have more benefits than I think?
So, instead of an object with fields and perhaps methods, no objects, no records, just a whole lot of scalar values passed to and returned from static methods? Edit: Your new example suggests otherwise: Objects, just without instance methods? Otherwise, what's Thing?
Jun
3
comment Tail-recursive implementation of take-while
Well, you can append to the end of the accumulator list at every step, but that takes quadratic time rather than linear, which makes it offensively stupid.
Jun
3
comment Are there advantages for using recursion over iteration - other than sometimes readability and elegance?
@RobertHarvey The expense can certainly be measured, I can whip up an example if you insist. Whether it actually matters in the majority of code (where any individual function only accounts for 0.5% of total run time and most of the time is spent in business logic, not looping or calling functions) is another issue, but the same is true for any micro optimization. Another thing, it seems strange to say overflowing the stack is "expensive". In most environments, it means data corruption or an insurmountable run-time error. That's not "expensive", that's "broken".
Jun
3
comment Are there advantages for using recursion over iteration - other than sometimes readability and elegance?
The recursive version can not only be more readable, it can also be more writable. While this is generally a lesser factor than readability (code is read far more often than it is written), it does matter since all good programmers are lazy ;-) The overarching advantage is that the recursive version is (usually) simpler, and this reflects on both reading and writing the code.
Jun
3
comment Are there advantages for using recursion over iteration - other than sometimes readability and elegance?
@RobertHarvey Function calls are not expensive, but they are almost always more expensive than merely going back to the start of the loop body. jmp vs (push r1, r2 and jmp) in C, "set up a whole frame object" versus "change the interpreter's instruction pointer" in CPython. A function call simply needs to do more than a loop backedge. The more important question then is whether you can do the required state management more effectively than the language implementation.
Jun
2
comment How can I be certain that my code is flawless?
Fun fact: One can test for all primes that fit into int. It's not even a lot, there are "only" about 2^31/ln(2^31) ~= 10 million prime numbers smaller than INT_MAX.
Jun
2
comment Is this simple XOR encrypted communication absolutely secure?
@Zack There are many problems with OTPs, but none threatens confidentiality. Note that even if you perfectly guess the previous message's plantext+key, the next message is encrypted with an entirely new, independent key (of considerable size too). There is nothing to adapt to over multiple interactions.
Jun
1
comment Is this simple XOR encrypted communication absolutely secure?
"Why aren't OTPs practical" might be another good question (for Information Security), but it's certainly a separate question.
Jun
1
comment Is this simple XOR encrypted communication absolutely secure?
Other than the specific scheme to coordinate which part of the key to use, this is just a one-time pad. But under closer inspection it turns out to not actually be useful for 99% of use cases.
Jun
1
answered Should sanity be a property of a programmer or a program?
May
29
comment If Scheme is untyped, how can it have numbers and lists?
@Evicatos Strictly speaking, not even atoms are necessary, only closures. Look up church numerals and related constructions. Of course, this is extremely convoluted and slow. But so is emulating lists with closures, though to a lesser degree.
May
29
comment If Scheme is untyped, how can it have numbers and lists?
@Dokkat Because it's not. What's the type of (if (the-stars-align) nil 5))?
May
29
comment If Scheme is untyped, how can it have numbers and lists?
@JimmyHoffa I agree with you about what OP is explicitly asking for. But I think OP is asking that because of an unstated confusion about the exact issue my answer discusses.
May
29
comment If Scheme is untyped, how can it have numbers and lists?
@RobertHarvey That is not what I'm trying to say. My point is that "type" can mean one of two very different things.