c# .net - um overview da linguagem

42

Upload: claudson-oliveira

Post on 26-Jun-2015

316 views

Category:

Technology


1 download

DESCRIPTION

Apresentação feita na disciplina de Linguagem de progração da Universidade Federal de Juiz de Fora.

TRANSCRIPT

Page 1: C# .NET - Um overview da linguagem
Page 2: C# .NET - Um overview da linguagem

Linguagem de programação

Adriele AlvarengaClaudson Oliveira

C#

Page 3: C# .NET - Um overview da linguagem

Histórico

• C#– Surgimento: 2001– Influências: Java, C++ , Object pascal, etc...

Page 4: C# .NET - Um overview da linguagem

Histórico

• C#– Surgimento: 2001– Influências: Java, C++ , Object pascal, etc...– Anders Hejlsberg (Turbo pascal e Borland Delphi)

Page 5: C# .NET - Um overview da linguagem

Histórico

• C#– Surgimento: 2001– Influências: Java, C++ , Object pascal, etc...– Anders Hejlsberg (Turbo pascal e Borland Delphi)– Objetivo: Plataforma .NET

Page 6: C# .NET - Um overview da linguagem

Características

• Normalizada (ECMA 334 e ISO/IEC 23270)

Page 7: C# .NET - Um overview da linguagem

Características

• Normalizada (ECMA 334 e ISO/IEC 23270) • Orientada a objetos

Page 8: C# .NET - Um overview da linguagem

Características

• Normalizada (ECMA 334 e ISO/IEC 23270) • Orientada a objetos• Compilação

Page 9: C# .NET - Um overview da linguagem

Características

• Normalizada (ECMA 334 e ISO/IEC 23270) • Orientada a objetos• Compilação• Visual Studio ou C# Express

Page 10: C# .NET - Um overview da linguagem

Propriedades

• Legibilidade e Redigibilidade

Page 11: C# .NET - Um overview da linguagem

Propriedades

• Legibilidade e Redigibilidade– Baseada em C++ e Java

Page 12: C# .NET - Um overview da linguagem

Propriedades

• Legibilidade e Redigibilidade– Baseada em C++ e Java

public class Hello1 {

public static void Main() {

System.Console.WriteLine("Hello, World!"); }

}

Page 13: C# .NET - Um overview da linguagem

Propriedades

• Confiabilidade– Tratamento de exceções

Page 14: C# .NET - Um overview da linguagem

Propriedades

• Confiabilidade– Tratamento de exceções– Utilização de ponteiros (unsafe)

Page 15: C# .NET - Um overview da linguagem

Propriedades

• Confiabilidade– Tratamento de exceções– Utilização de ponteiros (unsafe)– Coletor de lixo

Page 16: C# .NET - Um overview da linguagem

Propriedades

• Confiabilidade– Tratamento de exceções– Utilização de ponteiros (unsafe)– Coletor de lixo

Page 17: C# .NET - Um overview da linguagem

Propriedades

• Confiabilidade– Tratamento de exceções– Utilização de ponteiros (unsafe)– Coletor de lixo

unsafe static void usandoPonteiros(int* p) { int numero = 4; p = &numero ; }

Page 18: C# .NET - Um overview da linguagem

Coletor de lixo

• Gerência de memória da Heap

Page 19: C# .NET - Um overview da linguagem

Coletor de lixo

• Gerência de memória da Heap• Biblioteca Win32

Page 20: C# .NET - Um overview da linguagem

Coletor de lixo

• Gerência de memória da Heap• Biblioteca Win32

Page 21: C# .NET - Um overview da linguagem

Coletor de lixo

• Gerência de memória da Heap• Biblioteca Win32 • Busca linear

Page 22: C# .NET - Um overview da linguagem

Coletor de lixo

• Gerência de memória da Heap• Biblioteca Win32 • Busca linear

Page 23: C# .NET - Um overview da linguagem

Coletor de lixo

• Memória dividida

Page 24: C# .NET - Um overview da linguagem

Propriedades

• Ortogonalidade– Permite uso dos conceitos básicos

Page 25: C# .NET - Um overview da linguagem

Propriedades

• Ortogonalidade– Permite uso dos conceitos básicos– Poucas exceções• Ponteiros para void, array do tipo void

Page 26: C# .NET - Um overview da linguagem

Propriedades

• Eficiência– .NET• Just-in-time

Page 27: C# .NET - Um overview da linguagem

Propriedades

• Eficiência– .NET• Just-in-time• Compilação híbrida

Page 28: C# .NET - Um overview da linguagem

Propriedades

• Eficiência– .NET• Just-in-time• Compilação híbrida• Otimização de instruções

Page 29: C# .NET - Um overview da linguagem

Propriedades

• Portabilidade– dotGNU

Page 30: C# .NET - Um overview da linguagem

Propriedades

• Portabilidade– dotGNU – Portable .NET

Page 31: C# .NET - Um overview da linguagem

Propriedades

• Portabilidade– dotGNU – Portable .NET– Mono (Novell)

Page 32: C# .NET - Um overview da linguagem

Propriedades

• Portabilidade– dotGNU – Portable .NET– Mono (Novell)

Page 33: C# .NET - Um overview da linguagem

Entrevista

Page 34: C# .NET - Um overview da linguagem

EntrevistaHow long is the future of C#? You’ve been on it for almost 10 years.

C# the project started in late December of ‘98, so we’re coming up on our 10-year anniversary. That’s not 10 years of existing in the industry, but it’s 10 years sinceinception internally. I’d say we’ve got another 10 years at least, but it all depends. I’ve saidI’ve long given up predicting the far-off future of this industry because no one ever gets itright anyway. But I certainly see a strong healthy future for C#. We’re not done innovat-ing, and there’s plenty of work still to do.

Page 35: C# .NET - Um overview da linguagem

EntrevistaDo you get feedback regarding the C# language, not just the implementation?

(…) I read people’s blogs, I read forums where people ask technical questions, go to conferences—all sorts of ways that we get feedback daily on what works and what doesn’t in the language. We take that feedback back to the design team and we maintain a long laundry list of all of the crazy ideas. Some of them will never make it into the lan-guage, but we keep them on the list because there’s something there that maybe somedaywe’ll get a good idea around this area. We know that we don’t have it right yet, but there’s a desire to do something. Certainly there’s no way we could design the language without all this feedback, so it’s all based on listening to what people do withthe product.

Page 36: C# .NET - Um overview da linguagem

Entrevista

When I compare C# to Java, C# seems to have a stronger push toward evolution. The Java people seem to want a baseline where everyone’s code looks more or less the same. Whether you’ve programmed Java for a decade, never programmed before, or just graduated from a six-month course on Java, all of your code will look the same. C# seems to pull in new ideas from Haskell or from F#. Is there a desire to add new features that people who’ve just finished the six-month C# course haven’t seen and won’t immediately understand?

Page 37: C# .NET - Um overview da linguagem

EntrevistaI am not in this to engineer the next COBOL; let’s just put it that way.What is it that powers the Internet revolution and the electronic revolution that we’ve seen? It’s the fact that we’re constantly evolving. I bring it back to that. The minute you stop evolving, I don’t know that you’re adding any value. This is, again, taking it to the extreme. Of course, there is value in stability of the platform, but I think you provide that value by ensuring backward compatibility. You are free to get off the bus at C# 1.0 and justnot move any further. For those people that really want to be more productive and want to build newer kinds of apps like SOA or whatever and get into more dynamic styles of programming—adaptable programs and more declarative styles of programming like we’re doing with LINQ—then you’ve got to evolve or get out of the way, or something else will replace you.

Page 38: C# .NET - Um overview da linguagem

Entrevista

What do you suggest to become a better C# programmer?

It’s hard. There are many good books out there on C# programming and I would encourage people to pick up one of the better books. I’m not going to start naming names here, but there are many good books out there that will help you become a better C# pro-grammer and help you better understand the .NET Framework. There are many things available online that also help. There are things like Codeplex. There’s a bunch of open source projects that you can grab and look at and learn from and so forth.To become a better programmer in general, one of the things that have helped me is to look at different styles of programming and different kinds of programming languages(…)

Page 39: C# .NET - Um overview da linguagem

EntrevistaWhat’s facing us now and in five years?

Concurrency is the big one right now. That thing is right in our face, and we’ve got to find solutions to that problem. One of my biggest challenges in the foreseeable future is having our team work that issue.Again, we’d like to do it in an evolutionary fashion, but how do you deal with the shared state problem and side effects without breaking all the existing code? We don’t know yet, but it very well may be that that concurrency is a big enough paradigm change that whole new languages are needed or whole new frameworks are needed. Although I don’t think we’re at that point yet. I think there’s a lot of ground that we can gain from making it possible for people to write APIs that internally are massively parallel and written by people that really understand a particular domain, be it transformations or numeric processing or signal processing or bit- maps or image manipulation. (…)

Page 40: C# .NET - Um overview da linguagem

EntrevistaDoes the object-oriented paradigm create problems?You know, it depends on what you group under the object-oriented paradigm. Polymorphism and encapsulation and inheritance are as such not a problem, although functional languages typically have a different view of how you do polymorphism with their algebraic data types. Aside from that, I think the biggest problem typically with object-oriented programming is that people do their object-oriented programming in a very imperative manner where objects encapsulate mutable state and you call methods or send messages to objects that cause them to modify themselves unbeknownst to other people that are referencing these objects. Now you end up with side effects that surprise you that you can’t analyze.In that sense object-oriented programming is a problem, but you could do object-oriented programming with immutable objects. Then you wouldn’t have these same problems. That’s kind of what functional programming languages are doing, for example.

Page 41: C# .NET - Um overview da linguagem

Entrevista

Well, I certainly think that it is important to include functional programming inany computer science curricula. Whether you start with it that depends. I’m not sure that your very first introduction to programming should be functional programming, but I definitely think that it ought to be part of a curriculum.

Regarding your interest in functional programming, should computer science students study more math and experiment more with functional programming?

Page 42: C# .NET - Um overview da linguagem

Entrevista

What lessons should people learn from your experience?

Well, if you look at the first product I worked on, Turbo Pascal, it was very muchabout not believing the traditional way of doing things. Don’t be afraid. Just because people tell you it can’t be done, that doesn’t necessarily mean that it can’t be done. It justmeans that they can’t do it. I think it’s always fun to think outside of the box and try tofind new solutions to existing problems.It was the only thing I wanted to do. I was very, very passionate about it.You have to have that passion to get really good at something, because that makes you put in the hours, and the hours are the real key. You need to put in a lot of work.