Need help with learning how use Atom


#1

I’ve never used a text editor before, only ever used Codecademy to learn languages. I want to start learning C++ and all the courses require you to download an editor, so I thought Atom would be great because it’s free but I’ve gone through every tutorial and I cant find anything to show me how to open a C++ file or how to run code. I’ve been looking for hours so if anyone could walk me through the basics it would be greatly appreciated. Sorry if I seem like an idiot but I’m a complete newbie.


#2

Okay, the basics.

Text editors vs document editors vs code editors vs IDEs

Some of the first programs to be created for computers were text editors. As soon as we got monitors and command lines, people designed programs to allow writing documents. These were the digital cousins to the typewriter, and some of them were very bare-bones while others were developed by techies into very complex programs that could allow for rapid programming or data processing. If you say you’ve never used a text editor, I’d say you’re probably wrong, because everybody’s opened Notepad once or twice. It’s not a good editor by any means, but it edits text.

Following the invention of the desktop, document editors became the default editors. Microsoft Word is the most ubiquitous of these. They’re generally very opinionated about what and how people should write, and the WYSIWYG interface combined with these strong opinions can make it difficult to break the mold.

Another term you’ll hear around is “code editor”, which is a subset of text editors with features specifically geared toward programmers, like language recognition, the ability to control which invisible character gets inserted at the end of every line, automatic indentation, and so on.

Integrated Development Environments (IDEs) are like code editors, except that they’re very big because they come packaged with a full suite of tools for one or more languages. They aren’t happy with simply color-coding your code and automatically indenting new lines. Instead, they have tools for precise bug recognition, plotting out how your program should run, referencing documentation by hovering over a function call, and so forth.

Interpreted languages vs compiled languages

Before you get into choosing a language that fits your needs, you need to understand a bit about how different languages work. Interpreted languages (Python, Ruby, Perl, JavaScript, Lua, etc.) sit on your computer as plain-text script files. Anybody can open or read them at any time. When you want to run them, you send an instruction to a program (usually with the same name as the language) that tells the program where to find the script file. That program translates the code into computer instructions and executes them.

Compiled languages, on the other hand, are built by the program into stand-alone programs with all of the information they need to run themselves (libraries and dependencies are a thing, but that’s a separate concern). C++ is one of these languages, so in order to run C++ code, you need a program that can turn your code into an executable file. Until the code is compiled, it’s just a plain document, so the only thing you need to open a .cpp file is literally any text editor. Just right-click on the file and select “Open With” (as a side note, since you don’t know that, there’s probably a load of other computer science basics that you should explore before you get heavily into writing programs for people).

About Atom

Atom is a code editor, at its core. Like many code editors, it has support for add-ons that bring it closer to being an IDE, but it’s for those of us who do code but want a single editor for most of our work, without all the IDE baggage. I use Atom as a general-purpose text editor, too. There are some great packages out there for writing Markdown and Pandoc. But since Atom is not an IDE, it needs to use those other programs to run code. Packages such as gpp-compiler do that for you, but you have to download a separate program to handle the compiling (in this case, MinGW).

What should you do?

I say stick with Atom. Get a package and MinGW working and learn through experimentation. That’s the only way expertise ever gets cultivated: hands-on experimentation. If you really want to get to the C++, download an actual IDE like NetBeans or Visual Studio. Atom doesn’t hold your hand through anything, but they will.


#3

Also check out the Flight Manual for the basics of how to use Atom. If you’re intending to use Atom primarily for coding C++, open up the Settings View, go to the Install tab, and search for “C++”. That should get you started with some helpful packages.


#4

Thanks man I instaled an IDE and I got the hang of Atom afterwards, I now have a better understanding of how everythings so much appreciated.


#5

I can’t figure out how to run the C++ in atom, I need to add paths to Cygwin and MinGW, I read up on it but it still makes no sense to me, would you have like, a simple way to explain that process?


#6

I don’t use either of those. I’m assuming one of the packages you installed is asking for the paths to those? If so can you please provide a screenshot?


#7

So it’s the gpp.compiler package. This happens when I try to run the code, I downloaded Cygwin but all the tutorials are out of date so I’m not sure if I even added the right things and I couldn’t find the debugger anywhere. Is there a simpler way to get Atom to use the g++, again I’m not entirely sure how any of this works exactly, just the basic concept.


#8

Go to Control Panel -> System -> Advanced system settings -> Environment Variables. There’s one specific environment variable called "the PATH", which provides a list of directories for your computer to look in for programs you invoke.

For the linter-gcc error, you need to go to the settings pane for that package (Settings -> Packages and click anywhere in the box that isn’t the title or another button) and give it the directory to the g++ executable (which can just be g++ if it’s in your path).


#9

So I’ve managed to put Cygwin and MinGW into the path(assuming that I managed to download all the required add-ons) so that is solid, I think. Now, what do you mean “give the directory to the g++ executable” ? I typed “g++” into the gcc and g++ options, but I guess that would been to straight foward ha. So what should I do now?


#10

I just realized I can right click and compiler and run and it runs the code in the Cygwin command prompt, unbelievable, thanks for being patient with me man, I learned a lot of new stuff, really helped, much appreciation. Just want to ad this note for anyone who comes across this I think I had to many similar packages running at the same, I don’t know what combination I have but it’s working perfect now.


#11

If you installed the C++ compiler package when you installed MinGW, there should be a MinGW/bin/g++.exe file. You can either enter the path to that file in the linter-gcc settings, or you can add MinGW/bin/ to your path and add g++ to the package settings (do the second one, because then you can reference g++ or any of those executables from anywhere without worrying about where they are). There might also be one in your Cygwin folder. They should be the same.

I don’t know what combination I have but it’s working perfect now.

I know the feel. It’s kind of a crummy thing that some packages call for MinGW and some call for Cygwin. It’s not so bad because there are only two of those, but without a thorough knowledge of what’s in each of them, it’s difficult for a random user to know which things are cross-compatible. The thing is that not all bits of software rely on just one executable. MinGW and Cygwin are two versions of the same thing (which is visible if you look in the bin/ section of each), but they’re different environments, so a package of source code built on Unix that gets ported to Windows is often going to be built for whichever one of them the programmer is familiar with, and it may or may not work with the other. Since there are only two, and they’re both pretty small, it’s not hard at all to download both. When your smallest hard drives are hundreds of gigabytes, code compilers really aren’t a meaningful memory sink.


#12

Hello, I’m new to all of this as well and just wanted to add in my thanks for the patience. Been fighting trying to get it to compile to C for a while now. Worth mentioning that it needs to be running in administrator mode :flushed: Whoops.


#13

I actually know what went wrong, I set it all up perfect first time but I downloaded the linter package before I ran my code for the first time and that’s what the error was, then I ended up added things I didn’t need into my PATH, so even when I uninstalled the linter it wasn’t working. I just uninstalled every package and reset the PATH and stated from scratch and I realized what was actually going on in the process this time. So I think I’ll be okay if I find myself in a similar situation again.


#14

All I can say is “maybe”. It depends on where everything is on your system. Have you installed the compiler into one of your Program Files folders, or Windows? Have you put Atom there? Is something else pointing in that direction? Because that’s the only reason I can think of why it might not be working outside of administrator mode. Maybe if something’s pointing at or installed in a directory owned by another user. I have all of my compilers in C:/ for easy access (also they can be hard to find if buried in among other programs) and nothing requires administrator mode because I’m the only user and I own all of the folders and files.


#16

That seems to be the case. Atom is installed under my user directory, while the compiler is directly on C:/ Never knew that could cause that, good to know!


#17

Check the permissions on the compiler folder. That should not be a problem unless your user account is not part of the administrator group. Regardless, the problem is neither with Atom nor with the compiler, but it’s something regarding the permissions and locations where the files are or where the built executables are being put. Remote troubleshooting is not viable in this circumstance. You have to check all the various places yourself.

On Windows 7+ a user account with administrator access is different from the Administrator account, which is normally hidden. If the compiler folder or executable is owned by Administrator, that would be a possible reason why. The output folder is another possibility.


#18

I am new to atom and unable to get user input data in C++, Cin>> is now working…I am using Mac OSX, Please tell how to take input using cin>> in C++ ?


#19

What package are you using for C++?


Really dumb question but new to atom and i am not able to get input from user for my program. Please help!
#20

Poblem solved, gpp_compiler worked out…Thanks :slight_smile:
It opens the terminal window to get user input or cin>>.
btw any suggestion to improve terminal (font size,display etc ) ?


#21

What operating system are you running?