28 May 2019

#020 - Exploring C# Linguistics #100DaysOfCode

Alrighty! I am officially smitten with programming. I decided to take a leap of faith to explore the world of C# using the learning track from #Treehouse.

I think C# is a pretty language. It's very clean looking and less cumbersome than I expected. It's also an interesting step above JavaScript. With regards to the language syntax, they both appear very similar. I suspect most modern programming languages will have similar shape and form, as the underlying programming principals should remain consistent throughout each programming language.

The .NET framework is appealing with the whole System.Console I/O streams with the likes of ReadLine() and WriteLine(), etc. After stumbling upon the resourceful .NET Documentation on the Microsoft website, I never knew there are 18 forms of the Write() method. Blimey! I get why people prefer jQuery over vanilla JavaScript...

The whole namespace is interesting. If my understanding is correct, a namespace is like a workspace, where you can collate and organise classes within a given namespace. Thanks to Treehouse, I have adopted the State > City > Street convention when analysing namespaces, classes and methods respectively.

Of course, I am still learning the basics of C#, so I am doing various console app development at the moment. I am keen to see how C# works with web applications.

Edit: I also read the other day that Microsoft is aiming for a more unified .NET platform (https://devblogs.microsoft.com/dotnet/introducing-net-5/). I believe .Net Core 3.0 is the current edition, but from Fall 2020 it will mark the new future of the .NET platform starting with .NET 5. I am particularly excited to see what Microsoft is cooking with new versions of C# and the .NET platform as a whole. Hopefully, it will make the .NET documentation more unified with newer versions. All I can say is that I'm thankful and excited to have started learning C#.

I am using Microsoft's Visual Studio Community 2019 edition to write my code, as I want to grapple with the modern development tools used in the real world. I also installed the Mono compiler, so I can test some basic calculations and syntax outside my main work environment.

I like the specificity of the C# syntax, which I suspect is similar to C++ (another language that I hope to explore very soon).

For example, when declaring variables in JavaScript you would associate a value with a labelled const or let.

i.e.

const pi = 3.14;
let firstName = "John";
let secondName = "Smith";

But in C#, you can specialise a data type for a given variable.

i.e.

int theMeaningOfLife = 42;
string hitchhikerAuthor = "Douglas Adams";

I learned through Treehouse that most C# developers prefer to declare variables using the var keyword, as opposed to creating specific variable types like int, float and string, etc.

Mind you, the var keyword is also something I personally avoid using within JavaScript and I opt to use const and let. But to learn that C# developers prefer var as the defacto compared to specific data types, then I will want to adopt that mirrored approach. I also understand that in JavaScript, there are no data types - a variable is a variable that is typically stored inside const (if the value doesn't change), or let (if the value is likely to change).

Note: I am going to contradict myself here, but for a high-level language like C#, I can see the visual benefit in specialising a given variable type, so at least you can follow the data when debugging your code. For example, when developing a complex game engine, I would prefer to use specific data types, so I can see how the float co-ordinates and matrixes are calculated in the 3D world of a game. Anything outside the development of a 3D game engine, then I suppose using a generic var data type is fine (just like in JavaScript).

I am due to start another C# course and develop a Tower Defense game with Treehouse. Hopefully, I can grasp the advanced principals of Object-Orientated Programming (OOP) in the realm of C#. It would be good to understand the underlying core of C#, so I can start exploring fun programming projects which I know my portfolio will benefit immensely, once I create some interesting prototypes.

~Richard