Announcement

Collapse
No announcement yet.

ANSI C programmer. How-to start learning C++

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ANSI C programmer. How-to start learning C++

    Hi!
    I usually program in assembly (native processor and BIOS calls, writing hobby operating systems, not applications. I'm not totally insane :-P) C++, i understand, is a different beast, aside from some syntactical similarities, from C, in a similar way that Visual Basic is different from BASIC except syntactical similarities.

    I would like to learn GUI (WXwidgets, especially) programming, but since i have no experience whatsoever in C++ (and C does not support classes, as required by all the libraries i have found), i can't program with any of the currently available libraries (that i know of.)

    Could someone point me to a C library for GUI programming or a good book to learn C++ as someone who already programs in another language?

    #2
    Re: ANSI C programmer. How-to start learning C++

    I'm no expert on this, but AFAIK, most GUI toolkits (Qt for example) have what they call "wrappers" for other programming languages which allow a programmer to use the programming language of his choice and still be able to use that GUI toolkit. For example, Qt, the toolkit used in KDE, has C++ for its native language. However, there are wrappers available for C, Python, Ruby, etc., that will allow you to use C to develop Qt-based programs. Thse wrappers also provide a sort of "workaround" so that C could somehow implement classes.

    You might also want to check out GTK+, which is the toolkit used in GNOME and the GIMP (GTK actually means GIMP Tool Kit). Its native language is C, but has wrappers for C++ as well.

    I'm not familiar with any good books, or online books for C++. I'm also trying to learn that. I have a very very basic knowledge of C and a very short introduction to C++. I'm planning to learn programming for KDE, so I'm going to try studying C++. I personally (my own opinion, of course) prefer C++ anyway.
    Jucato's Data Core

    Comment


      #3
      Re: ANSI C programmer. How-to start learning C++

      GTK -- familiar with the name (many of the programs on my computer are written using it). It's native language is C? Shows how much i know about libraries :P Thus far, the only library i have used is stdlibc6, the standard C library

      Guess that answers that question -- no reason to change languages then i thought most (if not all) of the major GUI toolkits were C++ because of C's lack of high-level constructs.

      Thanks for the help!

      P.S.
      Not that I have any problem with C++, but I don't care for high-level languages usually (as you can tell -- i program assembly :P). The 2 are incongruent, completely different mindset and way of programming. In high level languages (C++ is about the lowest-level of what i would consider high-level), you describe what you want done, and the compiler, libraries, and operating system figure out how to do it. Low-level languages explain how to do it. That is the simplest explanation i have ever heard Also happens well to explain the fundamental differences in the way an assembly programmer thinks, and the way a Java programmer thinks.

      I still remember the time a while back, i do a small amount of Javascript, generally just enough to do small amounts of basic validation before submitting a form. And usually i double-check the validation on the server anyway. So i was helping a fellow out at one point on a forum, he was doing a school project on converting a decimal number to base 2. I showed him through writing a function that fundamentally divides by 2 and takes the remainder, adds it to a string, repeat until the original value is 0, then reverse the string to get the binary number. That's the way i do it in C and in assemly is even easier in this case because the div instruction returns both the dividend and the modulus in one instruction.
      That is, i was helping him with this until someone else came along and said "just use the dectobin() function." (i haven't used it since - i think that is the name of the function but i would again have to look it up)

      A fine illustration of the differences in thought between high-level (JavaScript is about as high as they get) and low-level languages Also, i might add, a fine demonstration of how much i love to type :P

      Comment


        #4
        Re: ANSI C programmer. How-to start learning C++

        Um... isn't C and C++ (along with Objective-C) considered "mid-level" languages? They're neither too high (they don't have built in I/O and string manipulation functions, for example) nor too low (definitely easier than assembly language). At least that's how it was described to me in the books I've read on C/C++. As I have understood it, C++ is just "C + classes + stricter type rules + stricter prototyping + a few more libraries and keywords". At least that's just how it looks to me. Then again, compared to you, I have very minimal programming knowledge.

        Javascript... well... that's a whole different monster. I personally don't consider it to be a true programming language like C or C++. Now Java, that's a real programming language, IMHO. But I don't like it either.
        Jucato's Data Core

        Comment


          #5
          Re: ANSI C programmer. How-to start learning C++

          Originally posted by Jucato
          Um... isn't C and C++ (along with Objective-C) considered "mid-level" languages? They're neither too high (they don't have built in I/O and string manipulation functions, for example) nor too low (definitely easier than assembly language). At least that's how it was described to me in the books I've read on C/C++. As I have understood it, C++ is just "C + classes + stricter type rules + stricter prototyping + a few more libraries and keywords". At least that's just how it looks to me. Then again, compared to you, I have very minimal programming knowledge.

          Javascript... well... that's a whole different monster. I personally don't consider it to be a true programming language like C or C++. Now Java, that's a real programming language, IMHO. But I don't like it either.
          Guess we're reading different books :-)
          How it's been described to me is that low-level languages generally have no constructs more complicated then arrays. Classes, for example, lean toward Object Oriented Programming, making C++ high-level. But C really has nothing but the absolute bare minimum. Then again, these are 2 languages which can, depending what angle you are coming from, be easily described both ways.
          So i say, the method I personally use to describe low-level vs. high-level languages is whether a function call reqieres more then about 6 assembly instructions in or out. C pushes the addresses or values of parameters onto the stack, call's the function, then gets the return value from the EAX register and pops the variables back off the stack. This is extremely simple. But when you get into C++ and call functions that have more complicated structures moving back and forth, I can barely program a simple function for the language. That is generally where my cutoff between low and high level languages resides.

          Javascript is also a hotly debated language.
          Technically, it meets most of the requirements of any language -- it can recieve input, has a place to send output, can manipulate data, is perfectly able to produce whole programs, works within a virtual environment (as does java, i should add. Just a very different kind. But there is no JavaScrpit OS :-P). Given the string processing functions available, and all the DOM browsers today, there is no reason a Javascript interpreter couldn't be written in Javascript (as slow as it might be). Personally, i find it fits all the basic reqirements of a language. The debate really comes in whether it is a language because it cannot be compiled to native code. Technically, it is an interpreted language. No, it cannot be compiled. But then again, until late in it's better years, BASIC was also interpreted - disqualifying it on those groinds. For that matter, Java is still interpreted even if it is compiled first. So on the grounds that being compiled to native code makes it a real language, Java, BASIC, perl probably, and a bunch of others are not real languages

          Java is a good language to learn. It's similar in many respects to a combination of C and C++ in that it is missing some things from C++ but has more then C. Moreover, because it is a virtual machine, hardware issues are no concern. It can be run on any computer in the world. Makes java a worthwhile language to at least know the basics, even if you never take it seriously.

          Maybe that's just me i love computers -- been programming since i was 6. (No joke. I'm 16 now. Been at it for 10 years. After the first couple when my dad guided me through learning BASIC, i taught myself Not trying to sound like a total expert. I've never had a class, so there are probably gaps in my knowlege that are leaving me with different considerations then a trained professional may have... But i try )

          By the way, just a curiosity, what do you use to define a true programming language?

          I have simple requirements i use to define one:
          -it must be able to recieve input
          -it must be able to produce output
          -it must be capable of producing an application (not just a toy has to do more then, say, whitespace might do)
          -it must be able to interpret or compile itself (be able to write an interpreter or compiler for the language using the language, and even more so be able to interpret or compile a DIFFERENT language)

          Comment


            #6
            Re: ANSI C programmer. How-to start learning C++

            Oh crap you're younger than me and yet know all this!?!(I'm 23...)
            I really should have taken up Computer Science in college. (But noooo! I had to take Philosophy... )

            The only reason that I initially didn't consider Javascript to be a "true" language is because it can only run through a web browser. Whether it's interpreted or compiled wasn't the issue. For me it's basically just a script. But some script, like Bash scripts, can be run alone. But with the advent of Web 2.0 and Web applications, that view of mine is slowly changing.

            I guess we really do have different sources/understanding of some basic programming concepts. And mine are obviously more superficial than yours. My background started with BASIC and never had the chance to try assembly language.

            Btw, aren't records/structures more complex than arrays, since arrays are a collection of the same data type, while structures can contain more than one data type? Plus the fact the you can have arrays or structures. And this is found in C. I've always thought that C itself was mid-level. Of course I have almost no knowledge of assembly so I can't compare it.

            I've always thought that OOP is just a logical extension of the concept of structures. Of course, under the hood, it's implementation might be more complicated than that, specially compared to assembly language. But any language compared to assembly is bound to be more complicated.

            Still C++ lacks a few features that would make it a truly high-level language, right? For one, built-in functions. I'm not sure about others, because I have made a decision to study C++ intensively and just take a few glances at Java if I have the time. Python and Ruby also come to mind. But my focus is on C++. More of a personal choice, and that I think that GUIs are, by nature, OOP-based. Of course, GTK+ is proof that you can use C for GUIs, but I heard (just heard) that in order to do that, they have to come up with ways that would render the code quite hard to read compared to a C++ counterpart, some thing like this_is_a_very_long_but_valid_variable_name ... Not really sure though.

            Thanks for this conversation. Knowing your age has inspired me to keep on moving (I've actually stopped moving because I feel so lazy...). By the way, I'm only doing self-study as I can't go to college again... Family reason...
            Jucato's Data Core

            Comment


              #7
              Re: ANSI C programmer. How-to start learning C++

              There is one overwhelming negative with respect to java for systems programming. It does automatic garbage collection. It would be laughable to write an operating system in Java (some have been) because the JVM might suddenly waltz off and start freeing memory in the middle of a time critical operation, like reading or writing data from a disk. Aside from that, though Java is slightly "easier" than C++, which is "easier" than C, where I'm defining easier to mean more things are done for you. If you're an assembly language programmer, the languages get "higher" in the sense of farther from the machine in the order C, C++, Java.

              The really nice thing about C++ (in addition to the fact that it's easier to do GUI programming, compare GTK+ and Qt) is the C++ libraries. Between the Standard Template Library and Boost, C++ can handle almost any sophisticated algorithm and data structure that you might want to use. Java also has extensive libraries, but I believe that they're not as extensive as STL and Boost.

              You can learn either language online from books by the same author, Bruce Eckels (sp?). Google for "Thinking in C++" or "Thinking in Java". They are written for experienced C programmers, who know somethng about data structures, e.g. if you know what a stack, a linked list, a binary tree and a hash table look like, and when to use them in C, you're good to go.

              Comment

              Working...
              X