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. Daily Olds?

Daily Olds?

Scheduled Pinned Locked Moved The Lounge
c++htmlcomquestionannouncement
23 Posts 7 Posters 0 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.
  • S Offline
    S Offline
    Stefan_Lang
    wrote on last edited by
    #1

    The most recent CP 'Daily News' posted a link to an article labelled 'Improving and Fixing C Code'. I clicked on it because I was really wondering who thinks any new programmers still bother with C and not C++, and what kind of tips he thinks are worth assembling that haven't been published hundreds of times before over the past 30 years. What I found was a horribly outdated article that, while correctly pointing out some bad practices didn't seem to have qualms with quite a few other bad practices in the provided examples, such as multiple return statements. I started to grow suspicious very fast when the article implied that size_t might be of smaller size than unsigned long on some architectures. And my suspicions were confirmed with a statement close to the end, where the article read: ...the size of a C-language integer; that is 2 bytes on most PC architectures and 4 bytes elsewhere :wtf: This article is at least 15 years old! At the end of the page it says last time the document had been updated was in 2003, but the original article is obviously much older. Now, who at CP thinks this is actually worth providing a link for in the 'Daily News'? :confused:

    L C B P 4 Replies Last reply
    0
    • S Stefan_Lang

      The most recent CP 'Daily News' posted a link to an article labelled 'Improving and Fixing C Code'. I clicked on it because I was really wondering who thinks any new programmers still bother with C and not C++, and what kind of tips he thinks are worth assembling that haven't been published hundreds of times before over the past 30 years. What I found was a horribly outdated article that, while correctly pointing out some bad practices didn't seem to have qualms with quite a few other bad practices in the provided examples, such as multiple return statements. I started to grow suspicious very fast when the article implied that size_t might be of smaller size than unsigned long on some architectures. And my suspicions were confirmed with a statement close to the end, where the article read: ...the size of a C-language integer; that is 2 bytes on most PC architectures and 4 bytes elsewhere :wtf: This article is at least 15 years old! At the end of the page it says last time the document had been updated was in 2003, but the original article is obviously much older. Now, who at CP thinks this is actually worth providing a link for in the 'Daily News'? :confused:

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

      C is the most common language for embedded systems because of the run time overheads of C++.

      Join the cool kids - Come fold with us[^]

      S 1 Reply Last reply
      0
      • L Lost User

        C is the most common language for embedded systems because of the run time overheads of C++.

        Join the cool kids - Come fold with us[^]

        S Offline
        S Offline
        Stefan_Lang
        wrote on last edited by
        #3

        While this was not the point of my post, is there really that much overhead? It's all a question of choosing the right OS, the right compiler and the right libraries. You can have very small and useful C++ executables. In fact, many OSs are full of them. I've been to a C++ Embedded system design course in ~2000, and many of the attendees were working on systems in the 100KB range. In C++. Considering that at that time it was difficult to get memory units smaller than that (depending on types of memory); I can hardly believe anyone's still working with that little memory.

        R L 2 Replies Last reply
        0
        • S Stefan_Lang

          While this was not the point of my post, is there really that much overhead? It's all a question of choosing the right OS, the right compiler and the right libraries. You can have very small and useful C++ executables. In fact, many OSs are full of them. I've been to a C++ Embedded system design course in ~2000, and many of the attendees were working on systems in the 100KB range. In C++. Considering that at that time it was difficult to get memory units smaller than that (depending on types of memory); I can hardly believe anyone's still working with that little memory.

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

          Stefan63 wrote:

          I can hardly believe anyone's still working with that little memory

          80% of the embedded electronics in a car runs with <64K.

          1 Reply Last reply
          0
          • S Stefan_Lang

            The most recent CP 'Daily News' posted a link to an article labelled 'Improving and Fixing C Code'. I clicked on it because I was really wondering who thinks any new programmers still bother with C and not C++, and what kind of tips he thinks are worth assembling that haven't been published hundreds of times before over the past 30 years. What I found was a horribly outdated article that, while correctly pointing out some bad practices didn't seem to have qualms with quite a few other bad practices in the provided examples, such as multiple return statements. I started to grow suspicious very fast when the article implied that size_t might be of smaller size than unsigned long on some architectures. And my suspicions were confirmed with a statement close to the end, where the article read: ...the size of a C-language integer; that is 2 bytes on most PC architectures and 4 bytes elsewhere :wtf: This article is at least 15 years old! At the end of the page it says last time the document had been updated was in 2003, but the original article is obviously much older. Now, who at CP thinks this is actually worth providing a link for in the 'Daily News'? :confused:

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #5

            I will yell sternly at Mr Insider and tell him to only include hip and trendy reading from now on. Or maybe I'll ask him to include something on FORTRAN.

            cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

            L P S 4 Replies Last reply
            0
            • S Stefan_Lang

              The most recent CP 'Daily News' posted a link to an article labelled 'Improving and Fixing C Code'. I clicked on it because I was really wondering who thinks any new programmers still bother with C and not C++, and what kind of tips he thinks are worth assembling that haven't been published hundreds of times before over the past 30 years. What I found was a horribly outdated article that, while correctly pointing out some bad practices didn't seem to have qualms with quite a few other bad practices in the provided examples, such as multiple return statements. I started to grow suspicious very fast when the article implied that size_t might be of smaller size than unsigned long on some architectures. And my suspicions were confirmed with a statement close to the end, where the article read: ...the size of a C-language integer; that is 2 bytes on most PC architectures and 4 bytes elsewhere :wtf: This article is at least 15 years old! At the end of the page it says last time the document had been updated was in 2003, but the original article is obviously much older. Now, who at CP thinks this is actually worth providing a link for in the 'Daily News'? :confused:

              B Offline
              B Offline
              Brady Kelly
              wrote on last edited by
              #6

              Stefan63 wrote:

              quite a few other bad practices in the provided examples, such as multiple return statements.

              Are you trying to start a flame war here? Wanna take this outside, huh? :) I too was taught, and religiously believed, that multiple return statements were bad. I have come to realise that deeply nested and unnecessarily complex if blocks are more detrimental to readability and defect rates in code than multiple returns. Of course practice has a justification and place to be used, but I prefer clear and early returns to nested conditional blocks. However, my code is normally quite explicit about what it is doing. Of course in untidy and unstructured code, multiple returns are going to bring confusion. BTW, I don't code C, but C#, but I was first indoctrinated against multiple returns in Pascal and C++.

              S 1 Reply Last reply
              0
              • C Chris Maunder

                I will yell sternly at Mr Insider and tell him to only include hip and trendy reading from now on. Or maybe I'll ask him to include something on FORTRAN.

                cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

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

                Chris Maunder wrote:

                Or maybe I'll ask him to include something on FORTRAN.

                Will you trawl through you backups and publish some of your FORTRAN from back in your mud pie making days? When's the piss up?

                Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

                C 1 Reply Last reply
                0
                • L Lost User

                  Chris Maunder wrote:

                  Or maybe I'll ask him to include something on FORTRAN.

                  Will you trawl through you backups and publish some of your FORTRAN from back in your mud pie making days? When's the piss up?

                  Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

                  C Offline
                  C Offline
                  Chris Maunder
                  wrote on last edited by
                  #8

                  Hey, that was serious, scientific, digital modelling of mud-pies, thank you very much. A beverage or two? Maybe Jan.

                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                  L 1 Reply Last reply
                  0
                  • C Chris Maunder

                    Hey, that was serious, scientific, digital modelling of mud-pies, thank you very much. A beverage or two? Maybe Jan.

                    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

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

                    Chris Maunder wrote:

                    A beverage or two? Maybe Jan.

                    That's what I said 10 (I write binary and read decimal). First week would be best as I have the 24-12-2010 till 10-01-2011 off. I'm thinking Lord Nelson, since if your only having 2 at least they'll be pints, of good stuff.

                    Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

                    C 1 Reply Last reply
                    0
                    • L Lost User

                      Chris Maunder wrote:

                      A beverage or two? Maybe Jan.

                      That's what I said 10 (I write binary and read decimal). First week would be best as I have the 24-12-2010 till 10-01-2011 off. I'm thinking Lord Nelson, since if your only having 2 at least they'll be pints, of good stuff.

                      Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004

                      C Offline
                      C Offline
                      Chris Maunder
                      wrote on last edited by
                      #10

                      The first week's not an option unfortunately. Family business down in rainy Melbourne. Rainy Sydney will have to wait until at least mid Jan.

                      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                      1 Reply Last reply
                      0
                      • C Chris Maunder

                        I will yell sternly at Mr Insider and tell him to only include hip and trendy reading from now on. Or maybe I'll ask him to include something on FORTRAN.

                        cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                        P Offline
                        P Offline
                        peterchen
                        wrote on last edited by
                        #11

                        Yes, because if it doesn't come with an XML cloud, it's not worth reading. :rolleyes: Generally, using only trendy and hip reading is a good approach. This can be improved further by keeping out all the the practical, applicable things. Most of us read it only to slack off anyway.

                        Agh! Reality! My Archnemesis![^]
                        | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                        C 1 Reply Last reply
                        0
                        • S Stefan_Lang

                          The most recent CP 'Daily News' posted a link to an article labelled 'Improving and Fixing C Code'. I clicked on it because I was really wondering who thinks any new programmers still bother with C and not C++, and what kind of tips he thinks are worth assembling that haven't been published hundreds of times before over the past 30 years. What I found was a horribly outdated article that, while correctly pointing out some bad practices didn't seem to have qualms with quite a few other bad practices in the provided examples, such as multiple return statements. I started to grow suspicious very fast when the article implied that size_t might be of smaller size than unsigned long on some architectures. And my suspicions were confirmed with a statement close to the end, where the article read: ...the size of a C-language integer; that is 2 bytes on most PC architectures and 4 bytes elsewhere :wtf: This article is at least 15 years old! At the end of the page it says last time the document had been updated was in 2003, but the original article is obviously much older. Now, who at CP thinks this is actually worth providing a link for in the 'Daily News'? :confused:

                          P Offline
                          P Offline
                          peterchen
                          wrote on last edited by
                          #12

                          Fact: size_t might be smaller than unsigned long.

                          Agh! Reality! My Archnemesis![^]
                          | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                          1 Reply Last reply
                          0
                          • S Stefan_Lang

                            While this was not the point of my post, is there really that much overhead? It's all a question of choosing the right OS, the right compiler and the right libraries. You can have very small and useful C++ executables. In fact, many OSs are full of them. I've been to a C++ Embedded system design course in ~2000, and many of the attendees were working on systems in the 100KB range. In C++. Considering that at that time it was difficult to get memory units smaller than that (depending on types of memory); I can hardly believe anyone's still working with that little memory.

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

                            Yes - on small systems there is the memory overhead and larger systems (we produce SoCs for STBs and TVs amongst other things) the overhead with constructors which afect driver timings as well as the memory costs. Add the overhead in usign collections etc. and controlling performance becomes almost impossible. A TV can have 20-50MB of code, sometimes more and the cost of fitting a 32MB flash device instead of 16MB in a STB (Set Top Box) can determine if there is enough margin to make it worth selling a product.

                            Join the cool kids - Come fold with us[^]

                            S 1 Reply Last reply
                            0
                            • C Chris Maunder

                              I will yell sternly at Mr Insider and tell him to only include hip and trendy reading from now on. Or maybe I'll ask him to include something on FORTRAN.

                              cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

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

                              Having written the request in Prolog.

                              Join the cool kids - Come fold with us[^]

                              1 Reply Last reply
                              0
                              • B Brady Kelly

                                Stefan63 wrote:

                                quite a few other bad practices in the provided examples, such as multiple return statements.

                                Are you trying to start a flame war here? Wanna take this outside, huh? :) I too was taught, and religiously believed, that multiple return statements were bad. I have come to realise that deeply nested and unnecessarily complex if blocks are more detrimental to readability and defect rates in code than multiple returns. Of course practice has a justification and place to be used, but I prefer clear and early returns to nested conditional blocks. However, my code is normally quite explicit about what it is doing. Of course in untidy and unstructured code, multiple returns are going to bring confusion. BTW, I don't code C, but C#, but I was first indoctrinated against multiple returns in Pascal and C++.

                                S Offline
                                S Offline
                                Stefan_Lang
                                wrote on last edited by
                                #15

                                My experience with other people's code is that in the vast majority of cases early returns are just lazy coding, and a way out of overlong functions that shouldn't have been that long in the first place. And I've seen quite a few places that didn't properly clean up the previously allocated resources. If you have 1 return, then you have 1 point to clean up. Not saying an early return can't be easy and clean and readable, but the examples I've seen mostly weren't like that at all. Maybe your experience is different.

                                1 Reply Last reply
                                0
                                • P peterchen

                                  Yes, because if it doesn't come with an XML cloud, it's not worth reading. :rolleyes: Generally, using only trendy and hip reading is a good approach. This can be improved further by keeping out all the the practical, applicable things. Most of us read it only to slack off anyway.

                                  Agh! Reality! My Archnemesis![^]
                                  | FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy

                                  C Offline
                                  C Offline
                                  Chris Maunder
                                  wrote on last edited by
                                  #16

                                  Right: more fluff, less brain tax. Got it.

                                  cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    Yes - on small systems there is the memory overhead and larger systems (we produce SoCs for STBs and TVs amongst other things) the overhead with constructors which afect driver timings as well as the memory costs. Add the overhead in usign collections etc. and controlling performance becomes almost impossible. A TV can have 20-50MB of code, sometimes more and the cost of fitting a 32MB flash device instead of 16MB in a STB (Set Top Box) can determine if there is enough margin to make it worth selling a product.

                                    Join the cool kids - Come fold with us[^]

                                    S Offline
                                    S Offline
                                    Stefan_Lang
                                    wrote on last edited by
                                    #17

                                    Interesting, I really didn't know that. Thanks for the info. Regarding the bigger systems, I know exactly what you mean, had been designing embedded systems with a considerably huge amount of 16MB flash, although only about a third of that was actually available for the app. Still, we did some pretty sophisticated programming (at least when considering this was an embedded system), including smart pointer mechanics, pool allocation, lots of inheritance and polymorphism, etc.. Each actuator and each sensor of the machine had it's counterpart in the software. The only thing we had to look out for is keep down the use of templates, which tend to blow up the binary. Now, I have no idea how much overhead all of this introduced for using C++ instead of C, but the high level of abstraction and object orientation based on physical parts of the machine allowed us to adapt our software to a new machine prototype within just one day! I don't think I've ever done a project that allowed this high degree of reuse. And that was only possible because OO mechanisms fit so well with software that is so closely linked with physical hardware.

                                    L 1 Reply Last reply
                                    0
                                    • C Chris Maunder

                                      I will yell sternly at Mr Insider and tell him to only include hip and trendy reading from now on. Or maybe I'll ask him to include something on FORTRAN.

                                      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                      S Offline
                                      S Offline
                                      Stefan_Lang
                                      wrote on last edited by
                                      #18

                                      Seriously, the web site was last updated more than 7 years ago, so it's hardly news. But maybe my expectations were wrong? Don't get me wrong. Even old articles have their merit, and just because they're old doesn't mean everyone is already aware of their existance. So I actually appreciate these links - I just find it odd to find something that old on a newsletter titled '*** News'. Have you considered changing the sub-headline from 'Developer News' to 'Developer Articles' or something else that doesn't imply a recent date?

                                      C T 2 Replies Last reply
                                      0
                                      • S Stefan_Lang

                                        Seriously, the web site was last updated more than 7 years ago, so it's hardly news. But maybe my expectations were wrong? Don't get me wrong. Even old articles have their merit, and just because they're old doesn't mean everyone is already aware of their existance. So I actually appreciate these links - I just find it odd to find something that old on a newsletter titled '*** News'. Have you considered changing the sub-headline from 'Developer News' to 'Developer Articles' or something else that doesn't imply a recent date?

                                        C Offline
                                        C Offline
                                        Chris Maunder
                                        wrote on last edited by
                                        #19

                                        Normally the news items are recent - very recent - but occasionally an oldie will be thrown in because it might generate some discussion, might be a blast from the past, or is just too good not for everyone not to know about it. I'll pass your feedback on, though. It's definitely valuable.

                                        cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                        1 Reply Last reply
                                        0
                                        • S Stefan_Lang

                                          Seriously, the web site was last updated more than 7 years ago, so it's hardly news. But maybe my expectations were wrong? Don't get me wrong. Even old articles have their merit, and just because they're old doesn't mean everyone is already aware of their existance. So I actually appreciate these links - I just find it odd to find something that old on a newsletter titled '*** News'. Have you considered changing the sub-headline from 'Developer News' to 'Developer Articles' or something else that doesn't imply a recent date?

                                          T Offline
                                          T Offline
                                          Terrence Dorsey
                                          wrote on last edited by
                                          #20

                                          A sharp-eyed reader would notice that very few of the items in the Daily Insider newsletter are particularly newsy. I've intentionally shied away from an approach of regurgitating the day's tech news in the newsletter. If that's what you want, go check TechMeme or Mashable or CNET... they do a way better job at it than I ever could. Do you really want to know who's got VC funding, or that Justin Bieber is trending on Twitter? Instead, my focus is on looking for items that will be of interest specifically to programmers, with slight bias toward programmers working on the Microsoft stack. (Though not exclusively, because I think y'all need to be well-rounded in your skills and environments.) Very little of this is news in any sense. If it's news because you don't know much about NoSQL, then it's equally possible someone else doesn't know much about C -- particularly if they started coding in the last decade. We're not all grizzled veterans of COBOL and TurboPacal. In fact, my real goal in all of this is to do at least one of the following: A.) Make you laugh 2.) Help you learn something new III.) Spark a conversation I think this ancient article on C did all three. The feedback *is* always appreciated. Really. I'd like to see more of it, because I really do listen to the good and the bad and make changes accordingly (usually... well, sometimes). But let's dispel the notion that the daily news is actually news in the traditional sense.

                                          S 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