The Programming Super Thread

Tip: When you're posting a piece of code, try to use the "<code>" tags. For example:

//Hi, this is a piece of text with the "<code>" tags.

for(int lol, >=100, lol++){

//something here

}

Still wondering why Python isn't included on this list. It was what got me into coding...

Very nice guide!

Glad I could help.

I'm a novice to C++, so this might be understood by someone with more experience, but I have a question:

If C++ is cross-platform almost natively, why can't .exe applications with C++ source code be run on Linux?

I've only worked with the command prompt as far as running programs I've made (Compiled using G++ on Windows 8, editor is Sublime Text) so maybe it's different for applications using a visual method (forms, buttons, etc)?

In any case, an answer would be appreciated!

In the case of cross platform languages the reason a .exe can't run on another machine even if that machine can run programs in that language has to do with the runtime environment.

lets say you make your .exe this can run on the common language runtime which is what Microsoft machines use to turn your code into an intermediate language (if your using visual C++) so when you compiled your program it was built for the CLR, Some assemblies you can use are also compiled for a specific CLR making them non-compilable with other runtimes.  now if you change your compiler to output a .dmg(.exe for macs) what happens is it turns the code into the intermediate language for Macs.

TL;DR code is converted into operating specific languages, some code can be turned into many of these languages(like in the case of C++) other code is specific to certain OS.(like how objective C only runs on iphones)

 

So what's the deal, I don't see FORTRAN 77 om the list...

If anyone has good experience in any particular language, please feel free to type it up here.

Both of us will be more than willing to add to the thread and help. We can't learn everything so its not limited to our knowledge.

Hello everyone, I'm new to coding, I don't even think that I can say I code or program or whatever. I have been messing around with python and reading a lot of books and stuff. The thing is, I don't know what to do, I mean, since I'm not majoring in computer science (even though I would love to) I don't have the need of doing something specific. And I know that a lot of people will say that I should just look up something on the internet, but I have already done that and I just feel I'm not making any progress.

Can someone help me on this one? I'm just a begginer and I really enjoy this things. I would like to become a great coder, just don't know how to.

Thanks anyways and I hope someone can give me some good advice!! 

Thanks for your answer. Very informative, but it left me needing another one answered:

If I make Program A which runs in a command prompt on Windows, could I compile it to .dmg and .exe and get the same result on both? Or would it not run on OS X? Like I said, complete newb to programming.

So what really makes a good programmer is how they look at a problem and how they're going to fix a problem. 

Usually its not the language, but the way the programmer goes at the problem. Yes, there is a difference between being experienced in programming, and being experienced in a language. And this is something I see a lot from programmer to programmer. The ability to create close to the most efficient code in a set amount of time is something that doesn't really just come out of nowhere and can (not always) take time to develop as a programmer. 

As far as furthering yourself in programming in general, I'd just stick to simple tutorials. Maybe learn a C Syntax based language like C++, Java, or even C#. But you don't have to know those languages to be a good programmer. You just have to be able to understand the functionality of things and really the ins and outs. I only recommend those languages because I know they have reliable and really in depth tutorials about specific things.

As far as what to learn, I always try to just take some time every couple of months, maybe a day after I finished a big project, to just look at what other people have made. See what inspires me and what I want to make.

I had a different perspective on the case. This has really helped me to have a better understanding of all this subject. Thank you sir for your advise, it was trully helpfull. I will try to focus on analysing problems and other peoples solutions instead of being worried about the languaes themselves (but obviously I won't stop trying to learn them as best as I can). 

Oh and by the way, excuse my english hahaha, not my "main" language.

Languages typically have a standard library which includes the basic I/O routines, among other nice things. The interfaces that a programmer uses remain the same, but the background implementation can be different for each platform the library has been ported to.

This allows a programmer to write code that will compile without changes on any supported platform. There are lots of other libraries that are cross-platform besides the standard library, too.

Take the basic C "Hello World" example:

#include <stdio.h>

int main(void) {

  puts("Hello, world!");

  return 0;

}

(Sorry code tags are horribly broken.)

It will compile and run on Windows, Mac, Linux, and countless other platforms. This isn't to say that a program compiled for Windows would run on a Mac, of course (though if you try hard enough pretty much anything is possible). It is also important to remember that some things ARE operating system specific, so don't complain when your code includes <windows.h> and then you try to compile it on a Mac and get errors like 'HWND, wot?'

I went through my C++ courses doing all the development on OS X, and just doing a final test to make sure it compiled the same on Windows before turning in assignments. They were all simple command line utilities like you described (except .dmg is not the Mac equivalent of .exe: OS X executables are Mach-O and do not have an extension; a dmg is a disk image that contains files like a zip or iso file).

The ONE thing to watch out for, on Windows you might end up developing with Visual Studio, and the command prompt likes to disappear after your program exits so you learn quickly that you must do something to stop the window from closing. Some people put a cin block at the end. I always used system("pause"), which happens to be Windows specific. I ended up working out a simple macro which detects the build platform and throws in the pause on Windows. It allows me to just return MAIN_SUCCESS and it would automatically include the pause if built with MSVC++ in a debug configuration (because releases shouldn't need pauses, either).

*digs them up*

HERE, someone might find this useful.

By habit/wanting proper tools, I have Visual Studio express installed but I edit with Sublime Text 3 and compile via command-line with G++.

Where is Python?

Yay, Python!

is this a sticky? if not, it should be

It is.

For anyone learning C++, I recommend that you manually link and compile. Learning the GCC toolchain is a very important part of understanding the language.

I.E., don't use an IDE for C++.