C/C++ and the codeblocks IDE - Page 1
Forum section: electronics / general

author: ampdoctor
author_rank: Frequent Contributor
timestamp: November 12, 2014, 02:56:27 am
content: It's been forever and a day since I've done any embedded work let alone any other sort of programming with the exception of some basic PHP and javascript for a few websites I've helped out with. In light of this I have a three part question that hopefully won't stir up too much controversy.First, I've seen a few people mentioning recently that C as a programming language has become a bit old and outdated. So the question here is what are these people using and what would be considered THE language to get proficient in while looking a few 5 or so years down the road, assuming they're not just talking out their backsides?Second question, that relates somewhat to the first is if you were to want to get good at a language would you go hard at C++ or C and why? I ask this because in a recent job interview the hiring team seemed to be very interested in people that could work comfortably in C++, and as languages go they don't seem to be much different.Finally, yesterday I downloaded a copy of the codeblocks compiler/IDE and it seems fairly decent at first blush with support for both ARM and AVR processors as well as matlab. I know IDE's are a hotly debated area, but I'd like some subjective as well as objective opinions on it just the same.

author: briselec
author_rank: Regular Contributor
timestamp: November 12, 2014, 03:42:18 am
content: I've been using codeblocks for about a year and quite happy with it. Tried eclipse first and didn't like it.I prefer C. Never been much of a fan of C++ for embedded work.

author: Bored@Work
author_rank: Super Contributor
timestamp: November 12, 2014, 06:36:16 am
content: Many people are running around claiming C is dead, trying to push the hype-of-the month programming language instead. Still C is the most popular programming language. Not only for embedded work, but for all programming work. And it has been #1 or #2 for at least the last decade. It changed place only with Java a few times.Java is currently second (so much for "no one uses Java" and "Java is dead"), Objective-C is third (that's almost exclusively thanks to Apple), C++ is forth.I consider C++ for low-level embedded work rather pointless. That is especially for what is called a free standing environment - one where you don't have a big fat operating system at hand. You can't harvest the full power of C++ in such an environment, and boy, does it have some power.C++, when fully used, is much different than C, although the syntax is similar, the concept's aren't. You can of course ignore most of the C++ features and just code as if you are using C. But what is the point of using C++ then if you treat it like C? However, that is what you often see when people use C++ for embedded work, they use it like C with some syntactic sugar.It already starts with the basic libraries. You hardly see C++ libraries like a working STL implementation for your microcontroller, esp. not for 8-bit one*. Or a half decent streams implementation. Instead people use the classic C libraries with C++.You also don't see people using object-orientation in embedded C++ code. With that I mean really applying the OO concepts and having an object-oriented program architecture. There is more to OO than grouping things together in a random class here and there.Regarding IDEs. Unfortunately it has become common for programming shops to "standardize" on an IDE, instead of letting people chose their editor and environment according to their individual preference. Standardize on the protocols, not the tools.What people also miss is that being able to use a particular IDE is really not a great achievement. You manage to use a tool of your trade? Wow - not. But what separates the boy from the men is if people manage to tame their preferred IDE to do what it should do. I have seen many fanboys of particular IDEs who couldn't for the life of them change a compiler option in the IDE. Because they didn't know where that stuff was buried in their IDE and they have no clue about the meanings of the compiler options. Or, one of the most annoying things, people not being able to adjust the space/tab expansion and substitution behavior.So, if you to crown a particular IDE as THE ONE AND ONLY IDE, spend at least some time to learn that thing, dammit.* Despite what some fanboys claim, 8-bit microcontrollers are also not dead.

author: dannyf
author_rank: Super Contributor
timestamp: November 12, 2014, 11:58:56 am
content: QuoteSome form of graphics driven, library based coding approach is likely the future as mcus get more and more powerful and the software side of the cost equation becomes more significant.QuoteRight now, an embedded C programmer is far more marketable than an embedded C++ programmer, although it is hard to find a C++ programmer who isn't familiar with C.QuoteI have been using CB for a long time now (10 years?). Love it for its utilitarian approach, and its small size, and its flexibility (via plugins). It is however quite limited when it comes to debugging, particularly for embedded projects.For larger projects, I use programmer's editors, like SI, or NP+, or Sublime - the ability to see across your modules and analyze the code at source levels (SI wins hands down there) is critical to me.

author: mikerj
author_rank: Super Contributor
timestamp: November 12, 2014, 03:15:14 pm
content: Quote from: briselec on November 12, 2014, 03:42:18 amHave you found any issues with the CodeBlocks editor? I find that when I'm cutting and pasting lines of code, I very often end up with random bits of code pasted throughout the module.

author: tggzzz
author_rank: Super Contributor
timestamp: November 12, 2014, 04:03:23 pm
content: Which language? It completely depends on the application domain. Use a language inappropriate for the application domain and you are wasting everybody's time and money.Apart from that, the language is often chosen on the basis of other criteria, e.g. what does the company/team already know, or what language are the library componsnets written in.

author: ehughes
author_rank: Frequent Contributor
timestamp: November 12, 2014, 04:43:02 pm
content: Anyone who was C is dated or going away does not do *any* embedded programming:Page 20:http://images.content.ubmtechelectronics.com/Web/UBMTechElectronics/%7Ba7a91f0e-87c0-4a6d-b861-d4147707f831%7D_2013EmbeddedMarketStudyb.pdfJava, etc has NEVER been anywhere near a position in embedded systems to take over C.All of the other languages below qssembly are on "embedded systems" that are essentially PC's in a box.If you do "real" embedded (not a PC in a box), you need to know C. There is no way around it. It is not going away because there is a new scripting,functional,magical,etc. language popular among the web programming and linux geeks that live in their parent's basement.C is well understood with a long history of proven tools. It is the only language you can currently write safety certifiable code to. (I.E. MISRA). (C++ is close but not widely adopted as you have to strip out virtually every feature of C++ to be compliant)For getting started, think of a project you want to do, pick a random board (Freescale FRDM, NXP LPC XPresso are very inexpensive) and just use the tools they give you. Worrying about the IDE is somewhat pointless. Worrying that something is not available on Linux is also pointless.Every compiler, IDE does exactly the same thing. Learn the C build process and you be able to move to any other platform. For example LPCXpresso with NXP is just eclipse + GCC + a debugger. If you learn that it is not hard to move to anything else. IF you know C, you can move to anything and make it work.That being said, there is a lot of convergence on all of the vendors to use eclipse. If you have real money ($5k) you purchase the Keil or IAR tools. (They are the dominate tools in the professional world) but for the rest it is generally GCC + some front end (which tends to be eclipse).Use whatever gets the job done. Stick with the project even when you get frustrated. After a bit you will find that it not that bad.Stay away from Arduino if you every want to do something beyond LED blink programs and simple demos. I have now been on 3 design reviews for external clients who thought they could take an Arduino and make it into a product. They hired embedded "consultants" who promised them the world with an Arduino only to find that it simply is not for product development and they were left with a half working mess that has no transition path to manufacture.99% of real world embedded development means you start with project specs, pick a CPU from your existing toolbox (or find a new one), acquiring dev board for said CPU and moving forward (start writing firmware, work on PCBs, etc).Some Starter Videos, projects if you are interestedBare metal bring up with the FRDM-KL25Z ($13 board):https://community.freescale.com/docs/DOC-93960https://community.freescale.com/docs/DOC-95170Some projects that use FRDM but are more focused on DSP. Intended for just out of college students who have never coded any DSP, etc who need something a little more advanced than an LED blinker to get started.https://community.freescale.com/docs/DOC-99621In the end , find an interesting project, find a board (really doesn't matter which brand, etc) and start figuring it out.

author: dannyf
author_rank: Super Contributor
timestamp: November 12, 2014, 07:44:28 pm
content: The OP's question is more forward looking ("what will be the language of the future?"), and your answer is present-focused ("what is the language of now?").QuoteDepending on how you define the market (or "mcu", or "embedded systems"). I don't know the specific size but if you count phones / phone apps or tv settop boxes / certain wearables, it wouldn't surprise me that Java or non-C languages have a significant market share.and I would further assert that if you wait long enough, you will witness the certain death of any language, C included.

author: briselec
author_rank: Regular Contributor
timestamp: November 12, 2014, 09:34:20 pm
content: Quote from: mikerj on November 12, 2014, 03:15:14 pmNo, I've never had that happen. I'm still using version 12.11 with the code completion plugin disabled because it doesn't play well with Linux. They were doing a complete rewrite of that plugin so it may be fixed in the latest version.

author: ampdoctor
author_rank: Frequent Contributor
timestamp: November 13, 2014, 02:18:11 am
content: Thanks, lots of really good info here!Where I'm at right now is just using codeblocks to write and compile some basic command line executables to get a feel for the language and syntax. I plan on taking an hour or so a night and working my way though the tutorial found here...http://www.tutorialspoint.com/cprogramming/index.htmWhile I don't expect it to make me an expert programmer, I'm just using it to ease the transition a bit and get my general coding chops back up to speed. Cleaning up some php code or writing a few custom CMS sites doesn't really count in my opinion.I've looked at several dev boards and environments and the ST dev boards from mikroelektronika and the avr dragon seem to be the best contenders for entry level experimental programming. Sure I could just get a pickit or an avrisp connected to an mcu on a breadboard a little cheaper, the lure of one stop shopping with a bundled "kit" seems hard to pass up.Whatever avenue I wind up taking, 20 years of hardware only systems design and maintenance isn't going to cut it in 2015!

author: Bored@Work
author_rank: Super Contributor
timestamp: November 13, 2014, 05:51:24 am
content: Quote from: ampdoctor on November 13, 2014, 02:18:11 amWell, the mikroelektronika stuff is more for posing. ST has a good collection of their own dev and eval boards. They call them Discovery kits. They are dirt-cheap and have a programmer on board (maybe even a debugger, I forgot). Typically around $20.QuoteThe dragon is only a programmer/debugger. And a bad one that is. Cheap compared to other Atmel programmer/debugger offerings from Atmel, but prone to beak down, and not even compatible with all of Atmel's controllers.On the other hand, Atmel has cheap dev and eval boards. The all have "xplained" in their name. Most have a programmer, often even a debugger, on board. From $10 to $30.

author: mtdoc
author_rank: Super Contributor
timestamp: November 13, 2014, 06:51:01 am
content: Quote from: ampdoctor on November 13, 2014, 02:18:11 amThat actually looks like a pretty cool website for learning beginning C.... But in pink! Really?If you're interested in learning C for embedded projects, I can highly recommend the free online embedded programming MOOC from University of Texas. Next session will start up in January at edXHERE

author: Jeroen3
author_rank: Super Contributor
timestamp: November 13, 2014, 07:18:33 am
content: For running C or C++ on the pc I use Qt. It offers plain C/C++ and Qt library with extensive gui options (where you'd use boost for if you're using codeblocks with compiler)And one major advantage is that there is no hassle with compilers, on any platform. Manually setting up a toolchain is not something I enjoy.I've worked with codeblocks, it seemed like a minimalistic and outdated ide. But that might just be what you're looking for.

author: dannyf
author_rank: Super Contributor
timestamp: November 13, 2014, 11:50:00 am
content: QuoteI would encourage you to take a look at the ST discovery boards, as well as the Nucleo boards. Both offer incredible value for the money, and are ready to go / all-in-one boards. The Nucleo has the added advantage of offering arduino connectors so lots of cheap shields to use.I use CoIDE myself and have no complaint about it.The dragon was a versatile board for its time but it offers too little for the money in today's market.

author: ampdoctor
author_rank: Frequent Contributor
timestamp: November 14, 2014, 06:15:37 am
content: QuoteIt's not bad for getting up to speed but it would probably be useless if you've got no programming experience whatsoever. WRT the edX course, I noticed that and was considering it but life for the foreseeable future is a bit hectic and unpredictable which puts me into the get a board and start mucking about in your free time camp.Quote from: Jeroen3 on November 13, 2014, 07:18:33 amI'm not really looking for a compiler to build windows apps, though I may get that hair up at some point. For now I just wanted something that I can practice the basics and build some kind of executable to see the result without a lot of clutter. If I can get hex and makefiles as well then all the better.Quote from: dannyf on November 13, 2014, 11:50:00 amThe number of development boards from all the mfg's give you a crazy number of options. However, it seems most of them are aimed squarely at the ARM cortex chips. Since I'm pretty green at this point I'm leaning more toward the Atmel AVR mcu's, not because they're in any way better but rather that it's quite popular with the hackers/makers so there's a lot of resources available for dicking around. I'd also like to have the flexibility of being able to pull the chip and use it in actual projects and not be married to a specific dev board. Having said that, I'm almost tempted to order up an el cheapo isp from adafruit and get a copy of avrdude then just have at it with a breadboard and some junk box parts.

author: westfw
author_rank: Super Contributor
timestamp: November 14, 2014, 07:23:30 am
content: QuoteYou can hardly go off looking for "the next big thing" in programming languages, and then say you'd rather use a CPU architecture from two decades ago... Not that the AVR isn't a pretty good chip, as long as you don't exceed 64k or so of memory space. But "C" it will be (including "primitive" C++ bits and pieces, which I actually think can be a good thing (but don't expect your AVR embedded C++ programs to look much like the C++ they teach you for desktops.)

author: Unknown
author_rank: Unknown
timestamp: November 15, 2014, 12:40:43 pm
content: I use codeblocks and C with a custom build script for my embedded stuff; once you understand pointers in C you're ready to take on any language!