2,443 reputation
2618
bio website github.com/CodesInChaos
location Frankfurt, Germany
age
visits member for 3 years, 11 months
seen 7 hours ago

Aug
21
comment Passing functions into other functions as parameters, bad practice?
@ZevSpitz I know, I have a pretty functional programming style. But the OP's example of passing callbacks to a function which run on completion of an asynchronous operation is one that I wouldn't use in .net since Tasks are nicer to use.
Aug
20
comment Why does Linq to Entity Sum return null when the result set is empty?
I wonder if it's a bug in the specification (also known as broken-by-design), or if that was just a bug in the code (i.e. this wasn't designed at all).
Aug
20
comment Passing functions into other functions as parameters, bad practice?
The main reason for avoiding callbacks is that your language or library already supports a better alternative. For example in .net there is the Task class which you'd return from the asynchronous method.
Aug
18
comment When is type testing OK?
1) If the type you're checking for is an interface 2) If there is a limited amount of subtypes.
Aug
18
comment In the days of modern computing, in 'typical business apps' - why does performance matter?
Another example: If processing one element takes 30 CPU cycles or 10ns (which is quite cheap), the algorithm will already take a full second if you only have 10000 elements. 10000 elements isn't much in many contexts.
Aug
15
comment There's a most performant way to check that a collection has exactly 1 element?
The third one is horrible: 1) It doesn't work if the sequence returns null elements 2) It enumerates the sequence twice
Aug
15
comment There's a most performant way to check that a collection has exactly 1 element?
Your second solution doesn't dispose the enumerator. Add a using block.
Aug
15
comment Difference between reverse lookup tables and rainbow tables
Rainbow tables are a specific lookup table compression technique so the size of the table is not linear in the number of passwords.
Aug
14
comment Why were magic methods implemented in C#?
@svick foreach(T x in sequence) applies explicit casts to T on the elements of the sequence. So if sequence is a plain IEnumerable and T is a value type it will unbox without any explicit cast being written in your code. One of the uglier parts of C#.
Aug
14
comment Calculate Pi to N number of places
You can take a look at Mini-Pi. Same author as y-cruncher, but simpler and slower.
Aug
6
comment Non Existent Keys Returning Null Instead of Exception
@EliasVanOotegem I did not recommend ignoring those notices. I only explained why the original coder might not have noticed or cared about those messages.
Aug
5
comment Omitting “destructors” in C is taking YAGNI too far?
Note that this doesn't apply if the only time you do allocations is during startup, which is a pattern I'd seriously consider in memory constraint devices.
Aug
5
comment Non Existent Keys Returning Null Instead of Exception
Accessing a non existent key returns a value (null, undefined or something like it, forgot the details) and continues execution. The message you're seeing is only a notice, you can hide them by changing the warning level to exclude notices in your configuration.
Jul
7
revised Is it okay if we use an arbitrary string as UUID?
deleted 4 characters in body; edited title
Jul
6
answered Alias variable vs multiple use of getter
Jul
4
comment How can I close my Open Source project and what is required from me in order to make it closed source?
I'd restrict the last paragraph to GPL, not open source in general. The conditions vary between licenses, for example AGPL requires you to provide the source code, even if you run it as a publicly accessible server without distribution the binary code.
Jul
4
comment Is it safe to generate client nonces using random number generator?
Random 32 bit numbers collide pretty often. If you want uniqueness, use at least 120 bits.
Jul
1
comment In Java, why use bit hacks when non-bitwise technique it is more readable?
@MichaelT Removing the if is obviously necessary to avoid side-channels. But even without an if, I wouldn't trust < to be constant time. Since the output of a comparison goes to the flag register not to a normal register of x86, I wouldn't be surprised if a compiler emitted a branch to turn the flag into 0 or 1. I've never seen < in code claiming to be constant time, always workarounds like subtract and shift.
Jul
1
comment In Java, why use bit hacks when non-bitwise technique it is more readable?
I'm not convinced that any code containing < is constant time. I've never seen it in crypto code claiming to be constant time. Typically alternatives like (x-y)>>31 are used.
Jul
1
comment Why And is needed when there is AndAlso
C# has both the short circuiting AndAlso in the form of && and the non short circuiting And in the form of &.