why console box is used to learn computer language

why console box is used to learn computer language. Why we don't use directly windows form, so that everything will be clear there. And if any body learn using console box, then is it possible to convert console app to windows app easily? And what kind of software that will be? Or he has to learn more software to get desired results. I am asking this in sense of C++ programming.

we need to walk before running...

there is a lot of code behind windows form .
For learning we must first learn algorithms , data structures , OOP , design patterns .
When you know all the basis , you would not need windows form but instead will create your own :)
Although it is true that the basics of programming doesn't require graphics it is never the less made difficult, for I believe intellectual snob reasons, for a beginner to implement them. There is no reason why they could not be made easy to use (this was done with devpak for some libraries with devcpp) but it appears to be a rite of passage that you learn all the magic incantations if you want to join the c++ club. You should be able to simply write" import library X" and it would set itself up but for some reason they have chosen not to implement it. What will take a beginner months to learn how to do in c++ can be done within hours using another language.

Last edited on
Yes , but the thing is a lot of c++ book were written by 40 + y.o ...
And they teach you a little of c , c# can be a good start with Unity the game engine .
Well, what i understand that to learn any computer language, use of console is an easy step to get the results, what u have coded. But in real world these prog. (Console Apps) are less beneficiary. But by coding console apps u can arrange ur mind so that in future u will be able to create GUI apps. If i am right, reply me plz.
But in real world these prog. (Console Apps) are less beneficiary.


You are absolutely wrong. What you have to understand is C existed long before any GUI apps. The GUI exist to make things easier for end users. It doesn't make it easier to program either, it makes it harder.

The GUI doesn't make your computer faster, in fact it takes a lot more resources.
Your super high end servers and mainframes in most cases don't have a GUI.
Some don't even have monitors. Why would you need a GUI if you dont have a monitor?
The main reason to learn to make console apps, IMO, is that is the most portable way to make a program and be able to run it on any OS, with the fewest amount of changes.
The second reason is that instead of learning how to program for windows, you simply learn to program, which is what a programming class is for. You don't pick up a math book to learn how to read.... You could, but it's not efficient.
It depends on what sort of programs you end up writing. You need to input/output data and all the programs I have written (in BASIC) used graphics.
Hi,

suzuka wrote:
But in real world these prog. (Console Apps) are less beneficiary


There are lots of programs in the real world that are console or shell programs, not everything revolves around applications being GUI.

Often it is not worth going to the extra effort and expense to write GUI programs, nor is it even necessary - there are lots of programs that take no user input, so it is pointless making a GUI program.

Writing code for a GUI program is much more involved, might use more OS and hardware resources / memory and also may even be slower.

Also, shell programs are not necessarily just used for simple tasks - there are many shell programs that do quite complex tasks.

Having said all that, having a goal of learning how to do GUI programming is perfectly fine. But one does have to learn quite a bit about c++ first, otherwise one might not understand much when trying to read the GUI program documentation how-to, or reference manuals.

Windows 32 is not the holy grail IMHO either. There are other frameworks which allow one to write cross-platform code - such as Qt and others.

I can go even further - Windows OS is not the sum total of everything. I would highly recommend getting hold of a Linux distribution to broaden ones education and for the shear amount of quality programming oriented stuff that is available for free. Then there is Apple as well.

Hope all this helps a little :+)

Actually you should not see two worlds apart . You can write a window app with a console window output to print errors or warnings . Algorithms and data structures are still the same.

By default cout will try to print the streams into a console output window , but it can as well print it in a window form or GUI pretty easily .

A stream is an object , you can do whatever you want with .

Console app are learn first because Windows app requires a little more experience in programming. Such as event , threads , etc.

The thing with windows form is that it use C++/CLI I think , which is a little managed . But you can create you own forms with Win32 API . You can create them from scratch or use a library like QT .
by coding console apps u can arrange ur mind so that in future u will be able to create GUI apps
This part of your post is correct. The purpose of any book is to teach you how to program. Not how to create windows and move them around.

Choosing to do it this way allows to throw out clutter which you cannot yet understand and ensure that examples would work for everyone (every standard-compliant compiler in their classroom on every OS).

Console I/O is simpliest way to input data and see what happened. You just tell host OS "show this" and do not care about complex underlying process caused by that action. Console input is also balanced in exposing internals of the language and abstracting from machine. It also introduces to term "stream" which is important in programming world.

You coud write to file instead (not always obvious location of required/created file when launched from IDE, possible problems with OS security mechanism) or just see values directly in debugger (need to know how to use debugger)
closed account (E0p9LyTq)
@suzuka,

would you prefer to learn how to program like this:

1
2
3
4
5
6
7
8
#include <iostream>

int main()
{
   std::cout << "Hello World!" << std::endl;

   return 0;
}


or like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* a minimal Windows API application skeleton, 32-bit */

#include <windows.h>

/* Window Procedure function prototype ========================================= */
/* this is a callback function, only the Windows operating system calls it
   the application should NEVER call the window procedure directly */
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR lpCmdLine, int nShowCmd)
{
   UNREFERENCED_PARAMETER(lpCmdLine);

   /* define some variables */
   const char szWinClass[] = "WinSkeleton32bit";                 /* the name of the window class */
   const CHAR szAppTitle[] = "Skeletal Windows API Application"; /* the app's title */

   HWND       hwnd; /* the handle to the created window */
   MSG        msg;  /* a structure containing message information */
   WNDCLASSEX wc;   /* a structure containing the attributes of the application's window class */

   /* define the window class */
   wc.cbSize        = sizeof(WNDCLASSEX);              /* size of the WNDCLASSEX structure */
   wc.hInstance     = hInstance;                       /* handle to this instance */
   wc.lpszClassName = szWinClass;                      /* window class name */
   wc.lpfnWndProc   = WndProc;                         /* points to the window procedure */
   wc.style         = CS_HREDRAW | CS_VREDRAW;         /* redraw the window if the window changes size or location */
   wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION); /* predefined icon */
   wc.hIconSm       = NULL;                            /* no small icon */
   wc.hCursor       = LoadCursor(NULL, IDC_ARROW);     /* predefined cursor */
   wc.lpszMenuName  = NULL;                            /* no class menu */
   wc.cbClsExtra    = 0;                               /* no extra class info needed */
   wc.cbWndExtra    = 0;                               /* no extra window info needed */
   wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);     /* predefined color brush for the client area background color */

   /* register the defined window class */
   if (0 == RegisterClassEx(&wc))
   {
      /* unable to register the window class, abort */
      MessageBox(NULL, "Couldn't Register the Window Class!", "ERROR", MB_OK | MB_ICONERROR);
      return FALSE;
   }

   /* now that a window class has been registered, create the main window */
   hwnd = CreateWindow(szWinClass,          /* name of window class to create */
                       szAppTitle,          /* window title bar caption */
                       WS_OVERLAPPEDWINDOW, /* window style - this is the normal style for most main windows */
                       CW_USEDEFAULT,       /* X coordinate - let Windows decide */
                       CW_USEDEFAULT,       /* Y coordinate - let Windows decide */
                       CW_USEDEFAULT,       /* width of the entire window - let Windows decide */
                       CW_USEDEFAULT,       /* height of the entire window - let Windows decide */
                       NULL,                /* no parent window */
                       NULL,                /* no menu */
                       hInstance,           /* handle to this instance */
                       NULL);               /* no additional arguments */

   /* check to see if window was successfully created */
   if (NULL == hwnd)
   {
      /* couldn't create the main window, abort */
      MessageBox(NULL, "Couldn't Create the Main Window!", "ERROR", MB_OK | MB_ICONERROR);
      return FALSE;
   }

   /* display (and update) the newly created window */
   ShowWindow(hwnd, nShowCmd);
   UpdateWindow(hwnd);

   /* create the message loop - if GetMessage() returns zero the app is being closed */
   while (GetMessage(&msg, NULL, 0, 0) != 0)
   {
      TranslateMessage(&msg); /* translate virtual key messages into character messages */
      DispatchMessage(&msg);  /* send the message to the window procedure and return control to Windows */
   }

   return (int) msg.wParam;
}


/* processes the messages that Windows sends to the application */
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   /* choose which Windows messages you want to process */
   switch(message)
   {
      /* the window is being destroyed, so tell Windows the application can be terminated.
      this message is one every application is required to process,
      all other messages are optional depending on the program */
      case WM_DESTROY:
         /* send a message to Windows the application can exit */
         PostQuitMessage(0);
         return 0;
   }

   /* let Windows default process any messages not specified in the switch statement */
   return DefWindowProc(hwnd, message, wParam, lParam);
}


The Windows source doesn't even printout "Hello World," something the C++ console source does.
Last edited on
There are a number of answers to your question:

1) C++ has no built-in support for Windows Forms, or any other GUI for that matter. So if you want to learn the "pure" language, then you want to be competent in using the base language before moving on to GUI libraries.

2) Windows Forms runs on only a single platform. C++ console apps run on any platform that supports C++.

3) As someone else pointed out not all C++ platforms support GUIs. I work on a mainframe that that has no GUI interface. All C++ programs run in console windows. There are also embedded devices/controllers where programs are written C++, but don't have a GUI, and may not even have a console window.

@FurryGuy nice :)
But in real world these prog. (Console Apps) are less beneficiary


You are right, that is if you think of compilers, for example, as less beneficial.
@suzuka

I guess you have been hammered a bit in this topic, don't worry it's all for your education (you weren't to know at your level anyway :+) ). Also, this is the nature of forums - if someone says something wrong, there are plenty of people to say so.

FurryGuy's post is a great example of why I wouldn't code in Win32, and would much prefer something like Qt. Win32 uses the C language, while other systems use C++. Even if one restricted themselves to Windows, there are other options like .NET that has got to be easier IMO. Note that frameworks like Qt and wxWidgets run on windows & Mac too.

The "Visual" in Microsoft programs means that one can visually create forms with all their controls, then go back and write code to carry out the actions for command buttons, and other things such as dynamically changing the appearance of things. In other words, one doesn't have to write code to create the form or any of it's controls. MS is not the only one to have this feature.

So one could start out with something simple, using whatever system suits you (Qt, .NET, wxWidgets, whatever), but be prepared to run into items on the list below - sooner rather than later. So this is why everyone recommends learning C++ first, then tackle GUI.

A thing to be wary about .NET is that they have made changes (invented new types for example), so that one can use various languages (C#, C++, C++/CLI, VB etc) with .NET. Also, they seem to push languages like C# (A MS only language) and discourage C++, by providing minimal examples in C++. That's just my opinion, but I had the definite impression that using C# would be easier

Going back to what knowledge might be needed in order to learn GUI programming in general (not just MS), this is probably a too short list of some of the things needed in order to understand reference manuals.

- Types - what they all mean for arguments / parameters / return values of functions.
- Function overloading
- Constructors and their overloading, initialiser lists
- operators and their overloading
- pointers and references
- containers
- algorithms
- classes & OOP (not trivial at all, despite first appearances)
- virtual functions
- events (not a c++ thing per se, more of a design pattern thing obviously used a lot in GUI's)


Anyway, best of luck - the really good thing is that you can always ask questions here, there are plenty of really knowledgeable ready to help. :+D


Thank you, thank you all, you all have cleared me. Now i have set my mind to learn C++ as it is needed. I have started from beginning with console box and hope will learn basics of C++ within three months. I have erased that part in my mind, that was irritating me to make database apps, just after learning basics of C++. I am enjoying this forum as every one is trying to help each other, either he is newbie or expert. Hope very soon, my dream to make database apps will be true.
Topic archived. No new replies allowed.