Why are APIs talked about on here?

Pages: 123
When I tried to google what APIs are the only understanding I could get is that they are for web-apps so I'm wondering why they are talked about on here in relation to C++ since C++ isn't a web language.
APIs (application programming interfaces) are not only for web apps they are just the public interface to a library/sdk.
they are just the public interface to a library/sdk.
Isn't that what an IDE is/is for?
An IDE and an API are two entirely different things. What do you think they are?
Just as a small remark:

To understand "public interface" in this context, you need to understand about Classes and their access specifiers:

http://cplusplus.com/doc/tutorial/classes/


Consider an API like the person you speak to when you go to the post office to send a letter.
You hand the person the letter, pay him the money, etc - what happens to your letter and money after that is hidden from you.

So the person at the post office is your interface to the post office, whilst the actual implementation of the sending of your letter is hidden from you.

All the best,
NwN
closed account (3qX21hU5)
One example is Direct3D which is a graphics API which is used in almost every major video game.
An IDE is just a text editor with a built in compiler and usually a debugger.
An API are the functions that a certain library or sdk provides the programmer with.
IDE = Integrated Development Environment, usually contains excessive amounts of superfluous stuff that you will never use.
API = Application<->Program Interface, usually doesn't contain everything you want forcing you to do hacky things to get what you want.

As you can see, they're perfect opposites.
An IDE is just a text editor

Text-editor is a generous term for the notepad-esque crap they expect you to type into.
An IDE, as pointed out, is an integrated development environment (meaning it is just a IDE that is designed to combine the compiler and sometimes a debugger into it. Otherwise you would be stuck opening a notepad-esque text editor, entering your code and saving the source file. Then opening the command prompt (terminal) and typing in the gcc/g++ commands to compile the file to the desired output (.o) then use the linker to make the executable or library. Then have to compile with debug symbols to debug it. IDEs that do all this for you are really nice.

An API also are the function a library gives you, for example:
1
2
3
4
5
6
7
8
9
10
11
// Allegro 5 API
al_create_bitmap(800, 600);
al_draw_bitmap();

// SFML API
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

// SDL API
SDL_Init( SDL_INIT_EVERYTHING );
SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
SDL_LoadBMP();
Otherwise you would be stuck opening a notepad-esque text editor, entering your code and saving the source file. Then opening the command prompt (terminal) and typing in the gcc/g++ commands to compile the file to the desired output (.o) then use the linker to make the executable or library.


To be fair, in most editors the process isn't quite that laborious. In Emacs all I have to do is hit Ctrl-x-o-g to compile, which can be done in under a second. I have yet to see an editor that auto-generates makefiles like an IDE does, however...
ascii wrote:
To be fair, in most editors the process isn't quite that laborious. In Emacs all I have to do is hit Ctrl-x-o-g to compile, which can be done in under a second. I have yet to see an editor that auto-generates makefiles like an IDE does, however...


Yeah, but problem is that most programming tutorials end up going through the command line compilation so they normally say "Notepad is fine for now, but you may want to look into MSVC or equivalent for your OS later." Most of my programming books even say just to open Notepad and assume you are coding under Windows and not another OS (while I use Qt Creator for my big projects and Geany for my simple projects under Ubuntu). Not been in my Vista OS for a year or more now.
but problem is that most programming tutorials end up going through the command line
That's a problem?
closed account (3qX21hU5)
I would say that is actually the better way to learn. Its always better to learn the back end of things before you start using tools to do it for you. Or else you will have trouble later.

For example if you don't learn about make files and having to use the command line when you first start programming you will have trouble later when you start using libraries for the first time (SFML is the main one I think of) since you wouldn't know how to build the library ect.
However, there's the issue that you're trying to learn C++ while you're also trying to learn the compiler. Having a newbie use an IDE first separates the process of learning the two, which leads to less confusion while learning.
Then opening the command prompt (terminal) and typing in the gcc/g++ commands to compile the file to the desired output (.o) then use the linker to make the executable or library

I have my terminal up and my my text editor up at the same time. All it requires is hitting save, then up arrow and enter on my terminal to recompile.

but problem is that most programming tutorials end up going through the command line compilation

How is that a problem? It makes the tutorial apply to anybody, not just a particular IDE. Everyone should at the very least know how to work their compiler through the command line. It's not hard (at least on Linux, setting up Windows to do it always seems like a hassle so I don't even bother there).
I've never had any hassle with compiling via command line on Windows, except that the compiler documentation is generally unhelpful to Windows users, but that's not related to Windows.
Eh I guess my experience is limited with Windows. I can never seem to get it set up and I can't ever find anything on Windows anymore.
Yeah, it took me two hours to figure out how to get clang on Windows the first time, but it's actually pretty straightforward, they just make it annoyingly obscure.

I have always noticed an overflow of helpful tutorials in writing code and doing things (many of them very poor because nobody writing them is an expert) and an overwhelming lack of tutorials in actually setting up an environment to code in other than "install this" or "I used this for this tutorial". Basically people want to learn to program and they always end up starting at Step 2, and having to go and figure out what Step 1 is themselves.
People only start with step 2 because step 2 is what they want to know. Generally speaking, you'll be fine learning part 2 before part 1 because, with an IDE, the two pieces are separated pretty well. After they've learned C++, knowing how their compiler works will be more meaningful to them and they'll actually care about it at that point.
Last edited on
Pages: 123