76

The title itself is a recipe for disaster. Also this is a semi rant.

Yesterday I was informed that I will have the honour to implement the core functionality - which is an interface layer to use the driver of a very expensive hardware shit - of the software I’ve been working on as a frontend dev.

There are two possibilities for the language: C++ or C#. The one that was proposed/imposed is C#, which I know nothing of, while at least I have some hobbyist experience with C++; when asked if I could take some time to familiarise myself with C# I was basically laughed in the face, saying I will learn on the field and at least some of them have some experience with it.

Should I insist to go with C++, or is that an even worse idea in an already fucked up situation?

you are viewing a single comment's thread
view the rest of the comments
[-] Heavybell@lemmy.world 32 points 1 year ago

If you can code in C++ you should be able to muddle through in C# no problem. The runtime will help prevent the worst SNAFUs; y'know, pointer errors (there are none, unless you use the unsafe block or p/invoke), memory leaks etc. Just look at the existing code and cargo-cult it til you make it. You got this. :)

[-] nitefox@lemmy.world 2 points 1 year ago* (last edited 1 year ago)

The project is brand new (as in, the integration backend doesn't exist), I have to code and architecture it

[-] Heavybell@lemmy.world 5 points 1 year ago

Okay that is a bit rougher. Best of luck I suppose. Hopefully you can lean on your colleagues somewhat. If I had one piece of advice, look up the using block, it basically ensures an object gets disposed immediately when it goes out of scope, which is the closest C# lets you get to deallocating memory. The object needs to implement IDisposable tho.

[-] Lucky@programming.dev 3 points 11 months ago

To clarify for OP, the only time you need this at all is when the object has a reference to something that the garbage collector won't dispose of naturally. Things like an open file stream, db connection, etc.

You won't need to dispose of an object you created if it just has properties and methods

[-] Heavybell@lemmy.world 1 points 11 months ago

Circular references can also impede garbage collection, don't forget.

And to further clarify, a proper object wrapping a resource like the ones you listed will release them when it is eventually collected, in the finalizer/destructor. However, you can't know when that will happen, so we have IDisposable.Dispose() which can be used to release whatever critical resources the object is holding right away. :)

[-] PixxlMan@lemmy.world 1 points 11 months ago

This is very wrong. Circular references are no problem for the garbage collector at all (https://stackoverflow.com/questions/8840567/garbage-collector-and-circular-reference). You basically don't need to worry about manual memory management at all, if you're only dealing with managed code.

[-] Heavybell@lemmy.world 1 points 11 months ago

I was specifically thinking of circular event handler references, which I know was a thing at some point in the past. If .Net has improved since then, great.

[-] PixxlMan@lemmy.world 1 points 11 months ago

You only need to use IDisposable for disposing unmanaged resources (file io etc). In modern .NET there are actually ways to perform manual memory management using malloc and delete etc, but it's unlikely you'd ever need it.

[-] BaskinRobbins@sh.itjust.works 1 points 11 months ago

I recommend looking at a Shawn Wildermuth course that seems related to the type of project you will be creating. He has a bunch on pluralsight and his website. He was instrumental for me in my early days of learning .net and architecture.

this post was submitted on 23 Aug 2023
76 points (93.2% liked)

Programming

16700 readers
217 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS