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. Are there reasons for beginner programmers to learn C ?

Are there reasons for beginner programmers to learn C ?

Scheduled Pinned Locked Moved The Lounge
learningc++oopperformance
100 Posts 44 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.
  • M Maximilien

    Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:

    Watched code never compiles.

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

    The smaller the program memory you have to deal with the lower the level language you need to know. If you're working with a microprocessor with 8K memory you better be tight and right so you would need C unless speed is also a restriction then assembly. But if you're working with say 128K memory then the added flexibility of C++ might be an option. Right tool for the right job!

    VS2010/AVR Studio 5.0 ToDo Manager Extension

    1 Reply Last reply
    0
    • M Maximilien

      Shouldn't code be as machine/hardware independent as possible ? If you really want to go down on your knees and look under the hood, it is still possible with C++ and C, but that is not a beginner topic.

      Watched code never compiles.

      K Offline
      K Offline
      killabyte
      wrote on last edited by
      #23

      Maximilien wrote:

      Shouldn't code be as machine/hardware independent as possible ?

      Not if your writting a device driver.... I think if you build your knowledge up from HW level your are a much better software engineer (bias cos i started out as an embedded C guy)

      M 1 Reply Last reply
      0
      • J Joe Woodbury

        Absolutely not! Code should do the best it can to solve the problem (for your customer.) I'm having this very argument now over writing generic code that can be ported to Linux vs. sharing that code which you can, but tailoring the core to each platform. (The current version is more generic and simply doesn't scale well.) I'm also tired of using programs that suck on every platform, all in the name of being cross-platform.

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #24

        Language feature should make our lives easier to make portability as transparent as possible. Using standard C++ libraries (streams, collections, algorithms, memory management, ...) ), I can write portable code that runs on major OS without the need to think about it.

        Watched code never compiles.

        E J K 3 Replies Last reply
        0
        • K killabyte

          Maximilien wrote:

          Shouldn't code be as machine/hardware independent as possible ?

          Not if your writting a device driver.... I think if you build your knowledge up from HW level your are a much better software engineer (bias cos i started out as an embedded C guy)

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #25

          Well, device driver is not a beginner topic; and is one exceptions, but I would be surprised if proper C++ features were used it could make better and safer code.

          Watched code never compiles.

          1 Reply Last reply
          0
          • L lewax00

            Python's a good starting language, the syntax is simple and it's easy to read, plus it enforces code indentation practices.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #26

            I've seen a little bit of Python (in MIT's video series), but not used it so I didn't feel I could recommend it.

            1 Reply Last reply
            0
            • K Kevin McFarlane

              _Josh_ wrote:

              Imagine a c++ programmer armed with a few smart pointer classes from boost and the stl and no understanding of the underlying issues each is designed to address.

              Nevertheless, Stroustrup recommends learning high-level procedural C++ and then learning the low-level stuff, i.e., the exact opposite of what you say.

              Kevin

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

              Well I didn't really suggest an order, just that knowledge of both is required to make the most of c++. If people want an easier language there are plenty out there.

              E 1 Reply Last reply
              0
              • J Joe Woodbury

                Yes, C is very good at teaching you HOW computers work. Think of C as super-assembly. (And if you learn assembly language first, C is a walk in the park.) I run across too much C++ code that would be much more stable if more C-type constructs were used. On the other hand, I've also dealt with too much C++ code that is nothing but C with classes and misses out on some truly great features of C++. I've also observed that C programmers who start thinking about encapsulation end up with many of the basics of C++. I remember when I very first learned C++ and realized that the this pointer is what I'd already been doing in a lot of my code, though having it built in was quite nice. Final point and a narrow observation; I've worked with several people whose first language was C#. Not one of them understood memory management. I've also found that they had a hard time moving "down" toward C or even C# code that had to be very hardware aware.

                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #28

                Joe Woodbury wrote:

                I've worked with several people whose first language was C#. Not one of them understood memory management.

                I am one of those people, and actually my first language is VB.NET. IDisposable[^] seems quite hard to implement correctly and even if you implement it there seem to be times when you simply cannot call it. Sometimes even Microsoft recommends not calling it if it gets to difficult[^]. There's also a great article on it right here on CP on the difficulties with IDisposable: IDisposable: What Your Mother Never Told You About Resource Deallocation[^]. In our company not calling IDisposable on a Crystal Reports Object caused quite some frustration... It led to customers not being able to print any more reports after 50 or something. Anyway, today a coworker had a problem. He had a BindingSource in WinForms and bound it to a list variable. After that he created a new list and assigned it to the variable. In his mind the variable and the BindingSource still pointed to the same memory. Unfortunately things don't quite work like that... Of course I wouldn't know how you guys fix that sort of stuff in C or C++. Anyway, having some clue as to what you're doing considering memory management is pretty handy at times, even in a high level language like C# or VB. But I think that's the problem, as a .NET programmer you're led to believe you don't need to know this stuff.

                It's an OO world.

                public class Naerling : Lazy<Person>{
                public void DoWork(){ throw new NotImplementedException(); }
                }

                A 1 Reply Last reply
                0
                • M Maximilien

                  Are there reasons for beginner programmers to be taught C instead of C++? I'm not even thinking about Object Oriented programming, but simple declarative programming. I'm reading a lot of questions on CodeProject and on StackOverflow where people ask about issues with C language features that are so prone to errors and defect that it makes me cringe. A lot of those issues could be handled by simple C++ features (memory management (new/delete, smart pointers), strings, collections, references, ... ) I know there are lot of legacy code out there and it should still be maintained, but old code "ways" should not be the emphasis of the education. :confused:

                  Watched code never compiles.

                  W Offline
                  W Offline
                  W Balboos GHB
                  wrote on last edited by
                  #29

                  It may produce a spiritual awaking. C was deliberately written to be unrestricted (to port the Unix O/S). It does what it's told to do, no questions asked. That means you have to pay attention to what you're doing. That is a good habit to learn. I'd even go so far as to suggest you dabble with the in-line assembler.

                  "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                  "As far as we know, our computer has never had an undetected error." - Weisert

                  "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                  C 1 Reply Last reply
                  0
                  • L Lost User

                    Well I didn't really suggest an order, just that knowledge of both is required to make the most of c++. If people want an easier language there are plenty out there.

                    E Offline
                    E Offline
                    Espen Harlinn
                    wrote on last edited by
                    #30

                    :thumbsup:

                    Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

                    1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      Not as a first language. Nor should an OOP-only language (VB, C#, etc.) be the first language. In my opinion BASIC and Pascal (and maybe Perl?) are still good first languages even though they won't apply very well to modern business. Professional developers still to be smacked with C.

                      E Offline
                      E Offline
                      Espen Harlinn
                      wrote on last edited by
                      #31

                      PIEBALDconsult wrote:

                      Not as a first language

                      How about assembly?

                      Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

                      P R 2 Replies Last reply
                      0
                      • M Maximilien

                        Language feature should make our lives easier to make portability as transparent as possible. Using standard C++ libraries (streams, collections, algorithms, memory management, ...) ), I can write portable code that runs on major OS without the need to think about it.

                        Watched code never compiles.

                        E Offline
                        E Offline
                        Espen Harlinn
                        wrote on last edited by
                        #32

                        Maximilien wrote:

                        I can write portable code that runs on major OS without the need to think about it

                        Lucky you ;)

                        Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

                        1 Reply Last reply
                        0
                        • J Joe Woodbury

                          Yes, C is very good at teaching you HOW computers work. Think of C as super-assembly. (And if you learn assembly language first, C is a walk in the park.) I run across too much C++ code that would be much more stable if more C-type constructs were used. On the other hand, I've also dealt with too much C++ code that is nothing but C with classes and misses out on some truly great features of C++. I've also observed that C programmers who start thinking about encapsulation end up with many of the basics of C++. I remember when I very first learned C++ and realized that the this pointer is what I'd already been doing in a lot of my code, though having it built in was quite nice. Final point and a narrow observation; I've worked with several people whose first language was C#. Not one of them understood memory management. I've also found that they had a hard time moving "down" toward C or even C# code that had to be very hardware aware.

                          E Offline
                          E Offline
                          Espen Harlinn
                          wrote on last edited by
                          #33

                          :thumbsup: And most c and c++ programmers usually become better java and c# programmers than those who have only developed in those languages.

                          Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

                          1 Reply Last reply
                          0
                          • L Lost User

                            Until you want to pass it to an api that takes LPTSTR

                            D Offline
                            D Offline
                            djdanlib 0
                            wrote on last edited by
                            #34

                            A cringe-worthy proposition! I'm quite pleased by the way the StringBuilder class works so nicely with interop.

                            1 Reply Last reply
                            0
                            • P PIEBALDconsult

                              Not as a first language. Nor should an OOP-only language (VB, C#, etc.) be the first language. In my opinion BASIC and Pascal (and maybe Perl?) are still good first languages even though they won't apply very well to modern business. Professional developers still to be smacked with C.

                              O Offline
                              O Offline
                              Oshtri Deka
                              wrote on last edited by
                              #35

                              I somewhat agree, but I would chose those languages only for lower level of education.If it's for college than I am for C all the way. What the heck, C should be in secondary schools as well.

                              P R 2 Replies Last reply
                              0
                              • Sander RosselS Sander Rossel

                                Joe Woodbury wrote:

                                I've worked with several people whose first language was C#. Not one of them understood memory management.

                                I am one of those people, and actually my first language is VB.NET. IDisposable[^] seems quite hard to implement correctly and even if you implement it there seem to be times when you simply cannot call it. Sometimes even Microsoft recommends not calling it if it gets to difficult[^]. There's also a great article on it right here on CP on the difficulties with IDisposable: IDisposable: What Your Mother Never Told You About Resource Deallocation[^]. In our company not calling IDisposable on a Crystal Reports Object caused quite some frustration... It led to customers not being able to print any more reports after 50 or something. Anyway, today a coworker had a problem. He had a BindingSource in WinForms and bound it to a list variable. After that he created a new list and assigned it to the variable. In his mind the variable and the BindingSource still pointed to the same memory. Unfortunately things don't quite work like that... Of course I wouldn't know how you guys fix that sort of stuff in C or C++. Anyway, having some clue as to what you're doing considering memory management is pretty handy at times, even in a high level language like C# or VB. But I think that's the problem, as a .NET programmer you're led to believe you don't need to know this stuff.

                                It's an OO world.

                                public class Naerling : Lazy<Person>{
                                public void DoWork(){ throw new NotImplementedException(); }
                                }

                                A Offline
                                A Offline
                                Andy Brummer
                                wrote on last edited by
                                #36

                                I'm always flabbergasted when I ask basic questions about using an object that implements IDisposable to developers with many years of C# experience and they are completely clueless, let alone the caveats about implementing it correctly. It's even rarer for developers to know about the using statement. I often wonder how their apps don't leak database connections all over the place. I worked with one system that completely threw me for a loop. Every object was created in a using block in a factory method and returned to the caller. Each object was auto generated with a sql connection as a property which was opened in the constructor. Calling dispose closed the connection so it could be returned to the "business logic" layer. :sigh: :doh:

                                Curvature of the Mind now with 3D

                                Sander RosselS 1 Reply Last reply
                                0
                                • K killabyte

                                  C is very important and a great way to learn exactly how a computer works, which is a double edged sword but if you push on through and gain a good understanding of C all other languages are a piece of cake.

                                  L Offline
                                  L Offline
                                  lewax00
                                  wrote on last edited by
                                  #37

                                  killabyte wrote:

                                  C is very important and a great way to learn exactly how a computer works

                                  That's debatable. I'm taking a class that brings you from NAND gates and D Flip Flops all the way up to the operating system (so far I've built a computer (CPU + RAM) from only NAND and DFFs and an assembler), and I don't see much relation to C. Admittedly it's a better model than a higher level language like C# or Java, but it's still pretty far abstracted.

                                  K 1 Reply Last reply
                                  0
                                  • A Andy Brummer

                                    I'm always flabbergasted when I ask basic questions about using an object that implements IDisposable to developers with many years of C# experience and they are completely clueless, let alone the caveats about implementing it correctly. It's even rarer for developers to know about the using statement. I often wonder how their apps don't leak database connections all over the place. I worked with one system that completely threw me for a loop. Every object was created in a using block in a factory method and returned to the caller. Each object was auto generated with a sql connection as a property which was opened in the constructor. Calling dispose closed the connection so it could be returned to the "business logic" layer. :sigh: :doh:

                                    Curvature of the Mind now with 3D

                                    Sander RosselS Offline
                                    Sander RosselS Offline
                                    Sander Rossel
                                    wrote on last edited by
                                    #38

                                    What you are describing there has nothing to do with having C# as a first language... Actually it has nothing to do with programming! It sounds more like these people were baking an apple pie and somehow ended up in an office with a computer where someone mistook them for programmers.

                                    Andy Brummer wrote:

                                    Every object was created in a using block in a factory method and returned to the caller.

                                    I can't imagine how that would've been... Employee: "There's a bug in Visual Studio that throws ObjectDisposedExceptions at random!" Boss: "We better turn off the 'Break when a common language runtime exception is thrown'-option then!" Third person: "Perhaps there really IS something wrong in your software?" Employee: "Hell no! I'm even using the 'using' keyword with some Objects that can, for no appearent reason, be used with it. Microsoft recommends it!" Boss: "Good job, now we should send Microsoft a report on that Visual Studio bug..." Third person: "By the way, I'm out of apples, anyone here has some?" Employee: "Sure, if I can have an ounce of flour." ... :laugh:

                                    It's an OO world.

                                    public class Naerling : Lazy<Person>{
                                    public void DoWork(){ throw new NotImplementedException(); }
                                    }

                                    1 Reply Last reply
                                    0
                                    • M Maximilien

                                      Language feature should make our lives easier to make portability as transparent as possible. Using standard C++ libraries (streams, collections, algorithms, memory management, ...) ), I can write portable code that runs on major OS without the need to think about it.

                                      Watched code never compiles.

                                      J Offline
                                      J Offline
                                      Joe Woodbury
                                      wrote on last edited by
                                      #39

                                      Maximilien wrote:

                                      I can write portable code that runs on major OS without the need to think about it.

                                      If you're writing generic algorithms, of course. Writing a high performance server or something comparable and it's a different situation. The standard C++ libraries make up a miniscule fraction of the code base I'm working on (and some of that is still tricky, such as the differences in UNICODE. A few days ago, I had a small class where the entire class is different between Win32 and Linux. Another class has huge differences between Win32 and CE; I haven't even looked at what the Linux version will be like. :) )

                                      K 1 Reply Last reply
                                      0
                                      • E Espen Harlinn

                                        PIEBALDconsult wrote:

                                        Not as a first language

                                        How about assembly?

                                        Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

                                        P Offline
                                        P Offline
                                        PIEBALDconsult
                                        wrote on last edited by
                                        #40

                                        No, but I had that before I learned C.

                                        E 1 Reply Last reply
                                        0
                                        • O Oshtri Deka

                                          I somewhat agree, but I would chose those languages only for lower level of education.If it's for college than I am for C all the way. What the heck, C should be in secondary schools as well.

                                          P Offline
                                          P Offline
                                          PIEBALDconsult
                                          wrote on last edited by
                                          #41

                                          Oshtri Deka wrote:

                                          for lower level of education

                                          Exactly.

                                          Oshtri Deka wrote:

                                          for college than I am for C all the way.

                                          Yes, after they have the fundamentals and before they're released on the world.

                                          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