{"id":1776,"date":"2009-03-13T09:34:11","date_gmt":"2009-03-13T14:34:11","guid":{"rendered":"http:\/\/bobbeaty.com\/wp\/?p=1776"},"modified":"2009-03-14T08:13:55","modified_gmt":"2009-03-14T13:13:55","slug":"its-amazing-what-passes-for-a-language-c","status":"publish","type":"post","link":"https:\/\/bobbeaty.com\/wp\/archives\/1776","title":{"rendered":"It&#8217;s Amazing What Passes for a Language &#8211; C#"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bobbeaty.com\/wp\/wp-content\/uploads\/2009\/03\/csharp.jpg\" alt=\"Csharp.jpg\" border=\"0\" width=\"125\" height=\"125\" align=\"right\" \/><\/p>\n<p>OK, I'm <em>old school<\/em>, and as such, I'm not a big IDE user, but I recognize that they have a place in this world, and it saves a lot of people a lot of time. Just not me. Not most of the time. But when I'm coming into a new project, and it's already established in this IDE and a certain language, it's just plain <em>silly<\/em> to buck these established \"standards\".<\/p>\n<p>But I have to say... C# is one of the oddest languages that I've ever seen. I believe it's written for people who have never seen a programming language before, and it's meant to be \"easy\" for them to understand what it's doing. Let's look at the setters and getters in C#, shall we?<\/p>\n<pre class=\"csharp\" style=\"font-family:monospace;\">  <span style=\"color: #0600FF; font-weight: bold;\">private<\/span> <span style=\"color: #6666cc; font-weight: bold;\">string<\/span> _farm<span style=\"color: #008000;\">;<\/span>\n&nbsp;\n  <span style=\"color: #008000;\">...<\/span>\n&nbsp;\n  <span style=\"color: #0600FF; font-weight: bold;\">public<\/span> <span style=\"color: #6666cc; font-weight: bold;\">string<\/span> Farm <span style=\"color: #008000;\">&#123;<\/span>\n      <span style=\"color: #0600FF; font-weight: bold;\">get<\/span> <span style=\"color: #008000;\">&#123;<\/span>\n          <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> _farm<span style=\"color: #008000;\">;<\/span>\n      <span style=\"color: #008000;\">&#125;<\/span>\n      <span style=\"color: #0600FF; font-weight: bold;\">set<\/span> <span style=\"color: #008000;\">&#123;<\/span>\n          _farm <span style=\"color: #008000;\">=<\/span> <span style=\"color: #0600FF; font-weight: bold;\">value<\/span><span style=\"color: #008000;\">;<\/span>\n      <span style=\"color: #008000;\">&#125;<\/span>\n  <span style=\"color: #008000;\">&#125;<\/span><\/pre>\n<p>where the first line is the definition of the instance variable, and the thing that looks like a method definition in Java or C++ or C is really a combination definition and meta-data for the getter and setter. The use of this code is simple:<\/p>\n<pre class=\"csharp\" style=\"font-family:monospace;\">  obj<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Farm<\/span> <span style=\"color: #008000;\">=<\/span> <span style=\"color: #666666;\">&quot;three&quot;<\/span><span style=\"color: #008000;\">;<\/span>\n&nbsp;\n  <span style=\"color: #008000;\">...<\/span>\n&nbsp;\n  <span style=\"color: #6666cc; font-weight: bold;\">string<\/span> l <span style=\"color: #008000;\">=<\/span> obj<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Farm<\/span><span style=\"color: #008000;\">;<\/span><\/pre>\n<p>Here the first call will end up calling the <tt>set<\/tt> 'method' in the <tt>Farm<\/tt> definition, and the second will call the <tt>get<\/tt> method. C# looks at the usage and then decides what method to call based on the naming conventions. I can see this, in theory, but it's so totally contrary to what you'd expect if you knew Java or C++.<\/p>\n<p>In fact, in either of these two languages it's clear what:<\/p>\n<pre class=\"csharp\" style=\"font-family:monospace;\">  obj<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">cnt<\/span><span style=\"color: #008000;\">++;<\/span><\/pre>\n<p>means, but in C# is it calling the getter, doing the increment and calling the setter? It would appear it would have to. However, it's not clear from the language structure. Call me silly, but I like the language to infer as little as possible about the workings of the code for me. If I wanted that, I'd have written macros for preprocessing.<\/p>\n<p>I have to use C#, so I will, but I can't imagine that I'm going to look at this anytime soon and see this as a good, descriptive, understandable, language. No time soon.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OK, I&#8217;m old school, and as such, I&#8217;m not a big IDE user, but I recognize that they have a place in this world, and it saves a lot of people a lot of time. Just not me. Not most of the time. But when I&#8217;m coming into a new project, and it&#8217;s already established [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1776","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/1776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/comments?post=1776"}],"version-history":[{"count":1,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/1776\/revisions"}],"predecessor-version":[{"id":1777,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/1776\/revisions\/1777"}],"wp:attachment":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/media?parent=1776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/categories?post=1776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/tags?post=1776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}