What SHOULD I be learning?

Like many novice programmers, I dove into C++ mainly because it was popular (at least in my area) and it was "cool." I also started off making small games without learning how to implement GUI.
If my future involves working with circuit boards and robotics, should I even bother learning GUI? And even then, is C++ the proper language to learn? Or would some assembly languages or C be better?

Appreciate any responses.
closed account (Dy7SLyTq)
yes c++ is good and it is good to learn a gui because you might need an application interface
I would say, learn the basics, but focus on areas you are interested in. C++ is a very good language to know, but you may want to learn some ASM (PIC maybe) and if you understand C++, C is basically C++ without OOP and a few other features that you often do not need when designing a robot.
Assembly language is non-portable (very specific to the architecture of the machine).
C is excellent, but C++ can do all that C can, plus the 4 polymorphisms (templates, function overloading, runtime-polymorphism, coercion), classes,...
Last edited on
@DTSCode
That is a good point. I hadn't thought of that. -_- I guess I forgot that some machines do have a screen for user interface.

@Script Coder
Personally, I think C is a whole 'nother beast. Before C++, I tried learning C but gave up and moved on to C++. For some reason I found C++ with its extra features easier to understand than all the scanf, printf tokens and the malloc and dealloc functions everywhere.

@Bourgond Aries
But for maximum control, assembly languages are one alternative, right?

Thanks everyone for your responses. I was worried that I was going down the wrong path.
closed account (zb0S216C)
Embedded systems are normally implemented with C simply because of its small binary output, limited overhead and simplicity. With embedded programming, "pretty" C++ features like templates and object-orientated-programming are simply too expensive in terms of size and/or performance. Normally, the resolving of function calls during run-time (polymorphism and abstract classes) is too expensive of an operation to perform when CPU power and RAM resources are limited.

Assembly language, too, is a must have with embedded programming -- both C and C++ allow in-line assembly.

Wazzak
Last edited on
@Framework
Oh, okay. I have heard that C is more efficient than C++. Guess I'll have to start learning how to use parts of C that are not available on C++ (if there is any?).
in-line assembly? Is that why on the forums, some users put up code with labels and goto? I always found it strange that a compiler would allow that.
But does that also mean that you can push and move things among registries in a c or cpp file? How much of the assembly languages' syntax is available in C and C++'s?
This is inline assembly, it adds two numbers into another variable. Try hitting CheatEngine with memory view to look at program's OPcode (Altho CE uses Intel syntax). Here in GCC I need to use AT&T syntax for OPcodes. You can also debug your program by setting a breakpoint in any function and then opening the disassembly window (at least in code::blocks).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int main()
{
    int a = 3, b = 9, c;

    asm
    (
        "movl %1, %%eax;" // move variable a (3) into eax
        "movl %2, %%ebx;" // move variable b (9) into ebx
        "addl %%eax, %%ebx;" // add eax and ebx together inside ebx
        "movl %%ebx, %0;" // move variable contained int ebx (12) into c
        : "=r" (c)    // this is a variable to move data into. It is the first listed, so it is %0
        : "r" (a), "r" (b) // these are the variables to get data out of, a = %1 and b = %2 because of their order.
        : "%eax", "%ebx" // these registers are "clobbered" and can't be used by the compiler because we are using them.
    );

    return c;

}
closed account (zb0S216C)
Daleth wrote:
"in-line assembly? Is that why on the forums, some users put up code with labels and goto?"

In-line assembly is where the programmer uses raw assembly code, like "mov" and "push", to get something done. Here's an example of standard in-line assembly:

 
asm( "mov eax, 4;" );

In-line assembly code is placed directly into the assembly file (the compiler generates this file) at the same point within the program.

The assembly code Bourgond Aries posted is non-standard assembly; it's GCC's extended in-line assembly. Each compiler has their own way of representing assembly within C/C++ source files, but they are non-standard and won't work with other compilers.

Daleth wrote:
"But does that also mean that you can push and move things among registries in a c or cpp file?"

Yes, you're able to load your variables into select registers with in-line assembly. However, with C/C++ source code, the compiler usually picks the best registers based on the optimisation scheme it has in place, but if you have something specific that needs to be done, then by all means use in-line assembly.

Daleth wrote:
"How much of the assembly languages' syntax is available in C and C++'s?"

Pretty much every instruction is available for the target architecture.

Wazzak
Just my 5 Australian cents worth.

Daleth wrote:
Is that why on the forums, some users put up code with labels and goto?


People do this for 2 reasons:

1: Path of least resistance for a beginner - out of ignorance of the concept of loops;
2: In an assignment, to ease them into the idea of asm programming. Typically the assignment is "write this C program using only goto". So this can get them into the idea of using jump instructions to achieve flow control.
closed account (G309216C)
Daleth,

Learning GUI programming via C++ is good but not the best as using Native C++ to create wonderful GUI is hard & cumbersome I may suggest learning to create GUI with C#.net or maybe just C# with the interior code such as a engine or calculations being programmed in C++ or C.

If you future offer Robotics or such C++ should be a MUST as C++ has many ways which allow you to interact with hardware. Of course there is a MSDN forum related to Robotics.

Link: http://social.msdn.microsoft.com/Forums/en-us/category/robotics

If I were you MSDN would offer you a great Information which is necessary for you.

Hope this helped

Kind Regards
SpaceWorm
Thanks everyone for your inputs! I really appreciate the knowledge, and my programming world suddenly just became more flexible!
Topic archived. No new replies allowed.