Moving from C# to C++, and tips? [closed]

I’ve been using C# for a while now, and for the sake of furthering my career and extending my knowledge of programming, I want to get into C++. C# is very useful, and fast to work with, but since my team and I will be making large scale projects I need to consider working at a lower level language for several reasons. Most commercial companies use C/C++ due high performance and portability. Of course, C# isn’t necessarily bad compared to C or C++, but I just prefer to have a different tool for each job.

So I read C++ is harder because it is a low level language, machine code, and doesn’t have memory management. But the fact that it is machine code also reduces the amount of memory consumed. The language is hard to work with, but in a way difficulty makes it a powerful language. It was made to be fast and efficient, machine code, but this makes it harder to understand and learn “since it is closer the the machine”.


I’ve made up my mind, and I want to learn C++, so what are some tips to keep in mind while learning? It’s best to avoid getting into bad habits rather than to try and break them later, safe than sorry.

I plan to use the resources stated here, but I would prefer any personal recommendations, books or online guides, possibly those that can be easily understood by someone who has fair knowledge of C#.

7

I actually went the opposite way, from C++ to C#. I really cut my teeth on good OO design in a C++ context, so I feel I can talk about this okay.

Tips:

  • Unlike C#, C++ has been around for a long time. Since the 70s. As such, what constitutes ‘good C++’ depends on who you ask and when they got involved writing C++ and what books they’ve read. Bjarne Stroustrup’s The C++ Programming Language has been revised four times, and went from a 300 page book in the first edition, to a 1500 page book in the fourth. Simply put, a lot has changed over the life of the language, and so there is a lot of history and opinions on how to solve problems. C++ 11 still does more of the same.
  • Learn about how to use pointers, and what they are useful for. If you can, try using pointers to work with hardware directly.
  • Memory management in C++ is often managed using a good practice called RAII. jalf of StackOverflow fame has an excellent article on this: The Meaning of RAII. Also, learn about using shared_ptr, auto_ptr, and the other pointers from the “smart pointer” family. Using these techniques will prevent you from running into memory management issues.
  • Even with the above techniques, you still might run into some memory management issues, in which case valgrind is super-useful to know how to use (especially massif – massif and I got to be good buddies when we were using weak_ptrs in a funky way in some code).
  • C++ has a number of confusing syntax rules (which the C# designers tried to avoid in their language design), many of which if you do not follow carefully will cause you to have confusing results. For example, you may commonly see const className& as the input type of function parameters – there are very good, extremely detailed reasons for this. Marshall Cline’s C++ FAQ is invaluable for this.
  • C++ has a lot of features and flexibility and power, which is a good thing, but it doesn’t often make the garden-path choices the best for new users. This means, if you aren’t careful, your code will be horrible. It took me a good 18 months to figure this out and realize how crappy my code was and why I was getting bad code reviews. Learning to write an interface in C++ (hint: lookup what an abstract-base-class is) is crucial to making great code. Don’t be afraid to replicate good concepts and programming constructs you learned in C# land back into C++ land, when you are able.
  • Do learn about template-based programming. Learn what its strengths and weaknesses are, and how it differs from C# generics.

1

This is likely to get closed due to open-ended-ness, but hopefully this tip is important enough and un-controversial enough to help:

Be aware of ownership.

In C# (and other languages with automatic memory management), what object owns a variable can be a bit fuzzy. Does the event own the handler, or does the “catcher” of the event? In C#, it doesn’t really matter. In C++, your program will die a horrible, horrible (and often subtle) death if you don’t know who owns that handler.

This is the key difference in how you need to design programs, and will manifest itself in subtle ways if you’re not very careful with it. Learning to design around who owns what is the most important transition you’ll need to make, so focus on it early.

I think that you need to be a little careful with the language that you are using to describe C++ (low level language), and also with some of the technical description (machine code) as it reads as inaccurate.

Then you need to work out why you really want to learn a new language. Many companies are using C/C++ and many are using Java and many are using Perl and Python and Scala and … (some are even using Fortran). Maybe you have a specific company, sector or project in mind? If it is purely for employment reasons I’d caution against it unless you have a way of getting provable experience (I never managed to use my spare time projects as experience in an interview). Pick something that you are interested in, maybe it won’t be OO at all; you’ll be better at it in the long term through being genuinely interested. Then code in public and see how it goes, asking questions as you go, if it is C++ it’s going to take a little while especially if you want to get into memory management!

0

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Moving from C# to C++, and tips? [closed]

I’ve been using C# for a while now, and for the sake of furthering my career and extending my knowledge of programming, I want to get into C++. C# is very useful, and fast to work with, but since my team and I will be making large scale projects I need to consider working at a lower level language for several reasons. Most commercial companies use C/C++ due high performance and portability. Of course, C# isn’t necessarily bad compared to C or C++, but I just prefer to have a different tool for each job.

So I read C++ is harder because it is a low level language, machine code, and doesn’t have memory management. But the fact that it is machine code also reduces the amount of memory consumed. The language is hard to work with, but in a way difficulty makes it a powerful language. It was made to be fast and efficient, machine code, but this makes it harder to understand and learn “since it is closer the the machine”.


I’ve made up my mind, and I want to learn C++, so what are some tips to keep in mind while learning? It’s best to avoid getting into bad habits rather than to try and break them later, safe than sorry.

I plan to use the resources stated here, but I would prefer any personal recommendations, books or online guides, possibly those that can be easily understood by someone who has fair knowledge of C#.

7

I actually went the opposite way, from C++ to C#. I really cut my teeth on good OO design in a C++ context, so I feel I can talk about this okay.

Tips:

  • Unlike C#, C++ has been around for a long time. Since the 70s. As such, what constitutes ‘good C++’ depends on who you ask and when they got involved writing C++ and what books they’ve read. Bjarne Stroustrup’s The C++ Programming Language has been revised four times, and went from a 300 page book in the first edition, to a 1500 page book in the fourth. Simply put, a lot has changed over the life of the language, and so there is a lot of history and opinions on how to solve problems. C++ 11 still does more of the same.
  • Learn about how to use pointers, and what they are useful for. If you can, try using pointers to work with hardware directly.
  • Memory management in C++ is often managed using a good practice called RAII. jalf of StackOverflow fame has an excellent article on this: The Meaning of RAII. Also, learn about using shared_ptr, auto_ptr, and the other pointers from the “smart pointer” family. Using these techniques will prevent you from running into memory management issues.
  • Even with the above techniques, you still might run into some memory management issues, in which case valgrind is super-useful to know how to use (especially massif – massif and I got to be good buddies when we were using weak_ptrs in a funky way in some code).
  • C++ has a number of confusing syntax rules (which the C# designers tried to avoid in their language design), many of which if you do not follow carefully will cause you to have confusing results. For example, you may commonly see const className& as the input type of function parameters – there are very good, extremely detailed reasons for this. Marshall Cline’s C++ FAQ is invaluable for this.
  • C++ has a lot of features and flexibility and power, which is a good thing, but it doesn’t often make the garden-path choices the best for new users. This means, if you aren’t careful, your code will be horrible. It took me a good 18 months to figure this out and realize how crappy my code was and why I was getting bad code reviews. Learning to write an interface in C++ (hint: lookup what an abstract-base-class is) is crucial to making great code. Don’t be afraid to replicate good concepts and programming constructs you learned in C# land back into C++ land, when you are able.
  • Do learn about template-based programming. Learn what its strengths and weaknesses are, and how it differs from C# generics.

1

This is likely to get closed due to open-ended-ness, but hopefully this tip is important enough and un-controversial enough to help:

Be aware of ownership.

In C# (and other languages with automatic memory management), what object owns a variable can be a bit fuzzy. Does the event own the handler, or does the “catcher” of the event? In C#, it doesn’t really matter. In C++, your program will die a horrible, horrible (and often subtle) death if you don’t know who owns that handler.

This is the key difference in how you need to design programs, and will manifest itself in subtle ways if you’re not very careful with it. Learning to design around who owns what is the most important transition you’ll need to make, so focus on it early.

I think that you need to be a little careful with the language that you are using to describe C++ (low level language), and also with some of the technical description (machine code) as it reads as inaccurate.

Then you need to work out why you really want to learn a new language. Many companies are using C/C++ and many are using Java and many are using Perl and Python and Scala and … (some are even using Fortran). Maybe you have a specific company, sector or project in mind? If it is purely for employment reasons I’d caution against it unless you have a way of getting provable experience (I never managed to use my spare time projects as experience in an interview). Pick something that you are interested in, maybe it won’t be OO at all; you’ll be better at it in the long term through being genuinely interested. Then code in public and see how it goes, asking questions as you go, if it is C++ it’s going to take a little while especially if you want to get into memory management!

0

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Moving from C# to C++, and tips? [closed]

I’ve been using C# for a while now, and for the sake of furthering my career and extending my knowledge of programming, I want to get into C++. C# is very useful, and fast to work with, but since my team and I will be making large scale projects I need to consider working at a lower level language for several reasons. Most commercial companies use C/C++ due high performance and portability. Of course, C# isn’t necessarily bad compared to C or C++, but I just prefer to have a different tool for each job.

So I read C++ is harder because it is a low level language, machine code, and doesn’t have memory management. But the fact that it is machine code also reduces the amount of memory consumed. The language is hard to work with, but in a way difficulty makes it a powerful language. It was made to be fast and efficient, machine code, but this makes it harder to understand and learn “since it is closer the the machine”.


I’ve made up my mind, and I want to learn C++, so what are some tips to keep in mind while learning? It’s best to avoid getting into bad habits rather than to try and break them later, safe than sorry.

I plan to use the resources stated here, but I would prefer any personal recommendations, books or online guides, possibly those that can be easily understood by someone who has fair knowledge of C#.

7

I actually went the opposite way, from C++ to C#. I really cut my teeth on good OO design in a C++ context, so I feel I can talk about this okay.

Tips:

  • Unlike C#, C++ has been around for a long time. Since the 70s. As such, what constitutes ‘good C++’ depends on who you ask and when they got involved writing C++ and what books they’ve read. Bjarne Stroustrup’s The C++ Programming Language has been revised four times, and went from a 300 page book in the first edition, to a 1500 page book in the fourth. Simply put, a lot has changed over the life of the language, and so there is a lot of history and opinions on how to solve problems. C++ 11 still does more of the same.
  • Learn about how to use pointers, and what they are useful for. If you can, try using pointers to work with hardware directly.
  • Memory management in C++ is often managed using a good practice called RAII. jalf of StackOverflow fame has an excellent article on this: The Meaning of RAII. Also, learn about using shared_ptr, auto_ptr, and the other pointers from the “smart pointer” family. Using these techniques will prevent you from running into memory management issues.
  • Even with the above techniques, you still might run into some memory management issues, in which case valgrind is super-useful to know how to use (especially massif – massif and I got to be good buddies when we were using weak_ptrs in a funky way in some code).
  • C++ has a number of confusing syntax rules (which the C# designers tried to avoid in their language design), many of which if you do not follow carefully will cause you to have confusing results. For example, you may commonly see const className& as the input type of function parameters – there are very good, extremely detailed reasons for this. Marshall Cline’s C++ FAQ is invaluable for this.
  • C++ has a lot of features and flexibility and power, which is a good thing, but it doesn’t often make the garden-path choices the best for new users. This means, if you aren’t careful, your code will be horrible. It took me a good 18 months to figure this out and realize how crappy my code was and why I was getting bad code reviews. Learning to write an interface in C++ (hint: lookup what an abstract-base-class is) is crucial to making great code. Don’t be afraid to replicate good concepts and programming constructs you learned in C# land back into C++ land, when you are able.
  • Do learn about template-based programming. Learn what its strengths and weaknesses are, and how it differs from C# generics.

1

This is likely to get closed due to open-ended-ness, but hopefully this tip is important enough and un-controversial enough to help:

Be aware of ownership.

In C# (and other languages with automatic memory management), what object owns a variable can be a bit fuzzy. Does the event own the handler, or does the “catcher” of the event? In C#, it doesn’t really matter. In C++, your program will die a horrible, horrible (and often subtle) death if you don’t know who owns that handler.

This is the key difference in how you need to design programs, and will manifest itself in subtle ways if you’re not very careful with it. Learning to design around who owns what is the most important transition you’ll need to make, so focus on it early.

I think that you need to be a little careful with the language that you are using to describe C++ (low level language), and also with some of the technical description (machine code) as it reads as inaccurate.

Then you need to work out why you really want to learn a new language. Many companies are using C/C++ and many are using Java and many are using Perl and Python and Scala and … (some are even using Fortran). Maybe you have a specific company, sector or project in mind? If it is purely for employment reasons I’d caution against it unless you have a way of getting provable experience (I never managed to use my spare time projects as experience in an interview). Pick something that you are interested in, maybe it won’t be OO at all; you’ll be better at it in the long term through being genuinely interested. Then code in public and see how it goes, asking questions as you go, if it is C++ it’s going to take a little while especially if you want to get into memory management!

0

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật