Jump to content

Oh, I'm a beginner in C# and was never taught that you could do it at all. If you're able to "cast" and allow it to happen then it makes sense that this would occur.

 

You'd do something along the lines of...

double pi = 3.1415926535dfloat roundedPi = (float)pi;

That would achieve a successful assignment of a double to a float. You would lose precision in a process such as that, and I believe the compiler would issue a warning about that. But there's the proper way to ensure type-safety.

Link to comment
https://linustechtips.com/topic/18221-c-or-c/page/2/#findComment-237581
Share on other sites

Link to post
Share on other sites

The question really needs to be what do you want to do? If you're just getting into programming, C# is probably better, because you don't have to worry about memory management as much, as everything is a pointer allocated on the heap.   That being said, it can be slower depending on what you're doing.  If you're writing a program that needs to be high performance c or c++ are way better.  I've never used C# on any platform other than Windows, but depending on what you're doing c and c++ can get annoying if you're doing anything non-trivial with sockets or files cross platform, as directories and sockets are platform independent   Java is also a good bet, since its a "write once, run everywhere" type language.  I'm not a huge fan of Java, I think it takes most of the skill and fun out of it, with almost everything you could want being already in a standard library for you, and tends to have a lot over overhead.  There are a lot of good Java IDE's though, which can be useful when you're just starting.  C vs C++ is an interesting debate, I think C++ is better even if you don't use objects, because you have access to the "new" and "delete" keywords, which are a lot less daunting then having to use malloc when you're just starting out.  There's also no // comment and no Boolean type in standard C (c88?).

 

When I just need to get something working quickly (on Windows) I go with C#, on Linux I always go with C++, just my opinion, but I'd go with C#.

Link to comment
https://linustechtips.com/topic/18221-c-or-c/page/2/#findComment-242877
Share on other sites

Link to post
Share on other sites

The question really needs to be what do you want to do? If you're just getting into programming, C# is probably better, because you don't have to worry about memory management as much, as everything is a pointer allocated on the heap.   That being said, it can be slower depending on what you're doing.  If you're writing a program that needs to be high performance c or c++ are way better.  I've never used C# on any platform other than Windows, but depending on what you're doing c and c++ can get annoying if you're doing anything non-trivial with sockets or files cross platform, as directories and sockets are platform independent   Java is also a good bet, since its a "write once, run everywhere" type language.  I'm not a huge fan of Java, I think it takes most of the skill and fun out of it, with almost everything you could want being already in a standard library for you, and tends to have a lot over overhead.  There are a lot of good Java IDE's though, which can be useful when you're just starting.  C vs C++ is an interesting debate, I think C++ is better even if you don't use objects, because you have access to the "new" and "delete" keywords, which are a lot less daunting then having to use malloc when you're just starting out.  There's also no // comment and no Boolean type in standard C (c88?).

 

When I just need to get something working quickly (on Windows) I go with C#, on Linux I always go with C++, just my opinion, but I'd go with C#.

 

C# is also cross platform. Check out the Mono framework. I think C# is better designed, less bloated (and, most importantly, faster) than Java in every aspect. C# also has a glut of great libraries and in the open-source implementation, most those libraries are implemented. It also allows for the hosting of ASP.NET MVC 4 applications on Linux servers. Check out the Mono project. ;)

 

Also, C has come a long long way since the C99 (which added Boolean data types) standard. C11 is the newest standard. My father remembers a time when he had to typedef integers to create Boolean behavior. He started writing C++ in the mid-90's and is finally adopting the C++03 standard even though C++11 is out. I'm pressuring him to look into the C++11 features and finally start using them.

Link to comment
https://linustechtips.com/topic/18221-c-or-c/page/2/#findComment-243257
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

C# gets my vote

 

It's a lot easier to pick up and master than C++ and once you're comfortable with C# you'll be much better-placed to tackle C++

 

If you jump into C++ straight away you might find yourself taking longer to master it than if you'd learned C# first. Plus, C# is a good language to know - C++ not as much unless you know exactly what you want to do and where you want to work 

Link to comment
https://linustechtips.com/topic/18221-c-or-c/page/2/#findComment-336696
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×