What’s up, C# 8?
C# 8? Already? But I’m just finishing understanding version 6…! I know, I feel too the dizziness of the speed of the change of versions, but while we still are enjoying version 7, in channel 9 they are showing “breadcrumbs” of what will come with version 8, and if you haven’t seen it, here I leave the first 4 announced characteristics:
Null reference type
By default, the objects of reference type have null value (like String objects) which won’t be applicable anymore in this version; that indicates that, as the primitive types, this type of objects must be marked as nullables (type?) and according to their creators, it will lead to a cleaner code and bigger control of the content of this type of variables, without generating bigger damages at coding time.
Asynchronous flows
Commonly known as foreach async, they are the equivalent to an IEnumerable asynchronous. Here it is defined an iterator where it is constructed an object flow in lazy mode, but who controls the speed is who consumes it (pull model) so the producer never overflows with flows that can’t control.
Implementation of default interfaces
They are a limited way of multiple inheritance and will allow to abstract interfaces to completely define methods as if they are and abstract class, although you can’t declare constructors or fields… Yet. One of the main benefits is to be able to add new methods to an interface without changing backwards compatibility.
Extend everything
It is created a new high-level constructor called “extension” that allows to extend properties, events, overload operators and many more.
It seems interesting, right? If you want to see what Channel 9 guys said, you can see them here talking about it.
https://channel9.msdn.com/Blogs/Seth-Juarez/A-Preview-of-C-8-with-Mads-Torgersen
¿Qué hay de nuevo, C# 8?
¿C# 8? ¿Ya tan rápido? ¡Pero si apenas estoy terminando de entender la versión 6…! Lo sé, También siento el vértigo del cambio de versiones tan rápido, pero mientras todavía estamos disfrutando de la versión 7, ya en Channel 9 están mostrando “probaditas” de lo que se vendrá con la versión 8, y si no las has visto, acá dejo las primeras 4 características anunciadas:
Tipos referencia nulos
Por defecto, los objetos de tipo referencia tienen valor nulo (como los String) lo cual ya no sería aplicable en esta versión, lo que indica que, al igual que los tipos primitivos, este tipo de objetos hay que marcarlos como nullables (type?) y según sus creadores, llevará a un código más limpio y mayor control del contenido de este tipo de variables, sin generar grandes traumatismos al momento de codificar.
Flujos asíncronos
Más conocidos como foreach async, son el equivalente asíncrono a IEnumerable. Acá se define un iterador donde se construye un flujo de objetos de manera perezosa, pero quien controla la velocidad es quien lo consume (pull model) de modo que el productor no lo inunda con flujos que no puede controlar.
Implementaciones de interfaces por defecto
Son una forma limitada de herencia múltiple y permitirá abstraer interfaces para definir completamente métodos como si fuera una clase abstracta, aunque no se pueden declarar constructores o campos… Todavía. Uno de los principales beneficios es poder agregar nuevos métodos a una interfaz existente sin alterar la compatibilidad hacia atrás.
Extienda todo
Se creó un nuevo constructor de nivel superior llamado “extension” que permite extender propiedades, eventos, operadores de sobrecarga, métodos y muchas cosas más.
Pinta muy interesante el panorama, ¿verdad? Si deseas ver lo que dijeron los chicos de channel 9, acá puedes verlos hablar sobre el tema.