Learning C# – Sort Of

By Shamus Posted Friday May 19, 2017

Filed under: Programming 142 comments

As I alluded to last Friday, I’ve been dabbling with the idea of expanding (modernizing) my programming knowledge and learning some Unity. I’ve been stuck in my old habits for a long time now. I’ve always been caught in this Catch-22 where I don’t want to stop working on an existing project to learn something radical and new, because doing so would bring the project to a halt. But if I’m not working on a project then I don’t have any immediate use for the New Thing. I’m either too busy or I don’t need it.

But for whatever reason, now feels like a good time to take a crack at it. To this end I’ve been watching Unity tutorials. This is both fascinating and maddening.

I have decades of coding experience, but I’m new to both Unity and C#. I’m a C++ programmer. C# and C++ are very similar, but not so similar that I can just jump in and begin writing useful C# code without educating myself first. The problem is that aren’t really any tutorials out there for me. Everything is either high-level stuff that assumes a deep knowledge of both C# and Unity, or (I am not joking here) it teaches you how to make some rudimentary “game” without needing to write a single line of code.

The latter actually kind of pisses me off. I get that this is part of the allure of Unity for most people, but for me it’s like I took a class with a master carpenter in hopes of learning woodworking, and instead he spent the entire class showing us how to assemble IKEA furniture. This wouldn’t be so bad if I was just scanning a text document, but it’s pretty annoying to sit through fifteen minutes of rambling video waiting for them to get through this introduction crap and to the main part of the video, only to realize that this click-and-drag stuff IS the main part of the video and I’ve just wasted my time again.

For couple of days in a row I’ve opened up Unity to an empty project with the silly notion that I was going to begin making some small thing. But then two hours later I was still scanning through video tutorials looking for answers and I hadn’t typed a single line of code.

Part of the problem is that what I want to do is kind of strange. I don’t want to import a model from the model library. I want to create my own out of raw polygons. I want to set up my own surface normals, set the UV mapping, and render it.

For my money, this series on Procedural Landmass Generation by Sebastian Lague is the best tutorial so far. It has a lot of what I need to get going. The problem is that the bits I need are little ten-second segments sprinkled throughout the sprawling four and a half hour video series. That’s not a very efficient way of learning.

Why Video?

I'm about 60% sure this is unrelated to the Unitarianism in Dead Space.
I'm about 60% sure this is unrelated to the Unitarianism in Dead Space.

I get that there are some concepts that work really well in video. In the past I’ve tried to describe fiddly concepts like surface normals, bilinear filtering, one-sided polygons, Z-buffering, camera views, and texture addressing. These concepts are all things that are relatively easy to illustrate using video but somewhat long-winded to explain in prose. When teaching this sort of high-level conceptual stuff, video is tremendously useful.

And the other hand, when it’s time to write code then nothing beats plain text.

I’m not sure why video is such a popular format when it’s so obviously inferior. Is this what the public wants? Does it make the material more approachable? Does it feel more comfortable when it’s delivered like a lecture in school because that’s how most people learned as children? Or is the tutorial a video simply for the convenience of the producer? I don’t know. The whole thing is so strange to me. I’ve always thought of video as more labor-intensive to produce and lectures more time-consuming to consume, so from my perspective it feels like everyone is wasting their time for no reason.

So we’re actually facing two problems: One is the problem where there aren’t good tutorials for experienced programmers to bring them up to speed in Unity, and the other is that most tutorials are videos when they should be articles. I’m caught at the intersection of these two problems, which means I’ve spent a couple of hours this week watching someone explain to me nine things I already know and one thing I can’t understand because I don’t have the context.

C# First Impressions

Here, have a random Good Robot screenshot for no reason.
Here, have a random Good Robot screenshot for no reason.

C# and C++ are so similar that C# falls into some kind of uncanny valley for me. It’s so much like C++ that I get baffled when presented with something very different from what I’m used to. If the two languages used radically different syntax then the deviations wouldn’t feel so strange. But as it stands this thing looks so familiar yet feels so alien.

Consider the classic “Hello World” program:

// my first program in C++
#include <iostream>
 
int main()
{
  std::cout << "Hello World!";
}

When your write a program in C or C++, the program begins at main (). The operations within main () will be executed in order, and when main () ends the program stops running. Here’s the main() loopThis is actually the main loop for the incomplete Linux version. The Windows version uses WinMain () and… uh. Look, it’s stupid but we don’t have to to get into it. from Good Robot:

1
2
3
4
5
6
7
8
int main(int argc, char** argv)
{
  init();
  run();
  term();
  SteamAPI_Shutdown();
  return 0;
}

On line 3 the program calls init () to initialize everything. This starts up the rendering, initializes the sound system, loads the fonts, reads in all the data files that drive the game, and so on. Then the program spends most of its time in run (), which keeps the whole thing going by maintaining the rendering loop, reading input, and doing all the other stuff a program needs to do to keep itself alive. When the user exits the game, run () ends. Execution passes to term () to clean up all the stuff we did in init (). After that we shut down the Steam API. Technically SteamAPI_Shutdown() ought to go inside of term (), since that’s what term() is for. I think Arvind put it here because we were always shy of modifying each other’s code.

At any rate, once main () is out of instructions to run, execution ends and the program poofs out of existence.

This is how things have worked since literally before I was born. (Development began on the C language in 1969, and I didn’t show up until 1971.)

Now let’s look at “Hello World” in C#:

// Hello1.cs
public class Hello1
{
   public static void Main()
   {
      System.Console.WriteLine("Hello, World!");
   }
}

As a veteran C and C++ programmer, this source code is surreal in the way it mixes the familiar with the inexplicable.

First off, we declare a class. Okay. That’s a fine thing to do. That’s something you can (and often should) do in C++ in any program above trivial complexity. But usually you declare a class and then you instantiate it. The class definition is the blueprint, and somewhere in your code you need to actually create something that uses that class. Maybe something like this example of C++ code:

1
2
3
4
5
6
7
8
9
10
11
12
13
//This class is stupid because all the members are private and there are no methods to 
//make use of them. But just go with it. It's an example program and I don't want to 
//build a whole class interface. That would only confuse people.
 
class Player
{ 
  string name;
  int    hitpoints;
  int    mana;
  int    XP;
};
 
class Player player1;

On lines 5 through 11 we define the blueprint for the Player class. But nothing actually happens until line 13 when we cause a specific player to exist, and we store their data in a variable named “player1”.

But that doesn’t happen in the C# program. We define a class called Hello1, but then… what causes an instance of Hello1 to begin existing?

Things get even more bizarre when we see that Main () is inside of this class! So now our program is contained within a class that never exists? Madness! What would happen if I made another file called Hello2.cs, with a class called Hello2, which also contained Main ()? Who is in charge, here?

This is just a small example of the strangeness.

To be clear, I’m not saying that C# is a dumb language for dumb people. This sort of thing makes sense once you know the rules. I’m just trying to show that learning C# after all of these years of C++ is filled with strange moments of hilarious confusion.

You can compare this to something like PHP. PHP is an objectively terrible language. But when I looked at PHP code for the first time I was immediately able to grasp where execution would begin, what order operations would be performed in, and I was able to get the general gist of what a PHP program was doing. I might get tripped up on some funny syntaxOr worse, in familiar syntax that behaves in confusing ways. Seriously. PHP is a minefield., but the large-scale stuff was easy to follow. In contrast, in C# the mysteries are all structural rather than syntax-based. Where does the program begin execution? Where does it end? When are the members of Hello1 allocatedIn the example above Hello1 doesn’t have member variables like “hitpoints” to “favorite fruit”. But it COULD.?

I think to do this properly I need to back off from Unity, learn some C#, and then come back to Unity. Trying to learn both at once is like trying to build without a foundation.

As a bonus, I’m pretty sure you can learn C# without needing to sit through hours of stupid video tutorials.

 

Footnotes:

[1] This is actually the main loop for the incomplete Linux version. The Windows version uses WinMain () and… uh. Look, it’s stupid but we don’t have to to get into it.

[2] Or worse, in familiar syntax that behaves in confusing ways. Seriously. PHP is a minefield.

[3] In the example above Hello1 doesn’t have member variables like “hitpoints” to “favorite fruit”. But it COULD.



From The Archives:
 

142 thoughts on “Learning C# – Sort Of

  1. Retsam says:

    Learning C# in isolation is definitely the way to go, IMO.

    And if you think C# and C++ are similar, you should compare it to Java; C# literally has its origins as “Java with the labels filed off” because Microsoft wasn’t allowed to use Java due to some legal shenanigans with Oracle. Over time, C# and Java have drifted apart somewhat: largely to C#’s benefit, IMO, though Java has started to “catch up” in recent releases.

    They both buy heavily into Object-Oriented Programming, but C# has quite a bit of functional DNA nowadays. (Though, again, the most recent version of Java also mixes some functional stuff in, too). It’s a very nice and pragmatic language, IMO; though I admit I haven’t used it extensively in the last few years.

    To specific questions about C#: (Though, doubtless, if you’ve started looking at a tutorial they’ve probably covered this)

    > what causes an instance of Hello1 to begin existing?

    Nothing; your program, as written, isn’t creating an instance of Hello1. Since Main is a static method, it doesn’t need a constructed class instance, it’s called like Hello1.Main().

    Hello1 is necessary because C# and Java expects all code to be contained within classes.

    Static methods are useful for various things other than entry points; sometimes they’re used as pseudo-constructors, sometimes they’re used for utilities: basically any time you have code that should be associated with a class, but that doesn’t need it’s own instance of a class.

    > What would happen if I made another file called Hello2.cs, with a class called Hello2, which also contained Main ()?

    You can start your program by running any static Main method; so you can create a program with multiple entry-points if you like. It can actually be useful if you want a normal start point and a debugging start point, for example.

    > Who is in charge, here?

    Nirvana is achieved when you accept that control is an illusion.

    1. Ryan says:

      I was pretty much going to say all of this. I started off with C++ too, and spent a bit of time in Java, but I made the transition over a decade ago to now working almost entirely in C# (when I’m not doing SQL, JavaScript, or some other non-C-family coding).

      The concept of the program root itself being considered an object is definitely a change for people coming from C++, and the proper utilization of namespaces is even more of one. C++ allows static methods, but they certainly don’t seem as common as in C#. For the record: like mentioned, you can have multiple “[int/void] Main(string[])” entry points, but at any given time the project needs to have one set as the default, which IIRC is stored in the project’s properties via the “.proj” file. The default can then be modified to any other valid entry point (as long as it matches the required signature, not just having the name) if needed.

      1. Blakeyrat says:

        Multiple entry points is handy if you have, for example, a single executable that can be run either as a CLI application or a Windows Service. (Think of MongoDB for a good example of a single .exe file that does either based on how it’s launched.)

        That’s functionality that’s handy to have, but it’s certainly not used very often, and I can definitely see how it’d be confusing.

        (It’s also not really a C# thing– it’s a Windows executable file format thing. Presumably you could do the same in C or C++ if you know how to tell the linker you wanted that. Mongo isn’t written in C#.)

        1. Ryan says:

          Multiple entry points is handy if you have, for example, a single executable that can be run either as a CLI application or a Windows Service

          Every time I’ve ever seen code for an EXE that runs as either a console/gui or service, it used the boolean runtime environment variable “Environment.UserInteractive” (that’s the .Net name for the Windows runtime value needed — not sure what other languages use) to determine which path to take, branching from within a single Main() that is called either way. I’ve never seen one that uses independent Main() entry points for this.

        2. Wide And Nerdy ♤ says:

          Multiple entry points is handy if you have, for example, a single executable that can be run either as a CLI application or a Windows

          I was on to the next post before my brain reminded me what “CLI” stands for and then my eyes lit up. Its been a while since I’ve seen that but it does get used and I’ve always wondered how (being a front end guy myself.)

          I might have an opportunity here soon to dive into C# with a team that lets its members learn as they go so I’m glad I’m seeing this post.

          1. Wide And Nerdy ♤ says:

            I apologize for the round of cringing I no doubt triggered in experienced devs when I talked about “learning as I go.” I promise I’ll try to remain cognizant of what I’ve read about design patterns and code smells and try to cross apply my Javascript experience where I can. (While being aware of where I want to differ)

            We can’t afford proper devs, I can’t change the thinking of the people who can change this. And its their inability to offer competitive pay that is giving me this opportunity so I’m taking it.

    2. evileeyore says:

      “Nirvana is achieved when you accept that control is an illusion.”
      Tea on the Zod-damned keyboard!

      Luckily it’s water-proofed, but still man. Warning labels eh?

    3. Will says:

      C# literally has its origins as “Java with the labels filed off”Âť because Microsoft wasn't allowed to use Java due to some legal shenanigans with Oracle.

      Technically, legal shenanigans with Sun, since the first version of C# was released about eight years prior to Oracle’s (a pox be upon their name) acquisition of Sun. Also, the nature of the legal shenanigans is that Sun wouldn’t let Microsoft extend their version of Java for Windows (that would be the “extend” part of “embrace, extend, extinguish”), so Microsoft went home and made their own programming language with””I probably shouldn’t finish that joke here, eh? With gin rummy and cake. Yeah.

      There’s an alternate universe somewhere where either Microsoft complied with Sun’s Java licensing or Sun didn’t pursue the issue and the modern high-level language of choice for desktop development on Windows was Java. That would be an interesting world to live in.

      Anyway. Total nitpick. But that is pretty much what we do here, so…

    4. Zak McKracken says:

      Ah, that makes sense, static methods!

      … but the main question remains unanswered (even more mysterious, in fact): who or what decides which method to call if all code must be within classes? Will executing Shamus’ code indeed print “Hello World”? What would it do of there were several classes with several static Main functions?

      I’m familiar with static methods from Python, but they still need to be called. Shamus’ program has nothing to call that method.

      1. John says:

        Well, I don’t know about C#, but in Java you would type

        java SomeClass

        on the command line and the Java Runtime Environment would execute SomeClass.main().

      2. Kyte says:

        The runtime calls it. In fact, you can ask the same about C/C++. Who calls main()? The answer is the C runtime.

        What function the runtime knows to call upon execution is decided by the compiler (or linker, in some cases).

        The C/C++ standards actually define it must start at Main in certain situations, but there’s no real block preventing them from doing it in some other way.
        C++ Windows programs are set to WinMain, C++ console programs are set to main.

        In C#’s case, the entry point is controlled by the project properties, where you set what class to use. This is usually taken care for you when you create a new project. If you open Visual Studio, Project Properties, Application, you’ll see a dropdown saying Startup object. It’ll look for Main there.

        If you go deeper, main is not the actual real entry point in any of these. The OS will actually go to a predefined entry point (I forget the name, I think it’s _crt_init?) that’s defined as part of the executable file format, which spins up the runtime, performs some initialization and then finally calls your main.

        In Python’s case, the entry point is the first line of the .py file being executed.

        1. Richard says:

          In fact, no C, C++ or C# program starts at “main”, “winmain” etc.

          The executable first starts up the appropriate runtime library (inc. loading any immediate-load dynamic libraries), and performs various other platform and runtime-specific low-level shenanigans.

          Then it constructs and initialises all your static variables and objects – in an undefined order!
          – It is even permitted to do them simultaneously (multiple threads) if desired, due to the “as-if” rule.

          Then finally it selects a main thread and calls your apparent entrypoint in it.

          Potentially, lots of your code has already executed before main!

          At the end of main(), the runtime then tears it all down. Except not necessarily in the same order.

          1. Kyte says:

            It’s quite amazing all the work that is done even if all you’re running is an empty program.

  2. gejimayu18 says:

    As a Java developer, I probably more naturally intuit C# than you coming from a C++ background. I remember going the other way trying to teach myself C++ and getting very confused.

    I remember a post you made recently that was about the argument against Object oriented Programming. And while you don’t necessarily need to program in an OO way using C#, it kinda assumes you are going to.

    The classes I took in college where I learned C++ was much more having to do with Logic and Computer Science things like Logic Gates and how computers do things. The classes I took where I learned Java (and some with C#) were all programming methodologies like the tenants of OO.

    I know a new programming paradigm might be difficult to adopt when you have so many years of a different way of doing things, but maybe doing some in depth reading of Object Oriented design might help with why C# is the way it is.

  3. Cinebeast says:

    I’m one of those people who prefers video tutorials to written tutorials, although I can’t really explain why. I guess I just prefer the sound of a human voice relaying instructions.

    To be fair, I’m not catching tutorials on coding, per se. I work in Unreal Engine 4, which means I’m mostly dealing with blueprint nodes and stuff, which come off better in a video than a paragraph of code does. I tried Unity a few years ago, but it was actually too complicated for me, since I can’t write code to save my life.

    Anyway. I think you’ve got the right idea taking a break from Unity to focus on C#.

  4. CrushU says:

    So my background is in Java, but C#, as someone mentioned above, is pretty close to Java.
    (I also know some C++, but it’s at a beginner/intermediate level… I can play with pointers?)

    What makes an instance of Hello1? In Java, the Interpreter makes a ‘publically accessible’ version of every class… that has anything declared as Static. It’s a little weird, because you almost have two versions of every class, one that you have to explicitly instantiate, and a version that is implicitly created at program start. Anything labelled ‘static’ is created at program start and can be accessed by using the classname, from anywhere. (If you declare it Public, any other class can access it, otherwise it follows the encapsulation rules of Private/Protected.)

    The quirk is that if you’re calling a Static method, you can only use Static members. The Constructor is not necessarily called, as I recall… So basically, using your Player class, if you added a method ‘public static void printStuff()’ you can have:

    Player.printStuff();
    Player playerOne = new Player();
    playerOne.printStuff();

    The second call to printStuff() will cause compiler error, because you’re not allowed to call static methods from created Objects. Only Static Objects can call Static Methods. It’s a little weird… Generally you use Static for anything you want to be able to do regardless of whether you have a specific instantiation of that class. (Normally it’s used in Utility classes. Stuff like Math.sqrt(n) you don’t want to bother creating a Math Object just to get a square root…)

    1. Ryan says:

      The second call to printStuff() will cause compiler error, because you're not allowed to call static methods from created Objects. Only Static Objects can call Static Methods.

      You’re correct that the compiler will throw an error, but it’s slightly different than this. Static methods, members, and properties cannot be called/accessed directly off of an instance of the class, and when interacted with externally need to be referenced by the class name itself, but internally there is no issue. If code execution is currently within a non-static method, a call/access of a static element of the same class is just fine. So the following applies:

      class demo {
         public static void printStuff() { Console.Write(“Hi!”); }
         public void doStuff() { printStuff(); }
         // works, despite an instance calling a static
      }
      class test {
         public void Run() {
            demo.printStuff(); //works
            var v = new demo();
            v.doStuff(); //works
            v.printStuff(); //error
         }
      }

      Where things start getting real weird is that you can have the following and it’s also valid:

      class demo {
         public static void printStuff() { Console.Write(“Hi!”); }
         public void doStuff() { printStuff(); }
         public static void doStuff() { printStuff(); }
         // we have 2 versions of the same method
         // but one is static
      }
      class test {
         public void Run() {
            demo.printStuff(); //still works
            var v = new demo();
            v.doStuff(); //works despite 2 versions of method
            demo.doStuff(); //works despite 2 versions of method
         }
      }

      The reason that still works is because technically, the method signatures are different, so they’re actually calling two different versions of the method. There’s a catch, however — if you tried to call “doStuff();” from anywhere WITHIN the demo class in which those two methods are defined, the compiler will error out saying it’s too ambiguous to tell which version you want. And for some reason, that error can’t be fixed by prefixing the class name and/or “this.” onto the calls.

      1. Wide And Nerdy ♤ says:

        So I guess this would be like method overloading right? I was trying to think of the use.

        I guess it would be useful if I wanted “doStuff()” to do something basic like “Console.Write(‘Hi!’)” if I called the method like Person.doStuff() and something more specific like “Console.Write(‘Hi ‘ + name + ‘!’)” if I called Bob.doStuff(). An instance specific implementation of the same variable.

        Question. How far out have you gone with polymorphism and method overloading? I’ve seen maybe 5 or 6 different forms of the same method. You ever seen more? Is that a good thing or a bad thing? Bad code smell?

        1. Kyte says:

          It’s not overloading, because one isn’t replacing the other. Hence why it’ll error out if the call turns out to be ambiguous. Since it’s not overloading, there’s no rules on which one to pick.
          They’re just two methods with the same name. Bad practice anyways.

          Whether it’s good or bad depends a lot on what’s being modeled, although most people in the know will recommend you to do composition over inheritance. In other words, instead of inheriting and overloading, split the specific functionalities into smaller objects you store in your class and get called as needed. The advantage here is that it’s much easier to switch out these components if something needs to get changed (for example, for testing).

          1. Wide And Nerdy® says:

            Oh you’re right. Different scopes. I should have caught that.

    2. Richard says:

      (I also know some C++, but it's at a beginner/intermediate level… I can play with pointers?)

      You can, but don’t.

      Raw pointers should never* be used in modern C++, because they make it really easy to make daft mistakes.

      Instead there are a host of “smart” pointers, eg:
      – “Scoped” pointer that automatically deletes the object when the ‘pointer’ goes out of scoped
      – “Strong” reference counting: Delete the object when the last reference goes out of scope
      – “Weak” reference counting: Created from a strong one, except it isn’t counted as being a reference until converted into a strong one
      – “Unique” pointers: There can be only one pointer to the object. It can’t be copied but can be moved.

      etc.

      Use those, they’re easy and fast.
      The hard part is of course working out which “smart” pointer you need – choice can be a burden!

      * Unless you really want to.

      1. Blake says:

        Eh, my 9 years in game dev have made me see things the opposite way.
        There are occasional times when you need to do something like ref-counting, but most of the rest of the time you want to be explicit about your memory ownership.

        Classes with scope pointers as members would generally be better off containing the objects they point to (so there isn’t the extra pointer dereference when accessing it), scope pointers in functions is often indicative of slow code since malloc is slow as is touching other bits of memory. Better off having either scoped variables or (for bigger things) one big linear allocator you can unwind at the end of your function.

        Unique pointers are ok in concept, but in reality you rarely want to be passing ownership of something more than once, and should be explicit enough about it that you know you’ll be needing to call free/delete when you’re done with the object.

        If you’re worried about memory leaking, then you should check against that case instead, in our engine every time we transition between the front end or a level we verify our heap is identical to how it was after we finished initialisation. Not a single byte is allowed to have been allocated or moved. Our commit box runs some tests on every code commit before it is allowed to be pushed out and if anyones commit causes a leak, our heap tracking code will show the callstack when that allocation occurred.

        All this isn’t to say that special pointer classes are never useful, we have a few things like textures that use ref-counting because we need to wait for our graphics code to finish with things before we free them, as well as custom pool pointers you can call delete on so that you don’t have to know where the object was allocated from in order to know how to free the memory.
        But generally speaking there’s nothing wrong with raw pointers, they’re as fast as you can go on debug builds (which other smart pointer objects will not be, they’ll be copied all over the stack even when it doesn’t make sense, and will still load and call destructors that do nothing giving you extra function call overhead), and anyone who wants to write fast code (which should be everybody) should feel totally comfortable using pointers and undertanding exactly where each bit of memory is allocated and freed.

  5. Zimdar says:

    As a C# developer who knows a bit of C++ and keeps meaning to learn more, this is super interesting to me and I hope you do more articles on the subject.

    1. FelBlood says:

      As a guy who learned some C++ in school, but quickly found all the projects he wanted to join on were grounded in C# ideology, I am really looking forward to this.

      I never managed to separate the two inside my head properly, and I keep doing c++ things in C# programs if I don’t drink enough coffee.

      Maybe this will finally help.

  6. Aaron says:

    I have to give a plug for my favorite Unity and C# YouTube channel: Quill18Creates

    He does a great job of walking through the code he creates and explaining WHY he is doing what he is doing as often as he explains the hows.

    Two playlist of particular interest:
    Intro to C# https://www.youtube.com/playlist?list=PLbghT7MmckI7JAftgv0CUdU4RLNivG6wY – he goes through all of the necessary syntax in the context of making a fairly simple game all in C#. It’s good for making sure you have a firm grasp on the syntax and major subtleties of C#.
    Unity 3d: Procedural Mesh Generation – https://www.youtube.com/playlist?list=PLbghT7MmckI6Tm0jUrhLZG8sEBI1hgCL8 – a little old but right up the alley of what you want to do!

  7. Paul Spooner says:

    Exiting to see that you’re branching out! Hopefully, becoming proficient in C# will prove useful.
    The OO-centric asumptions in C# and Java are pretty crazy though. I learned Java for a project, used it that once, and never returned.

  8. Bryan says:

    The CLR (Common Language Runtime) is what calls your main function. In C#, methods that are declared static do not need the class to be instantiated to be called. It’s similar to have a C++ file that’s just functions. Making everything a class is the only thing I don’t really like about the language, although I suppose it forces these standalone functions to be in a namespace.

    I strongly recommend you learn the language from a book, than through Unity tutorials. C# in a Nutshell is a great book, despite “in a nutshell” being 1100 pages. The good thing about this book is that it should cover everything you want to know and more, and you don’t have to read it cover-to-cover. Just look at what you want to learn from the table of contents and jump to that chapter. I would recommend reading the first few chapters in order, though, to get an understanding of the language.

    1. 4th Dimension says:

      Yeah, since Shamus will be working with the lower level stuff, and since Unity is maybe based on Mono (is it?) knowing how the Net framework is put together in general and how C# interracts with it is something he really needs to know. And basically any good reference book should explain those things in it’s intro chapters.

      Also it will explain how garbage collection, and different heaps (places where variables and objects are kept) work and when are they GCd, which I expect is something that should interest him given the performance requirements on graphic programs.

      On the other hand while I did go once through this using a book, there is probably all of this and more in Microsoft tutorials and articles online. It’s just a matter of finding them in a sea of data.

    2. Zak McKracken says:

      Wait, this does not really clarify it. (to me, who does not know either C++ or C#, but a little plain C, some Fortran and a lot more Python). If I have a program that consists only of functions and nothing to call them, then why should anything ever get executed? And who or what decides which of the functions/methods will be executed? This is Anarchy!

      To be honest, even the definition of Main() in the C++ example confuses me. Why is Main executed if it’s not called? (I suppose it’s in the name, but still)

      1. Crespyl says:

        The CLR in C# is roughly like the “Java Virtual Machine” in Java, both of these are actually separate programs that handle setting up and managing the environment necessary to run C# and Java programs.

        When I compile a Java source file, I don’t actually get a real x86 executable binary that I can run like a normal program. What I get is a “.class” file (or several) that contains “bytecode” instructions that the JVM (or CLR) knows how to interpret.

        When I want to run a Java program, I don’t run that program directly, I have to run the JVM first and then tell it what class has the “main” method to start my program.

        So in C, I compile a source file “hello.c” into an executable program “hello”, and run it like “./hello”

        In Java (and C# is analogous), I compile a source file “Hello.java” into a bytecode file “Hello.class”, and tell the JVM to run that program like “java Hello”

        Of the languages you mentioned, the closest is Python, in which you have to run a program with “python some_file.py”, except with Python the interpreter just knows to start at the top and work its way down, while Java and C# start at “public static void main()”.

      2. Richard says:

        All programs have an arbitrary entry point, defined by the language runtime (low-level routines you never see).

        C and C++ picked:
        int main(int argc, char** argv)

        However, this is convention. Most C and C++ compilers have ways to tell the runtime to start somewhere else.

        – Also, this isn’t actually where the resulting binary starts executing anyway.

    3. Chris says:

      I want to second that book recommendation. It’s a really excellent resource that doesn’t waste a huge page count explaining what loops or conditionals are.

  9. Tohron says:

    And in Unity C#, the same code would be

    public class HelloWorld : Monobehaviour {
    void Start() {
    print(“Hello World”);
    }
    }

    Oh, and the reason the Hello1 class in your C# example doesn’t need instantiated is because its only method is static – which means it can’t use class variables, but it can be called anwhere using Hello1.Main();

    1. Matt Downie says:

      MonoBehaviour – case sensitive. (All code is bugged until it’s been tested.)

      And that still wouldn’t do anything on its own.

      You’d have to take another step, like creating an empty object in your Unity game window, and then add your script to it. That would then run on startup when the game object initiates.

  10. John says:

    Although I seem to be a little late to the party, I just want to chime in and confirm that, yes, C# looks a hell of a lot like Java. Everything in Java has to get wrapped in a class one way or another, but the class containing the main loop of a program doesn’t actually need to contain anything but the main method. In Java, the the declaration for the main method has to look like this:

    public static void main(String[] args)

    The “String[] args” is there in case you want to pass any arguments to the program from the command line and it has to be included even if the program you’re writing has no possible use for arguments. I’m sort of jealous that C# doesn’t make you do that.

    1. 4th Dimension says:

      Well how can you know you won’t need some command line arguments before you start working? :) Even if you are making a desktop application the command line arguments are useful because through them you get the file location if you try opening a file associated with your program. ;)

      1. John says:

        Because I’m writing simple programs for my own personal use. I’m a hobbyist, not a professional. In four-odd years of Java-ing, I have written precisely one program that used command-line arguments.

    2. Mephane says:

      I can’t remember the exact syntax right now, but in any .NET language you can retrieve the command line arguments from anywhere with some always available system utility functions.

  11. Adamantyr says:

    I’ve used C# for several years, and at my current employment we switched to Java because AWS (Amazon Web Services) is mainly oriented for non-Microsoft technologies. (Basically, they offer grudging basic support.) Also, the boss is a Mac/Linux fanatic and he wanted to move to Java.

    I miss C#, seriously. Java is okay but C# is like Java but with a LOT of things fixed and made better. For example, in C#, strings are treated as a primitive in terms of equality, adding, and so forth. You get the flexibility of treating them like you used to in BASIC, but you can in a pitch treat them as an object as well. In Java, they’re objects and if you forget that “==” only checks an object’s reference and “.equals()” checks it’s content, you’re in for some hurt. (We’ve had this bug crop up several times in production code before we trained ourselves out of it.)

    Also, C# has a better infrastructure system. With a “proj” file, you can clearly delineate which files are used by your project, and even specify versions, as well as define the build types. By contrast, Java uses the file system in a clunky fashion to determine package names, what files to use, etc. Working with imported packages is a pain too; many times we’ve discovered some package we included for a single item ended up trying to force upgrade several other packages to support itself, causing everything to break.

    Also, Visual Studio is probably one of the best development tools ever written. It used to NOT be, I’ll concede that, but their debugging system is fantastic. I’m presently using IntelliJ for my Java work, and it’s okay. I flat out refused to use Eclipse, which I found incredibly weird and hard to configure and use.

    1. Bloodsquirrel says:

      Yeah, Visual Studios is a gigantic leap over every other tool that I’ve ever used. Eclipse doesn’t even feel like a professional product by comparison, and the load times don’t help.

      1. Richard says:

        I find Visual Studio to be pretty awful for writing code, and really awful for sharing code (the project files cannot be properly merged by any of the source control systems).

        However, the debugging support is simply awesome.

        1. Deadfast says:

          the project files cannot be properly merged by any of the source control systems

          Yes, they can. They are just XML files. They can be merged just as easily as any other XML file.

          Mind you, this doesn’t mean I actually like them. I find the UI for managing the properties absolutely terrible. Nothing quite like the fun of finding out that an individual .cpp file has its own properties set (like precompiled headers enabled when the project itself has them disabled)…

          1. Richard says:

            It’s not enough to be able to merge XML, because MSVC stores most of the configuration as a text element.

            For example, a simple linker config looks like this:
            <Link>
            <AdditionalDependencies>QtCored4.lib;OtherLibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
            <GenerateDebugInformation>true</GenerateDebugInformation>
            <SubSystem>Windows</SubSystem>
            <TargetMachine>MachineX86</TargetMachine>
            </Link>

            Add a library and it just adds a bit more text to the ‘;’ separated list of AdditionalDependencies text element.
            Thus merging not only needs the know how to merge XML, it also has to know how to merge MSVC’s specific use of it.
            Which also changes each version.

          2. Blake says:

            The .filters files are annoying for git to merge, because VS likes to always add to the end of the list instead of sorting alphabetically or something so every time 2 people add a file, it tells you it’s conflicted because the same part of the file has been modified.

            I’ve resorted to having those files gitignore’d and just not having everything nicely sorted in the Solution Explorer. Not ideal, but better than manually merging the filters files all the time.

  12. Bloodsquirrel says:

    Thing is- some of this isn’t even C# specifically, it’s a method of doing things that is around in C++. A static class function that you use without instantiating an object is part of C++ as well, for example.

    A lot of this is probably less “C# vs C++” and “modern object oriented vs procedural”, where C# is designed to push you more into object-oriented code while C++ is classically full of libraries and tools that were designed around a procedural methodology.

    You’ll be able to take some of what you learn from C# right back to C++, if you want to.

  13. Vegedus says:

    For a good blog (no video, except for showing the game running!) on Unity and C#, I can recommend theliquidfire.wordpress.com/. The “Tutorials” page has some posts for fairly basic/intermediate C# syntax, and the “Projects” has more applied Unity programming, at a pretty high level. I recommend the “Tactics RPG” one. He’s all about structuring his code and creating production-ready systems. It’s not at all “baby’s first game”. Like, providing an implementation and example use of state machines in post 5.

    I’ve also used this chrome extension plugin to speed up youtube videos so I can go quickly over the easy parts without actually missing anything: https://chrome.google.com/webstore/detail/youtube-playback-speed-co/hdannnflhlmdablckfkjpleikpphncik

    As someone who grew up with Java (which is more alike to C# than C++), I’m befuddled by your befuddlement :D. “Of course you have a static main method inside a class, what else would you do?”

    1. Echo Tango says:

      YouTube allows fast-forward in videos now, from 0.25 speed to 2.0 speed. Don’t need a plugin to keep watching too-slow videos! :)

      1. Zak McKracken says:

        Since I’ve discovered that you can skip five seconds forwards and backwards with the cursor keys, 10 seconds with “j” and “l”, pause with “k”, youtube has become so much better! And I regularly get angry that not all videoplayers use these hotkeys (also: shift+”,” to play slower, shift+”.” to go faster, and the number line on the keyboard to go move to 10, 20 …% of the video play time).

        … but for programming tips, nothing beats Text (either the online code documentation, Stackoverflow, or very seldom som programmer’s blog) unless you try to actually code up an animation or so, then video certainly helps.

  14. Matt Downie says:

    I find googling for answers to Unity questions much more effective than watching the videos. The answer is usually out there. The difficult bit is phrasing the question, especially if you don’t know what something’s called.
    Creating a Procedural Mesh in Unity

  15. Blakeyrat says:

    Traditionally, C# programs are static classes that never get instantiated. (Static classes also exist in C++, although I’m not sure how much you’ve used them.) Honestly I didn’t know making your main class non-static like in your code example above even worked, I’m mildly surprised that it does.

    The entry point to a C# program is inside a class because everything in a C# program is inside a class. (Which the exception, IIRC, of struct definitions which can be inside a namespace or a class.) This is a more Java-esque way of looking at the world than a C++ way, so I can see how that’d be confusing. Don’t worry, the compiler has no trouble figuring out where the program’s entry point is.

    BTW, I 100% agree with you that video tutorials suck. Different people learn in different ways, but it seems like in the last 5-6 years the only “way” anybody bothers to make anymore is video. It’s frustrating.

    1. Blakeyrat says:

      Oops, put my foot in my mouth. I guess it’s normal for your Program class to not be a static class, that’s what the default Visual Studio “New C# Project” creates. Sorry, never looked at it closely before.

      The important thing is that Main() itself is static, which means the class doesn’t have to be instantiated to use Main(). And, again, these concepts all existed in C++ also, that’s where I first learned them way back in college using C++ Builder.

      C# isn’t as different from C++ as you think, it’s just that C# is exercising C++ features I don’t think you’ve been using. (And one thing about C++: it has a LOT of features. So I don’t blame you.)

    2. Rick C says:

      C# classes don’t have be static, though. (you could do it either way, I guess.) It’s perfectly legitimate to do something funky like have your main class derive from Form, and then do something like

      Application.Run(new MyClass());

      in MyClass.Main. You probably shouldn’t do that in a non-toy program, though.

      Interestingly(?), C++ .Net programs don’t have the same limitation; by default, the entry point is the regular C++ main().

  16. Elemental Alchemist says:

    Unity is ass. Keep your C++ and use Unreal 4 instead.

  17. Rick C says:

    Skipping existing comments, so apologies if this post is redundant.

    In .Net, one class has a static function named Main, and when you run your program, that method gets called. If you need to do anything with any kind of nonstatic members, create a class instance. Java is more or less the same way.

  18. silver Harloe says:

    I use class methods a lot – the class becomes not a template for an object, but a place to put methods so they don’t pollute the global namespace. So “static Main()” or the fact that Hello1 isn’t instantiated as an object washed right over me. Plus there were those three years I was a professional Java programmer, so Of Course one declares a class just to hold a class method to start the program. Different past experiences.

    1. Zak McKracken says:

      For my understanding: In Python, the difference between a class method and a static method is that the class method has access to the rest of the class (other class methods and static methods, or class-global variables), whereas a static method is just a “stupid” function, and can only see what you hand it.

      Does this work the same way in C#? The reason I’m asking is that you talk about class methods, but Shamus defined a static, and I had to learn the difference (in Python) the hard way, so it matters to me.

      1. silver Harloe says:

        Different languages in OO and subcultures of OO use different terms for different things, so I’ll just explain my particular point of view:

        an object method works on an instantiated object, whereas a class method is associated with the class, not with any particular object in the class.

        “static” is the keyword used by C++, C#, Java, and PHP to say “this is a class method” – it stems from C++ trying to minimize the number of new keywords they introduced to C to make C++ go, since C++ originally compiled to C, and then you had to compile the C to machine language. So they re-used “static” (which was already a keyword in C) rather than introduce a new keyword. The other languages copied from C++ to reduce the learning curve or something.

        I don’t know how Python organizes methods or names them – your description of its “static methods” sounds like a third type of method relative to the two I’m familiar with.

        1. Zak McKracken says:

          Within Python classes, you have three levels (that I know and work with):

          1: Static methods. Defined within the class, but they know nothing about any classes or instances. You adress them as .(), and it’s basically just a way of associating a regular function (which can exist outside of a class) with a class. You don’t need an instance of the class to call them. Useful if you have some amount of inheritance, where different classes only differ in how they do a certain thing, but where you also want to be able to do that thing without instantiating the class first.

          2: Class methods. In addition to the regular arguments, they are implicitly handed the class itself. So that allows them to use “cls.xx” to refer to any property of the class, including static methods, or instantiate the class (by calling cls(), which returns an instance). They can be used as alternative “constructors”.

          3: The “regular” methods, which are parts of instances. They can only be called from other methods on the same level, or via “.()”, and they implicitly get handed an instance of the object itself when called, so you can always address the current instance via “self”. This includes access to all static and class methods.

          All of these can be “protected” by prefixing an underscore to the name. That means they won’t be listed as external references. That does not make them impossible to call from outside the class/instance but it requires a certain amount of determination.

          1. Zak McKracken says:

            Argh — did not pay attention, and the parser ate all my larger-than signs I put my names in…

            1: static mathods are addressed as classname.methodname()
            2: “regular” (or instance) methods are addressed as either objectname.methodname() or as self.methodname() (when calling from within the instance). they can address both static methods and classmethods as self.methodname() — so the object keeps all the static and class methods.

          2. silver Harloe says:

            Cool. I think we’ve now answered your original question: the ‘static’ keyword there in the C# example (could also have been a C++, Java, or PHP example) does not make it a “static method” as you’re familiar with the term. It’s just the keyword used by that family of languages to denote what we both appear to call a “class method”.

            As far as I know, the C-like-OO languages I refer to here do not have an equivalent of a ‘static’ method – to them that’s just a class method that doesn’t actually call any other class methods or refer to any class properties.

            1. Zak McKracken says:

              great, thank you! I just got smarter :)

      2. Kyte says:

        Your idea of static methods sounds like a globally scoped static method. Methods, instance or static, can only see what’s in their scope or higher, up to the global scope. So a method in the global scope can only see other stuff in the global scope.

  19. Dev Null says:

    I've always thought of video as more labor-intensive to produce and lectures more time-consuming to consume

    I’ve always thought of video as the easy way out for most things (collaborative gameplay stuff like Spoiler Warning being the exception, for various technical reasons.) Most online video seems to be sparsely-edited, if it’s edited at all, so to make a 15-minute video it feels like a lot of these people are sitting down in front of a camera for 15 minutes, and then pressing “Submit”. Crafting text takes longer – it’s taken me a lot longer to type this comment than it would take me to read it out loud, for instance.

    A lot of that comes down to quality though; dashing off misspelled, error-filled garbage text is probably a lot faster than scripting and editing quality video. So maybe the medium isn’t really relevant there. I do agree with you that video is incredibly annoying for me in a lot of cases, and learning programming is definitely one of those. Among other things, in video the creator dictates the pace, while in text the reader does. It’s also much easier to skip around to the bit that’s relevant to what you’re currently working on.

    1. Zak McKracken says:

      I’d say it wildly varies. John Blow’s 2-hour rant about programming languages for games did certainly not take much longer to make than the video itseà¶f plays, but even most people whose videos are just them talking into the camera edit a lot. If you want to have some well-prepared pieces of code to go with it, some images, some demo … that must be incredibly time-intense.

    2. Philadelphus says:

      This is my thinking as well. For a video you can just talk to a camera while doing the thing being demonstrated, import it into a video editor, trim the ends, render, and upload (at minimum, obviously you can extend this time depending on the amount of editing). You can simply explain the thing as you go along as if you were telling a friend next to you how to do it, and you only have to go over it once. Making a text tutorial with pictures requires doing the thing and being interrupted periodically every time you do something that needs a picture in order to take said picture, then going back and sitting down and mentally doing the thing again and writing up the procedure along with manually putting all the pictures you took in the right place to illustrate what you’re doing (I suppose you could write as you go, but I don’t think that would increase efficiency all that much). And just like the video editing above, you can extend the time required arbitrarily by cropping, annotating, etc. the various photos used in the tutorial.

      This is not to imply that either is trivial; a quality tutorial is a lot of work whichever way you do it. But if you’re already really good at public speaking while showing something off, video may be a very attractive medium compared to writing.

      This is not to defend video as a medium for tutorials, either, as I usually prefer text ones myself; just a thought experiment of why it might be easier or more convenient for people to do.

  20. Geoff says:

    If you are cool with making the jump to a public game engine, Unreal would let you keep using C++ and is also free and is fully functional unlike the free version of Unity (until you start making notable profits anyway).

    It has some downsides, code compile times tend to be longer than in Unity for some reason (I’m not a programmer, but plenty of programmers have ensured me this is the case) and by default it comes with a lot of extra bells and whistles you may not need. It’s also not that great at UI yet (though its slowly improving).

    For a game like Pseudoku, that is largely (or entirely) 2D UI driven, Unity is probably a much better fit. For 3D games with lighter UI, like a 3D version of Good Robot, Unreal makes a stronger case.

    1. Geoff says:

      Err… Code compile times are longer in UNREAL, which also comes with all the extra bells and whistles and is not that great at UI.

      The dangers of discussing two game engines that are only a couple of letters different.

    2. Misamoto says:

      Please don’t. I’ve been really looking forward to you starting learning C# and Unity (whether you realise it or not, you’ve been coming to it for a long time now)

    3. Jirin says:

      The free version of Unity doesn’t lock off any features either, actually. They switched models around the time Unreal became free.

      The paid version is all about services, like their analytics, cloud build and multiplayer matchmaker. As far as the actual API goes and what you can do with the engine, the free version isn’t restricted.

      The main difference in their pricing models is that Unity asks for a subscription once you start making significant money, while Unreal asks for royalties instead.

  21. “instantiate”

    In my entire +30 years of life, I have never seen this word before. At first, I thought you’d just made it up. Looking it up, i still don’t have a clue what it’s supposed to mean in the context of the sentence it’s being used in.

    1. Shamus says:

      instantiate = “create an instance of”

      1. Echo Tango says:

        To phrase it another way: To create a real, actual copy of something, instead of a blueprint, idea, or concept of a thing.

    2. Robert Conley says:

      I can write a class to define a point.


      Public Class Point

      Public X as Double
      Public Y as Double
      Public Z as Double

      End Class

      Public Sub MyMethod
      Dim aPoint as Point

      aPoint.X=10
      'will throw an error because aPoint has not been instantiated yet.

      Set aPoint = New Point
      aPoint.X = 10
      ' this will work because I created a new point and assigned it to the variable a Point.

      End Sub

      Why we do this?


      Public Sub MyMethod

      Dim aPoint as Point
      Dim bPoint as Point

      'Instantiate a new point and assign it to aPoint
      Set aPoint = New Point
      'assign the value 10 to X
      aPoint.X = 10
      'assign the point in aPoint to bPoint
      Set bPoint = aPoint
      'instantiate a new point and assign it to aPoint
      Set aPoint = New Point
      aPoint.X = 20

      System.Console.WriteLine(aPoint.X) 'Will print 20
      System.Console.WriteLine(bPoint.X) 'Will print 10

      End Sub

      What happening behind the scene is that every time you use new you are reserving a section of memory big enough to hold the header information and data of a Point object. That process is called instantiating a object.

      Note: Not sure how to format code using this editor.

      1. King Marth says:

        Point made.

        Or should I say, Point instantiated?

  22. Robert Conley says:

    The thing to remember is that C# and the .Net framework are interwoven together. To understand why a little bit of history.

    Back in the 1990’s there were issues in reusing code and sharing (or selling) code through libraries. To fix this issues a number of vendor developed frameworks designed to work within an operating system. One of which was COM or Common Object Model. If you wrote (in C++ at first) a library that adhered to the COM standard it could be used by any other programming language capable of using COM to to talk to libraries.

    Along the way, Visual Basic became a popular. To bring Visual Basic into the 32-bit world and object oriented programming, it decided with VB4 to make it work with COM. The reason that VB4, 5, & 6 object oriented programming works the way it does because it is an implementation of how COM handles object orientation.

    Java came along with elements of this shared library but it was along for the ride because of Java’s focus on write once run everywhere thanks to the use of a Virtual Machine to run the code on.

    COM had issues, Java had a nifty thing going with its VM so by the early 2000s, Microsoft took another stab at it and created a new way of defining how to get software libraries talking with each other along with taking some of the ideas behind Java VM to create a managed environment to control how memory is used. This developed into the .NET framework.

    COM had Visual Basic 6, and so the .NET framework had C#. Visual Basic .NET was also created as the successor to VB6. Most everything weird about C# is because it being a wrapper around how the .NET framework and core libraries manage things. Just as most everything weird about VB6 was because it was a wrapper around COM.

    To make it weirder for the two major .NET languages C# and VB.NET it doesn’t matter which one you learn. Behind the scene they both are translated into an assembly like Intermediate Language or IL. That is what is executed by the Framework. It trivial to compile a C# program into IL and then reconstitute it as a VB.NET program complete with variable names, and vice versa. There are differences but most of them are syntax sugar. If you know how the IL works and what it calling in the framework you can generally replicate the functionality in both languages.

    Like COM, .NET is concerned a lot with exposing what a software library can do. You can query any .NET assembly (the generic term for a .NET binary) and discovered what public subroutines and object are in there and can be used by another program.
    Broken down this is what the following means.

    To make a .NET exe work the framework needs to know it starting point. Within the assembly header the programmer can say “Hey this routine is my starting point.” When the framework tries to run the exe it will check the header, find the routine you specify and run it. The routine has to be a static method. And since all methods have to be part of an object, in C# you need a class. In VB.NET you can use a module which behind the scene looks the same as a class with nothing but static methods. So it really the same thing.

    So in your example, the class is Hello1, by convention for C# the startup routines is main with a void return type. In VB.NET it is just Public Sub Main() in a module. I can also use a static Main in a class if I wanted to in VB.NET

    public class Hello1
    {
    public static void Main()
    {
    System.Console.WriteLine(“Hello, World!”);
    }
    }

    The Console.Writeline is part of the standard library the framework provides.

    So that the convulsed answer of why things look weird.

    1. Mike C says:

      That’s a very good, unbiased summary.

      As a primarily VB.NET developer, it’s refreshing to see. :-) Hopefully Shamus won’t get confused by .NET Standard vs .NET Core, with the major shift in .NET underway to make it more cross-platform.

      I’m also keen to follow along with Shamus’s journey into C#, and hope it concludes with one of his projects on a HoloLens.

      1. Robert Conley says:

        Nice to say. I am also a VB.NET developer myself. The problem I am dealing with is the my company part design and machine control software is written in VB6 (by me mostly). The software been maintained since the middle 80s with three major ports between different platform. The leap from VB6 to .NET will be the fourth.

        I have some very strong opinions about where Microsoft can shove it in regards to the compatibility between VB6 and VB.NET.* But the situation is what is so what I been doing for the past decade is converting the software over piece by piece. I had to dig into the guts of the .NET framework to understand how certain things worked so I could pick the right path for compatibility with the low level libraries we use for machine control.

        That where I learned that most of the differences between VB.NET and C# are cosmetic.

        *For example Integer changing to be a 32 bit integer instead of a 16 bit integer. Behind the scene it gets compiled to Int32 IL datatype so it the change was completely arbitrary. If they kept integer as Int16 and it a C# assembly referenced it, it would show up as short. Right now having a parameter like flag as integer, will show up as flag as int, in C#.

        I replicated enough of the VB6 graphics engine so I can copy and paste the graphics code from VB6 to VB.NET. Why I had to do that?

        However for the new stuff VB.NET does I just love it especially generics and the framework. So much easier than VB6. And having more control over the forms is very nice as well.

        1. Kyte says:

          The thing is, moving from VB6 to VB.net was gonna be a breaking change anyways, so might as well do all the changes so VB.net could be viable moving forwards rather than stick with backcompat.

    2. Zak McKracken says:

      But, but …

      …but what if there’s a second class Hello2, which also contains a static methods “Main()”? Which one is executed? Or both? Or would that give me an error?

      I feel like this would immediately become more readable if the first line of the program was some statement which points to the main routine.

      1. Kyte says:

        The startup object is defined in the compiler options.

        1. Richard says:

          This is also the case in C and C++ – the default entrypoint for a Windows C++ application is int WinMain(int argc, char** argv).

          Very few people change it because there isn’t much point.

          1. Kyte says:

            Technically the standard says certain types of applications must have their entrypoint defined as main, but even then you can just have main redirect to WinMain or whatever else you use.

  23. Alan says:

    I’m with you on tedious videos. I think it’s because terrible video is arguably easier than text; turn on your screen capture, do whatever you’re doing, then upload to YouTube. And I certainly see a lot of that. Gods, it is infuriating to have a simple question, and the majority of Google’s hits are 5 minute videos in which someone tediously uses an un-narrated screencast to show me something trivial.

    As for C# and other languages in the Kingdom of Nouns, I always get a laugh of out Steve Yegge’s ” Execution in the Kingdom of Nouns” https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

    1. Abnaxis says:

      Thirded on the hatred of tutorial videos. Every. Single. Time. I have a question I have to either trawl Stack Overflow for the answer or suffer through at least an hour of useless video–neither of which works when you aren’t trying to answer a question, but looking for a tutorial.

      I’ve taken up searching for textbooks instead, and dropping the cash for them to get me rolling. There’s a lot more out there in print for “advanced programmer but don’t know the language” then there is on web-sites, though it’ll set you beck at least fifty bucks (more often close to 100)

      My theory is that it’s a lot easier to get dollars out of people in the “I know what I’m doing and I need a new tool to do it” demographic (tax deductible and/or employer pays for it) so all of the quality resources require funds to get hold of.

    2. Will says:

      Fourthed? on hatred of video content. Unless it’s clearly superior, it’s almost always much much worse than text. Takes forever to consume, can’t (easily) be skimmed, criminally unparsimonious with bandwidth. It’s just the worst. In fact, even when a concept is more clearly conveyed with video, I find I almost always prefer an animated gif embedded in a page of prose.

      Also seconded on the tragedy of the Kingdom of Nouns. I live in it professionally, but I sure don’t like it at all.

      1. baud001 says:

        Can’t be copy-pasted like SO / any other text-based solution is another big problem. And it’s much harder to keep / make an off-line copy of it.

    3. Mephane says:

      As for C# and other languages in the Kingdom of Nouns, I always get a laugh of out Steve Yegge's “Âť Execution in the Kingdom of Nouns”Âť https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

      I remember reading this years ago. I saw your link and immediately thought “and then in the end it is all managers” and yepp, there it is.

    4. Xeorm says:

      I can understand why they do video, though it is infuriating sometimes. It’s much easier to show something than it is to write it out, especially if you might not have a great grasp of the English language. Plus, while most of the time a written explanation will do great, some of the time pictures are required (and usually quite helpful anyway). Then a small portion of the time a video to show exactly how it’s done is required. Given that Unity bills itself especially with all the 3d tools to get things working, video is going to be required for a number of people. No way to get around that.

      They could do a video tutorial and a text tutorial, but that’s likely more than they want to spend on the subject. Their manual isn’t terrible at least text-wise. I recently started trying to relearn Unity for a personal hobby project, and it’s been mostly good so far. I’ve managed to learn while mostly skipping the videos, thankfully.

    5. Mistwraithe says:

      I will join the bandwagon. Videos are incredibly irritating ways of learning anything complex in my experience. The mere fact you can’t determine if a video will really answer your question without watching significant chunks of it is a killer. It is vastly simpler to scan through a written article or tutorial, not to mention that there are tools like “Find” which work very efficiently on text to allow you to jump to the area you want…

      I assume that the current world-wide conversion to using videos to communicate information is an coordinated scheme of great evil, but I have yet to work out which supervillain is behind it.

      1. Pinkhair says:

        I assume that the current world-wide conversion to using videos to communicate information is an coordinated scheme of great evil, but I have yet to work out which supervillain is behind it.

        Google, especially since they took over Youtube.

    6. Bryan says:

      Yeah, the insanity pointed to by the Kingdom of Nouns rant is why Main is inside the Hello1 class. Because in a kingdom of nouns, it’s not possible to have code that *does* anything itself. The code has to be attached to a noun, to enable the noun to do the thing.

      Apparently.

      Sigh.

      1. Kyte says:

        To be fair, having an object represent the startup state is a fairly valid concept, and helps prevent contamination of the global scope, which is a thing that happens in Javascript for example.

        And even in Python, the file/directory itself (the package) is technically a class-equivalent, with the code running outside any given functions/class definitions simply being the equivalent to a static constructor.

        Even in C/C++, the translation unit (the file + includes) is technically its own container-type thing, so even unbound functions are kinda-sorta contained in A Kind Of Thing. OO languages just make it explicit. And most OO languages do allow for functions as first-class or at least second-class constructs. It’s only Java that is dogmatically opposed to this.

  24. Sean Hagen says:

    Well, everybody has already covered the “C# is more Java than C++” stuff. I was going to chime in, but A) already been done, and B) my only experience with Java OR C++ was over a decade ago. I mostly do Ruby & Go these days.

    But! I got GameMaker Studio Pro from a recent Humble Bundle, and I want to start working on a game. I’m running into the same problem as you, though. Everything I find is either aimed at complete beginners, or are tidbits on how to do something really advanced. What would be really nice is a resource like Lazy Foo’s SDL tutorials, which were a great help when I was poking about with SDL forever ago.

    I also need some time to experiment and play around, but hopefully this coming long weekend will let me play around a bit.

  25. Nimrandir says:

    It’s been a long time since I’ve done any serious coding (unless you count TI-83 or Mathematica programs for my students), but I have to admit that I was caught off-guard by the difference in the C++ and C# programs. I really would have expected more congruence between the two.

    As to your other point, I am generally frustrated by what I perceive as a move to video as the default format for freaking everything. When a colleague sends me a link to something related to our work, I would really rather not have to spend the first fifteen seconds waiting for the opportunity to stop the inevitable video at the top so I can read the transcript in peace.

  26. Ross McLaren says:

    Well within the month then, I am so pleased. Really look forward to this journey.

  27. Garrett Carroll (Son of Valhalla) says:

    I started learning to code in January, shortly before my 21st birthday. As a result of this, and as a result of the fact that I really only wanted to do it as a hobby (so I could understand computers more), I’ve come to the conclusion that… The book I bought on Java was too complicated. As a result, I decided to start with python and some html instead. (but it’s a money-making career! Why would you rather become an English professor? Questions to be asked…)

    That said, I understood the double parentheses portion of this post. Why would a coding language use two parentheses with one… empty, I believe? I don’t get that.

  28. Mephane says:

    For my money, this series on Procedural Landmass Generation by Sebastian Lague is the best tutorial so far. It has a lot of what I need to get going. The problem is that the bits I need are little ten-second segments sprinkled throughout the sprawling four and a half hour video series. That's not a very efficient way of learning.

    You just summed up why I generally dislike tutorials, guides etc. in video form. More often than not you need only a specific part of the information; in a written text you can usually skip ahead to the paragraph you need, even use things like search to find the right part etc.

    Meanwhile, video tutorials require you to spend so much time on needless smalltalk, stuff you already know, stuff you don’t need right now, in order to get to the tiny portion of information you were looking for.

    (This all goes especially for video game guides, like the many “all collectibles found in in ” videos where you have to sit through 10 minutes of video in order to find the 5 seconds relevant to you.)

  29. poiumty says:

    This is relevant to my interests! I’ve been scripting in C# for about 2 years now. Going backward to C++ would likely feel intense. There’d be a lot of “WHAT!? WHY!?” and “what the hell is a PTR” going on.

    Yeah, I’m the IKEA furniture installer of the programming world.

    I taught myself (the basics of) C# starting almost from scratch, and almost entirely from indians with near-silent microphones on youtube. Honestly, if someone just said “do this” and didn’t walk me through the process visually I would either quit because I was getting bored of reading or quit because I wouldn’t be able to understand what I’m supposed to do. So don’t discount video tutorials, they’re pretty good for absolute beginners like me.
    And well, I had a developer friend who was willing to tolerate my incessant questions. That helps too, I guess.

  30. Paul Spooner says:

    Just realized you missed the opportunity to name this post C#.Sort(“Of”)
    No idea if that’s proper syntax or not.

  31. 4th Dimension says:

    I’m about to commit OO HERESY and possibly explain the static methods. More likely show my ignorance.

    Static methods are for all intents and purposes FUNCTIONS in C#, in that they are used like you would use a function. You use a function to do some type of processing that can’t really be tied to an object. Like making a function (static method) to calculate a power of a number (Math class has those BTW). And static variables inside of the same class can be essentially used as global variables if you need them.

    Placing a function in a class (theretofore making it a static method) really simplifies the problem of namespace since now you can reuse the same name of the function for different things i different classes. Like if you wanted to have two functions, one to add Complex numbers, another to do vector addition so now you can have a class Complex that deals with working with Complex numbers (it can both represent a Complex number AND contains static and not functions for working with them) (probably also HERESY as far as OO programming is concerned, but it works) and Vector for working with Vectors numbers and both will have their own version of Add: Complex.Add and Vector.Add.
    Which IMO simplifies the namespace problems of having long ass function names to separate them by different flavors.

    Oh and BTW, one thing which you will probably learn once you actually start learning C# (which is what I recommend, since you really need to know what the NET and C# are doing because performance is important to you) is that static variables of a class can be given a value during their declaration
    static int x=5;
    but they can also be given values using a static constructor of the class:
    class A{
    public static int x;
    public static A(){
    x=5;
    }
    }
    So the first time I think any of the static variables of this class is called the Framework will run the static constructor (if it exists) to populate them. It will not be run afterwards. Now you are unlikely to use this for simple things like this, but if you want to load variables that you want to use from let’s say the file system, you will need some code to load the file and parse it first, which can be done in a static constructor.

    But seriously, get a book or read microsoft articles to get the idea what C# and .NET do in the background and how it’s concepts work.

  32. Alrenous says:

    The thing to do with video is put it on behind a light videogame that doesn’t mind being alt-tabbed.
    Playing Salt and Sanctuary. After the first runthrough, like any game, it’s not really enough by itself to hold my attention, meaning it’s perfect for putting in front of video lectures or podcasts. Now I have two chars in NG+5, plus five more chars in various advanced states.

    But, likewise, much of the video is fairly pointless. There’s no reason to give it more than a fragment of my attention…until it gets to a good part. Then I can tab to it, rewind, pause, etc.

    In past I’ve use WoW, Dwarf Fortress, Darkest Dungeon…. I find Legend of Grimrock, both 1 and 2, are highly meditative zen experiences to replay, provided the game doesn’t have to hold my attention by itself.

  33. Alex Broadhead says:

    C# sounds disturbingly Java-like; my experience with Java is slim, but it always struck me as being C++ with the training wheels welded on.

    It’s a shame that you’re bound to the PC-verse, as I think Objective C (macOS/iOS) would be much more to your liking. It’s a pretty simple meta-set on C (not even C++, though you can add C++ to Objective C) that makes OO work very straightforward.

    Of course, it’s also theoretically going away, replaced by Swift…

  34. Noah Gibbs says:

    It is *not* video for the convenience of the producer. You are 100% correct that video is much harder to create.

    However, videos are still novel and get a lot better search mojo. The best is video-with-transcript, for the producer.

    1. Matt Downie says:

      Not always harder. A sequence of five button presses takes a few seconds if you’re recording video. Taking screenshots and highlighting the buttons and writing text to explain it all and laying it out nicely is a lot harder.

  35. Riley Miller says:

    Catlike coding is exactly what you are looking for. http://catlikecoding.com/unity/tutorials/
    A bunch of text articles that talk about procedural generation. Section 1.2 should be what you are looking for.
    I’m working on implementing marching cubes and his articles are invaluable.

    1. Mistwraithe says:

      They look excellent, thanks for posting the link.

  36. Robert Conley says:

    Shamus why don’t you get one of Petzold’s books? He always does the trick for me. Granted he doesn’t have anything for unity but he can get you up to speed on C# and the .NET environment.

    https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=Petzold+C%23&rh=i%3Aaps%2Ck%3APetzold+C%23

    Or perhaps one of these books
    https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=C%23+Unity&rh=i%3Aaps%2Ck%3AC%23+Unity

  37. Jeff says:

    “I've always thought of video as more labor-intensive to produce and lectures more time-consuming to consume, so from my perspective it feels like everyone is wasting their time for no reason.”

    I find this comment hilarious, because it more or less reflects my feelings when your blog started having videos.

    Except the rollercoaster ones, because human bowling is always worth watching.

  38. Joshua says:

    “I'm not sure why video is such a popular format when it's so obviously inferior. Is this what the public wants? Does it make the material more approachable? Does it feel more comfortable when it's delivered like a lecture in school because that's how most people learned as children? Or is the tutorial a video simply for the convenience of the producer? I don't know. The whole thing is so strange to me. I've always thought of video as more labor-intensive to produce and lectures more time-consuming to consume, so from my perspective it feels like everyone is wasting their time for no reason.”

    And why I came to this site for the articles, not the videos. I don’t think I ever watched a single episode of Spoiler Warning all of the way through. Well, technically articles and comics because my first introduction was when of my fellow NWN players linked DMotR back in 2006.

    1. rabs says:

      I guess most people reading articles here are finding text better for how they consume things. That’s also my case.

      But I started listening to podcasts and some videos when I discovered I could do that while playing many “mechanical” games (no deep storytelling): rogue-likes, strategy games, and most action games (like Good Robot)… Sometimes I miss something, but it works quite well overall.
      I doubt it would be great for programming tutorial, though…

  39. rabs says:

    Since a few months I’m also contemplating learning Unity and C# while feeling that videos are mostly a waste of time, so I’m really looking forward for your next posts on that subject.
    But I have some Java experience in addition to C++, so as other commentators have noted it should be easier.

  40. Ninety-Three says:

    Speaking of strange moments of hilarious confusion, Shamus’ hilarious confusion is itself hilariously confusing to me, because I got into programming from Python where everything just works and you never think about things like the locatioon of main().

    To the tune of “But what do they eat?”:
    But what instantiates the variables?

  41. No One says:

    Last time I worked in Unity (2015) it was still based on an older version of Mono (the free MS implementation of the .NET framework) due to a licence change, so it was missing language features in the latest MS C#. This sometimes became an issue, as online C# language references would be for the later revs. I don’t know if this has changed since.

    1. 4th Dimension says:

      I don’t think Mono was made by Microsoft. .NET is allready free. What Mono is, is what .NET was supposed to be is an implementation of the .NET compilers (since all .NET assemblies are compiled by JIT right before the execution) that can run on enviroments that are not Windows.
      Basically they took the specification of JIT and bunch of other low level features of .NET and whose expected behavior is known and implemented those.

    2. Kyte says:

      They are using Mono 4.4 which offers significant upgrades but the compiler still targets C# 4 .NET 3.5.
      Most of the C# 5 and higher features aren’t really needed anyways, they’re mostly async stuff which don’t quite match with Unity’s coroutines. At least not without significant engineering.

      Although if they did the effort to make coroutines play with async/await that’d be amazing.

  42. Mark says:

    I’ve found that a good rule of thumb is to pretend all video tutorials don’t exist. Saves me a bunch of time.

  43. Sirius Spamalot says:

    Worse than videos explaining how to do something that would be better explained as text are videos which are literally a sequence of text images with annoying background music. No speech, no moving parts, just text. This has to be more work than just putting the text on a blog. The only reason I can think of is they might get money out of youtube if enough people watch it, and if they’re getting money they don’t care if all their customers are just pi**ed off at them.
    Also, having watched some video tutorials, I’m not convinced much work has gone into them.

    1. Zak McKracken says:

      ohhhh, still worse are videos where the text is also read by a speech synthesizer!

  44. dan says:

    Shamus…

    Take the “why even a video” thing to the logical extreme:
    Why don’t you contact Sebastian Lague (or someone similar) and do a video series TOGETHER, titled “Sebastian teaches Shamus C#” or some such?

    I feel like you’re in a really unique position here, as someone that both wants to consume the tutorial content, but also someone who’s job is producing content, like this blog, and has had some success doing video content.

    I dunno if it would be popular or interesting, but the back-and-forth between two different programmers coming from their different perspectives could be interesting and entertaining in and of itself. I’m imagining something like you’re both recording in real time, while one is remoted into the other’s desktop or something similar, with a good Unity IDE open; so you could actually be stealing the cursor back and forth in video and typing out the code and talking about it all in a piece.

    Like a “Let’s Play” of learning a new language. I think it could work?

  45. Ilseroth says:

    As of this week I am a full time indie game dev (me and an artist friend of mine are making a go of it) and our first game is in Unity. Honestly when it comes to Unity it is almost all “knowing that thing you do.” I’m part of a discord group with a bunch of hobbyists (which I was until recently) and apparently having me in there is great since I tend to know the answer to everything from years of poking at Unity.

    Learning C# wasn’t too bad for me, but I cheated by being taught Java and C++ back a decade ago in high school. But learning unity took a while of prodding, figuring out what works and doesn’t in the engine.

    That being said if your interests lie in procedural terrain generation it may not be something I can help with. If I had to do it, I’d probably write a shader that takes in a randomly generated heightmap and deforms a plane to do it, but then there’s already a terrain system build into unity that can take in height maps.

    That said, I tend to stay away from the graphical side of things when it comes to programming. It’s practically another language and while I could learn it, I’ve got a whole lot of game to make right now. Despite that, if you have any questions, either here or by email, regarding Unity I’ll try to answer it best as I can.

  46. Zak McKracken says:

    Yay! Shamus will explain C# to me! I’m not likely to use it soon but I keep feeling that I should try and keep visibility of something which is not Python. So thanks a bunch for doing this!

  47. Spectralist says:

    I also went to C#/Unity from c++ and it was an interesting road. My strategy was to buy an intro to programming/C# through Unity book after also being frustrated by the fact that almost all the tutorials were video.

    I think that strategy worked out fairly well. Learning from a beginners book like that was naturally a bit slow but liberal skimming sped it up and I only finished maybe 1/3 of the book before I knew what I was doing enough to set off and start a project of my own/researching whatever specifics interested me. Of course the downside of that is said book was outdated within months of being published, and would be horrifically outdated now, like 4 years later.

    But if you want text-based tutorials books seem to be the only way to go, I half suspect that’s why they’re so rare on the internet, people who write them can sell them so why give them away for free?

    At any rate I hope you continue writing on this topic. Your programming posts always serve as a nice inspiration to stop procrastinating on my hobby projects.

  48. Lanthanide says:

    I haven’t read any of the other comments so this might have been said already, but perhaps not.

    You’ve identified a gap in the market, Shamus, and given your writerly persuasions and knack with breaking down technical concepts for people to understand, YOU could potentially be the author of a book: Introduction to Unity for Experienced Programmers.

    Or you could do online articles and gain search results / clicks that way, etc.

  49. toadicus says:

    I don’t know your specific learning style, Shamus, but I taught myself C# just by having a task I wanted to complete. I got in to the modding scene for KSP (all C# + Unity) and taught myself C# (but not Unity, sorry) to pick up a mod I liked when its creator dropped it, then went on to write three or four more of my own. I find that having a goal in mind really helps with learning because it’s practical, needs-driven learning. You need a thing but you don’t know what it is, so you go and find it.

    Here’s to a successful learning endeavor!

  50. Droid says:

    As a mathematician using Python (among others), I’ve always wondered what that final step is that takes programs from “execute your .py file using your installed python distribution” to “execute this self-contained executable that does not need anything pre-installed”. Apparently it’s not that big of a step, since C-style programs also simply point to a first line of code to start at, in their case a function. Python may be doing the same thing, just (conceptually if not literally) putting a main() wrapper around the file you’re trying to run.

    Anyone interested in enlightening a dabbling programmer?

    1. 4th Dimension says:

      Well, from what I understand it’s basically what you are saying. Pure exe machine code files have a certain format that OS expects so it can determine where the entrance/start is and start executing from there. And that is all there is to it. All the rest of the loading of other libraries is done by OS or by the exe itself.

      On the other hand Phyton scripts need to be passed to a processor/compiler/whatever it’s name is that will read them and interprets each command in the script file in turn.

      Java and .NET are somewhere in between (disclamer, I don’t know Java arhitecture). The exe files for .NET aren’t simply encapsulations of the C# scripts. Actual compiling does happen in that the C#/F#/VB code is converted into machine independent CIL (common intermediate language) and packed into an assembly (exe or dll).
      Then once you double click on the .NET executable the system determines that this is in fact a .NET executable and passes it to the framewrok which uses Just in Time Compiler to compile the machine independent CIL into actual machine DEPENDENT machine code to run on the computer. This machine code is basically like any other machine code on the system.
      This should allow you to compile one exe, and then be able to run it on Linux and Windows with no recompiling. And it does work mostly like that, with the trouble being that the full framework implementation is only available on Windows, while Mono (a community developed alternative implementation) which does target linux and Windows doesn’t have the full implementation. Still this does allow you to run simple Windows Forms applications on both Windows AND Linux with next to no recompiling.

    2. PeteTimesSix says:

      The difference is between interpreted languages (Python, JavaScript, etc.) and compiled languages (C, C++, etc.). Basically, where normally a program compiles to machine code (instructions that map directly to what the processor does) and you then run the compiled executable file, interpreted languages execute the program code directly (or, well, since that’s not actually possible, translate it to machine code right before a given line of code runs) and thus need to be run through an interpreter that actually knows what the code means (whereas a compiled program already matches the instruction set of the computer its on).

      EDIT: Ninjas! Eloquent ninjas!

  51. DivFord says:

    Have you encountered the scripts and tips wiki? They aren’t tutorials as such, and the quality of the commenting varies, but I’ve found example scripts pretty useful. There’s a fair bit on there about procedural mesh generation. Also, the Mesh class in the actual unity documentation is very well documented.

    EDIT: I should mention, I tried implementing something based on Project Frontier in Unity a couple of years back. It’s javascript, so the code probably isn’t of much interest to you, but I may be able to help with the Unity side of things.

  52. Blue Painted says:

    On video …

    … the place I work does a lot of training and informational stuff. There was some video content, simple piece to camera, originally done by the “Manager in charge” and it was …. poor, to say the least. Later on the client had the content updated and this time paid to have a professional presenter — she’s a local TV presenter — do the piece to camera: The difference!! You could see why she had spent those years at stage school.

    TL;DR Video presentation is a real skill — and that’s not even touching production and editing!

  53. Jack V says:

    It occurs to me, C# is a bit like C++ with the debugging turned on. All the objects continue to exist at run time, with names and everything, instead of being aggressively optimised.

    As for main, I think that’s really really a special case. It is in C too — “something” knows to call main. And in C#, “something” knows to call that main function.

  54. default_ex says:

    As a programmer that jumped from C and C++ to C# during the .NET 2.0 days and stuck with it. I find it to be an incredible language but at the same time it was difficult learning the differences at first. The obvious difference is that with C# everything is an object. While at the same time some things are not objects but instead are object-like wrappers around data types.

    The whole instance and static dichotomy in C# is weird at first but something that eventually you grow to embrace and appreciate. It forces you to keep things neatly categorized. If you look into the IL being generated when you call a static and instance method that are otherwise identical, you begin to see what the actual difference is. In the function call there is a hidden parameter the compiler handles for you on instance method calls. That parameter is the instance to execute it on. So Add(X, Y) is really Add(this, X, Y). Extension methods kind of expose this to you while not directly making it obvious what’s going on.

    However I have one not so confusing thing to help you out. The best resource for learning C# is not a tutorial, it’s not a book or even a teacher. It’s the official Microsoft documentation that gets installed with the IDE. Especially for a programmer that is familiar with C++ and programming in general. I’m sure you know what constructs you need, digging through the documentation is pretty easy if you know what you need in C++ and just want to learn the C# equivalence (or alternative in some cases). There’s a damn good reason why people whom are familiar with Microsoft’s documentation call it the ‘gold standard of documentation’; it really is that good.

  55. MichaelG says:

    “These concepts are all all things”. Y’all need one less “all”.

  56. Syal says:

    so from my perspective it feels like everyone is wasting their time for no reason.

    Welcome to the wide world of extroversion. They have cakes, and are prepared to tell you about the cakes’ life history in exhaustive detail even if you try to walk away.

  57. Phil says:

    class Player player1;

    I know I’m being slightly unreasonable, but this bothers me. ‘class’ isn’t a holdover from C, such that you’ll still see C++ code that might typedef away the need to use the word ‘struct’ in an object declaration, because it was either that or ‘struct SomeStruct object;’ in C.

    Is this a typo slash copy/paste issue, or do you typically declare class objects this way? If so, where did you pick that up from?

    1. Shamus says:

      Copy / paste issue. It’s a bit strange when I write about code here on the blog. On the front page you see it with nice fixed-width font, highlighting, and other IDE-type comforts. But when I’m editing a post I have to type everything using the same variable-width font as everything else. So I often don’t notice odd looking code, because in the editing page it ALL looks odd.

      Confession: Some programmers are really bad with copy / paste errors, but I am indefensibly bad about it. I LOT of my bugs are copypasta.

  58. diegzumillo says:

    Ah.. the world of tutorials. We all need them but I hate it. And video tutorials drive me insane! they are always, 100% of the time, way too slow. I mean, it’s a video, for christ’s sake, I can go back any time I want! you don’t have to repeat yourself. And video tutorial for coding doesn’t even make sense. Loading a 4K video just to read text on the screen? naaah.

    Discovering I can alter playback speed on youtube made my life much better. I’m always messing with the speed, even for non tutorials.

  59. Vi says:

    I didn’t realize how fortunate I was! My computer science classes taught mostly Java, which I subsequently forgot, only to marvel years later at how this Unity3D thing felt oddly painless. But it sounds like when I need to use Unreal Engline with its C++ for something, it’s going to be quite an uphill battle. :(

  60. For some good articles on Procedural Generation in Unity. I quite like these:

    interesting case studies:
    http://catlikecoding.com/unity/tutorials/

    great introduction:
    http://www.gamasutra.com/blogs/JayelindaSuridge/20130903/199457/Modelling_by_numbers_Part_One_A.php

  61. Adeon says:

    I’m totally with you on the video tutorial issue. There are some things that do make more sense as videos (car maintenance for example) but for a lot of topics I can process the information in a written tutorial much easier and faster than a video tutorial.

  62. CliveHowlitzer says:

    This is only somewhat related but the video thing infuriates me to no end. So often I click a link expecting text or an article and get a video and immediately back out of it. No patience to watch it when I likely only need information from 15 seconds of the 5-10 minute video or longer.

  63. LCF says:

    Please keep us posted on the C# learning!
    Even if I don’t make much with it, it’ll be a good read.

  64. Milton says:

    hey) I’m new in programming and it is interesting to read how others are conquering this hard tower))). But the author is not so new in this field, like me) i I started without any basic knowledge of programming… I started at here https://codeasy.net. The only thing that made me complete the course is curiosity – there read chapters of the story and code while reading. Otherwise I stopped at the very first task))

    Actually, I’m junior now, so, it’s not much time passed when I just started….even though I have nothing to compare with (I mean C# with the other programming language, as the author does) – but i can say that C# is a beautiful language, it is clear and logical. I will surely continue mastering it – and thanks for the author for sharing his knowledge of C and comparison with c#.

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun. Your email address will not be published. Required fields are marked*

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>

Leave a Reply to Deadfast Cancel reply

Your email address will not be published.