Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. I like C more than I thought I would

I like C more than I thought I would

Scheduled Pinned Locked Moved The Lounge
c++wpfiot
50 Posts 20 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    I've always been a C++ nerd. I came at C++ self taught, but I came at it fresh, without "graduating" from writing C code. I've never regarded C++ as OOP, but rather GP oriented, although in truth it's a chameleon, and can do pretty much anything. However, I make heavy use of template based programming. So I didn't think I'd enjoy C. I figured I'd miss templates. I still do. There is some real ugly in terms of things you have to do with C that are elegant in C++. That being said, I don't miss them as much as I thought I would. Also, using the preprocessor freely is kind of liberating. In C++ I use it only as a last resort. In C it's more first class for me. Anyway, I like C. I do wish it had templates! And it's kind of verbose, which is hard on the fingers (everything has a handle) but also it wasn't a huge transition for me, since I do a lot of IoT coding I don't use things like exceptions, nor do I make heavy use of the STL, so C wasn't so bad. :)

    To err is human. Fortune favors the monsters.

    R C Mike HankeyM L M 14 Replies Last reply
    0
    • H honey the codewitch

      I've always been a C++ nerd. I came at C++ self taught, but I came at it fresh, without "graduating" from writing C code. I've never regarded C++ as OOP, but rather GP oriented, although in truth it's a chameleon, and can do pretty much anything. However, I make heavy use of template based programming. So I didn't think I'd enjoy C. I figured I'd miss templates. I still do. There is some real ugly in terms of things you have to do with C that are elegant in C++. That being said, I don't miss them as much as I thought I would. Also, using the preprocessor freely is kind of liberating. In C++ I use it only as a last resort. In C it's more first class for me. Anyway, I like C. I do wish it had templates! And it's kind of verbose, which is hard on the fingers (everything has a handle) but also it wasn't a huge transition for me, since I do a lot of IoT coding I don't use things like exceptions, nor do I make heavy use of the STL, so C wasn't so bad. :)

      To err is human. Fortune favors the monsters.

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      C is still the language for embedded - and I like it a lot. As you pointed out, lots of things that were improved with C++ are not necessary in the embedded world, which makes C plain sufficient for the job.

      Do not escape reality : improve reality !

      Greg UtasG 1 Reply Last reply
      0
      • H honey the codewitch

        I've always been a C++ nerd. I came at C++ self taught, but I came at it fresh, without "graduating" from writing C code. I've never regarded C++ as OOP, but rather GP oriented, although in truth it's a chameleon, and can do pretty much anything. However, I make heavy use of template based programming. So I didn't think I'd enjoy C. I figured I'd miss templates. I still do. There is some real ugly in terms of things you have to do with C that are elegant in C++. That being said, I don't miss them as much as I thought I would. Also, using the preprocessor freely is kind of liberating. In C++ I use it only as a last resort. In C it's more first class for me. Anyway, I like C. I do wish it had templates! And it's kind of verbose, which is hard on the fingers (everything has a handle) but also it wasn't a huge transition for me, since I do a lot of IoT coding I don't use things like exceptions, nor do I make heavy use of the STL, so C wasn't so bad. :)

        To err is human. Fortune favors the monsters.

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        On the opposite, forced to work with C, I really miss C++.

        "In testa che avete, Signor di Ceprano?" -- Rigoletto

        1 Reply Last reply
        0
        • R Rage

          C is still the language for embedded - and I like it a lot. As you pointed out, lots of things that were improved with C++ are not necessary in the embedded world, which makes C plain sufficient for the job.

          Do not escape reality : improve reality !

          Greg UtasG Offline
          Greg UtasG Offline
          Greg Utas
          wrote on last edited by
          #4

          I'd guess that the mantra "C is for embedded" is mostly because of legacy systems. There was also Embedded C++, which removed templates, exceptions, and RTTI. Memory is now so cheap that C is only justified in small systems. I wouldn't sign onto a C project unless the team was small and disciplined. The risk of dealing with hacked-together code is simply too great. "Embedded" is a broad spectrum. At the toaster end, C is fine, but it quickly becomes unjustified as one moves away from that.

          Robust Services Core | Software Techniques for Lemmings | Articles
          The fox knows many things, but the hedgehog knows one big thing.

          <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
          <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

          H D U 3 Replies Last reply
          0
          • H honey the codewitch

            I've always been a C++ nerd. I came at C++ self taught, but I came at it fresh, without "graduating" from writing C code. I've never regarded C++ as OOP, but rather GP oriented, although in truth it's a chameleon, and can do pretty much anything. However, I make heavy use of template based programming. So I didn't think I'd enjoy C. I figured I'd miss templates. I still do. There is some real ugly in terms of things you have to do with C that are elegant in C++. That being said, I don't miss them as much as I thought I would. Also, using the preprocessor freely is kind of liberating. In C++ I use it only as a last resort. In C it's more first class for me. Anyway, I like C. I do wish it had templates! And it's kind of verbose, which is hard on the fingers (everything has a handle) but also it wasn't a huge transition for me, since I do a lot of IoT coding I don't use things like exceptions, nor do I make heavy use of the STL, so C wasn't so bad. :)

            To err is human. Fortune favors the monsters.

            Mike HankeyM Offline
            Mike HankeyM Offline
            Mike Hankey
            wrote on last edited by
            #5

            I graduated up through the ranks; C, then C++ the C#. I found going from C to C++ like going from B&W TV to Color.

            PartsBin an Electronics Part Organizer is finally available for download. JaxCoder.com

            1 Reply Last reply
            0
            • H honey the codewitch

              I've always been a C++ nerd. I came at C++ self taught, but I came at it fresh, without "graduating" from writing C code. I've never regarded C++ as OOP, but rather GP oriented, although in truth it's a chameleon, and can do pretty much anything. However, I make heavy use of template based programming. So I didn't think I'd enjoy C. I figured I'd miss templates. I still do. There is some real ugly in terms of things you have to do with C that are elegant in C++. That being said, I don't miss them as much as I thought I would. Also, using the preprocessor freely is kind of liberating. In C++ I use it only as a last resort. In C it's more first class for me. Anyway, I like C. I do wish it had templates! And it's kind of verbose, which is hard on the fingers (everything has a handle) but also it wasn't a huge transition for me, since I do a lot of IoT coding I don't use things like exceptions, nor do I make heavy use of the STL, so C wasn't so bad. :)

              To err is human. Fortune favors the monsters.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Years ago I was asked to write an application to capture information from a mainframe to PC. It had to be written in 8086 Assembler or C as the only available options. So I borrowed a copy of K&R for the weekend and read it through a few times. I started the project the following week and got it working within an acceptable timeframe. I have had a love for C ever since, even though I tend to use C++ and C# for most work these days. And I do like Python despite its weirdness.

              1 Reply Last reply
              0
              • H honey the codewitch

                I've always been a C++ nerd. I came at C++ self taught, but I came at it fresh, without "graduating" from writing C code. I've never regarded C++ as OOP, but rather GP oriented, although in truth it's a chameleon, and can do pretty much anything. However, I make heavy use of template based programming. So I didn't think I'd enjoy C. I figured I'd miss templates. I still do. There is some real ugly in terms of things you have to do with C that are elegant in C++. That being said, I don't miss them as much as I thought I would. Also, using the preprocessor freely is kind of liberating. In C++ I use it only as a last resort. In C it's more first class for me. Anyway, I like C. I do wish it had templates! And it's kind of verbose, which is hard on the fingers (everything has a handle) but also it wasn't a huge transition for me, since I do a lot of IoT coding I don't use things like exceptions, nor do I make heavy use of the STL, so C wasn't so bad. :)

                To err is human. Fortune favors the monsters.

                M Offline
                M Offline
                megaadam
                wrote on last edited by
                #7

                Three things about C++ that I love more than template: Overloading, increased type-safety, std::,

                "If we don't change direction, we'll end up where we're going"

                H 1 Reply Last reply
                0
                • M megaadam

                  Three things about C++ that I love more than template: Overloading, increased type-safety, std::,

                  "If we don't change direction, we'll end up where we're going"

                  H Offline
                  H Offline
                  honey the codewitch
                  wrote on last edited by
                  #8

                  I do like overloading and increased type safety, but those are things you can find in other languages. And sure C# has generics but it's just not the same. I can make the C++ compiler dance the tango in a way I just can't with any other language, and it's not me - it's the compiler. Metaprogramming, for example. There's nothing else that really compares to it, at least not in common use. So that's why I miss them, and why they stand out to me. You can't do it in other languages. It sets C++ apart.

                  To err is human. Fortune favors the monsters.

                  M U 2 Replies Last reply
                  0
                  • H honey the codewitch

                    I do like overloading and increased type safety, but those are things you can find in other languages. And sure C# has generics but it's just not the same. I can make the C++ compiler dance the tango in a way I just can't with any other language, and it's not me - it's the compiler. Metaprogramming, for example. There's nothing else that really compares to it, at least not in common use. So that's why I miss them, and why they stand out to me. You can't do it in other languages. It sets C++ apart.

                    To err is human. Fortune favors the monsters.

                    M Offline
                    M Offline
                    megaadam
                    wrote on last edited by
                    #9

                    I thought we were comparing C++ vs. C which is why I mentioned those things. I never had tasks where those wilder template things came into play. However, I've many times seen code, where people out of love for templates, have created totally abhorrable contraptions. I've seen pretty nifty uses as well :cool: If you are into metaprogramming, Haskell comes to my mind as a jewel, but I might be just wronk.

                    "If we don't change direction, we'll end up where we're going"

                    H 1 Reply Last reply
                    0
                    • M megaadam

                      I thought we were comparing C++ vs. C which is why I mentioned those things. I never had tasks where those wilder template things came into play. However, I've many times seen code, where people out of love for templates, have created totally abhorrable contraptions. I've seen pretty nifty uses as well :cool: If you are into metaprogramming, Haskell comes to my mind as a jewel, but I might be just wronk.

                      "If we don't change direction, we'll end up where we're going"

                      H Offline
                      H Offline
                      honey the codewitch
                      wrote on last edited by
                      #10

                      Yeah Haskell doesn't run everywhere or let me get close to the metal. There's one easy instance I can think of for templates. In IoT, when you wire up an LCD display, you need to tell your display library/driver what pins its using (and if the driver supports more than one type, what kind of display it is) With a C app, you would have to set a bunch of defines, which can be done on the command line but is prohibitive when it comes to like 10 of them, leading a lot of people to create a "configuration" header that needs to be modified for one's project. Worse, because of that, it only supports one display type at a time. Templates allow for plugging in compile time constants all on a single line if desired, obviating the need for 10 #defines. More importantly templates allow for statics that are local to the template instantiation allowing you to create static variables that are different for different pin assignments. This then allows you to run multiple displays.

                      To err is human. Fortune favors the monsters.

                      pkfoxP 1 Reply Last reply
                      0
                      • H honey the codewitch

                        Yeah Haskell doesn't run everywhere or let me get close to the metal. There's one easy instance I can think of for templates. In IoT, when you wire up an LCD display, you need to tell your display library/driver what pins its using (and if the driver supports more than one type, what kind of display it is) With a C app, you would have to set a bunch of defines, which can be done on the command line but is prohibitive when it comes to like 10 of them, leading a lot of people to create a "configuration" header that needs to be modified for one's project. Worse, because of that, it only supports one display type at a time. Templates allow for plugging in compile time constants all on a single line if desired, obviating the need for 10 #defines. More importantly templates allow for statics that are local to the template instantiation allowing you to create static variables that are different for different pin assignments. This then allows you to run multiple displays.

                        To err is human. Fortune favors the monsters.

                        pkfoxP Offline
                        pkfoxP Offline
                        pkfox
                        wrote on last edited by
                        #11

                        I think you are a very clever guy

                        Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP

                        H 1 Reply Last reply
                        0
                        • pkfoxP pkfox

                          I think you are a very clever guy

                          Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #12

                          I mean, not really. The thing is, I ran face first into this very thing. It was only after that point at which it occurred to me that I could use templates to create copies of static variables per template-arguments/pin-assignments. Enter use #342 of templates, the swiss army knife of C++ development.

                          To err is human. Fortune favors the monsters.

                          1 Reply Last reply
                          0
                          • Greg UtasG Greg Utas

                            I'd guess that the mantra "C is for embedded" is mostly because of legacy systems. There was also Embedded C++, which removed templates, exceptions, and RTTI. Memory is now so cheap that C is only justified in small systems. I wouldn't sign onto a C project unless the team was small and disciplined. The risk of dealing with hacked-together code is simply too great. "Embedded" is a broad spectrum. At the toaster end, C is fine, but it quickly becomes unjustified as one moves away from that.

                            Robust Services Core | Software Techniques for Lemmings | Articles
                            The fox knows many things, but the hedgehog knows one big thing.

                            H Offline
                            H Offline
                            honey the codewitch
                            wrote on last edited by
                            #13

                            I'd argue that C++ is valid anywhere C is. It's just - you have to know what you're doing to get it to generate the equivalent machine code you would with C. For example Anywhere in C you take a handle of any sort, that handle becomes the this pointer of a class's instance methods. Inline constructors**, and don't initialize things unless they need to be, etc. Pretty soon you have a C++ rendition of your C code. Same machine code. ** don't actually use the inline keyword, because the compiler doesn't care about it except for linking purposes. I just really mean avoid heavy constructors.

                            To err is human. Fortune favors the monsters.

                            Greg UtasG 1 Reply Last reply
                            0
                            • H honey the codewitch

                              I'd argue that C++ is valid anywhere C is. It's just - you have to know what you're doing to get it to generate the equivalent machine code you would with C. For example Anywhere in C you take a handle of any sort, that handle becomes the this pointer of a class's instance methods. Inline constructors**, and don't initialize things unless they need to be, etc. Pretty soon you have a C++ rendition of your C code. Same machine code. ** don't actually use the inline keyword, because the compiler doesn't care about it except for linking purposes. I just really mean avoid heavy constructors.

                              To err is human. Fortune favors the monsters.

                              Greg UtasG Offline
                              Greg UtasG Offline
                              Greg Utas
                              wrote on last edited by
                              #14

                              I thought the major concern with C++ rather than C was more memory for C++, not more CPU time. That, at least, was what Embedded C++ addressed. C++ allows almost all of C, so it's just a question of when you need C++ things.

                              Robust Services Core | Software Techniques for Lemmings | Articles
                              The fox knows many things, but the hedgehog knows one big thing.

                              <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                              <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                              H 1 Reply Last reply
                              0
                              • Greg UtasG Greg Utas

                                I thought the major concern with C++ rather than C was more memory for C++, not more CPU time. That, at least, was what Embedded C++ addressed. C++ allows almost all of C, so it's just a question of when you need C++ things.

                                Robust Services Core | Software Techniques for Lemmings | Articles
                                The fox knows many things, but the hedgehog knows one big thing.

                                H Offline
                                H Offline
                                honey the codewitch
                                wrote on last edited by
                                #15

                                I think that's only true if you're using the STL. Exceptions also cause hidden overhead, but those things are optional.

                                To err is human. Fortune favors the monsters.

                                1 Reply Last reply
                                0
                                • H honey the codewitch

                                  I've always been a C++ nerd. I came at C++ self taught, but I came at it fresh, without "graduating" from writing C code. I've never regarded C++ as OOP, but rather GP oriented, although in truth it's a chameleon, and can do pretty much anything. However, I make heavy use of template based programming. So I didn't think I'd enjoy C. I figured I'd miss templates. I still do. There is some real ugly in terms of things you have to do with C that are elegant in C++. That being said, I don't miss them as much as I thought I would. Also, using the preprocessor freely is kind of liberating. In C++ I use it only as a last resort. In C it's more first class for me. Anyway, I like C. I do wish it had templates! And it's kind of verbose, which is hard on the fingers (everything has a handle) but also it wasn't a huge transition for me, since I do a lot of IoT coding I don't use things like exceptions, nor do I make heavy use of the STL, so C wasn't so bad. :)

                                  To err is human. Fortune favors the monsters.

                                  D Offline
                                  D Offline
                                  David ONeil
                                  wrote on last edited by
                                  #16

                                  First time I saw C I immediately liked it. The syntax made sense at a gut level. I had Fortran and Basic under my belt at that time, so not a lot of exposure to other languages, but it was non-case locked, and arbitrary length variable names were a godsend. But I still dislike two items about it. First is the typedefs that surround all structs in the MS headers. I still don't understand why that was done, although I never delved into it very much. The second is that everything has to be casted on both sides of the '='. That got old quick. I still like the language, though. C++ is far betterer! And when I finally understood true OOP in C++ I was in heaven!

                                  Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                                  J D U 3 Replies Last reply
                                  0
                                  • D David ONeil

                                    First time I saw C I immediately liked it. The syntax made sense at a gut level. I had Fortran and Basic under my belt at that time, so not a lot of exposure to other languages, but it was non-case locked, and arbitrary length variable names were a godsend. But I still dislike two items about it. First is the typedefs that surround all structs in the MS headers. I still don't understand why that was done, although I never delved into it very much. The second is that everything has to be casted on both sides of the '='. That got old quick. I still like the language, though. C++ is far betterer! And when I finally understood true OOP in C++ I was in heaven!

                                    Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                                    J Offline
                                    J Offline
                                    jmaida
                                    wrote on last edited by
                                    #17

                                    My path was PL/I, Fortran, C. Never did get into C++. The C++ coding I saw from other programmers was inscrutable. In fact, the problem was they all did their own thing when creating objects. I just didn't want to learn to crawl around in their individual sand boxes of objects and classes. True one can get crazy with C but it's twice as crazy in C++.

                                    "A little time, a little trouble, your better day" Badfinger

                                    D 1 Reply Last reply
                                    0
                                    • J jmaida

                                      My path was PL/I, Fortran, C. Never did get into C++. The C++ coding I saw from other programmers was inscrutable. In fact, the problem was they all did their own thing when creating objects. I just didn't want to learn to crawl around in their individual sand boxes of objects and classes. True one can get crazy with C but it's twice as crazy in C++.

                                      "A little time, a little trouble, your better day" Badfinger

                                      D Offline
                                      D Offline
                                      David ONeil
                                      wrote on last edited by
                                      #18

                                      Check out the C++ Object Oriented Programming tutorial in my sig. It may be clear enough to understand some of the additional power that C++ gives you with respect to C (without taking templates into account). If you have suggestions for improvement, holler!

                                      Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                                      J 1 Reply Last reply
                                      0
                                      • D David ONeil

                                        Check out the C++ Object Oriented Programming tutorial in my sig. It may be clear enough to understand some of the additional power that C++ gives you with respect to C (without taking templates into account). If you have suggestions for improvement, holler!

                                        Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                                        J Offline
                                        J Offline
                                        jmaida
                                        wrote on last edited by
                                        #19

                                        Thank you, so much for your response, David. My critique was probably more about the programmers use of C++ than the language. I did a quick look at your article and found it well organized. Good Job. I made a PDF copy of your article to read offline. BTW your complaints about C are also some of mine.

                                        "A little time, a little trouble, your better day" Badfinger

                                        D 1 Reply Last reply
                                        0
                                        • J jmaida

                                          Thank you, so much for your response, David. My critique was probably more about the programmers use of C++ than the language. I did a quick look at your article and found it well organized. Good Job. I made a PDF copy of your article to read offline. BTW your complaints about C are also some of mine.

                                          "A little time, a little trouble, your better day" Badfinger

                                          D Offline
                                          D Offline
                                          David ONeil
                                          wrote on last edited by
                                          #20

                                          I hope it shines a light on some new stuff for you! Best wishes!

                                          Our Forgotten Astronomy | Object Oriented Programming with C++ | Wordle solver

                                          J 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups