11,805 reputation
12852
bio website
location
age
visits member for 4 years, 1 month
seen 1 hour ago

Jan
15
comment Is the use of security conditionals in a view a violation of MVC?
What would be the alternative?
Jan
13
comment How to protect my php code running on a client server?
@Songo client as in "the guys paying me for the code", I presume.
Jan
9
comment Possible to implement OOP without using extensive heap operations?
Well, the question of location applies when you look at the implementation. And most implementations allocated practically everything dynamically (though the downsides are offset by tuning the way that memory is allocated). However, PyPy sometimes removes dynamic allocations completely (if the JIT compiler can prove they don't escape), and sometimes optimizes them (delays them, doing some work without touching the heap before allocating).
Jan
9
comment Is it possible to use python as a shell replacement?
Looking just at "just python" (which I presume is core language + stdlib to you) is useless IMHO, in that it doesn't match how the language is actually used.
Jan
9
comment What are the challenges related to typing in writing a compiler for a dynamically typed language?
@SK-logic The only thing that's an implementation detail for me is changes to return value of locals() persisting across calls to locals. What's documented and definitely not an implementation detail is that not even locals or globals can change in which scope each variable is looked up in. For every single use of a variable, the scope to which is refers is statically determined. Which makes it decidedly lexically scoped. (And btw, eval and exec are definitely not implementation details either - look at my answer!)
Jan
9
comment What are the challenges related to typing in writing a compiler for a dynamically typed language?
@SK-logic One can't even change the values of existing variables with locals(), let alone introduce new ones. Well, apparently locals()['foo'] = ...; locals()['foo'] does work in CPython, but this is not documented anywhere (read: is an implementation detail), and doesn't affect the meaning of the identifier foo anywhere -- if it's global according to static analysis, meddling with locals doesn't change that. globals is more powerful, but it just allows you to add/remove attributes of the module, which is no different from adding/removing attributes to any other object.
Jan
8
comment What are the challenges related to typing in writing a compiler for a dynamically typed language?
@SK-logic You can dynamically create code and execute it, but that code also runs lexically scoped. For every single variable in a Python program, you can easily determine which scope a variable belongs to just by inspecting the AST. You may be thinking of the exec statement, which is gone since 3.0 and hence outside my consideration (and probably Guido's, as the talk is from 2012). Could you give an example? And your definition of "dynamic scoping", if it's [different from mine](en.wikipedia.org/wiki/Dynamic_scoping).
Jan
8
answered What are the challenges related to typing in writing a compiler for a dynamically typed language?
Jan
8
comment What are the challenges related to typing in writing a compiler for a dynamically typed language?
@SK-logic Dynamic scoping in Python? Last I checked, all constructs in the language use lexical scoping.
Jan
4
comment Is it possible to read memory from another program by allocating all the empty space on a system?
Aren't there platform specific APIs that can circumvent this? I honestly don't know, but I wouldn't be surprised (for example, Linux allows preventing the OS from moving a page out of physical memory, via mlock).
Jan
3
comment Expensive AOT Optimizations
That's a bit misleading. Popular AOT compilers don't use graph coloring either, they use heuristics as well (examples: LLVM, GCC). Compile time matters for AOT compilers too; the threshold is higher, but graph coloring is so darn hard that it's not feasible for them either. But yes, AOT compilers can and do invest more time in register allocation, which usually leads to better runtime performance.
Jan
3
comment (Dis)advantages of datetime vs. long in globally used applications
I don't know the common databases' datetime types well, but the behavior you describe should be trivial to support with those types (=> you should use them, because otherwise you'd be re-implementing their functionality for your custom timestamp): Just convert to a canonical timezone before storing in the DB. What's wrong with that?
Jan
2
comment finding the time complexity of the following program
Actually, the space complexity is different (unless you assume a very specific optimization which is not done in many major languages [implementations]). And to piggyback on this transformation when proving the space complexity, you'd have to prove equivalence (which is easy, yes, but it's not the point of the exercise).
Jan
2
comment Evaluate math expressions without a stack
Possible, it's just contrary to my observations (note that I'm talking about heuristics which are actually used in real-world compilers, not simply about any register allocator). As a counter-examples, a LLVM guy didn't mention graph coloring, and a paper about linear scan says it's "not based on graph coloring". Every time I encountered, it was general introduction to the topic, often immediately followed by "but we don't do that because it's slow".
Jan
2
comment Evaluate math expressions without a stack
That's kind of correct in that someone who devises a register allocator probably thinks in terms of graph coloring at least part of the time. But saying the resulting compiler is "using graph coloring" is like saying a GPU is solving the rendering equation. It's overstating what actually happens by mixing up the knowledge of the programmer with the implemented algorithm. I'm likely too harsh, I'm just rather tired of that meme and related ones.
Jan
2
comment Evaluate math expressions without a stack
Actually, real-world compilers rarely use graph coloring because it's just too damn slow (NP-compile). Instead, every register allocator I've seen uses some heuristic (e.g. linear scan).
Jan
2
comment Use Queue<T> or stick to native f# lists
RE sitting well with purely functional programming: There are multiple persistent queues that perform reasonably well (cf. Okasaki's Purely Functional Data Structures). They're not trivial to implement and understand though.
Jan
1
revised How can variables be created at runtime?
added 218 characters in body
Dec
31
answered C++ name mangling and linker symbol resolution
Dec
29
comment Why aren't user-defined operators more common?
I don't see how the parts about operator overloading apply to defining completely new operators.