Reputation
16,311
Top tag
Next privilege 20,000 Rep.
Access 'trusted user' tools
Badges
1 41 64
Newest
 Guru
Impact
~224k people reached

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)).
Jul
12
comment Banning zero-argument functions — what problems could it cause in a hypothetical language?
I see. But with this function call syntax, a better option is to go all the way with currying. Then no separate function is necessary and it becomes more consistent that binding the only remaining parameter calls the function.
Jul
12
comment Is there any programming language(s) which has mathematical number types?
@nawfal Just the names is a strange requirement. In particular for your favorite approximation of reals, names like "float" or "double" or "decimal" are good, I'd argue, even for beginners, because they make very clear that there are not the real numbers (and unlike integers for example, the differences are easy to hit even without overflow). As for uncountability: In short, there is no way to list all reals - any list, even infinite, must necessarily miss most of them. More technically, there is no one-to-one mapping from the natural numbers to the reals. See Cantor's diagonal argument.
Jul
12
comment Banning zero-argument functions — what problems could it cause in a hypothetical language?
I don't quite follow the part about parameter binding. If f is a function T -> U, then f x doesn't just bind a value to the first parameter, it calls the function, because now all arguments are supplied. This is what several functional languages do. In fact, it is the only reasonable course of action that I can imagine with that function call syntax.
Jul
12
comment Banning zero-argument functions — what problems could it cause in a hypothetical language?
Isn't this exactly what Haskell does? Well, except that variable = expression defines an unchangeable binding rather than assigning to a variable.
Jun
27
comment What problem do algebraic data types solve?
@usr Finding the catch-all clause is not what the compiler does (and in any case is a simple syntactic transformation as you describe). However, the compiler instead has to check if clause1 || clause2 || ... is a tautology, which is indeed equivalent to testing the satisfiability of !clause1 && !clause! && ... - but I'm still skeptical because this is a reduction from exhaustiveness to SAT, not the other way around (i.e., if we can solve SAT we can solve exhaustiveness, but no mention of the other way around).
Jun
27
comment What problem do algebraic data types solve?
@usr No language I'm aware of attempts a perfect solution, either the compiler understands that it's exhaustive or you're forced to add a catch-all case where you crash and burn. I don't know of a relation to SAT though, do you have a link to a reduction? Regardless, for actual code written in real programs, exhaustiveness checking is a drop in the bucket.
Jun
22
comment What problem do algebraic data types solve?
@Ian Most functional languages are statically typed and check exhaustiveness of pattern matching. However, if there is a "catch all" pattern, the compiler is happy even if the function would have to deal with the new case to do its job. In addition, you have to recompile all dependent code, you can't compile just one library and re-link it into an already-built application.
Jun
20
comment Are Constant Time and Amortized Constant Time effectively considered equivalent?
Does the assignment specify how random removals are performed? Are you given an index to remove or a reference to a queue element?
Jun
14
comment Compilation to bytecode vs machine code
@Julian "middle end" is a real term, coined in analogy with "front end" and "back end" with no regard for semantics :)
Jun
14
comment Compilation to bytecode vs machine code
Ignoring optimizations and such is silly. These "optional steps" make up a great deal of the code base, complexity, and compile time of most compilers.
Jun
12
comment Why do programs use call stacks, if nested function calls can be inlined?
@moonman239 Then your wording threw me off. Still, your question can be decomposed as I do in my answer and I think that's a useful perspective.
Jun
12
comment Why do programs use call stacks, if nested function calls can be inlined?
I am skeptical of that but regardless that's not what I claimed.
Jun
12
comment Why do programs use call stacks, if nested function calls can be inlined?
It's very debatable is CPS has no "call stack". It's not on the stack, the mystical region of ordinary RAM that has a little bit of hardware support through %esp etc., but it still keeps the equivalent bookkeeping on an aptly named spaghetti stack in another region of RAM. The return address, in particular, is essentially encoded in the continuation. And of course continuations are not faster (and it seems to me this is what OP was getting at) than making no calls at all via inlining.