5 ms·
The funny thing I come back to question myself with after seeing ExpandoObject and not needing to declare types (var blah = ), is, why not just go all the way t
by bfung 16y ago
The funny thing I come back to question myself with after seeing ExpandoObject and not needing to declare types (var blah = ), is, why not just go all the way to Ruby instead of being stuck inbetween?
- cema 16y agoAs they used to say, why not just go all the way to Lisp instead of etc? Just so as not to scare people off.
- rbanffy 16y agoOr Python, or Lisp... The use of .NET and C# (and Java) is often mandated by management levels, specially in large companies. For those unlucky folks, even a tiny little progress is a move in the right direction. Even if you want a .NET-like environment, you could use JRuby, Jython or Clojure and have a far better programming experience on top of the JVM. I really see no reason to even consider C# or .NET.
- jacquesm 16y agoMan the moderation in this thread is biased. Would whoever modded this down please explain how this is worth modding down instead of writing why you disagree with it?
- mquander 16y agoI didn't mod it down, but it seems intentionally shortsighted. I use both C# (for work) and Clojure (for fun) regularly; I'm a big Lisp weenie, and even I don't feel like I'm having a "far better" programming experience with Clojure than with C#. The language is somewhat better, but the tooling is somewhat worse, in my opinion. Saying those things are "far better" is just flamebait. If you're going to write such criticism, it's up to you to justify your statements, not up to other people to defend against a non-existent argument. EDIT: Stop modding me up, holy shit. This is off-topic and it's not important. Why do you want to highlight this self-evident comment so much that you're giving it a bunch of points? If I could have just messaged jacques instead of posting, I would have done that.
- jacquesm 16y agoWhich is great, because you actually provide some arguments. Downmodding like that to me is like trying to muzzle someone, as though by downvoting you can somehow prove they're wrong, whereas you can only really show someone is wrong by bringing a counter argument, preferably a solid one.
- mquander 16y agoTo encourage counter-arguments, one ought to make the original argument concrete and objective. Making a post to argue against a paragraph of snubs and the unsupported statement that X is just a "far better programming experience" than Y feels to me like getting trolled, not like having an argument.
- jacquesm 16y agoYes, but your own counter argument is based on a feeling, that's not much more solid than what Ricardo said to begin with, it is also unsupported, or at best anecdotal. None of this based on objective facts or stuff that you could measure. His truth to me is as good as your truth. But he got modded in to the ground and you got modded up.
- mquander 16y agoI know. I didn't intend mine as a counter-argument, but just as background for why I felt it was flamebait -- I have experience that indicates to me it's not credible to just uncategorically state that one is "far better." Like I expressed, it doesn't seem like there was much of an argument to make a counter-argument to. I wouldn't have modded me up, either; in fact, I would have modded me down, because this whole discussion is off-topic and doesn't deserve attention. I think the majority of moderation on here seems awful and is rarely even vaguely proportional to the quality of the comments, and I agree that this is an example of awful moderation. So you're arguing with the wrong fellow. EDIT: I amended my comment above to be irritating and sarcastic toward people who modded me up.
- SamReidHughes 16y agoHis comment was idiotic and he's sounding like a smug dynamic language weenie. It pulls the "mandated by management" straw man, groups C# and Java together and treats them the same (which is strong evidence that the parent doesn't have a clue about what he's talking about) and did I mention it's got that classic dynamic language weenie smell? The image that got conjured in my mind when reading that post was one of a teenage girl on the phone going, "C#? What. everrrr." "I really see no reason to even consider C# or .NET." This looks like an exhibition of the classic blub fallacy.
- zephyrfalcon 16y agoThat would make sense, if C# was more powerful/expressive than Python, Lisp or the like. It's not; it's just the least sucky (language-wise) of the mainstream statically typed languages. Plus it has all the .NET libraries and works well on Windows (naturally), which are reasons why people choose (or are forced) to use it. Not because it's the epitome of power and flexibility...
- SamReidHughes 16y ago> That would make sense, if C# was more powerful/expressive than Python, Lisp or the like. What? My comment makes sense, even if C# is worse than Python, etc.
- zephyrfalcon 16y agoTo quote the relevant parts from [http://www.paulgraham.com/avg.html http://www.paulgraham.com/avg.html]: "As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down. Languages less powerful than Blub are obviously less powerful, because they're missing some feature he's used to. But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub." The "paradox" (or "fallacy", as you called it) here refers to looking at a language that is more powerful, but not realizing that it is. By contrast, when looking at a language that is less powerful, this is usually obvious.
- mquander 16y agoWell, I'm not sure that's fair. In most dynamic languages, you can add type annotations and/or formal pre/post-conditions to selected pieces of code, usually for either compiler verification or optimization purposes; thus making a little piece of your code statically typed. Would you say they should just "go all the way to C#" (or ML, or whatever you prefer?) Of course not. The C# situation with dynamic is analogous. It's for people who like working in a static language, but want a particular piece of code dynamically typed because it happens to be very convenient for the task at hand. Obviously, there are a fair number of such tasks; mostly whenever you're dealing with a piece of structured but unpredictable data that lives outside your static bubble, like XML or external unmanaged libraries. And var isn't really worth mentioning; it's just very simplistic type inference on declarations. It's just (very good) syntax sugar and doesn't have any special semantic meaning at all.
- bfung 16y agoThe part I fear most is that every object suddenly becoming an ExpandoObject; there will be someone 'clever' that will do that. I'm speculating, but when you have a hammer... I think this also has to do with language expectations, express-tivity, and maintainability. A project already using a dynamic language will have some sort method to deal with the nature that certain calls will or will not exist. The addition annotations/conditions seem like optimizations, but doesn't fundamentally change how a programmer would go about using that dynamic language. C#, on the other hand, the language is more constrained to begin with. A (C#) programmer would normally expect certain things such as an interface having a certain number of methods with certain types. Just imagine a library exposing an api with expandos... =p
- mquander 16y agoI agree, and so does Microsoft, actually; I had the chance to ask a fellow on the C# team (I don't work for MS but I was there recently) why some things in the BCL weren't made dynamic -- for example, when you call a constructor via reflection, and it passes you an object whose type is indeterminate at compile-time, why doesn't it now return type dynamic instead of type object? His answer was basically your concern, that they didn't want to get in the habit of exposing dynamic things all over the place, since they felt it was sort of an unexpected thing to be doing in a language like C#. Hopefully third-party library programmers will be equally judicious.
- sid0 16y agoBecause static typing is really, really useful?
- bfung 16y agoExpandoObject basically says you can add properties ad hoc. When that happens, how do I know when a property on the object exists or not? The value of static typing goes down with ad hoc properties.
- mquander 16y agoSure; if every object was an ExpandoObject, the value of your "static typing" would be nil. The point is that you can just make an ExpandoObject if you really need ad hoc properties in one place, and it cooperates with the rest of your statically-typed code. To illustrate the value of such a thing, I invite you to look at the ADO.NET libraries for data access, which provided a verbose, painful "dynamic property bag" experience as far back as .NET 1.0; you had DataTables with columns that you would pass a type to, and then you had DataRows that you indexed into with strings to put objects in and get them out, and you had to cast them back and forth as you did it -- all of it ugly, none of it checked at compile-time. The value of C# dynamic (besides interop) is that now you can have such a thing in a fairly concise form with syntax that doesn't make you sob uncontrollably when you use it.
- TeHCrAzY 16y agoAnd people do use it. I have worked on a mind bending .NET call centre application within which the entire state of the program is stored within untyped, globally accessible datatables. It's down to the old "with great power comes great responsibility" idea.
- frou_dh 16y agoThis ruby comparison might make sense if people were to use C#'s dynamic all over the place, but it's just a single feature intended for specific situations. Most of the code will remain as sensibly static as ever.
- 16y ago
- j_baker 16y agoThe main reason is that it makes it much, much easier to interface C# with languages like IronPython or IronRuby. This allows you to take advantage of those languages' dynamic typing, but not have to drop into C when you need to squeeze a bit more performance out of your code.