1,046 reputation
710
bio website py.phzzz.co.uk
location England, United Kingdom
age 22
visits member for 3 years, 11 months
seen Oct 16 at 13:19

Aug
20
comment When is type testing OK?
I disagree with never. I think you could put forward a solid argument for "only when making non-functional changes". For example, you might look at the type of a Collection to see if it supports random access if that makes your algorithm faster, otherwise you still work, you just do it slower. Obviously this is something you'd do in the last stages of a project, not while you were still working out correctness.
Aug
20
comment Passing functions into other functions as parameters, bad practice?
Then consider this a lesson! What academia teaches and what is actually useful often have surprisingly little overlap. There's a whole world of programming techniques out there that don't conform to that sort of dogma.
Aug
20
comment Passing functions into other functions as parameters, bad practice?
Why do you feel like that? Do you have any experience with functional programming? (I'll assume not, but you should take a look)
Aug
12
comment Python case statement?
Something which is used by experienced developers in the industry would be avoided by teachers in college. -- Exactly this. Academia has different goals than real code that actually solves problems, and academics typically don't have the industry experience to know exactly how they differ.
Aug
6
comment When using Visual Studio 2012 do you have to use the drag and drop system?
Why would you want to? Writing raw winforms is only slightly nicer than raw SWT. At very least do WPF, which is reasonably nice to use without editors.
Aug
3
comment A question about static types
@davidk01: Right. Whereas unityped Javascript has /only/ the root return type, strongly typed languages can often still use a root type. object in C#, as per my example, could return the value of any arbitrary C# expression.
Aug
1
comment A question about static types
What does that return in JavaScript? You can get the exact same effect in, say, C# by returning something of the root type object. You have no type safety, but it is equivalently powerful to your JS snippet, which has no type safety either.
Aug
1
comment How does a stack VM manage with only one stack?
Yes, exactly. That's why we only really use the stack for local variables, and anything that needs to go "up" the stack frame is typically heap allocated.
Aug
1
comment How does a stack VM manage with only one stack?
Do you know how this is done on physical machines? I can't tell you the specifics from any VM, but on a physical machine your end instruction would also have to do something to tear down the stack frame. You always maintain a pointer to the start of your functions little bit of stack. The return address is just above that, not at the very end.
Jul
31
comment “Immutable” interfaces
The distinction for no /observable/ side effects is mostly for things like logging, caching, lazy eval, et cetera. Read observable as "functional"--as in, if you removed them, the program's correctness would not change. In this case, your side effects are behavioral and your function is impure.
Jul
16
comment Does it make sense to use interfaces if you don't have polymorphism?
@m3th0dman: Interfaces are giving you polymorphic behaviour whether you like it or not. If new ClientA(new ImplementationB()) is valid code that works, and yet breaks at runtime, then you have polymorphism, and it is being misused. Interfaces are not just categorising, they are abstracting over behaviour.
Jul
15
comment Does it make sense to use interfaces if you don't have polymorphism?
@m3th0dman: Then this is a clear misuse of polymorphism.
Jul
15
comment Does it make sense to use interfaces if you don't have polymorphism?
If I use ImplementerB in ClientA, will it break?
Jul
9
comment Python API: Extension Module or Pure Module
What is your software? If it's (Something) but /really/ fast then your choice is made for you. If it isn't, then is the speed hit even relevant?
Jul
8
comment Why isn't there a next operation on enums?
A quick check in Java implies you can reference enum members in the ctor of another member so long as it's been defined already. Sunday, Saturday(Sunday), Friday(Saturday),... could work. Alteratively, a .next method that's a little bit reflective would work. I think the real reason is because, as you say, not all enums have a meaningful or trivial ordering.
Jul
4
comment How many mistakes does a good software developer make?
I've been programming for over a decade now. I recently wrote some networking code which worked, first time, perfectly. Zero flaws throughout the whole project. Every time anything went wrong, my first thought was that I'd finally discovered the bug in that piece of code.
Jul
3
comment Is there a real advantage to dynamic languages?
@Doval: Oh, sorry, I wasn't even thinking about that. Replace logging with memoisation or something, then. The important part was if your function only takes a concrete type in C# or Haskell, your flexibility is limited. In either language, if you use the tools they give you for polymorphic behaviour, you get a lot of flexibility. I don't think this is the problem typeclasses were intended to solve, because they don't solve that problem. They're better, in many ways, than subtyping polymorphism, but they don't fix this particular issue.
Jul
3
comment Is there a real advantage to dynamic languages?
@Doval: Yes, I understand the advantage of typeclasses, but they don't help you if your function is not of type (Barkable b)=>b->Whatever. If your function is of type Dog->IO() and you want to pass in a logging auto-proxy you're just as stuck as a method in C# or Java of type void(Dog).
Jul
3
comment Is there a real advantage to dynamic languages?
@Doval: Because you're using their systems for polymorphism. You don't get that problem in C#/Java either if they're defined on interface types. Typeclasses are not helpful if you have a function from concrete type T to concrete type K, and indeed you may be worse off in those languages due to not having the same kind of subtyping relationships an OO language might have if your lazy library developer has left everything open for inheritance. A well written program is flexible in any language, but dynamic languages can make even poorly written programs flexible.
Jul
3
comment Is there a real advantage to dynamic languages?
@Doval: So? You can't define anything /but/ objects, and you have a contract to stick to just as much as if you were in a strictly typed language. Just because I wrote makeItBark with my own types in mind doesn't mean you can't use yours, wheras in a static language it probably /does/ mean that. Besides, you don't need to make a class, as shown in my original snippet. Anything that supports the right accessors will work, whether you're patching them into an existing class, making your own, using a namedtuple, a dict with a wrapper to direct d.k to d[k], /whatever/.