7,759 reputation
11835
bio website
location
age
visits member for 3 years, 5 months
seen 3 hours ago

1d
comment Inheritance: Is code from superclass virtually *copied* to subclass, or is it *referred-to by subclass*?
@MichaelT "virtually copied" is the keyword. Also, even if the code was literally being copied, this might only happen after class loading.
1d
comment Design Hash table with simple hash function
However, the sum MOD k is a bad way of combining the digits into a hash, because it ignores order and has almost no avalanching. It's still fine for an educational project, but in practice it's a pretty awful choice even for hash tables optimized for consecutive/predictable hashes.
2d
comment Why Num&sizeMinusOne faster than num&(size-1)
@LarsViklund It was about both, I just overlooked the other part because it accounted for about 1/4th of the text. I added something about that.
2d
revised Why Num&sizeMinusOne faster than num&(size-1)
added 763 characters in body
Apr
13
answered Why Num&sizeMinusOne faster than num&(size-1)
Apr
12
comment What kind of processes or static alaysis would you use to catch impropper buffer bugs such as the one that caused heartbleed?
Strictly speaking, the relevant property is memory safety, not the (broader and ill-defined) "managed-ness". I mention this because some memory safe languages don't rely on GC, reference types, etc. for memory safety. Crypto code is systems code (in the sense of C, not in the sense of Go), and features associated with "managed" languages interact poorly with the demands of that domain (see also Jörg's comment above). The only remotely popular and mature example of that is Rust, but I hope that design niche becomes more popular in the near future.
Apr
10
comment What made BASIC profitable?
@MichaelT Didn't Jetbrains get big with IDEs for many existing popular languages? Lots of companies with other sources of income create languages for reasons other than direct profit from it. Also, selling a language is a slightly different beast from creating a free language and selling an IDE. They may be banking on brand recognition or association with their other products; neither language seems anywhere popular enough (yet) to offset the considerable costs of creating a full language + associated products.
Apr
10
comment What made BASIC profitable?
@MichaelT the link behind "but not today?" says so, and it's right. There are business reasons to develop languages, but developing a language won't make you rich. At the very least, you need some other product or leverage to convince others to lock themselves into your proprietary language. And if you have that, you'll probably have more luck boosting sales of that other product by making the language good, rather than selling the language.
Apr
10
comment Is my application secure enough
Have you read about, and understood, CSRF and the standard measures taken against it? You seem to be worried about CSRF and IIUC your "form tokens" solution is a known-flawed defense against it.
Apr
10
comment Why can't Java/C# implement RAII?
@supercat I don't think comments on a half year old answer are an appropriate venue for tangentially related language design ideas, in particular if they don't address the very same problems outlined in the answer. Also, if you want to further thought into that direction, you should really look into linear type systems, Rust in particular.
Apr
5
comment What are the advantages of recursion compared to iteration?
@Euphoric Yes, should have discussed that too, but doesn't affect my main point. Even in the worst case (multiple uses of recursion, no help from the language) it doesn't account for a 5x blow up in code size, probably around 2x. In easier cases, you can get away with some stack manipulation (push for call, pop for return) and continue.
Apr
5
comment What are the advantages of recursion compared to iteration?
10 lines to 50 sounds like hyperbole. You need to wrap the recursive version's body in a loop and create+use stack data structures to use instead of locals, but for a ten line function that's at most some 5-10 additional lines, not 40.
Apr
5
comment What are the advantages of recursion compared to iteration?
@MetaFight You remember correctly, though it does support about 1000 recursive calls, and accordingly recursion is used when it's inconceivable to go beyond a few dozen levels (e.g. traversing balanced or otherwise shallow trees).
Apr
4
comment When is it suitable to use inheritance
Actually polymorphism is not a good reason to use inheritance. Interfaces accomplish polymorphism too, and are less prone to the typical inheritance problems.
Apr
1
comment When is it beneficial to not use utf-8?
@DonalFellows Could you give an example? Note that I encourage constant time indexing, but with byte indices rather than code point indices. What problem requires constant time access to the ith code point, yet not to the ith grapheme cluster, and can't make do with the nth byte? UTF-8 is no panacea for bad algorithms, but I don't know any problems where it prevents good algorithms.
Apr
1
comment When is it beneficial to not use utf-8?
I'm not sure what you're getting at with #3 and #5. Are you saying languages require source files to be 7 bit ASCII? Then that should be just another example of legacy systems/data/protocols. And for #5, unless you're referring to legacy systems, you should elaborate why it's "easiest". Also, #6 doesn't make sense to me. Even if it's not "needed" you can simplify everything, improve user experience, and rule out several kinds of data mangling by simply using UTF-8 whenever possible. That it's not needed should make no difference since using UTF-8 should be at least as easy, if not easier.
Apr
1
comment When is it beneficial to not use utf-8?
-1 for the constant time access myth. Almost all string processing be done equally fast and convenient using any arbitrary unit (e.g. bytes or code units) for indexing and sequential iteration (from start and end). And as others point out, UTF-32 only gets you O(1) access to code points, but another important (I'd say more important) notion of character are grapheme clusters, and in that regard UTF-32 gets you nowhere. See also: utf8everywhere.org/#myths
Mar
31
comment When is it beneficial to not use utf-8?
Almost never.
Mar
30
comment Why do higher level languages have neither xor nor nand short-circuit operators?
@Netch No, I didn't (well, except the paper introducing hamming codes). But 50's and 60's books wouldn't help your case, focus and terminology change. Again, these extensions and their ambiguity is real but the default meaning of "XOR" is the 2-ary operation. Unless the speaker says "n-ary XOR" or something to that effect, I will not assume those extensions are of interest. Doubly so in the context of operators in programming languages, which are virtually always unary and binary, with longer expression just being nested application of the binary operation.
Mar
30
comment Why do higher level languages have neither xor nor nand short-circuit operators?
@Netch There's only ambiguity if you talk about an n-ary extension of the XOR operation, but the standard definition is a binary (2-ary) operation, and I see nothing in the question or comments indicating that OP is asking about a n-ary extension.