Announcement

Collapse
No announcement yet.

Mono Developing A New .NET Interpreter

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Originally posted by Hi-Angel View Post
    I do not think C# is a nice language. Its destructors doesn't work upon coming out of scope, which complicates the code. Type inference of templates is basically non-existent. Oh, and by the way, did you hear that C# frees you from manual memory management? Well, too bad it's not true — it only frees you from calling "delete()", but then again, you rarely use it in C/C++ code either! On the other hand you can't just declare a class object and hope the compiler will sort it out — you have to manually call "new" every time, and ashes on your head if you forget it.

    There's too much hype around C#. That said, I do see its upsides — when you're new to programming, C# is much easier than C++, because the later have got too many corner cases that would leave you frustrated until you get better. But for experienced programmers C++ much better than C#.
    So you don't like languages where you don't manage your own memory.... you do realize that's not just C#, right?

    Comment


    • #22
      Originally posted by wizard69 View Post
      Maybe that explains seeing very little .net related tech.
      It's everywhere in the corporate world, especially in US/state government systems (of which there are a lot more of than most people realize). The ability to convert and run those on linux will be better for everyone. Operations teams prefer linux and it makes security much, much easier.

      I'm not suggesting everyone go out and start using C# on linux... but this open source transition is good for other reasons.
      Last edited by fuzz; 11-16-2017, 03:59 PM.

      Comment


      • #23
        Originally posted by fuzz View Post

        So you don't like languages where you don't manage your own memory.... you do realize that's not just C#, right?
        I don't know where did you get it. I don't consider the concept as useless, more over, I like Haskell, which I hardly could imagine to be such beautiful language if it didn't manage memory behind the scene.

        Comment


        • #24
          I'm working on a Civilization clone, for which I use Visual Studio Code/.NET Core 2.0: https://github.com/SWY1985/CivOne

          It's very possible to develop something nice in C# that also works on Linux.
          Ironically, the reason I was able to remove Windows 10 from my home computer and move on to Linux is because Microsoft released VScode and .NET Core.

          Comment


          • #25
            Originally posted by Hi-Angel View Post
            I do not think C# is a nice language. Its destructors doesn't work upon coming out of scope, which complicates the code.
            You're using the language wrong if that's one of your complaints, although I can see why you'd try to do that coming from c++. In C#, you should be using the IDisposable/using pattern for that.

            Type inference of templates is basically non-existent.
            I'm curious what you mean by that. Could you post a c++ example?

            Comment


            • #26
              Originally posted by smitty3268 View Post
              You're using the language wrong if that's one of your complaints, although I can see why you'd try to do that coming from c++.
              Well. When I got introduced to C#, I was just an inexperienced student. I could've went with Qt&C++, but advises on C# were coming from more experienced colleagues, so I thought it's something cool. I was actually excited, back then I liked the idea of error handling through exceptions. In retrospective, with regard to day-job I'd better went off with Qt. However experience-wise I'm glad I got to use C# so really much, at least now I know what I'm talking about and how not to get caught to a marketing
              Originally posted by smitty3268 View Post
              In C#, you should be using the IDisposable/using pattern for that.
              So I did, but this is irrelevant to the complain, isn't it? I admit it's definitely better than nothing, but compared to RAII of C++ it still complicates the code — adds a boilerplate construction, another indentation level, and another place to make a mistake (i.e. by forgetting to use the pattern).

              Originally posted by smitty3268 View Post
              I'm curious what you mean by that. Could you post a c++ example?
              Sure. The most annoying one is this:

              HTML Code:
              $ cat test.cpp
              template<typename T>
              T add(T t){ return t + t; }
              
              int main()
              {
                  add(1);
              }
              $ g++ test.cpp
              $ cat test.cs
              namespace Test
              {
                  class Test
                  {
                      static T add<T>(T t){ return t + t; }
                      static void Main()
                      {
                              add(1);
                      }
                  }
              }
              $ mcs test.cs
              test.cs(5,38): error CS0019: Operator `+' cannot be applied to operands of type `T' and `T'
              Compilation failed: 1 error(s), 0 warnings
              I thought I could workaround it most of the times with a lambda, which pushes us to the following example:

              Code:
              $ cat test.cpp
              int main()
              {
                  auto addlambda = [](int x){return x + x;};
              }
              $ g++ test.cpp
              $ cat test.cs
              namespace Test
              {
                  class Test
                  {
                      static void Main()
                      {
                          var addlambda = (int x) => {return x+x;};
                      }
                  }
              }
              $ mcs test.cs
              test.cs(7,13): error CS0815: An implicitly typed local variable declaration cannot be initialized with `anonymous method'
              Compilation failed: 1 error(s), 0 warnings
              I recall having a third type of error, when it couldn't infer assignement type, but now that I'm trying to remember, I just can't, although I stumbled upon it a lot. Anyways, I think these two examples are good anyway.

              Comment


              • #27
                Originally posted by Hi-Angel View Post
                I thought I could workaround it most of the times with a lambda, which pushes us to the following example
                Hmm wait, I couldn't workaround it this way. Probably what I was meaning is the following example — it is also a third one btw:
                Code:
                $ cat test.cpp
                int main()
                {
                    auto addlambda = [](auto x){return x + x;};
                }
                $ g++ test.cpp
                $ cat test.cs 
                namespace Test
                {
                    class Test
                    {
                        static void Main()
                        {
                            Func<int, int> addlambda = (var x) => {return x+x;};
                        }
                    }
                }
                $ mcs test.cs
                test.cs(7,13): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
                Compilation failed: 1 error(s), 0 warnings

                Comment


                • #28
                  Originally posted by Hi-Angel View Post
                  Sure. The most annoying one is this:
                  I see.

                  Typically I don't use a lot of operator overloading so it's tough for me to see exactly how this would be directly useful.

                  You can constrain the generic types based off of interfaces so that you can call various methods they all share, which tends to be all I need, but you are correct that the operators don't really work with it.
                  Code:
                  static T add<T>(T t) where T : IAdder { return t.Add(t); }
                  //but wouldn't work directly with ints, you'd have to wrap it in a struct first
                  
                  //the closest i could come is UGLY, although i think the optimizer is smart enough to strip all this out if you're passing ints in
                  static T add<T>(T t) where T : struct { return (T) Convert.ChangeType(Convert.ToInt32(t) + Convert.ToInt32(t), typeof(T)); }
                  You can also do something like that lambda since 4.0, but I'm not wild about recommending the use of dynamic types either, since I view static typing as a benefit.
                  Code:
                  Func<dynamic,dynamic> addlambda = (dynamic x) => { return x+x; };
                  Last edited by smitty3268; 11-21-2017, 10:51 PM.

                  Comment

                  Working...
                  X