Hi, I'm Jonathan Boccara. I am a senior software engineer in a tech company and I blog on Fluent C++ about writing clean code. Ask Me Anything!

Jonathan Boccara
Feb 11, 2018


I'm Jonathan Boccara. My job consists of writing and maintaining code in a large C++ codebase in a software company (Murex).

What I strive for is writing expressive code, that is, code where you understand the intent of the person that wrote it. I think this is the most important characterstic of a piece of code to survive over time.

There are plenty of ways to make code expressive, and I blog extensively about them on Fluent C++.

Ask me anything on:

  • writing expressive code
  • writing expressive code specifically in C++
  • keeping your spirits up when facing not expressive code

...and I'll do my best to answer! :)

joboc says:

This AMA will end Feb 18, 2018 11AM EST

What is the Vibe of this AMA? What is AMA Vibe?

This AMA has finished, no more comments and questions can be posted and votes submitted to those. Check other similar AMAs here or host your own AMA!

Conversation (90)

In three easy steps and under a minute you could be hosting your own AMA. Join our passionate community of AMA hosts and schedule your own AMA today.

Let's get started!

Do they teach C++ in school? What’s the best college course to get for those who want to learn about this?

Feb 18, 12:03AM EST0

You mentioned you never worked as a freelancer; would you consider doing so in the future?

Feb 17, 10:09PM EST0

What separates a great programmer from a good programmer?

Feb 16, 5:29PM EST0

Do you choose the clients you work with? Is there a particular niche you're most comfortable with?

Feb 14, 5:53AM EST0

I personally don't, because I work for a fairly large sofware company, that has their clients. But I'd imagine that some developers, in particular freelancers and consultants, must have more flexibility in choosing their clients. Although I hear freelancers that tell me that sometimes clients are too scarce to be picky.

Last edited @ Feb 16, 9:58AM EST.
Feb 15, 3:31PM EST0

Do you think a functional programming style enables you to write more expressive code than an imperative style?

Feb 14, 5:20AM EST0

I think that functional programming style allows to write more expressive code than an imperative style when it comes to code that performs computation. And by computation, I don't only mean maths, I also mean all the logic of a program (generating objects, comparing collections, ...).Functional programming style has the big advantage of guaranteeing side effects on objects. This makes the code easier to understand, hence more expressive, because you don't have to perform those side effects mentally to follow along.

However, I think that to perform operations, imperative style is more straightforward. By performing operations in include side effecs on the outside of the application, such as producing an output of the program (writing in a file, a DB, a UI), but I also include side effects on objects in code. For example, you have an object that is built by several functions:X myObject;changeThisToTheObject(myObject);activateThatInTheObject(myObject);in particular if various contexts would call various combinations of those funcitons.Those side effects are local to one variable, I find they are OK to follow, and they have the advantage of being straight to the point.

Now there are other coding styles as well. I've attended a talk of Anjana Vakil where she classifies programming paradigms in 4 categories: imperative, object, functional and declarative.

Take the object oriented style for example. Is object better than imperative or functional? Is it optimal that all the codeline consists in object exclusively?

It's funny how the periods of computer science history have had different views over those paradigms. In an (excellent) article of James Noble called Argument and Results, the author calls routines "protocols" and says that "a program's protocols are the glue that binds its objects together". It was written in 1997, when the world was object-centric.

Today, the Haskell language which is purely functional and has no notion of objects is increasingly growing in popularity. So much so that some universities I know ask of their students to hand in some of their assignments in Haskell. This is another extreme where the way of thinking revolves around functions.

So which one of object or functional is better?

I've had the opportunity to chat with Michael Feathers about this. His view on the topic sounded very sensible to me: a good design is to structure the code with objects, but to implement the methods of the objects by following the functional programming style.

Also, on the other way round, I think that objects can be used inside of reasonably functional code for two purposes:- lumping several functions into one entity (the object) that you can pass around in code. Even is this object has no mutable state or no state at all.- encapsulating a local state that would otherwise spill over into your calling code (such as mutable curried object, on which I'm preparing on article).

Now how about declarative style?

By declarative I mean code where you merely state your intentions of the desired behaviour rather than how to how to implement the desired behaviour. At this stage this seems very attractive to me, but technically hard to achieve in a lot of cases. One way is to design a declarative interface to which you can state your intentions, and an implementation behind which contains the nuts and cogs. But both parts represent some challenge.

This is a wide topic, very opinionated, and I'd love to hear more opinions on it. Yours would be welcome :)

Feb 15, 1:04PM EST0

Do coders get paid a lot of money? Is it better to get hired by a company or to just work as a freelancer money-wise?

Feb 13, 11:50PM EST0

Salaries can vary greatly. Typically it depends on the sector. The video games industry has the reputation of being tough and having not very attractive wages. On the other hands, some companies, like Think-Cell, openly display attractive salaries for their employees.

As for freelancer VS employee, I'm afraid I couldn't tell as I have never worked as a freelancer.

Feb 14, 12:47PM EST0

Does a coder’s job ever get boring especially since you deal with a whole lot of codes (obviously)?

Feb 12, 8:22PM EST0

Not necessarily. Coding is something developers choose typically because they love it. A lot of them also do some in their spare time.

It's been over 6 years (not counting the time where it used to be just a hobby) I've done coding pretty much every day and I still love it! :)

Feb 13, 5:00PM EST0

In layman’s terms or in ways a totally clueless person can understand, what does C++ coding mean?

Feb 12, 7:58PM EST0

Hi Pimark,

Imagine that you're sitting in front of a piece of sofware, say Microsoft Excel or Microsoft Word. You, as a human, do things on the computer, such as clicking with your mouse on buttons, and typings letters on your keyboard.

While doing this, you can see the piece of sofware reacting to your actions. How does the software know what to do when you click somewhere or type something?

To do this, programmers write instructions for the software. Something like "if the user clicks on the little button with a B on it, then write in bold the following letters that they will type".

The programmer needs a way to express those instructions in the software. The problem is that a computer only works with electricity flowing through its components, and you can't talk to it to give it instructions.

Here comes the code. The code is a way to express instructions to the computer, that is not plain English like the sentence I've written above, nor pure instructions about flowing electricity. It's something in between. It is written with basic words in a very structured way. And the computer has a mapping from those words to electricity.

Those words consistute a language. And, just like for communicating between humans there are many different languages, in software engineering there is also plenty of languages to express instructions to a computer. C++ is one of them.

Last edited @ Feb 13, 5:24AM EST.
Feb 13, 5:24AM EST0

What’s the most difficult or challenging part about your job?

Feb 12, 10:08AM EST0

Meetings? haha

More seriously, I think the most difficult part is when I need to make a fix on a piece of code that has been written long ago and that has badly evolved. In this case it is hard to be sure the additional fix I'm making is not in fact adding the general mess of this piece of code, and that it won't break anything.

Feb 13, 5:05PM EST0

Hi, i love C++ coding , but i dont know how it's working , on live projects

i am Asp.Net developer ( Intermediate) ,

so i would like to more about C++ coding and also would like to learn !!

Feb 11, 11:01PM EST0

Hi Nizam,

If you want to see what the language looks like, I hear that LearnCpp.com is a good reference.

Now if you want to know more about how C++ projects look like in real projects, I suggest you have informal conversations with C++ developers. And the place where you can meet them face to face is at meetups! If by any chance you're in Paris, we can chat about C++ in real projects and I'll be glad to answer your questions. Otherwise you can walk up to pretty much anyone at the food break in a meetup of your city and ask them any question about their daily life!

If you have a more specific question about C++ on real projects, you're welcome can ask it to me here, but for this general feeling you want to get, the most efficient is probably a face to face casual chat with C++ developers.

Feb 12, 1:17PM EST0

cuz of most of awesome softwares and games are all writtern in C++, just curious about it , yeah i am interested ,

i am not in paris , i live , Bangalore, India

Feb 12, 2:02PM EST0

I dont understand perfect forwarding. Any reference or help is appreciated. 

Feb 11, 2:31PM EST0

Hi Madhusudan,

I suggest you have a look at this article. It explains lvalues, rvalues and their references, and conludes with perfect forwarding in template code.

Hope that helps.

Last edited @ Feb 11, 3:32PM EST.
Feb 11, 3:32PM EST0

What is « expressive code »?

Feb 11, 12:39PM EST0

Hi Edith,

By expressive code, I mean code that tells something to its reader, code that is written and structured in such a way that it is fast and effortless to understand it.

Hope that makes sense.

Feb 11, 12:53PM EST1

In your large code base, how is the code logically separated to prevent small changes in especially header files causing a full recompile? Some ways I can think of to do this in C++ are forward declarations and pimpl classes. What other ways do you know of?

Feb 11, 10:48AM EST1

Yes forward declaration is the most direct, pimpl takes over in some cases but has its drawbacks.

Apart from that, I can think of template explicit instantiation, to avoid putting the body of template functions in headers (if you're not sure what I mean by template explicit instantiation, have a look at the section called "Explicit instantiation" in this article)

Other than that, a simple guideline is not to fit too many classes into a header file, to avoid recompiling the clients of another interface that shares the header but that you didn't modify.

Last edited @ Feb 11, 10:58AM EST.
Feb 11, 10:57AM EST1

At what age, you started writing the code? What is the ideal age to start according to you?

Feb 11, 9:59AM EST0

Hey Keith,

I must have written my first line of code when I was 13. But it's just because I hadn't been exposed to programming before, and I wish I had encountered programming earlier. I suppose that a kid of 10 or 12 must be able to understand?

That said, I was exposed to creativity before that, because my parents made me pick a musical instrument when I was 6 or something, and I'm very grateful to them for this. I think that giving kids a hobby when they're very young, like 5 ot 6 is a good thing for them, because it shows them that there is something else that school in life, stimulates their creativity, and gives them the desire to focus on stuff. This mindset fits well with programming I think, even it the code itself comes only a few years later.

Last edited @ Feb 11, 10:09AM EST.
Feb 11, 10:06AM EST1

How competitive is the coding field today? Is it difficult to get jobs? What are the best paid coding jobs?

Feb 11, 9:44AM EST0

I can only speak for the C++ market in Paris because that's where I am, and it is clearly in favor of applicants. There is much more demand than good profiles, so if you have good skills, there is no reason why you wouldn't find a job (and if you're interested by a C++ job in Paris, get in touch with me).

As for salaries, I have little info apart those in Murex where I work for, and the opinions on Glassdoor concur to say that they pay good salaries. That said, I'm sure that other places can give you a good pay as well, and for that you can look up specific companies on open websites such as Glassdoor to see where they stand.

Feb 11, 9:59AM EST2

How to go about learning C++ when you are coming from languages like Java/C# ? advise ? tips ?

Last edited @ Feb 11, 9:10AM EST.
Feb 11, 9:08AM EST1

Hi Vishy,

I'd say focus on the specific concepts of C++, in order to get into its mindset. This is how you will write idiomatic code and make the most out of the language.

Here are examples of such concepts that would be beneficial to get familiar with:

-RAII (check Fluent C++ on Tuesday where I will release an in-depth article about RAII). This is important to master because it illustrates well how C++ deals with memory.

- smart pointers, that go hand in hand with RAII, and save the trouble of managing dynamically allocated memory.

-The STL: this is the part of the standard library that deals with collections.

- When you're feeling comfortable with the language, have a look at templates. From what I hear of generics in Java, they have little in common.

- Exception safety. This also goes hand in hand with RAII but it's a little more advanced. So check this when you're already confortable with the language too.

Also, I suggest that you read the classical books of Scott Meyers, at the very least Effective C++. This book is not difficult but allows you to know what you're doing when coding in C++.

Feb 11, 9:24AM EST2

What is the best way to create/destroy a template class which may work well for different data structures? 

Feb 11, 8:40AM EST1

For performance it is more efficient to create data structures that are stored contiguously, for cache-friendliness (see the answer I gave to Mwangi on the question "how often do you find yourself using std::list in place of something like a vector container").

For an array (like std::vector) it goes without saying. But the thing is, this can also apply to more complex data structures.

Take maps or sets for example. They are typically represented as trees intenally. But you can get almost the same interface by representing them as a sorted vector. And this brings the performance advantage of contiguous data structures. For more about the performance of flatmaps, you can refer to Björn Fahller's article Performance of flat maps.

I hope this answers your question. If it doesn't, please let me know in another question.

Feb 11, 8:56AM EST1

How do you keep yourself motivated?

With big c++ codebase, the job is more often than not to fix issues. There's very few new development and it is often the backbone that makes everything else work, so you never really see the "end" of a project.

Feb 11, 8:24AM EST1

Hi Sebastien!

Here are a few things that keep me motivated:

- I try to learn continuously, even from bad code when I encounter it. For more about that, see the section 3) of answer to Babou's question "What are the important traits of a good code writer?" on this AMA.

- I don't mind fixing bugs, I see them as puzzles. Also, bugs give you the opportunity to explore an application and codeline, on a restricted scope.Also, in my team we have a target to fix a certain number of bugs by unit of time (N bugs by week, or N bugs every two weeks). And this makes it look like a reachable objective which is very motivating. A bit like gamification. Over time, this makes us fix a lot of bugs without it seeming too daunting.

- Not seeing the end of a development can be demotivating indeed. Chunking it up in small sub-development, tasks that could be as small as a day or half a day, also make it seem less daunting. And with this, you get the satisfaction of feeling you're making progress.

- I interact with people. I do blogging, dailies, I get involved in meetups. Interacting with people makes you realize that everyone has the same problems, and you're far from being in the worst situation. It gives you an opportunity to learn and help other developers, which is a different sort of motivation.

- I explore code techniques whenever I can. Even when making a fix for a bug, I try to decide what the ideal code would look like and then think it could be implemented. Even rewriting an if statement in an innovating way to make it clear is a good satisfaction (about this, I'm preparing an article specifically about declarative if statements to let you know more technically what I mean by that).

- I love coding. I've had the good (or bad?) luck of working in another domain than programming before, and now this makes me realize how beautiful a job where everything revolves around code is. When you like programming, that is :) I consider us developers lucky because there aren't so many people that choose a job by passion like we generally do.

- finally, here is my take about the attitude we should have about legacy code. It has helped me a lot.

Hope this helps!

Feb 11, 8:47AM EST1

Hello how often do you find yourself using std::list in place of something like a vector container and under which circumstances have you found list to be a better container. Thank you

Feb 11, 8:14AM EST0

Hello there,

I haven't found a use case where std::list was more appropriate than std::vector.

Initially, I thought that given that std::list had a complexity in O(1) for append and insert while vectors have a complexity of O(n) for both operations, std::list would be the default option for container.

But this is wrong, because there is another factor that determines performance: cache access. std::vector has a contiuous storage (the C++ standard guarantees that) so when traversing a vector, we don't reach out far into memory to get the next element, and that next element is likely to be in the cache line that was loaded when starting the traversal.

Whereas with a list, the next element may be anywhere in memory, and is likely to cause a cache miss.

So std::list are slower than std::vector. I learned that watching Chandler Carruth's talk Efficiency with Algorithms, Performance with Data Structures.

And since std::list and std::vector have nearly the same interface, I always use std::vector rather than std::list.

In fact, I always use std::vector for storing data when there is no addional constraint (if you need elements to be unique, or sorted for example, then you need something like std::set), except when storing booleans, because std::vector<bool> has issues (see Effective STL item 18) so I use std::deque<bool>.

Feb 11, 8:26AM EST1

What is your personally favourite project of all you worked on so far?

Feb 11, 7:14AM EST0

I've enjoyed nearly all the projects I've worked on so far, be there at work or in my personal time, but if I had to pick one, that would probably be the NamedType library.

This library implements strong typing in C++, and I believe that strong typing makes a difference when it comes to writing expressive code. It was a fun experience as it made me experiment with modern C++ and with a very concrete purpose in mind.

Other libraries I enojoyed working on include smart output iterators in C++, and expanding the algorithms on sets. This was fascinating.

Feb 11, 8:03AM EST1
About #TechAMA

Your source for anything and everything in the world of technology.  From cellphone reviews to the Oculus Rift. You won’t want to miss one AMA Event here!

Interested in participating? Our user-friendly channel makes it possible for anyone to create an AMA on just about any imaginable topic that’s relevant to technology--and you. Just click the button on top right called CreateAMA.

The #TechAMA channel is owned and operated by AMAfeed, LLC.