Reputation
16,586
Top tag
Next privilege 20,000 Rep.
Access 'trusted user' tools
Badges
1 42 66
Newest
 Good Answer
Impact
~234k people reached

Aug
26
comment Why do arrays in .Net have Length but other collection types have Count?
A T[] with a length of N always stores exactly N values of type T. Semantically, not all of those values may be meaningful (they might be null for example), but they exist. This is different from the usual meaning of capacity (as used by List<T> for example). You're right that Count can change while Length can't. Then again, nothing mandates that Count will, in fact, change. It is also used for immutable collections.
Aug
20
comment Why does Python's math.ceil return a float?
Actually in Python 3 it does return an integer.
Aug
19
comment Checking array size in C/C++ to avoid segmentation faults
The word statically is key: The reduction to the halting problem only works if we want to rule out all programs that go out of bounds, but no more, and without running the program. If run-time checks are permitted, the problem is almost trivial, it just has runtime overhead (and a quite large one, for a naive solution). Likewise, it is easy to reject all programs that go out of bounds as well as some that don't (the hard part is not rejecting practically useful ones).
Aug
18
comment Mutable AST vs. different immutable ASTs
@DeadMG The easiest example to defend would be if the semantic analysis is split in multiple passes (e.g., name resolution, then type inference). And it's pointless to argue whether this is a "semantic tree" or a "syntax tree". It contains all the original structure and nodes of the AST, though augmented with additional data, that's good enough for me.
Aug
18
comment Mutable AST vs. different immutable ASTs
@DeadMG Because some semantic analyses need to annotate basically every part of the program (with a type, for example) and preserve the syntactic structure for later passes? This is standard practice in compiler construction as far as I know.
Aug
16
comment Open Source License that prohibits verbatim resale?
If the trademark is something visible like the user name or the logo, then I don't think it will help with your intent. Yes, now these people need to change the name/logo/etc., but that is hardly any better than re-selling verbatim. So if they do that and release the result without any further changes, the situation is worse, because it's not obvious any more (to the casual observer) that this is exactly the same app.
Aug
14
comment Can higher order functions ever be pure?
@Giorgio I know all that. It's a cool idea that makes Haskell arguable the world's finest imperative programming language. It just doesn't matter here: We're talking about distinguishing pure computation from impure actions, and the IO monad does exactly that.
Aug
14
comment Can higher order functions ever be pure?
@Giorgio You could say that, but functions of type a -> IO b are the moral equivalent of impure functions, so in the context of this question I don't feel that is a useful position.
Aug
14
comment Why don't “multi-infinite” list comprehensions work with lazy evaluation?
For example, with most bijections the code in your questions would not find the first N Pythagorean triples, just some triples in an order that is meaningless unless you keep the exact bijection in mind. And none of this even begins to address the question of how you would decide when to apply this tranformation.
Aug
14
comment Why don't “multi-infinite” list comprehensions work with lazy evaluation?
All countable types can be represented by (non-negative) integers in some way. That is what it means to be countable. And all types expressible in Haskell (and indeed the set of all possible values in any computational process) are countable. The question is whether the compiler can infer an appropriate bijection, respecting the numerous invariants that most types have (e.g. rationals usually want to be irreducible, floating point-esque numbers want to be normalized, etc.) and whether the order is both (1) understandable and (2) the order the programmer wants.
Aug
14
comment Why don't “multi-infinite” list comprehensions work with lazy evaluation?
@TheEnvironmentalist There's more to infinite lists than infinite lists of integers, though. Why are those special? (Hint: They aren't.)
Aug
13
comment Can all code be represented as a series of Map / Filter / Reduce operations?
Idle thought: Even if we allow nonsense like my_list.map(_ignored => a copy of my_list), it seems like the space use of such a program is bounded by some polynomial (depending on the program length). Then such a language certainly couldn't compute problems that are not in PSPACE. However, as many problems in PSPACE are considered intractible, to say nothing of larger classes, this may not be a very serious restriction.
Aug
13
comment What prevents others from commerciallly redistributing open source software as-is?
There's a conflict between "allow commercial use" and "don't sell as-is". It is hard to define "as-is" in a satisfactory way: It can't simply mean bit-identical because it is easy to change some really minor aspect without meeting your intent, but to define "sufficently substantial" changes in a way that will hold up in court will at least require consultation with a lawyer, if possible at all.
Jul
25
comment What should JITed bytecode do exactly?
The last point cannot be overstated. All of these libraries take code that's almost at the level of machine code, and turn it into actual machine code. The tricky part in compiling most languages that are called "scripting languages" is getting from the dynamically typed, late-bound, huge, complicated source language to something that is even remotely efficient.
Jul
25
comment What should JITed bytecode do exactly?
@JörgWMittag Perhaps some Forth programs are faster than a C program that you spent the same amount of time writing and optimizing, but often faster than hand-optimized C? You'll excuse me if I am massively skeptical. In fact, if I didn't associate your user name with quite a few good answers, I'd simply dismiss this as yet another instance of the flat-out wrong propaganda that plagues programming language advocacy.
Jul
25
comment What should JITed bytecode do exactly?
FYI the second is called threaded code.
Jul
21
comment Error handling in math library functions
If 0 is a meaningful default value, then that is independent of the specific numeric type. Conversely, if semantically zero does not make sense as fallback, the IEEE float 0.0 is not a good value to return.
Jul
20
comment rand() gives same numbers again for a small range
@Dorus You still need to generate and store the entire list though. In most cases where shuffling the entire list is prohibitive, that's already a dealbreaker.
Jul
13
comment Is there any programming language(s) which has mathematical number types?
@SimonB You seem to confuse cardinality with well-ordering or something related to it. A countable set has a bijection with the naturals, but there is no requirement that this mapping preserves order (or that there even is such a thing as an "order"). The rationals are countable, for example, even though there is yet another rational between any two rationals.
Jul
12
comment When writing a math library, will operator overloading maintain OOP?
@Ixrec That is a different operation though. Your code does ((A + B) * C) + E, OP's method example does A + (B * (C + E)).