Author Topic: General IDE to learn C++ on  (Read 36853 times)

0 Members and 10 Guests are viewing this topic.

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17783
  • Country: fr
Re: General IDE to learn C++ on
« Reply #50 on: December 28, 2021, 07:04:04 pm »
Once those steps are well understood, you can switch to something more comfortable than the command line.  The IDE I liked most was Visual Studio from Microsoft.  There is a free and open source version of it, for any OS.  The Linux one is called "VS Code".  One of the best IDE out there, can be used with any programming language.

Except...  It won't print your files!  To me, this seems like a really HUGE failing.  Nevertheless, I use it for Python and VHDL and when I want a listing, I use Notepad++.

I would just get used to Visual Studio Community Edition (free) on Windows.  For Linux, I would probably just use GCC from the command line.  I run gfortran from Eclipse so I'm into most of the high end IDEs.

There are tons of options on Windows as well, as we mentioned. You can use command-line GCC or Clang either on MSYS2, or even directly in a Windows console. You can also use Codeblocks, which integrates all this nicely, so easier for people not comfortable with the command line. Or another IDE of your liking, and set it up for your compiler. If you like Notepad++, so be it. There is Geany also, which is rather nice, and has printing (and is cross-platform, while not being Java!). There's also Vim, for those who are into that, or Emacs, or Atom, or a bunch of others..

There definitely are a lot of options beyond MS tools. Some people here make it sound like there isn't, and frankly some even almost sound like MS salespersons. :-DD
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 4838
  • Country: us
Re: General IDE to learn C++ on
« Reply #51 on: December 28, 2021, 07:30:49 pm »
My point was that the book recommended visual studio based on what it was in 2005, I am fairly sure that it is a bit different now in 2021. I never did get the exercise to work.

And everyone here is telling you it's still a good recommendation in 2021.  There are other options as well.  Just pick something and use it. Literally anything you pick will work for your needs.  Don't worry about "bloat." You will have to learn how the tool works but you should be able to get any tool you pick running in an afternoon.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 14124
Re: General IDE to learn C++ on
« Reply #52 on: December 28, 2021, 08:08:28 pm »
My point was that the book recommended visual studio based on what it was in 2005, I am fairly sure that it is a bit different now in 2021. I never did get the exercise to work.
At the moment I just need to follow the exercises in the book. My first use will be in microchip studio for embedded stuff. Anything else will come later.

As I said earlier, Dev-C++ is still usable under Win 10, and can be upgraded to a reasonably current GCC version.   It took me about five minutes to create a Win32 Console project and enter the "hello_world.cpp" example from chapter two of your book, and as soon as I realized that the header "std_lib_facilities.h" is custom for the book and needs to be downloaded from Stroustrup's site, I added it to the project, and it then compiled with no errors or warnings and ran successfully and correctly.   

I detailed what's needed to get Dev-C++ up and running under Win 10 back in reply #34 and attach the minimum set of project files for Dev-C++ for the chapter two hello world program.  Just unzip them in a new folder, open the '.dev' (project) file and build and run.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17783
  • Country: fr
Re: General IDE to learn C++ on
« Reply #53 on: December 28, 2021, 08:27:56 pm »
Ah yes, I forgot about Dev-C++ (I thought it was dead, actually, but apparently, Embarcadero now "hosts" the project. But it's open-source and available there: https://github.com/Embarcadero/Dev-Cpp )
So, that's indeed yet another option.
 
The following users thanked this post: Ian.M

Offline IanB

  • Super Contributor
  • ***
  • Posts: 13031
  • Country: us
Re: General IDE to learn C++ on
« Reply #54 on: December 28, 2021, 09:51:04 pm »
Also, see this page: https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170

Quote
You can build C and C++ applications on the command line by using tools that are included in Visual Studio. The Microsoft C++ (MSVC) compiler toolset is also downloadable as a standalone package. You don't need to install the Visual Studio IDE if you don't plan to use it.

So, if you are really opposed to using an IDE, you can download and use the Microsoft compilers without needing to install Visual Studio.

Honestly, I do understand the annoyance of making a new project in an IDE just to run a few lines of code. The way I approach this is to make a "learning project", and then for each small example I want to test I just make a function in my project containing those few lines of code. It's pretty easy to have the main program call whichever test function I want to run.
 
The following users thanked this post: Ed.Kloonk

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18891
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: General IDE to learn C++ on
« Reply #55 on: December 28, 2021, 10:52:20 pm »
But how are you going to test your code? Step through it line by line with a debugger for example to see what is happening with the variable values. That is much easier to do on a PC based IDE than on a microcontroller. Likely Eclipse CDT and Visual Studio code offer a way easier to use workflow compare to Microchip's own IDE. Last time I had to program for a PIC processor I used Eclipse CDT instead of Microchip's own environment.

FFS read!

Lets start again for the hard of hearing (and intellect!):

while my ultimate aim is to program on a micro-controller I am following (or will when I get the time to set this up) a book with examples to use on a PC. The book recommends VS but does point out that this is 2005 (the guy had vision and knew that the book would be read years later when the IDE would be totally different and a mess). So if I try to follow the setup described notthing happens. So clearly as the author anticipated the IDE in 2005 has now changed to the point that it's more work to get the IDE to work than do the example.

Therefore I am looking for an IDE that is as simple to use as VS was in 2005 to carry out the examples as intended on a PC!

Once I have got to grips with the language yes my target will be embedded, for now I want a hassle free IDE that lets me test the code as I need at least one first little test program to work before I can figure if it's me or the IDE.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18891
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: General IDE to learn C++ on
« Reply #56 on: December 28, 2021, 10:55:48 pm »
My point was that the book recommended visual studio based on what it was in 2005, I am fairly sure that it is a bit different now in 2021. I never did get the exercise to work.

And everyone here is telling you it's still a good recommendation in 2021.  There are other options as well.  Just pick something and use it. Literally anything you pick will work for your needs.  Don't worry about "bloat." You will have to learn how the tool works but you should be able to get any tool you pick running in an afternoon.

NO IT WON'T AS IT HAS NOT!.  Clearly VS in 2021 is more complex than in 2005, I tried it and nothing happened! clearly too much going on, I need something that won't try to be too clever and just do what ID need it to, ever heard of MS writing software like that in the last decade? no me neither! I also want to use it at work and if I have to update something or log back in every 5 seconds I will drive the IT contractor up the flaming wall!
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 13031
  • Country: us
Re: General IDE to learn C++ on
« Reply #57 on: December 28, 2021, 11:28:53 pm »
Simon, you seem to be getting very agitated, but it is hard to figure out where the difficulty lies among three things:

1) Installing (just) the C++ desktop workload for Visual Studio Community
2) Getting code samples from the book to run
3) Following instructions in the book for installing Visual Studio

From your comments, it seems like you might be getting stuck on (3), but if so, do not even think about following those instructions. They will be 15 years out of date, and no longer applicable.

For item (1), if you were to go this way, you would just pick the "Desktop Development with C++" workload (see screenshot below), and nothing else. I am probably going to do this on my computer in a minute just to verify.

For item (2), this should be quite straightforward, once you have a compiler installed.

However, there is a caveat that nobody has mentioned in this thread so far. The C++ language today has evolved far beyond where it was in 2005. In 2005 we had "traditional C++" as Bjarne Stroustrup originally conceived it. Today, we have "modern C++", which has a much better, safer, and more reliable way of programming (which Bjarne Stroustrup strongly recommends).

So if you are going to learn C++, it would be best to use a modern reference, and try to use language standard C++17 or later.

The only counter to this, is for embedded programming, where vendor toolchains may not support all the features.

However: learning how to program includes learning how to obtain, install, and use development tools. You need to consider this as part of your learning exercise, and not just focus on the code examples.
« Last Edit: December 28, 2021, 11:31:05 pm by IanB »
 
The following users thanked this post: Tony_G, Lindley

Offline IanB

  • Super Contributor
  • ***
  • Posts: 13031
  • Country: us
Re: General IDE to learn C++ on
« Reply #58 on: December 28, 2021, 11:38:31 pm »
Here it goes:
 
The following users thanked this post: Tony_G

Offline IanB

  • Super Contributor
  • ***
  • Posts: 13031
  • Country: us
Re: General IDE to learn C++ on
« Reply #59 on: December 28, 2021, 11:50:03 pm »
And it's done, installed and working:
« Last Edit: December 29, 2021, 12:00:52 am by IanB »
 
The following users thanked this post: Tony_G

Offline Tony_G

  • Super Contributor
  • ***
  • Posts: 1081
  • Country: us
  • Checkout my old test gear channel (link in sig)
    • TGSoapbox
Re: General IDE to learn C++ on
« Reply #60 on: December 29, 2021, 12:25:30 am »
I think that Ian's post is pretty good start on the process of installing.

That said, Simon, I worked on the VS team for 17 years, and seeing how you're frustrated at using VS and the work you do for the forum as a moderator, I'd be more than happy to spend some time in a Zoom meeting with you to get you going in VS2021 Community Edition.

Just PM me if you'd like to give this a try.

TonyG

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: General IDE to learn C++ on
« Reply #61 on: December 29, 2021, 03:53:02 am »
I was looking at the book today. There are some other potential concerns with using a modern compiler/linker/IDE/OS with some of those code examples and exercises.

As was mentioned earlier, there is a common header file that needs to be used www.stroustrup.com/Programming/std_lib_facilities.h and that certainly is available, but could cause some issues. Maybe not though as you can see this comment "Revised August 3, 2020: a cleanup removing support for ancient compilers".

The graphics/GUI exercises and code use a tool library FLTK https://www.fltk.org/ In the book, they use "FLTK 1.1.x" and  I see you can still download 1.1.10, but I wonder if VSC22 will barf at the thought. More importantly, I wonder if modernish Windows will barf. Anybody have some thoughts on that?

I don't know, but I do know who the author is and I understand why you would want to start to learn C++ from him, but there are more modern texts available - no?
« Last Edit: December 29, 2021, 04:12:15 am by DrG »
- Invest in science - it pays big dividends. -
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11181
  • Country: fi
Re: General IDE to learn C++ on
« Reply #62 on: December 29, 2021, 11:57:21 am »
I can feel the frustration.

Do this:
Install mingw
Write hello world example.
Compile by:
g++ test.cc -o test.exe
Run:
test.exe

Take small steps. Go from there.

And despite what nctnico says, you don't absolutely need a full-fledged IDE. You might want it, you might not, it's also a personality question. I have no issue whatsoever working with a text editor and command line, but I do many other things completely opposite how nctnico claims they "must" be done, as well. I don't get frustrated at large number of errors and warnings because I don't usually write massive pieces of untested code at once. When I do, then I just work through the errors and warnings one by one, but this doesn't happen often.

But yeah, C++ has a tendency of generating 100 screenfuls of cryptic error messages on a slightest typo. I kinda understand the appeal to helper tools with such horrible language. You can still start without. I actually started with C++ as my first programming language - it was very new and trendy back then - and definitely did not have any IDE; not even alt+tab because was in MS-DOS, so it was save - exit - compile - start editor again process. That sucked, yes, but got the job done anyway.
« Last Edit: December 29, 2021, 12:02:12 pm by Siwastaja »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18891
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: General IDE to learn C++ on
« Reply #63 on: December 29, 2021, 12:02:04 pm »
The book is relatively recent but was first written a while ago so some of the text is old. This is why I suspect he noted the 2005 against the recommendation for VS. As there is now more to VS than then trying to follow setting up the IDE is not possible. I thought I had picked a console project and I don't think the option to keep the console open was there so it made the whole thing futile. My code may have run perfectly but I just never got to see it.

This is why I was thinking something a little simpler.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 18891
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: General IDE to learn C++ on
« Reply #64 on: December 29, 2021, 12:04:44 pm »

And despite what nctnico says, you don't absolutely need a full-fledged IDE. You might want it, you might not, it's also a personality question.

I do like to use colour as a way of differentiating things. I find reading block capitals hard so I prefer the colour coding of defines rather than writing them in block capitals
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: General IDE to learn C++ on
« Reply #65 on: December 29, 2021, 01:52:37 pm »
.
« Last Edit: August 19, 2022, 05:00:48 pm by emece67 »
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: General IDE to learn C++ on
« Reply #66 on: December 29, 2021, 02:29:08 pm »
I thought I had picked a console project and I don't think the option to keep the console open was there so it made the whole thing futile. My code may have run perfectly but I just never got to see it.

This is why I was thinking something a little simpler.

That is normal Windows console window programming working.

If debug mode, I make sure this is unchecked (VS19) [Tools->Options->Debugging->Automatically close the console]



But, this situation is well known and VS has advanced beyond having to use getchar() in the code to make blocking loops to keep the window open.

See here https://stackoverflow.com/questions/1775865/preventing-console-window-from-closing-on-visual-studio-c-c-console-applicatio [and a bunch of other places]


« Last Edit: December 29, 2021, 02:45:49 pm by DrG »
- Invest in science - it pays big dividends. -
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11181
  • Country: fi
Re: General IDE to learn C++ on
« Reply #67 on: December 29, 2021, 02:59:27 pm »
I do like to use colour as a way of differentiating things. I find reading block capitals hard so I prefer the colour coding of defines rather than writing them in block capitals

I also do use a text editor (gedit) which comes with decent syntax highligting. It's advanced enough to understand that #if 0 #endif is a comment, and color the text accordingly.

Between a massive bloat IDE and vi, there are many options.

In Windows, I'm pretty sure Notepad++ hits the sweet spot of being more than just primitive text editor, without being a full fledged IDE. But it's over a decade I last used it.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30155
  • Country: nl
    • NCT Developments
Re: General IDE to learn C++ on
« Reply #68 on: December 29, 2021, 03:34:44 pm »
But how are you going to test your code? Step through it line by line with a debugger for example to see what is happening with the variable values. That is much easier to do on a PC based IDE than on a microcontroller. Likely Eclipse CDT and Visual Studio code offer a way easier to use workflow compare to Microchip's own IDE. Last time I had to program for a PIC processor I used Eclipse CDT instead of Microchip's own environment.

FFS read!

Lets start again for the hard of hearing (and intellect!):

while my ultimate aim is to program on a micro-controller I am following (or will when I get the time to set this up) a book with examples to use on a PC. The book recommends VS but does point out that this is 2005 (the guy had vision and knew that the book would be read years later when the IDE would be totally different and a mess). So if I try to follow the setup described notthing happens. So clearly as the author anticipated the IDE in 2005 has now changed to the point that it's more work to get the IDE to work than do the example.

Therefore I am looking for an IDE that is as simple to use as VS was in 2005 to carry out the examples as intended on a PC!

Once I have got to grips with the language yes my target will be embedded, for now I want a hassle free IDE that lets me test the code as I need at least one first little test program to work before I can figure if it's me or the IDE.
Don't try to run before you can walk. Also don't expect a book from 15 years ago to be accurate. The C++ standard has changed in the meantime as well so some examples in the book could use constructs that throw an error instead of a warning.

To get going with Visual Studio Code:
https://code.visualstudio.com/docs/setup/windows
https://code.visualstudio.com/docs/cpp/introvideos-cpp

Found these with a website called Google.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11181
  • Country: fi
Re: General IDE to learn C++ on
« Reply #69 on: December 29, 2021, 03:43:08 pm »
Yeah, C++ has really indeed changed.

I learnt it in mid-90's. Then I learned it more in university in mid-2000's and had to use it at work around 2010. It felt like completely different language than what I originally learnt. Now if you look at the 2021 state, it's again completely different language.

It has changed both for worse, and better. Worse in the way that it's even more complex because not much is removed, only added to it. If you want to interact with other programmers, you need to understand a lot of different constructs. But better in the way that the new features can help reduce amount of boilerplate and make the language higher level.

In any case, C++ will be a massive beast for a beginner, and you can't go for arbitrarily minimal subset if you want to "know C++". For personal and practical purposes, you can of course limit to a tiny subset.

Sorry but if your biggest hurdle is that the IDE automatically closes the terminal window unless you check a checkbox in configuration, and this is enough to make you feel like giving up, I'm not sure if C++ is a good language for you. You need the endurance, because struggling is inevitable.

Some really modern examples, written to be as simple and as high level as possible, could be helpful. It's never a good idea to rely on a single book.
« Last Edit: December 29, 2021, 03:45:48 pm by Siwastaja »
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: General IDE to learn C++ on
« Reply #70 on: December 29, 2021, 04:36:13 pm »
So, I want to present a different perspective or, at least, a different context with respect to:

Quote
Sorry but if your biggest hurdle is that the IDE automatically closes the terminal window unless you check a checkbox in configuration, and this is enough to make you feel like giving up, I'm not sure if C++ is a good language for you. You need the endurance, because struggling is inevitable.

Please understand, that I harbor no hard feelings toward you (@Siwastaja) and, to the degree that I can remember, your reputation here is fine.

Nevertheless, what you say there is a bit on the “putting on airs” side. When someone starts on a road, you really do not know where they will end up and it could be in a place that is much “higher” than the place you are at – you just don’t know – even when you know, you don’t know (see reference to the movie “Let it Ride”).

I entered this thread because I am at a place with C++ not unlike the OP’s place. I don’t know C++. While I have “used” it sparingly, I don’t feel like I really know it at all, but learning it is on a very long “to-do” list. My last encounter with learning it shows here https://www.eevblog.com/forum/programming/scaling-brightness-using-pwm/msg3542942/#msg3542942 Translating some messy Arduino code/crap to a little better organized and systematic program was a good candidate for a little C++ learning.

I had the SAME issue and that was in March of this year. WTF?!! How am I going to rewrite the code when the &^@#$%ing window closes on me?! FFS, I am going backwards, not forwards, and I do have other things to do, so FTS!  Which person in this thread has not had similar ideations at some time?

So, yeah, I worked through that, but not because I went through 751,861 options in VS2019, but because I searched until I found some solutions (IOW I asked a friend, or rather eavesdropped on a conversation where someone asked a "friend" – i.e., the internet through Google.

Look at this passage in the very book in question (appendix C):

Quote
C.4 Later
The IDE has an apparent infinity of features and options. Don’t worry about
those early on — or you’ll get completely lost. If you manage to mess up a project
so that it “behaves oddly,” ask an experienced friend for help or build a new project
from scratch. Over time, slowly experiment with new features and options.

OK, maybe he was wrong in the sense that there ARE a few options you need to worry about straightaway, but the OP did ask experienced "friends" and there were plenty of responses, so that is a good thing.
- Invest in science - it pays big dividends. -
 
The following users thanked this post: Sherlock Holmes

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30155
  • Country: nl
    • NCT Developments
Re: General IDE to learn C++ on
« Reply #71 on: December 29, 2021, 04:55:49 pm »
I had the SAME issue and that was in March of this year. WTF?!! How am I going to rewrite the code when the &^@#$%ing window closes on me?! FFS, I am going backwards, not forwards, and I do have other things to do, so FTS!  Which person in this thread has not had similar ideations at some time?
Me certainly. But approaching a problem by throwing tantrums is not going to solve anything. In my experience it is better to take a break (go out for a walk or cycling) and give your brain a rest so it can process & organise the problem.

Nowadays it is super easy to find information on internet on how to achieve something. A couple of years ago I changed to a different PCB layout package. I didn't took a course because I had to get the program going before the first course dates so I used online tutorials and fora to get me going. A couple of hundred hours in I'm pretty good at using the package but I'm still learning. Yesterday I wanted to add some dimensions to a board layout for example. Google found me a video which showed me exactly how to do that.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline alexanderbrevig

  • Frequent Contributor
  • **
  • Posts: 706
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Re: General IDE to learn C++ on
« Reply #72 on: December 29, 2021, 05:03:37 pm »
You should let us help you with the issue of how to get a modern VS running your code as opposed to finding something akin to VS2005. IDEs are much much better now.

If you decide to hate VS my opinion is you have two choices: CLion and NeoVim.

Good luck!
 

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 8787
  • Country: 00
Re: General IDE to learn C++ on
« Reply #73 on: December 29, 2021, 05:25:37 pm »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 13031
  • Country: us
Re: General IDE to learn C++ on
« Reply #74 on: December 29, 2021, 05:47:42 pm »
I thought I had picked a console project and I don't think the option to keep the console open was there so it made the whole thing futile. My code may have run perfectly but I just never got to see it.

Ah, yes, this "feature" has been present in all versions of Visual Studio from the beginning, including the 2005 version. If you do a lot of debugging it does kind of make sense though.

The simplest solution is to use the "Start Without Debugging" option (the button highlighted in the screenshot below). At least this is on the toolbar by default in the latest version of VS -- in earlier versions you had to customize the toolbar to add it, or find it on the Debug menu. You can also use the keyboard shortcut, Ctrl-F5.

Part of learning to program is learning to use the tools, so you should expect to invest some time into this. It's not much different from learning to use an Oscilloscope when doing electronics.
« Last Edit: December 29, 2021, 07:28:10 pm by IanB »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf