It’s been a while I posted something here! If I’m doing it, it’s for a very worthy reason: there are currently too many people who are wrong, who think that tabs are better than spaces, or that spaces are better than tabs… I hope I can do something about it.
Here are some recent posts on this topic:
- The current state of things: https://medium.com/@hoffa/400-000-github-repositories-1-billion-files-14-terabytes-of-code-spaces-or-tabs-7cfe0b5dd7fd#.np1l4cbth shows indentation with spaces is more popular for most programming languages.
- A pro-spaces blog focusing only on alignment and forgetting about indentation and user preferences or needs: http://javarevisited.blogspot.fr/2016/09/why-use-spaces-over-tabs-for.html
Did you happen to wonder why there are tabs and spaces and why both are still used? There is a reason beyond all that: they serve different and compatible purposes!
Tabs are not a character per se, it’s a model of indentation, which can be rendered differently according to user preferences and editors (2, 4, 8 spaces; it’s up to you. For example, I use a 2-spaces wide tab in vim for XML, and a 4-spaces wide tab for the same in Eclipse IDE).
Tabs are not meant to align, they’re meant to conceptually highlight a “level” of a line in the file. This level can be imagined as an abstract column, with a width that’s not controlled by the author of the code. Tabs are used to group a block of successive lines with the same level together and to show them as more or less “deep” than some other lines, they appear on a same column independently of the tab width.
Tabs only make sense -and are perfect- at the beginning of a line, for indentation only. Their variable width rendering make them very bad to use for spacing and formatting content inside a line.
Spaces are for alignment. There size is exactly 1 character. If you have content with same level of indentation, then you can use spaces to align pieces of code or even parts of lines together.
However, spaces suck for indentation. They cannot be set by user to something more compact or wider (some editors have hacks to render spaces with different size than one character, but that simply highlights how the idea of indenting with spaces is wrong as some want them to behave just like tabs). They obviously consume more space in storage, and may even contribute to energy consumption and global warming more than tabs do. The only argument of spaces for indentation is that code looks the same on all editors and for all user. But it’s exactly a counter-argument, as we see above, customizing indentation rendering can be useful.
But once your line of code starts, after your indentation, then spaces become the only good whitespace to use until the next line! You can use it to align code, or to make a clear separation between 2 parts of the same line.
Now, what about mixing them? A drawing become viral on Twitter on this topic highlighting that people mixing them can upset the pro-tabs or pro-spaces. Well, it’s really a pity, because you should use tabs for indentation, and spaces for alignment, even on the same line!
This is exactly the purpose of those 2 character: the first one is an abstract whitespace and rendered freely, the other is concrete and mapped to an actual and immutable width of 1 character. They can and should be used together, each one for their specific use-cases.
And those are actually the default settings of Eclipse IDE! It indents with tabs, and allows to align with spaces; and in case you already used spaces after the indentation to align you code, it just shows the same indentation and alignment if you create a new line just after.
If you consider the definition of a tab and a space, and of indentation and alignment, Eclipse IDE defaults are simply the settings that are the more natural and efficient, the best ones, rather than the most popular ones.
I’ve been invited by Benjamin Cabe to be part of the Program Committee (PC) for EclipseCon France. Benjamin told me it wouldn’t take too much time and I thought it would be something interesting. Benjamin was partly right (it does not take too much time, but it definitely takes some time), and I was totally right to think it would be a good experience.
Here are some additional thoughts and explanation about how a Program Committee works
It’s been a few week since EclipseCon ended. It’s now time for a retrospective.
First, the event was great. Although I did not have time to view that many presentations, I was able to discuss with a lot of people about a lot of topics. I learned new stuff, and shared some knowledge. I made huge steps ahead in my own work, and helped people to go ahead in their own work too. I was also able to boost some projects I like and work in making them more widely used.
So I am pretty happy of this conference. Being at EclipseCon has and will improve my daily work, that’s the best thing to expect from this kind of event.
My Top #3 favourite talks
Since I spent most of my time chatting with several people, I could only see a few presentations. I’d like to share 3 of them:
- Persona non grata by Brian Fitzpatrick.
I like this idea to bring some practices coming from marketing into software development that are aimed to get a better knowledge of what your users want. Introducing Personas seems to be a high benefit for a team, since every participant will be able to talk about these personas instead of limitating users to only a role. It helps to have a clearer idea of what their users are like and can refer easily to them in their daily work. It makes product teams think more about their users being humans and act consequently, for instance when developing UI.
- CodeRecommanders, by Marcel Bruch
CodeRecommanders won the Best Developer Tool award, this talk demonstrated why this project deserves such a recognition. It is pretty easy to set-up, use and provide immediately a boost in your code-writing productivity. Code Recommanders has analyzed most of the open-source Java code on the planet and so comes into your IDE to provide you snippets, templates, examples, pieces of advice and more, gathered from all the code it has analyzed! You can save a lot of time since you do not have to search through the web anymore: CodeRecommanders has snippets and pieces of advice for you. Always.
- How to profit from static analysis, by Elena Laskavaia
This talk explains why static analysis makes you save (a lot of!) development time and money, and how to get the highest value from it. How not to spend more than necessary in setting it up, and how to get started in making static analysis part of your strategy. Very concrete lessons and tips! Here are my 3 favorite notes:
- Detecting a bug at dev-time with static analysis costs a few seconds, detecting it at build-time costs minutes to fix it, detecting it in a satellite costs millions. (slide 5)
- JDT provides you very good static analysis, but most rules are disabled by default. So just turning these rules on will make you more productive. (slide 18)
- full JDT analysis + PMD enabled in your IDE = profit.
What I presented
This year, I had the opportunity to be a speaker for 3 talks
How to remain agile in code generation approaches?
This short presentation during Modeling Symposium explains some good practices to use in order to avoid being locked in code-generation approaches. Indeed, the indirection introduced by code generation can have some pitfalls when it comes to customizing generated code. But actually, you don’t want to customize generated code, you want to customize generated behavior. Modifying generated code is not the best solution for that, here are some more sustainable approaches:
The lesson is: consider generator config/generated code the same way you consider source code/compiled code.
Some news of GMF Tooling, at Modeling Symposium
If you read this blog, you probably know most of it.
Get ready to fight your technical debt, with Tycho, Sonar, and Jacoco
I had the opportunity to present, together with Xavier Seignard, how easy it is to integrate Tycho, Jenkins/Hudson, Sonar and Jacoco together. This provides a 1st-class build environment that makes you go from continuous integration to continuous improvement. We think code quality is now pretty easy to get, even in the Eclipse world, so we should not do without it any longer. There are now very very very (…) very powerful and easy tools for quality in the Java world. They work with a few efforts and minutes. That was the aim of this talk: showing people that they are very close to continuous improvement and giving them some keys to set it up by and for themselves.
I was able to also make some lobbying on Sonar@Eclipse.org, so that there is progress on bug 360935 ! Woot!
Things I did
EclipseCon, like any conference, is mostly a social event. It is a great opportunity to meet people you need to help you, to meet people who need your help; and to get things actually done and gone ahead.
Tycho is the masterpiece of builds for projects I work on. With JBoss Tools, we have found some bugs, we often have some new requirements and ideas for improvements. Participating in the Tycho BOF was a great opportunity to chat with the other guys doing/using Tycho and to highlight some issues that are important to us. It’s worked and we are now pleased to see and provide “quality patches”, as Igor likes to say.
The Eclipse foundation is making an effort to improve the “Common Build Infrastructure”. The goal is to provide an efficient and easy-to-use build environment for Eclipse projects. This is something very interesting for Eclipse.org projects, but also for consumers such as JBoss Tools, since we have ideas on making Eclipse projects easier to consume. So that’s something we follow closely and we are happy to see all these efforts carried out to push Tycho and Jenkins usage for all Eclipse.org projects!
Let’s hope CBI will also address issues regarding p2 repository governance (lifecycle, availability, URL conventions…). As I am writing, a bug has just opened on this topic. Coincidence or esoterism?
I could see the presentation by Andres Alvarez Mattos and Ruben De Dios during Modeling Symposium. These guys made a very nice editor for GMF Tooling models that allows you to create a diagram editor graphically. It is not intrusive and is a much more efficient way to get started with GMF Tooling than the current approach based on models and tree editors. This editor simply looks like a renewal of GMF Tooling.
I helped them to get some of their patches applied into GMF Tooling code. I hope I’ll be able to nominate them as committers soon, since their editor would make a lot of sense in GMF Tooling.
That was a busy EclipseCon! But I enjoyed it! Some things got done, some can now be done, and some others will be done soon. There are some concrete results and some new opportunities, it’s everything I expected!
I don’t know if you know it, but I love Jacoco. Jacoco is a very neat and easy to use coverage tool. You can easily use it with existing Java applications, it is just about giving a -javaagent to your JVM parameters. It is so easy to have coverage reports as it is to increase a PermSize.
Everybody loves Jacoco. Those who don’t love it yet simply need to give it a try to get convinced Jacoco in the only good tool for code coverage.
We did enable Jacoco for our our Tycho-based builds of JBoss Tools and JBoss Developer Studio components thanks to its Maven plugin, so we get some very nice jacoco.exec files that developer can import into their Eclipse workspace thanks to EclEmma. Then developers can see how their tests cover their code. That’s very nice.
But I think that measuring unit test coverage is not the best thing we can do with Jacoco. Since it is just about a simple argument to the Java command-line, we can think of… Enabling Jacoco by default on real execution of Java applications to track real usage and deduce which pieces of code are really used! This is pretty easy to do, and the effect on performances is low enough to be acceptable in a lot of cases, especially on desktop applications.
Knowing which pieces of your software are critical in production, and which ones are useless and should get removed is a priceless information that for sure helps you in making your software better. That’s a topic we are working on for JBoss Tools and JBoss Developer Studio, and we got some ideas on how to make it real and already have ideas of improvements to have a better control over Jacoco.
Stay tuned. soon all Java applications will use Jacoco!
That’s now a few weeks since I joined the JBoss Tools and JBoss Developer Studio team and started working on build. JBoss Tools is a HUGE amount of code, with about 35 components (or modules in Maven terminology) that are aggregated in a way that can be compared to the Eclipse release train, and that all use a “Common Build Infrastructure” based on Maven/Tycho to perform build and Jenkins to trigger it.
There are a lot of improvements in the pipe for Nick and myself to make build more and more agile, and to make it produce more and more interesting results. I feel very interested in going a step ahead of continuous integration, and open the road towards continuous improvement, automating QA to get reports about static analysis and code coverage on each build. I bet it will help developers to avoid mistakes and improve there code. (Advertising: You can learn more on this topic during next EclipseCon ).
Here are some of these topics that are worth this blog post:
QA with Sonar
About static analysis, my choice fully goes to Sonar, a webapp that provides a dashboard aggregating reports from several QA “services” (Findbugs, Checkstyle, Test reports, coverage…). Sonar provides nice integration with Maven and Jenkins & Hudson, and getting the whole working together is about a few minutes of configuration. The return on investment when setting up Sonar is very high and immediate. In my humble opinion Sonar is a must-have nowadays.
So, there are 2 bugs I encourage you to look at/vote for, in order to leverage Sonar, QA and continuous improvements in your favourite projects:
- @Eclipse.org : Set up a Sonar instance of Eclipse projects
- @JBoss.org: Set up Sonar for JBoss Tools (and more JBoss stuff?)
Jacoco, without Sonar
Jacoco is a very easy-to-set-up code coverage tool, with a very convenient Maven integration. With Jacoco, there is no need for instrumentation step to get coverage results, all is about giving a -java.agent=jacocoagent.jar property to your JVM. While using it, I did not detect any effect on performances. That’s pretty cool.
The current issue for Jacoco adoption is the reporting. Here are the known ways to analyse reports from a Jacoco coverage output file (aka jacoco.exec):
- Use the Jacoco Ant task to generate HTML reports
- Use the Jacoco maven:site integration to generate reports as part of maven:site
- Une EclEmma plugin to analyse Jacoco reports in your IDE
- Use Sonar
As a fan of Sonar, I think the Sonar-based approach is the best one. But both previous bugs show something clear: despite of my full enthusiasm for Sonar, community-wide infrastructures such as Eclipse.org or JBoss.org cannot set up a Sonar instance immediately. I guess this is because of issues with credentials, or hardware, or IT stuff. So we need to be able to consume Jacoco reports without Sonar.
The issues with all these approaches is that it introduces the need for a new build step or a new developer tool to analyze reports. The main dashboard for JBoss.org builds in Jenkins (and Hudson for Eclipse.org), then the ideal place for such reports would be a Jenkins plugin for Jacoco. Unfortunately this does not existt (yet), but a Jenkins issue is open for this. Now that I have lost some optimism in getting Sonar available for Eclipse.org or JBoss.org community quickly (as an impatient guy, quickly means today), this Jacoco Jenkins is now my #1 wish in the whole Java software world. Although setting up Jacoco for execution is very easy, setting up integrated reporting is still almost a blocking point for adoption.
So please, vote for this bug!!! iJacoco Jenkins plugin
Some other stuff
Since I’m writing here a wish list, I’d also like to share with you thib Jenkins issue I opened: Add an option to select Build status when no Test is found. The idea is simple: Even if no-one should never do that, it happens that we need to run a Jenkins build with skipped tests. Ok, it’s bad, but it happens. In such case, the fileset for Test results in Jenkins JUnit plugin does not match any existing report, and then build turn to FAILED/Red. When you have cascading of jubs, this is pretty annoying, since you’d rather see this build UNSTABLE/Yellow -my favourite- or SUCCESS/Blue. So this issue simply requests the ability to change the result of plugin when no test is found.
If you find this useful, you can vote for it.
Today is my last day working for PetalsLink.
Working for PetalsLink was a quite interesting experience:
On the technical side, I enjoyed moving all the XML-based tooling of PetalsStudio to a more powerful EMF-based approach for Petals JBI editor – for those who don’t know JBI, it is a standard that allows to define SOA artifacts in your ESB. Moving to EMF allowed us to provide better tooling faster, because most of the complexity in manipulating JBI can be removed with very few efforts leveraging EMF ExtendedMetaData. That was the first time I faced this part of EMF, and I got pretty impressed of how well it works (working with EMF always gives this impression of “being well”). I also improved the ability to plug new JBI components into the Studio, which is a critical point when you have to deal with connectors for almost everything – Mail, SFTP, Talend, XSLT…. So that was an interesting challenge in term of conception and development.
Petals Studio was also the pretext to start using Git, GitHub and Sonar. I am pretty happy to have learnt these 3 tools that clearly improved the way I work.
Also, I had the great opportunity to work closely to several Eclipse projects:
- I could contribute the Tycho build of GMF Tooling, put it on Hudson, get source moved to Git/mirrored to GitHub, improve wiki… GMF Tooling is a project I’ve used for 3 years now and I often saw in it some critical organization points to improve to make it more dynamic in term of development. Working at PetalsLink gave me the opportunity to do what I think was necessary to keep the project healthy. With the help of Michael Golubev, I now think this was an real success.
- I could contribute to Nebula the TreeMapper widget, which will probably have some very interesting use-cases soon. As I became a committer, I also helped in improving Tycho build and CI, nad it seems like the project liked it if we look at the new p2 update-sites.
- I contributed some small improvements to Eclipse BPEL designer, tried (unsuccessfully) to make SWTBot use Tycho, and developed a useful extension for Draw2d.
The only thing I wish I would be able to do here is to push ahead the usage of Sonar at Eclipse, at least for GMF Tooling and Nebula.
But I probably learnt even more things from PetalsLink by discovering another company organisation that is very different from what I could experiment before (OpenWide and BonitaSoft): PetalsLink is focused on the Research about SOA and agility of Systems of Information. It is a wide topic! Petals products are quite good compared to other alternatives in the SOA landscape, but they don’t meet the success they deserve, it was a bit frustrating for a developer.
I enjoyed working for PetalsLink, all the expectations are fulfilled, so it is time for me to go ahead, to find a new experience, a new team, new challenges, new issues… I love discovering new things!
I’ll have the opportunity to work with a great team! My main occupation for the next monthes will be to assist Nick Boldt in making JBoss Tools CI and build infrastructure better and better. I’d also like to open the road towards efficient QA for JBoss Tools, including -among other- usage of Jacoco and Sonar. Then I’ll also work on developing nice stuff for some JBoss Tools modules, most probably on the SOA/BPM part.
That’s gonna be a lot of fun! I’m eager to be tomorrow and actually get started for this new team/employer/project/product/users.
Let’s keep in touch via this blog and twitter 😉