Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 332681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:53:21+00:00 2026-05-12T09:53:21+00:00

I’m a novice at programming although I’ve been teaching myself Python for about a

  • 0

I’m a novice at programming although I’ve been teaching myself Python for about a year and I studied C# some time ago.

This month I started C++ programming courses at my university and I just have to ask; “why is the C++ code so complicated?”

Writing “Hello world.” in Python is as simple as “print ‘Hello world.'” but in C++ it’s:

# include <iostream>
using namespace std;

int main ()
{
    cout << "Hello world.";
    return 0;
}

I know there is probably a good reason for all of this but, why…

  • … do you have to include the <iostream> everytime? Do you ever not need it?
  • … same question for the standard library, when do you not need std::*?
  • … is the “main” part a function? Do you ever call the main function? Why is it an integer? Why does C++ need to have a main function but Python doesn’t?
  • … do you need “std::cout << “? Isn’t that needlessly long and complicated compared to Python?
  • … do you need to return 0 even when you are never going to use it?

This is probably because I’m learning such basic C++ but every program I’ve made so far looks like this, so I have to retype the same code over and over again. Isn’t that redundant? Couldn’t the compiler just input this code itself, since it’s always the same (i.e. afaik you always include <iostream>, std, int main, return 0)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:53:22+00:00Added an answer on May 12, 2026 at 9:53 am

    C++ is a more low-level language that executes without the context of an interpreter. As such, it has many different design choices than does Python, because C++ has no environment which it can rely on to manage information like types and memory. C++ can be used to write an operating system kernel where there is no code running on the machine except for the program itself, which means that the language (some library facilities are not available for so-called freestanding implementations) must be self-contained. This is why C++ has no equivalent to Python’s eval, nor a means of determining members, etc. of a class, nor other features that require an execution environment (or a massive overhead in the program itself instead of such an environment)

    For your individual questions:

    • do you have to include the <iostream> everytime? Do you ever not need it?

    #include <iostream> is the directive that imports the <iostream> header into your program. <iostream> contains the standard input/output objects – in particular, cout. If you aren’t using standard I/O objects (for instance, you use only file I/O, or your program uses a GUI library, or are writing an operating system kernel), you do not need <iostream>

    • same question for the standard library, when do you not need std::*?

    std is the namespace containing all of the standard library. using namespace std; is sort of like from std import *, whereas a #include directive is (in this regard) more like a barebones import std statement. (in actual fact, the mechanism is rather different, because C++ does not use using namespace std; to automatically lookup objects in std; the using-directive only imports the names into the global namespace.)

    I’ll note here that using-directives (using namespace) are frequently frowned upon in C++ code, as they import a lot of names and can cause name clashes. using-declarations (using std::cout;) are preferred when possible, as is limiting the scope of a using-directive (for instance, to one function or to one source file). Don’t ever put using namespace in a header without good reason.

    • is the “main” part a function? Do you ever call the main function? Why is it an integer? Why does C++ need to have a main function but Python doesn’t?

    main is the entry point to the program – where execution starts. In Python, the __main__ module serves the same purpose. C++ does not execute code outside a defined function like Python does, so its entry point is a function rather than a module.

    • do you need “std::cout << “? Isn’t that needlessly long and complicated compared to Python?

    std::cout is only needed if you don’t import the cout name into the global namespace, either by a using-directive (using namespace std;) or by a using-declaration (using std::cout). In this regard, it is once again much like the distinction between Python’s import std and from std import * or from std import cout.

    The << is an overloaded operator for standard stream objects. cout << value calls cout‘s function to output value. Python needs no such extra code because print is built into the language; this does not make sense for C++, where there may not even be an operating system, much less an I/O library.

    • do you need to return 0 even when you are never going to use it?

    No. main (and no other function) has an implicit return 0; at the end. The return value of main (or, if the exit function is called, the value passed to it) is passed back to the operating system as the exit code. 0 indicates the program successfully executed – that it encountered no errors, etc. If an error is encountered, a non-zero value should be returned (or passed to exit).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 174k
  • Answers 174k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Microsoft released the Visual Studio Team System Web Access 2008… May 12, 2026 at 2:56 pm
  • Editorial Team
    Editorial Team added an answer Perl, 166 160 characters Perl, 251 248 246 222 214… May 12, 2026 at 2:56 pm
  • Editorial Team
    Editorial Team added an answer A capture group when searching/replacing with regex in VS can… May 12, 2026 at 2:56 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.