Why does compilation on Arduino IDE take much longer than Atmel Studio?

The same code on Arduino IDE takes much longer compared to Atmel Studio 6. Why is this so? Can the speed be improved?

I'm not sure but Arduino IDE is written in java. Java programs are not native machine binaries so tend to be a little slower. Also it does some preprocessing to convert .ino files to .cpp and then compiles the .cpp with winavr or avr-gcc. I guess this preprocessing takes that extra time. My be or not, its my belief.

If you are using the latest releases, the first run will take some time (and when changing boards), however subsequent compiles should be faster. The compiler does have minimum rebuild active.

On my machine, once first compiled, it only takes literally a few seconds to build and start uploading.

You can try also adding your Arduino directory as an ignore target for antivirus's. My system grinds to a halt when it refreshes its db and scans on access.

I made an exclusion for "C:\Users\Admin\AppData\Roaming\Arduino15" which reduced the time from 6 to 4 seconds to compile for my ESP8266.

How about using a make system, parallel make and the available processing power in modern computers? That is what I am doing in Cosa and this allows me to use all the available cores and SSD bandwidth on my laptop. A simple command does the whole job; compile, link, upload and serial monitor. Run directly from inside GNU Emacs you have the most programmable, efficient, low-resource, fastest, IDE ever. And you end up writing code 10X faster than in Eclipse, Arduino IDE, etc.

$ cosa uno avanti

With a make system you can also script a lot of tasks. For Cosa I have a few build scripts to regression test all variants. The below command will rebuild all variants of the Cosa core for all supported boards for the 1.6.5-r5 release of the Arduino IDE/AVR toolchain.

$ tutto 1.6.5-r5

The following command rebuilds all variants for all supported boards and supported Arduino/AVR toolchain releases.

$ rifare tutto


How about using a make system

I actually appreciate very much that the Arduino IDE covers all that confusing make file stuff.
make file is 1 of the reasons why I never got "native" GCC working on different embedded MCU platforms :-/

I fully understand that makefiles adds complexity and would be yet another language to master. Most programmers never learn make (or dependency driven programming) and strangely they also seem to avoid it.

What I am trying to say is that it is possible to design a build system using make that does not require that the user has to write makefiles.

In the Cosa build system make is hidden. Make is just an implementation method. The example commands above do not require makefiles. All is done through a script and the default rules.

Arduino IDE build system is implemented in java. That is one of the reasons to why it is slower than other IDEs.


Arduino IDE build system is implemented in java. That is one of the reasons to why it is slower than other IDEs.

I doubt that is really a contributing factor, the GCC compiler does everything in terms of significant processing. Also the code is not interpreted like old school java, it is compiled to machine code.

The fact that everything is copied to a temp location is probably more of a time waster. Systems with low ram or bad caching settings will be using the HDD far more intensively than compiling from where the code resides. In other IDE's compiling from the source location may not even use the HDD for the top level code as it may still be in ram from when it was saved (cache write pending).

The same code on Arduino IDE takes much longer compared to Atmel Studio 6.

Can you be more specific? WHICH code takes longer? How much longer? Using what version of the Arduino IDE? Is this the first or subsequent compile of the code? Using what operating system or what sort of hardware?

As people have mentioned, Arduino does not use "make", so it tends to compile a bunch of libraries whether or not they are needed. But in spite of that, your "much longer" description does not match my actual experience. I just fired up my windows Virtual box (XP, 2G Ram, one 2.8GHz cpu), and it takes Arduino (1.6.5) about 9s to compile "Blink", while it takes Atmel Studio (6.2.1502) about 7s to compile the "MEGA LED Example for Xplained Mini 328p" (both "initial" compiles. Subsequent compiles are about 3s for both of them.)

Every once in a while, someone complains that "Arduino compiles really slowly", by which they seem to mean "minutes for a small example", but I don't think any of those people have stuck around long enough for us to get to the bottom of their problems. "MUCH slower" (say, 5x longer for a significant sketch, or 30s longer for a trivial sketch) does not appear to be something that arduino can excuse under "well, we do things a bit differently and sometimes its a bit slower", but rather "something is seriously broken with respect to this particular example, and we should figure out what!" (but WE NEED DETAILS!) (5 to 10s longer in a 30s compile is not "much longer", IMO. Although perhaps that time waiting literal minutes for "page down" to happen on the mainframe terminal has skewed my perspective...)