|
Dren posted:I'd just like to say, even if I've said it before, gently caress #define. Don't hate the game, hate the playa. Microsoft
|
# ? Jul 11, 2013 17:07 |
|
|
# ? May 17, 2024 16:45 |
|
Quick one:code:
|
# ? Jul 11, 2013 18:02 |
|
code:
Is it a horror or just a funny convenience method?
|
# ? Jul 11, 2013 18:09 |
|
2banks1swap.avi posted:Is it a horror or just a funny convenience method? That's a horror for sure. The entire purpose of the ToString method is to give a string representation of an object. Here's a less horror-y but still totally useless version: code:
New Yorp New Yorp fucked around with this message at 18:25 on Jul 11, 2013 |
# ? Jul 11, 2013 18:19 |
|
Is it bad that I'm just laughing about it instead of getting mad? The only real teething problem I've had here was that I'm used to projecting my voice due to my past jobs and programmers in cubes like it quiet. That and I have allergies/reflux and I'm between docs because my new insurance hasn't come in yet and I'm coughing. Bleh. Y'all programmers are touchy.
|
# ? Jul 11, 2013 18:22 |
|
Ithaqua posted:That's a horror for sure. Tangential but is there anything inherently wrong with if (s == DBNull.Value) vs if (s is DBNull)?
|
# ? Jul 11, 2013 18:34 |
|
tef posted:i'd make a lilliputian reference to big-endian and little-endian, but satire is dead.
|
# ? Jul 11, 2013 18:37 |
|
Bunny Cuddlin posted:Tangential but is there anything inherently wrong with if (s == DBNull.Value) vs if (s is DBNull)? I don't think so. I've never had a need to use DBNull, honestly.
|
# ? Jul 11, 2013 18:41 |
|
Bunny Cuddlin posted:Tangential but is there anything inherently wrong with if (s == DBNull.Value) vs if (s is DBNull)? There's no functional difference worth caring about (in theory == is faster than is, but it's not going to be a measurable difference). I personally think is DBNull reads a little better (and ceteris paribus I favor the shorter version), but the it's not exactly a big difference here.
|
# ? Jul 11, 2013 19:28 |
|
Ithaqua posted:I don't think so. I've never had a need to use DBNull, honestly. Plorkyeran posted:There's no functional difference worth caring about (in theory == is faster than is, but it's not going to be a measurable difference). I personally think is DBNull reads a little better (and ceteris paribus I favor the shorter version), but the it's not exactly a big difference here. Alright cool, just curious since I saw "is DBNull" and I know Ithaqua is competent so I thought I'd check.
|
# ? Jul 11, 2013 19:36 |
|
From the code review I am doing:C++ code:
|
# ? Jul 11, 2013 19:39 |
|
So this works:code:
code:
code:
|
# ? Jul 11, 2013 19:40 |
|
That Turkey Story posted:Don't hate the game, hate the playa. Microsoft is far from the only vendor that pulls this poo poo. I'm using a third-party library that has to be included after boost or else it breaks boost.
|
# ? Jul 11, 2013 19:57 |
|
GrumpyDoctor posted:Microsoft is far from the only vendor that pulls this poo poo. I'm using a third-party library that has to be included after boost or else it breaks boost. 'sup crappy third party library buddy
|
# ? Jul 11, 2013 20:00 |
|
C# code:
|
# ? Jul 12, 2013 04:34 |
|
Gazpacho posted:
That's silly, especially if you're using MStest when you can just decorate the test method with [ExpectedException(typeof(SomeException))] I've written unit tests where I wanted to verify the contents of the exception, so I've had to do goofy stuff like code:
C# code:
New Yorp New Yorp fucked around with this message at 05:00 on Jul 12, 2013 |
# ? Jul 12, 2013 04:57 |
|
i've wanted to learn and use c# for a long while but haven't because I don't have anything to do with it. Sure sounds like a solid language though if you are making stuff to run on winders.
|
# ? Jul 12, 2013 06:14 |
|
Ithaqua posted:That's silly, especially if you're using MStest when you can just decorate the test method with [ExpectedException(typeof(SomeException))] The problem with ExpectedException is that you can't distinguish between an exception in your test code and an exception in the code under test. You can end up with tests that pass even though they never even get to the actual test part of the test, because your test setup happens to throw the same exception that you were asserting on. Okay, it's not particularly likely, but the day it happens to you you'll be none the wiser. I also view it as a bad thing that asserting on exceptions is so structurally different from asserting on values, which is why I always use this little snippet instead of ExpectedException: C# code:
C# code:
LOOK I AM A TURTLE fucked around with this message at 11:09 on Jul 12, 2013 |
# ? Jul 12, 2013 10:28 |
|
I'm sure this is entirely valid code but I still laughed at the name.Java code:
|
# ? Jul 12, 2013 17:17 |
|
spitefulcrow posted:For the Python developers in this thread, some truly horrible things you can do to Python: http://www.slideshare.net/r1chardj0n3s/dont-do-this-24000445. Hi! You seem to be pretty new at this programming thing. You might want to look at some interesting dynamic programming languages such as: Javascript, Lua, Scheme, Common Lisp, Ruby, Smalltalk, R, etc. But seriously. Why do you consider changing a function body a horror. (Besides the horrible underscores-based names and Rossum's ignorance of common programming language engineering terms.)
|
# ? Jul 12, 2013 17:19 |
|
Beef posted:Hi! You seem to be pretty new at this programming thing. You might want to look at some interesting dynamic programming languages such as: Javascript, Lua, Scheme, Common Lisp, Ruby, Smalltalk, R, etc. I don't have Python installed on this machine, or I'd check, but... I assume that changing a function in that way mutates the function. A competent Python programmer is au fait with mutable objects, but I think most people wouldn't really think of callables as mutable (exception: generators) If you pass a function into another function as a parameter, wouldn't you be surprised to find it got changed in place?
|
# ? Jul 12, 2013 17:24 |
|
Don't hate the game, hate the playa. No, you wouldn't want your junior programmer to be doing that. But a lot of those meta-programming options that change the basic behaviour of the language (or as in this case any object) is an extremely powerful tool for designing clean frameworks and DSLs. In some sense, it is similar to the operator overloading discussion in Java vs C++. It can be bad if you operator+() is overloaded by some dumb library to send an email to your mom. But simultaneously it allows Intel to make a nice parallel Vector library. edit: vvv Ooh yeah, decorators are a good example, I have to remember that when another of these discussion pop up. Beef fucked around with this message at 18:07 on Jul 12, 2013 |
# ? Jul 12, 2013 17:32 |
|
I suppose when I sayHammerite posted:If you pass a function into another function as a parameter, wouldn't you be surprised to find it got changed in place? that's what decorators do, which are powerful and good tools, so maybe my argument isn't so good.
|
# ? Jul 12, 2013 17:35 |
|
Decorators rarely change in-place, since they usually have the opportunity to simply return another one directly.Beef posted:Hi! You seem to be pretty new at this programming thing. You might want to look at some interesting dynamic programming languages such as: Javascript Since I've actually never seen it, how do you change a function body in JavaScript? As far as I can tell, you can build new functions with the Function constructor or eval, but never change a function's body. I'd also say that it would never get added to JavaScript, since the semantics of what it means are complicated, and would make JIT compilation more hell than it already is.
|
# ? Jul 12, 2013 18:11 |
|
Quicky checked the Python spec:code:
Of course, you wouldn't want your actual AST to be something you can mutate freely (as in, destructively assign parts of it). It used to be something common back in the 50's style LISP, but f-expressions got dumped in favor of macros. Only R is retarded enough to still do that. Decades after it's been shown that f-expr are an uncompilable mess, R comes out with semantics where functions get applied by literally substituting the actual arguments for the formal arguments in the body code of the function. 4% of a typical R runtime is spent on variable lookup, since the above semantics make lexical addressing impossible
|
# ? Jul 12, 2013 18:28 |
|
No popular JS JIT is a tracing JIT anymore. Turns out trace trees aren't really representative of real-world performance and you get knocked off-trace way too often, causing your perf to task. What it really means is that you can't accurately do inlining. If you have: JavaScript code:
|
# ? Jul 12, 2013 18:37 |
|
Munkeymon posted:"Languages that have first class functions and decent reflection support can do crazy poo poo if you really want them to "? As someone who's been using JavaScript for years, I'd just like to say: you don't loving say. You mean this one? UraniumAnchor posted:So I ran across this while trying to write some Ruby: I think the eventual consensus was that the assignment in the non-executing block still causes the interpreter to make "what" a local variable from that point on, instead of a function. So I guess Ruby functions aren't truly first class? Edit: Yup. code:
UraniumAnchor fucked around with this message at 19:07 on Jul 12, 2013 |
# ? Jul 12, 2013 19:02 |
|
UraniumAnchor posted:Guess functions aren't a type? Ruby semantics tend to be very misleading to people unfamiliar with the language due to that it's basically smalltalk's OO system wrapped up in a very non-smalltalk syntax.
|
# ? Jul 12, 2013 19:22 |
|
Amazon Reviewer posted:Additionally I found the "D is for deconstructor" subtext of "Let your mom clean up after you. That's her job." to be very sexist and added no value to the entry or related to the discussion of a deconstructor. http://www.amazon.com/Array-Brandon...=A+is+for+Array
|
# ? Jul 12, 2013 20:04 |
|
Yes, that's what I meant and Plorkyeran posted:Sort of, yes. Ruby "functions" are actually just methods on a semi-global object, and ruby uses message-based OO, which results in methods not actually being concrete things - conceptually they're move of just syntatic sugar for a big switch statement in method_missing. just confuses me more. Maybe I should learn SmallTalk first
|
# ? Jul 12, 2013 20:27 |
|
Yeah, for me the confusing part of that block is why a statement that clearly never executes still has a side effect. Maybe that's unavoidable due to the language design or something, but it's still weird.
|
# ? Jul 12, 2013 20:30 |
|
It is due to amateur language design
|
# ? Jul 12, 2013 20:36 |
|
The parser needs to know if something is a local variable or a function, otherwise what does what +1 mean? The parser doesn't know the result of if expressions, so it just blindly tracks which is what.
|
# ? Jul 12, 2013 20:38 |
|
Apparently ruby's parser/lexer is a horror. http://programmingisterrible.com/post/42432568185/how-to-parse-ruby Also tried to help out on topaz project, I know a goon works on that right?
|
# ? Jul 12, 2013 20:57 |
|
Conceptually, that ruby code is parsed as something vaguely along the lines of the following in Python:Python code:
(I'm not claiming that this behavior is good, just that it's not pure insanity) Munkeymon posted:just confuses me more. Maybe I should learn SmallTalk first
|
# ? Jul 12, 2013 21:13 |
|
Beef posted:Hi! You seem to be pretty new at this programming thing. You might want to look at some interesting dynamic programming languages such as: Javascript, Lua, Scheme, Common Lisp, Ruby, Smalltalk, R, etc. Thanks for talking down to me (for the record I'm going on my fourth year working in the industry professionally after finishing a CS degree… not an aged wizard but also not totally wet behind the ears). As I mentioned in my other reply, it's not strictly a horror, but if I saw it in someone's code that wasn't a testing framework or DSL implementation (or…) I'd probably slap them for being too clever. I would indeed consider it at least a little bit surprising if I handed a function object as a regular parameter to someone else's function and the original function I passed in was mutated to execute different code. Decorators achieve this in a non-destructive and repeatable way by wrapping the inner function's invocation with a new function. Yes, the original function's name is then re-bound to the decorated version, but the syntax makes it obvious that the decorator has been used and that the named function now has behavior other than what is directly inside its body. Even the example of a testing framework probably doesn't need this — since object attributes are mutable by default, mock.patch achieves the same goal in most cases without overwriting the innards of the actual function. It's conceptually cleaner to monkey-patch the entire function rather than violating the abstraction boundary. Yes, I know Python doesn't have real encapsulation because everything's mutable and this is just another case of that, but why break the conventions when you don't need to?
|
# ? Jul 13, 2013 17:56 |
|
spitefulcrow posted:As I mentioned in my other reply, it's not strictly a horror, but if I saw it in someone's code that wasn't a testing framework or DSL implementation (or…) I'd probably slap them for being too clever. Well, I mean... yeah. Like all reflection features, it's horribly inappropriate for most situations. But the language shouldn't make it more complicated to do just for the sake of disguising it. That's how you end up with things like Java reflection.
|
# ? Jul 13, 2013 18:36 |
|
Beef posted:Why do you consider changing a function body a horror. Because of obviosity? Why would you ever change a function body via spooky action at a distance? Maybe if you wanted to confuse everybody or had some other malicious goal in mind.
|
# ? Jul 13, 2013 18:59 |
|
shrughes posted:Because of obviosity? Why would you ever change a function body via spooky action at a distance? Maybe if you wanted to confuse everybody or had some other malicious goal in mind. Objective-C has a similar thing called swizzling where you can swap methods, so calling a method calls another, which can then call the original one. It's used to implement KVO, which lets allows classes to subscribe to get notified when the value of a variable changes.
|
# ? Jul 13, 2013 19:01 |
|
|
# ? May 17, 2024 16:45 |
|
Doctor w-rw-rw- posted:Objective-C has a similar thing called swizzling where you can swap methods, so calling a method calls another, which can then call the original one. KVO uses isa-swizzling, not method swizzling. (That is, it dynamically changes your object's class.) And for what it's worth, both kinds of swizzling are generally considered "horrors" in Objective-C land right up until the minute you need them, at which point they're very handy.
|
# ? Jul 13, 2013 19:17 |