Programming language discussions

Started by kaywhyn, June 10, 2026, 12:43:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kaywhyn


JawaJuice

Quote from: kaywhyn on June 10, 2026, 12:43:49 PMC#

Source code for NL editor:

https://bitbucket.org/namida42/neolemmixeditor/src/master/

Ah OK, makes sense. I would choose C# as well for that kind of desktop GUI app.

kaywhyn

#2
Quote from: JawaJuice on June 10, 2026, 12:56:42 PMAh OK, makes sense. I would choose C# as well for that kind of desktop GUI app.

I personally only have experience with C++, but I haven't coded in that language in over 15 years now, as the last time I did so was back when I was in college/university. Hence, I'm not sure how much it has in common with C#, let alone C, in terms of syntax, though it wouldn't surprise me if there are some similarities, especially with C. I recently re-installed Visual Studios on my machine again and am pleased that most of my assignments from the computer programming course I took all those years ago still compile properly ;)

JawaJuice

Quote from: kaywhyn on June 10, 2026, 01:04:21 PMI personally only have experience with C++, but I haven't coded in that language in over 15 years now, as the last time I did so was back when I was in college/university. Hence, I'm not sure how much it has in common with C#, let alone C, in terms of syntax, though it wouldn't surprise me if there are some similarities, especially with C. I recently re-installed Visual Studios on my machine again and am pleased that most of my assignments from the computer programming course I took all those years ago still compile properly ;)

Not wanting to derail the thread, but this is an interesting chat to me, so hey! As a C++ coder, C# is fairly easy to pick up because both languages share a common root in C. C# actually has a fair bit in common with C++ in terms of its syntax, the main architectural difference is around memory management, so C# is more like Java in that it's a managed language where garbage collection is automated. In C, you don't have that luxury at all and are completely responsible for your program's memory allocation and management through pointers (which makes it easily the most dangerous of the three to use if you don't know what you're doing!). Modern standards of C++ have introduced smart pointers, which makes memory management significantly easier, though it's still not fully automated. The reason C# is more suitable for GUI development though, is that it's closely tied to the .NET framework so has GUI elements built in that are almost drag-and-drop through Visual Studio, compared to C++, where you'd have to plug in third party libraries like Qt. Back in the day, we used to use MFC to build GUI apps but no-one in their right mind would choose that over C# these days! Good to hear that your old projects still compile in VS - I think you mentioned that before :thumbsup:

namida

No worries about the derailing - this can easily be split off into its own thread. :)
My projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

WillLem

Quote from: JawaJuice on June 10, 2026, 11:17:34 AMWhat language is NLEditor written in out of curiosity? I'd be interested how the Random ID button is implemented, presumably some kind of seeded rand function.

As kaywhyn said, it's C#. Which version are you using? The source code for the latest version is here:

NLEditor Source Code

The bit you're interested in is this:

        private void btnRandomID_Click(object sender, EventArgs e)
        {
            CurLevel.LevelID = (ulong)Utility.Random().Next() +
                               ((ulong)Utility.Random().Next() << 32);
            txtLevelID.Text = CurLevel.LevelID.ToString("X16");
        }

WillLem

Visual Studio is great for creating GUI-based Windows apps, but its own GUI can sometimes be a bit janky, especially when it comes to repositioning form elements. Delphi's GUI is actually way better for this. If I'm making a simple tool with a GUI, I often reach for Delphi first.

JawaJuice

Ah, OK. The only time I ever used Delphi at work was back in the early Noughts, and that was for a black box wargame simulation rather than a GUI. I've sure the language has evolved out of sight since I last looked at it! In my general course of work now I don't actually do much GUI development, just the odd utility app in C#, I'm mostly on back-end development, which is all C++. Interesting to know what people are using though!

WillLem

Quote from: JawaJuice on June 10, 2026, 03:49:17 PMThe only time I ever used Delphi at work was back in the early Noughts ... I've sure the language has evolved out of sight since I last looked at it!

NeoLemmix and SuperLemmix are both Delphi-based, which is pretty much the only reason I know it exists. I find its form-building interface very comprehensive and user-friendly, and it's still a great IDE for simple tool building.

JawaJuice

Re: the C# used in NLEditor for the Random ID generator

Quote from: WillLem on June 10, 2026, 03:31:10 PMThe bit you're interested in is this:

        private void btnRandomID_Click(object sender, EventArgs e)
        {
            CurLevel.LevelID = (ulong)Utility.Random().Next() +
                              ((ulong)Utility.Random().Next() << 32);
            txtLevelID.Text = CurLevel.LevelID.ToString("X16");
        }

Yes, interesting! I'm not familiar with the Random() method in C# but I'm guessing it must do automatic seeding. In C++, if you use srand() from the standard library, you need to manually seed it with a parameter otherwise it would generate the same random number every time the program is run. I assume '<<' in this context is a left-hand bitwise shift in the same way as in C++.