1,820 reputation
615
bio website kdgregory.com
location
age
visits member for 3 years, 9 months
seen yesterday

1d
comment What'd be better? To add one more local variable, or to call a method twice in general case?
@Doval - Yes IO is a side-effect. In my original edit I only had two points, but then thought that someone would be sure to call me out on volatile reads. That said, I think that it's important to understand and recognize the difference between what I'll call "active" and "passive" side-effects: the former are caused by your action, the latter are caused by external action. In my experience, most concurrency bugs are a result of the latter, not the former.
1d
comment What'd be better? To add one more local variable, or to call a method twice in general case?
@BartvanIngenSchenau - I always find that profiling leads to more dramatic code restructuring than simply introducing a variable.
2d
comment Disadvantages of Pointers
For whatever reason, the chat page thinks that I'm not logged in. So to respond to your earlier comment, I've updated the tag wiki to give a better explanation of what a "pointer" is.
Dec
18
comment Why can't the Scala compiler give pattern matching warning for nonsealed classes/traits?
It's unclear what you're asking. Do you want the compiler to emit a warning if the match expression doesn't cover all possible inputs? Perhaps an example would make your question more clear.
Dec
9
comment Using reflection vs creating a new class
Are you able to reflect on the Egg to determine what components it contains?
Dec
8
comment Caching build results
Does sbt do what you want? And if not, why not? You might have to modify your build to create actual JARs for your sub-projects. But yes, the dependency management problem has been solved.
Dec
6
comment Distributing a set of “Jobs” across multiple computers
You would probably find Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions by Gregor Hohpe and Bobby Woolf useful. In their terminology, you use a Splitter to distribute work and an Aggregator to assemble the results. Specific implementations of those patterns, however, are completely dependent on your requirements -- to use maple_shaft's term, it's a data store of some sort.
Nov
8
comment Smart fallback for line endings in code files?
This question is unanswerable without more context. How are the files exchanged between users? Is there a canonical version? How much effort do you want to spend doing conversion?
Nov
8
comment Quickest sorting algorithm for sorting a low number of integers
What were you using before qsort()? If your program runs 10x slower after changing that one thing you should switch back to whatever it was.
Oct
29
comment Should one value simpler code over performance when returning multiple values?
Actually, it would be better with a "real world" example (not to mention one that actually compiles). Especially because, in this case, count is simply word.length().
Oct
29
comment How was the system clock first used in early computers?
@DocBrown - it may be clear to you, but phrases such as "even an API for obtaining current time" make me wonder. (what use is a RTC if you don't have an API to access its information?) That, and I've only ever heard the term "system clock" applied to the clock used for synchronization. So rather than respond to my assumption of what the OP wanted, I thought it best to ask.
Oct
29
comment Should jars that are only gonna be used in one project be deployed to Nexus server
Also every time that the JAR gets updated. The alternative being that every team member recompiles on every update.
Oct
29
comment How was the system clock first used in early computers?
What is your definition of "system clock"? Do you really mean "external real-time clock"? Or do you mean the signal that is used to sequence all operations in the circuitry (that would be how I'd use the term)? If the latter, then it's fundamental to the operation of a stored-program digital computer; Wikipedia claims that ENIAC used a 100Hz clock. If you do mean this, then keeping track of "current time" is as simple as adding a counter to this signal, and I suspect it was added early, because timestamps are useful.
Oct
29
comment Algorithm to create custom ConcurrentHashMap?
In that case your point #3 is poorly described rather than being completely wrong. I suppose a list of locked buckets (and consequent linear search) would work. The JDK implementation, however, locks segments of the table -- a range of buckets. This is rather more efficient, as it can be done with simple math.
Oct
28
comment Algorithm to create custom ConcurrentHashMap?
You're missing the most important part: what is being locked. Start with how a hash-table works (it's unclear whether you know that from your post). Then think about how multiple concurrent updates to that table could be managed, and how locks might control those updates. Extra credit: how can reads proceed at the same time as writes.
Oct
24
comment Would forcing developers to fix at 3 AM the build they broke undermine motivation?
Why is the broken build discovered at 3 AM? If the developer checks in just before leaving at 6, that means a 9 hour build time. If this is a real question rather than a troll, perhaps you should focus on that.
Aug
25
comment Is method overloading anything more than syntactic sugar?
@Giorgio - I like that interpretation, although it leads to a pin-dancing debate of "is the operation addition, or is it addition of a double?".
Aug
25
comment Is method overloading anything more than syntactic sugar?
@back2dos - re operator overloading, there are two parts: one is a straightforward translation of an operator into a function call (eg, + becomes operator+), and I think that's clearly syntactic sugar. The second part is the overloading of operator+ to support different types, and, well, my answer shows my position on that.
Aug
25
comment Is method overloading anything more than syntactic sugar?
I'm also confused by your comments on compile-time type safety. First, because it assumes a statically-typed language, which doesn't seem to be a requirement. And second, because it seems to diverge from the idea of emulating language syntax using other syntax from the language. If you're going to consider compiler metadata to be under consideration, then you have to consider all metadata, including the basic keywords of the language. In which case, I contend that nothing is syntactic sugar.
Aug
25
comment Is method overloading anything more than syntactic sugar?
I'm not sure if I muddied the water by leaving variables (memory-based storage) out of my list of basic building blocks, but they are of course implied by Turing-completeness, and I assumed that you mentally filled in my omission.