14,230 reputation
13459
bio website
location
age
visits member for 4 years, 5 months
seen 2 hours ago

Jan
17
comment Is it a Good Practice to Catch All Exception?
It probably doesn't affect performance. It does, however, affect semantics. It can make the difference between correct and incorrect, between robust and not robust. That is approximately Double.POSITIVE_INFINITY times more important than performance.
Jan
11
comment What are some hashmaps we can easily implement?
In many standard libraries there is a perfectly good (sometimes even pretty superb) hash tables. Why do you want to implement your own? (If you want to learn, why focus on the simple ones?)
Jan
11
comment What are some hashmaps we can easily implement?
You also need good a story for collision resolution (linear probing can be pretty awful, separate chaining has pretty bad constant factors unless you get excessively clever), and the hash function depends on your keys (the question you link only considers string hashes).
Jan
10
comment Could programming ever have existed without error checking?
The idea of error checking never being invented strikes me as very odd, perhaps even metaphysically absurd. Certainly the program (say, the compiler compiling your program) would go wrong at some definite place. Regardless of whether it then crashes or gives wrong results, people would debug it and pinpoint the cause (surely you don't want to question the ability to debug too?). Going from that to inserting a test for the cause of the error requires nothing except the same affinity for automation and generalization that drives programming in the first place.
Jan
7
comment Lower and Upper bound of an algorithm
@user3902660 Some people only consider that, yes. Often it may be a better idea to think about other cases as well.
Jan
7
comment What's the benefit of having everything as an object in dynamically typed programming language?
The JS implementations I'm aware of don't heap-allocate primitives (they use NaN tagging).
Jan
7
comment What's the benefit of having everything as an object in dynamically typed programming language?
What do you mean by "as an object"? Are you referring to language semantics or implementation strategies?
Jan
7
comment Why would a program require a specific minimum number of CPU cores?
Since the number of cores can be retrieved, it can be compared to N, and if that comparison evaluates to true, the code can do whatever the hell it wants, including but not limited to behaving in ways not advertised. What's your question?
Jan
6
comment (almost) Pure C instead of C preprocessor
@SimonB When you run arbitrary code at compile time, it's indeed impossible to check whether compilation terminates. But the same check is already impossible for the resulting program, and it's almost never a problem in practice. Also, numerous newer languages do run arbitrary code at compile time, and their users get along just fine. A more common problem is that compilation terminates but takes rather long.
Jan
6
comment (almost) Pure C instead of C preprocessor
And I supplied evidence a similarly not-great macro processor might be implementable. I'm too young to make definite statements about the capabilities of 60's technology but so far you only asserted that "compiler technology was far too primitive".
Jan
5
comment (almost) Pure C instead of C preprocessor
It's certainly hard to give satisfactory syntax and semantics to compile-time metaprogramming, but then again the C preprocessor doesn't look too good in hindsight either. Working fully programmable macros are a Lisp thing, and while they didn't spring from McCarthy's mind fully grown, they existed in the sixties. Admittedly, interpreting Lisp at read-time is easier than interpreting (even a stripped-down dialect of) C.
Jan
5
comment (almost) Pure C instead of C preprocessor
@whatsisname I think the idea is to not substitute {printf(...)} for PI but to run the code from the macro definition and splice the output of that code in the place of PI.
Jan
5
comment (almost) Pure C instead of C preprocessor
Where would printf in the macro come from? Usually it's a library function declared in the header stdio.h which... is included using the C preprocessor. See the issue?
Jan
2
comment What does “business logic” actually mean if not “all non-3rd party code”?
You sweep all the scaffolding, infrastructure, boilerplate, library code under the "wheel reinvention" rug, but that's actually a good chunk of code, and not all of it could reasonably be third party code. Maybe it's not unique to your product, but unique to your product and three competing products. Maybe you have weird requirements that rule out existing solutions. Maybe existing solutions don't cut it for you for technical reasons (say, don't meet performance goals -- this is a common reason to reinvent basic data structured in game development).
Jan
2
comment What would be good factual arguments to convince high level management to consider functional programming?
The Graham article is very specifically about Lisp though and rather technical/developer-focused though (and IMHO not terribly convincing for my programmer brain nor my business brain).
Jan
2
comment Are noncontiguous arrays performant?
@Doval It's not really an unrolled linked list, since the 4M chunks are stored in an array themselves, so accessing any element is O(1) not O(n/B) where B is the block size.
Jan
2
comment Are noncontiguous arrays performant?
You've exhausted the theory (taken cache into account, discussed asymptotic complexity), all that's left is to plug in the parameters (here, 4M items per sublist) and maybe micro-optimize. Now is the time to benchmark, because without fixing the hardware and implementation, there is too little data to discuss performance further.
Jan
1
awarded  Nice Answer
Jan
1
comment What are the caveats of implementing fundamental types (like int) as classes?
@amon I know, and maybe I should have made that clearer, but it seems OP is only interested in Java- and C#-like languages where heap allocation is almost mandatory (and implicit) because of reference semantics and lossless casts between subtypes. Good point about Rust using what amounts to escape analysis though!
Jan
1
comment What are the caveats of implementing fundamental types (like int) as classes?
@TheodorosChatzigiannakis I include changing allocation strategy in escape analysis (because honestly that seems to be the only thing it's ever used for).