Marco Parenzan
1nn0va After Hour FY22 ep.23 // martedì 22 marzo 2022 h.21
Your contacts Your sites
Your badges
• Senion Solution Architect @ beanTech
• 1nn0va Community Lead (Pordenone)
• Microsoft Azure MVP
• Linkedin: https://www.linkedin.com/in/marcoparenzan/ • Slideshare:
https://www.slideshare.net/marco.parenzan
• GitHub: https://github.com/marcoparenzan
Marco Parenzan
• When you work with IoT Central, you work with IoT PnP
• IoT PnPDigital Twin Definition Language
• InterfaceComponentCapability
• Capability=Telemetry // Property // Command
• When you define a Telemetry, it has
• Semantic
• Unit
• Type
• You can do code generation in front of it!
Azure IoT Central and IoT PnP
demo
• An application of the new static generic abstracts in in an interface (argh!)
• https://devblogs.microsoft.com/dotnet/preview-features-in-net-6-generic-math/
.net6.net7 is introducing Generic Math
demo
• Scalar=Primitive=Struct(ural)=sealed[cannot derive]
• You cannot qualify a scalar
• All class goodies (type checking) are (almost) avoided
• Lot of mess:
• Method signs
• Overload collisions
• Custom Types can introduce more significance
• How?
• Like triggers in SQL, .NET has structs (missing in action)
«missing type»=scalars!
• ...or more simpler, structs in C#
• Remember: the formal definition says «allocated into the stack, not into the
heap»
• Be more precise
• Reference typea variable, or a parameter, containes a reference to an entity into the heap
• Value type a variable, or a parameter, containes directly the entity
• Value typecopy semantic
• Reference typereference (obviously) semantics
• Value types are fast
Value Types in .NET
demo
• Another «missing in action»: implicit operator and operator overloading
• Do you remember that you can overload aritmetic operators to use your value
types?
• And that you can cast from scalars to structural types (also reference types)?
• Do you know that all of these can become a great math?
Math with value types
demo
• Volt+Volt=Volt (you can add or subtract homogeneus values)
• Volt*Ampere=Ampere*Volt=Watt (multiplication is commutative)
• Watt/Ampere != Ampere/Watt (division is not commutative)
• ...and remember the plain good old ToString method!
Let’s remember physics
demo
demo
• Physics and math is about customizing a job (because you have to «express»
some laws)
• You have to express calculations
• A couple of choices:
• CSharp Scripting (Roslyn)
• ANTLR
«Scripting» in .NET
CSharp Scripting (Roslyn)
ANTLR
demo
demo
• Mathematica! From Stephen Wolfram!
• Now we have it also in .NET
• Notebooks
• Kernels
Where Math and science and code met 30yr ago
demo
• Math can be a lot of fun
• .NET can be a lot of fun in the science area
Conclusion
Math with .NET for you and Azure

Math with .NET for you and Azure

  • 1.
    Marco Parenzan 1nn0va AfterHour FY22 ep.23 // martedì 22 marzo 2022 h.21
  • 2.
    Your contacts Yoursites Your badges • Senion Solution Architect @ beanTech • 1nn0va Community Lead (Pordenone) • Microsoft Azure MVP • Linkedin: https://www.linkedin.com/in/marcoparenzan/ • Slideshare: https://www.slideshare.net/marco.parenzan • GitHub: https://github.com/marcoparenzan Marco Parenzan
  • 4.
    • When youwork with IoT Central, you work with IoT PnP • IoT PnPDigital Twin Definition Language • InterfaceComponentCapability • Capability=Telemetry // Property // Command • When you define a Telemetry, it has • Semantic • Unit • Type • You can do code generation in front of it! Azure IoT Central and IoT PnP
  • 5.
  • 7.
    • An applicationof the new static generic abstracts in in an interface (argh!) • https://devblogs.microsoft.com/dotnet/preview-features-in-net-6-generic-math/ .net6.net7 is introducing Generic Math
  • 8.
  • 11.
    • Scalar=Primitive=Struct(ural)=sealed[cannot derive] •You cannot qualify a scalar • All class goodies (type checking) are (almost) avoided • Lot of mess: • Method signs • Overload collisions • Custom Types can introduce more significance • How? • Like triggers in SQL, .NET has structs (missing in action) «missing type»=scalars!
  • 12.
    • ...or moresimpler, structs in C# • Remember: the formal definition says «allocated into the stack, not into the heap» • Be more precise • Reference typea variable, or a parameter, containes a reference to an entity into the heap • Value type a variable, or a parameter, containes directly the entity • Value typecopy semantic • Reference typereference (obviously) semantics • Value types are fast Value Types in .NET
  • 13.
  • 14.
    • Another «missingin action»: implicit operator and operator overloading • Do you remember that you can overload aritmetic operators to use your value types? • And that you can cast from scalars to structural types (also reference types)? • Do you know that all of these can become a great math? Math with value types
  • 15.
  • 16.
    • Volt+Volt=Volt (youcan add or subtract homogeneus values) • Volt*Ampere=Ampere*Volt=Watt (multiplication is commutative) • Watt/Ampere != Ampere/Watt (division is not commutative) • ...and remember the plain good old ToString method! Let’s remember physics
  • 17.
  • 18.
  • 20.
    • Physics andmath is about customizing a job (because you have to «express» some laws) • You have to express calculations • A couple of choices: • CSharp Scripting (Roslyn) • ANTLR «Scripting» in .NET
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
    • Mathematica! FromStephen Wolfram! • Now we have it also in .NET • Notebooks • Kernels Where Math and science and code met 30yr ago
  • 26.
  • 28.
    • Math canbe a lot of fun • .NET can be a lot of fun in the science area Conclusion