﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>jmorris commented on Statically typed? Compiler checked? Ha!</title><description>@Gauthier - yes a string constant would solve this "issue." I am surprised that your are the only one to notice the strawman...
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment22</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment22</guid><pubDate>Sat, 22 Dec 2007 03:59:48 GMT</pubDate></item><item><title>jmorris commented on Statically typed? Compiler checked? Ha!</title><description>Why not just use a language that supports that kind of construct? C# is not a be and do everything for everyone. If you want a more expressive language than C#, then use a language that _is_ more expressive than C#...Go play with the DLR or ruby...and yes i love static typed languages :)
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment21</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment21</guid><pubDate>Sat, 22 Dec 2007 02:56:05 GMT</pubDate></item><item><title>Gauthier Segay commented on Statically typed? Compiler checked? Ha!</title><description>Doesn't string constants "solve" the missing symbol feature "issue", or am I missing something else?
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment20</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment20</guid><pubDate>Sat, 22 Dec 2007 00:19:07 GMT</pubDate></item><item><title>Haacked commented on Statically typed? Compiler checked? Ha!</title><description>So in the case of the hash, the "special status" is that it's a key to a hash. I see.
  
  
Your symbol rename agument defeats me. I concede. :)
  
  
Though... I must point out the dangers in assuming that symbols make renaming safe. If I use :foo in one context and :foo in another, I'd be in danger if I did a symbol rename and those contexts were different.
  
  
So with symbols, you've solved the find and replace issue with renaming a symbol vs a string (aka with "red" and :red are differentiated). 
  
  
But you haven't solved:
  
  
hash = {:red =&gt; "foo"}
  
some_method :red = "bar"
  
  
Where :red in both cases means different things. 
  
  
Of course, it's probably just a "running with scissors" moment in which you need to be sure that symbols are unique globally when they are a symbol for the same thing, since renaming a symbol limited by scope would be problematic too:
  
  
def foo(hash)
  
  puts hash[:red]
  
end
  
  
def bar()
  
  hash = {:red =&gt; "foobar"}
  
end
  
  
A rename limited to scope wouldn't know that :red in both methods are the same thing and should both be renamed.
  
  
In any case, an interesting idea.
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment19</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment19</guid><pubDate>Thu, 20 Dec 2007 23:52:35 GMT</pubDate></item><item><title>Andrey Shchekin commented on Statically typed? Compiler checked? Ha!</title><description>&gt;No, this is an abuse of a language feature that was never meant to be use this way.
  
After some thinking, I agree with you. But I do not agree that symbols are compelling enough to hack the language to support them. In VB you can do dict!Value, which basically means dict["Value"], but I used it rarely because it was too easy to mistake this with something checked by the compiler.
  
  
What I would somewhat like too see would be actual checks:
  
string controller = "controller";
  
string action = "action";
  
RouteTable.Routes.Add(new Route {
  
 Url = $“admin/[${controller}]/[${action}]“,
  
 Defaults = new {
  
  { controller, “Admin“ },
  
  { acton, “Index” }
  
 },
  
 Validation = new {
  
   { controller, “Admin|Users|Categories” }
  
 },
  
 RouteHandler = typeof(MvcRouteHandler)
  
});
  
with string interpolation, type inference (infers Dictionary) and real compile-type checking. The one things that seems redundant is 
  
string controller = "controller";
  
but I can not think of language feature than fix this without losing the advantages of checking. Basically, we are saying here that this symbol is known and will be used, as opposed to "cntroller", "controler" or "control", which will be allowed by Ruby checker.
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment18</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment18</guid><pubDate>Thu, 20 Dec 2007 23:48:26 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>Phil,
  
You are focusing on an implementation detail that is rather unimportant from my point of view.
  
I am not talking about the immutability or mutability of strings, or whatever you can compare a symbol to a string or vice versa.
  
I am talking that it is much easier to read :this than "this". You have been trained that "this" is not text that should mean anything, it is just "text".
  
  
What I am saying is that this distinction is important. It is going to be helpful for both humans and tools that needs to deal with this.
  
Can you tell me how you are going to do a "symbol" rename, for example?
  
  
From the point of view of the reader, giving it a special status gives it special attention.
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment17</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment17</guid><pubDate>Thu, 20 Dec 2007 23:34:55 GMT</pubDate></item><item><title>Haacked commented on Statically typed? Compiler checked? Ha!</title><description>Syntactic sugar for what?
  
  
In Ruby, this makes sense because in Ruby...
  
  
  :foo != "foo"
  
  
Since strings are mutable and not interned in Ruby, it makes sense to have syntactic sugar for an immutable literal string. Because you don't already have syntax for that.
  
  
But in C#
  
  
   :foo in Ruby == "foo" in C#
  
  
They mean the exact same thing. 
  
So I don't understand why you'de have :foo = "foo" in C# as "syntactic sugar".
  
  
Let me pose it to you in another way. Should Ruby have the following syntactic sugar?
  
  
#foo
  
  
Where # is syntactic sugar for a mutable string? In other words:
  
  
#foo = "foo"
  
  
I mean, isn't that extra quote semantic cruft? ;)
  
  
If Ruby strings were immutable and interned like they are in .NET, I'm guessing there'd be no need for symbols in Ruby.
  
  
Phil
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment16</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment16</guid><pubDate>Thu, 20 Dec 2007 23:29:49 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>Phil,
  
I disagree. I think that syntactic sugar is super important, because it make the difference between an acceptable solution and something that you turn your nose at.
  
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment15</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment15</guid><pubDate>Thu, 20 Dec 2007 23:23:02 GMT</pubDate></item><item><title>Haacked commented on Statically typed? Compiler checked? Ha!</title><description>Hmm... 
  
  
Symbols are necessary in Ruby because strings are mutable, but symbols are not. Thus:
  
  
  hash1 = {"red" =&gt; "foo"} 
  
  hash2 = {"red" =&gt; "foo"}
  
  
(totally valid in Ruby) would have two different memory locations for the key "red". 
  
  
But with symbols:
  
  
  hash1 = {:red =&gt; "foo"} 
  
  hash2 = {:red =&gt; "foo"}
  
  
:red in both hashes refer to the same memory location.
  
  
It seems to me that since strings are immutable with .NET, string interning provides the same benefit as symbols do in Ruby.
  
  
So the only benefit of a symbol would be that you don't have to use quotes? You do have to use quotes for a symbol in ruby if you have spaces in the symbol.
  
  
  :"my symbol"
  
  
The .NET equivalent is even shorter:
  
  
  "my symbol"
  
  
I don't think this is semantic cruft at all to require quotes when it effectively is equivalent to the purpose of a symbol. A symbol is a simply a const literal within Ruby.
  
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment14</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment14</guid><pubDate>Thu, 20 Dec 2007 23:18:07 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>They wouldn't. Although I challenge you to come up with a good reason to use  "#)$*(&amp;)#" as a dictionary key.
  
  
The reason that I am saying that you want symbol is that you are _trying_ to get sybmols now. It has to do with the amount of 
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment13</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment13</guid><pubDate>Thu, 20 Dec 2007 22:31:07 GMT</pubDate></item><item><title>Haacked commented on Statically typed? Compiler checked? Ha!</title><description>Symbols? Not sure I understand why.
  
For example, what if I want this:
  
  
IDictionary&lt;string, object&gt; values = {"Footie Tutie"=123, "#)$*(&amp;)#"="bar"};
  
  
or
  
  
IDictionary&lt;MyObj, object&gt; values = {new MyObj(1), new MyObj(2)="bar"}; 
  
  
What would that look like using symbols?
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment12</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment12</guid><pubDate>Thu, 20 Dec 2007 22:26:33 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>Phil,
  
Hm, that isn't good enough, you really want symbols for something like that.
  
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment11</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment11</guid><pubDate>Thu, 20 Dec 2007 22:22:47 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>Andrey,
  
No, this is an abuse of a language feature that was never meant to be use this way.
  
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment10</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment10</guid><pubDate>Thu, 20 Dec 2007 22:20:12 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>Andrey,
  
No, this is an abuse of a language feature that was never meant to be use this way.
  
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment9</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment9</guid><pubDate>Thu, 20 Dec 2007 22:20:12 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>Nick,
  
How would it know to use the IRouteDefaults?
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment8</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment8</guid><pubDate>Thu, 20 Dec 2007 22:19:58 GMT</pubDate></item><item><title>Ayende Rahien commented on Statically typed? Compiler checked? Ha!</title><description>Luke,
  
That was intentional, and that isn't the only one.
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment7</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment7</guid><pubDate>Thu, 20 Dec 2007 22:18:10 GMT</pubDate></item><item><title>Haacked commented on Statically typed? Compiler checked? Ha!</title><description>You mean the ability to define a hash table like:
  
  
IDictionary&lt;string, object&gt; values = {"Foo"=123, "Bar"="bar"};
  
  
I'd love that too. ;)
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment6</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment6</guid><pubDate>Thu, 20 Dec 2007 21:55:58 GMT</pubDate></item><item><title>Andrey Shchekin commented on Statically typed? Compiler checked? Ha!</title><description>Is not it a first-class support?
  
The only problem is that it is not easy to get data out of it, but I think that was something C# architects wanted more time to think about.
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment5</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment5</guid><pubDate>Thu, 20 Dec 2007 21:38:19 GMT</pubDate></item><item><title>Nick commented on Statically typed? Compiler checked? Ha!</title><description>'new IRouteDefaults {' is ok, but my ideal compiler would just infer from the assignment that the anonymous type it generates should implement IRouteDefaults automatically.
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment4</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment4</guid><pubDate>Thu, 20 Dec 2007 21:35:56 GMT</pubDate></item><item><title>Luke Breuer commented on Statically typed? Compiler checked? Ha!</title><description>Conrtoller?  ouch, unless that was just a blog-typo. :-p
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment3</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment3</guid><pubDate>Thu, 20 Dec 2007 21:27:20 GMT</pubDate></item><item><title>Adam Tybor commented on Statically typed? Compiler checked? Ha!</title><description>It would be cool if you could use Interfaces like:
  
  
new IRouteDefaults { 
  
Controller = "Admin", 
  
Action = "Index", 
  
NotPartOfInterface = "ExtraProp"
  
}
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment2</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment2</guid><pubDate>Thu, 20 Dec 2007 21:24:02 GMT</pubDate></item><item><title>Adam Tybor commented on Statically typed? Compiler checked? Ha!</title><description>Unfortunately actually getting those properties like Controller, Action out of the anonymous type  you need to use a TypeDescriptor and some reflection.  Not great.
</description><link>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment1</link><guid>http://ayende.com/3062/statically-typed-compiler-checked-ha#comment1</guid><pubDate>Thu, 20 Dec 2007 21:21:04 GMT</pubDate></item></channel></rss>