166 Actions

The dream of declarative programming@jamesqf You can't really see the point without actually trying yourself (I'd recommend QML of Qt for playing with declarative ideas). Imagine someone who only knows imperative programming, and them trying to understand point of OOP or functional programming without actually trying it out for real.

Mar10

comment

The dream of declarative programming@jamesqf In declarative programming, you would just state that something is sorted. You could declare sort order be bound to some variable/property. And then it would be so. No need to explicitly call sort every time new data is added or sort order changes.

Mar9

comment

Why aren't `void *`'s implicitly cast in C++?It's worth noting, that casts through void* are more unsafe in C++, because with the way certain OOP features are implemented in C++, pointer to same object might have different value depending on pointer type.

Are all magic numbers created the same?@supercat Case by case I think. If it is a single bit, use << to indicate which bit, for example. If it is kilobyte division, then I'd use decimal number. Etc, case by case.

Dec20

comment

Are all magic numbers created the same?This answer could benefit from a mention, that some "obvious" numbers, 1024 definitely being one, are such that other developers are very likely to spontaneously write them as numbers, even when someone defines a named constant for them. I for one most likely would not even think of searching the source code for existing constant for 1024 if I didn't already know there is one, if I needed to use 1024 in byte amount conversion.

Nov8

comment

Is it good practice to rely on headers being included transitively?A note about including unnecessary headers, it does matter to compilation times, first of directly (especially if it is template-heavy C++), but especially when including headers of same or dependency project where the include file also changes, and will trigger recompilation of everything including it (if you have working dependencies, if you don't then you have to be doing clean build all the time...).

Is template “metaprogramming” in Java a good idea?Indeed, assuming there is a performance benefit now, without measuring is folly. Your goal could be, make sure code gets inlined and optimized by JIT. Another thing is, if it works and doesn't need maintenance, don't fix it.

Is there a benefit in compiling your code as you go along?Quite often scripting code is developed "live", that is it is executed in REPL environment. So "compilation" indeed happens all the time, most code that is written to the source file has also been executed once. Not all write script code this way, but I'd say anybody used to and fond of the relative "safety" of statically typed languages and compiler errors given by bad code, they should work in scripting languages this way.