101 reputation
2
bio website
location
age 24
visits member for 2 years, 10 months
seen Apr 9 at 11:53

I'm a science fiction & fantasy buff and casual tabletop gamer, recently graduated with bachelor's degrees in Computer Engineering and Computer Science (and a Japanese minor on the side).

Python and C++ are currently my preferred programming languages, but I've done some work with Objective-C (iOS apps) and some projects in Javascript (node.js, jQuery, etc.). I have possibly had more experience with Java than with Python or C++, but I have found that tasks that are comparatively elegant in Python and other languages that share similar design concepts (first-class functions, etc.) often require an annoying amount of boilerplate in Java (thankfully, Java 8's lambdas and method references seem like they'll alleviate a decent amount of my annoyances in that regard); I also wish Java had either reified generics or at least a bit more support for static/compile-time code generation like with C++'s templates (at the very least, method overriding based on runtime type would allow a whole lot of Java code that interfaces with non-generic/primitives-only APIs to be less verbose). I'm also trying out Scala and LISP, though I haven't made much progress on that recently.


Mar
10
comment Why are string resources generally kept external to the code and not inside the code?
This question can be generalized to any sort of resource, really, even with ease of localization/internationalization aside. What are the advantages of keeping any sort of resource separate from code? Why aren't images or audio files usually encoded in the source as binary strings? (Data URIs do exist, of course, but are generally impractical for large files). Others have provided some pretty good answers already, but I just wanted to point out that user-readable strings aren't the only resource type that gains a benefit from being externalized.
Mar
6
comment Should I refactor large functions that mostly consist of one regex?
I'd say named capture groups (capture groups in general, really) are most similar to final/write-once variables, or perhaps macros. They allow you to reference specific portions of the match, either from the match object returned from the regex processor or later in the regular expression itself.
Mar
5
comment Why do all <algorithm> functions take only ranges, not containers?
@delnan Saying that Python iterators "don't have most of the power" talked about is a misleading statement. The power of Python iterators lies in their integration with the language, which includes constructs for easy construction of simple to complex iterators (the most powerful of which would probably be generators and generator expressions, though the standard library's itertools module provides a lot of nice convenience functions for common composition patterns too). (This applies to plenty of other languages with similar design principles, of course. diff. iterators != weaker iterators)
Feb
25
comment How to write camel case for words like “phonenumber”, “motorcycle”, “wavelength”, etc
@PeterTurner Some programmers would say that street should be a class and name one of its attributes/data members.
Feb
14
comment What is the benefit of having the assignment operator return a value?
Also note the following: round(2**128 / 2.0) + 1 == round(2**128 / 2) + 1 == round(2**128 // 2.0) + 1 == 2**127 + 1, because the result of the float division is close enough to the correct result to be rounded (though to add more potential confusion, type(round(float_value)) == int while type(round(float_value), 0) == float).
Feb
14
comment What is the benefit of having the assignment operator return a value?
@wberry C also produces an FP result when using division involving a float; a better example of conversion confusion would be the fact that, in Python 3, 2**128 / 2 + 1 != 2**127 + 1 as / always produces a float, but the behavior of // is inconsistent with that as while it acts as as an integer division operator when applied to ints it is a floor-division operator when applied to floats, so 2**128 // 2 + 1 == 2**127 + 1 but 2**128 // 2.0 + 1 != 2**127 + 1. (The behavior of // actually does make sense after a bit of thought, though.)
Feb
14
comment What is the benefit of having the assignment operator return a value?
@wberry However, 2 == 2.0 does return true even though int and float are different types in Python. If anything, JavaScript's === is closest in equivalence to Python's is (you achieve similar loose equality effects with == by adding an __eq__ method to Python classes, it's just that strings and numbers in Python don't have implicit conversion built in; many object-oriented languages that don't support operator overloading usually have an explicit function pattern for that, like Java's Object.equals). (Apparently the recent Object.is seems to act even more like Python's is.)
Jan
30
comment 'import module' vs. 'from module import function'
There is also the situation where you have a package with subpackages or modules that exposes an attribute of one of those subpackages/modules in the top level package. Using from...import allows you to do package.attribute rather than package.subpackage_or_module.attribute, which can be useful if you have logical or conceptual groupings within the package but want to make things a bit more convenient for users of your package. (numpy does something like this, I believe.)
Jan
30
comment Is it acceptable to use lambda functions\methods in business software?
"In the second case, you have to know that doSomething takes an Action." And how is that any different from having to know that functionWithNameThatDoesNotSpecifyItsArgumentTypes takes an ObjectOfSomeType? In fact, in languages where functions are true first-class objects, it isn't any different.
Jan
28
comment Returning different types from one function in a dynamically typed language
@Aaronaught Relevantly, 1/0 appears to result in Infinity rather than a divide-by-zero error in Firefox's JavaScript implementation (I haven't tested with other browsers). (Versus Python, where any integer/float combination for 1/0 results in a divide-by-zero error.)
Jan
10
comment What is meant by “Now you have two problems”?
This makes me wonder how many people took the floating-point course versus the finite automata one at my university, where you only need one of the two for a CS degree. (I went for automata, though if I'd had time I would have tried to fit in the FP course as well.)
May
29
comment Do abstractions have to reduce code readability?
Namespace hierarchies are really nice, though.
May
28
comment Using public final rather than private getters
In other words, it's better to avoid explicit getters and setters in the first place unless the use case is trivial and is guaranteed to continue being trivial.
May
28
comment Using public final rather than private getters
Technically, when you use getters/etc. the client code will be hard coupled to method names instead. Look at how many libraries have to include old versions of methods with a "deprecated" tag/annotation because older code is still reliant on them (and some people may still use them because they find them easier to work with, but you aren't supposed to do that).
Aug
8
comment How does Python's handling of line-breaks differ from JavaScript's automatic semicolons?
@Aaron: You forgot "an unclosed set of parentheses ( () )". (Not strictly "an unclosed tuple" because parentheses aren't just used for tuples.)
Jul
26
comment What is each time through a loop called?
@Jay: Just tell it to "iterate once". Or something like that.
Jul
20
comment Recursion — is it “divide and conquer” or “code reuse”
Ah, yes, you're absolutely right. I should have said "in implementations of languages/language compilers that utilize stack-based memory".
Jul
20
comment Recursion — is it “divide and conquer” or “code reuse”
"Every function that can be implemented with recursion can also be implemented iteratively, often by pushing and popping a stack." After all, in languages that utilize stack-based memory, you're already pushing and popping the function data on and off the stack when using recursion.
Jul
13
comment Why shouldn't classes be designed to be “open”?
@Konrad: Until the developers decide to revamp everything and be non-backwards-compatible.
Jul
12
comment What did Bjarne Stroustrup mean by his characterization of C and C++?
@Shadur: Was he unaware of the existence of for loops?