Skip to main content

Posts

Showing posts with the label compiler

A evolução do C# - O início

Hoje vamos falar sobre História. Não aquela História das Guerras Mundiais, mas a história da evolução do C# como uma linguagem. Tenho em mente analisar as partes principais de uma das linguagens de programação em massa mais utilizadas no mundo. A grande parte do que vou falar é fruto de muita pesquisa, em parte porque quando o C# e o .NET foram disponibilizados eu ainda não tinha escrito uma única linha de código, por isso podemos dizer que sou novato neste mundo. No entanto, estou a esforçar-me por mudar isso, e cada nova descoberta é feita com muito entusiasmo da minha parte, e eu considero-me extremamente pro-activo, o que poderá até irritar quem está à minha volta. Uma das razões pelas quais estou a escrever este post, e já agora todo este blog, é porque eu tenho gosto em aprender coisas novas e principalmente partilhá-las com outros. Chega de conversa, vamos ao que interessa! O início do .NET A plataforma .NET traz uma nova forma de programar as nossas aplicações. A Microsof...

C# 2.0 - Property Acessor Accessibility

Let's talk about accessor's accessibility introduced in C# 2.0. This is a tiny little feature that can make your life easier in a number of ways. But first, let's define what i am talking about. Normally, a property is composed this way: So, from the example above, we can see that a property has a backfield (called _myProperty) and is composed by a getter and a setter . The getter is called whenever you get the value of that property. The setter is called when you set it's value. If we look carefully, we notice that the getter returns the value of the backfield, and the setter sets it's value, respectively. If we think about it, a property is nothing more than a wrapper around a private field. This way we can control all the access to that field's value. C#'s properties are nothing more than sintactic sugar for the following structure: This is an " old school property ". In languages where you don't really have the concept of prop...

C# 2.0 - Anonymous Methods

Let's get back to my series on the evolution of the C# language. Everybody is familiar with what a delegate is, right? We know that delegates are a big part of the events system in .Net. We register a method on that delegate ( called handler ) that is invoked when the delegate is invoked. In other words, a delegate simply points to a method. The advantage here is that, as the delegate wraps the method and is an object, we can simply pass it to a method as a parameter! Think about this: This is how we use a delegate in events, for instance. The class exposes the delegate and we register our method to listen it. When the delegate is called inside the class, all the registered methods will be called (because of this, we call it a Multicast Delegate ). This works well, because all you have to do is have a method with the required signature. In the example above, we needed to declare two methods just to make a Console.WriteLine. Isn't this too much? I think it's a bit to...

C# 2.0 - Partial Types

For those of you interested, i found a very interesting list of features that were introduced in C# in  here . This is a very complete list that contains all the features, and i'm explaining them one by one in this post series. We've talked about  Generics  and  Iterators . Now it's time for some partial types . A partial type  is a type which definition is spread across one or more files. It doesn't have to be in multiple separated files, but can be. This is a very simple concept that can give us many benefits, let's see: If a type is partial, multiple developers can work on every part of it. This allows a more organized way of working and can lead to production improvement.  Winforms , for example, generates a partial class for the form so that the client can separately edit other parts it. This way, a part contains information about the design and the other contains the logic of the form. In fact, this is a very spread pattern across .Net. Ent...

The evolution of C# Part One - The beginning

Today, let's talk about some history. Not that World War history, but the history and evolution of C# as a language. I would like to analyze the principal parts in one of the mainstream languages of mass production in today's software. Beware that most of what i am about to say is the fruit of much research, in part because when C# and the .NET became available i had not written a single line of code yet, so you can say that i am a newborn in this world. I'm inclined to change that, though, but every new discovery is done with much enthusiasm on my part, and i'm very proactive, which sometimes may upset my colleagues. One of the reasons i'm writing this article - and this blog all the same - is because i love to learn new things and share it with others. Enough talk, let's get to the point! The beginning of .Net The .NET platform brings a brand new and fresh way of programming your applications. Microsoft created the term "Managed Code" to refer t...