A concept I found interesting coming from the C++ world in Python is the parameter passing convention and the particular behavior with a mutable default argument such as a list.
In C++ the arguments can be passed by value or reference. This is clear and such arguments are pushed into the stack. In the other side, in Python, parameters are passed by object or call-by-object. A parameter is passed by reference, except when such parameter is updated then the parameter is passed b y value. Kind of weird, isn’t?
For mutable objects, such as a list, individual elements can be changed at the caller’s level.
Careful about having a default list argument as this list object will be created once in function definition then reused in every call!
In C++ there is something weird when having default arguments with virtual functions. These are not part of signature. Default values are evaluated at compile time.
If base class calls virtual function, in compile time the default value will be substituted accordingly to the defaut value of the object that points.
I watched this interesting Video from C++ creator Bjarne Stroustrup:
In this video, Bjarne mentions what hard is to start interesting projects in C++ such as GUIs and Database development mainly because of lack of tools easy to use, specifically at 37:50 he stresses that for his undergrad students, when trying to do GUI development “the greatest problem was to get the GUI library installed”. “It is painful”.
Historically, C or C++ development has been difficult, add different compilers, operating systems, libraries, build systems and tools all of them different between them.
In this post I did a “quick” exercise to tests those sentences. My first try was to setup an environment to develop C++ with GTK+, spoiler alert: It was not quick, it was not easy even for me having experience in the C/C++ world. My second try was with mongodb library in Fedora Linux. In this post I will show the setup I have to work and be more productive with this “kind” of development. The first challenge was to get an editor providing intellisense auto completion and source code browsing
In previous posts I showed how to setup Neovim to provide C++ intellisense using Programming Language Server (PLS) with Coc plugin. I did not realize that for third party libraries you need to do further setup.
There are 2 ways to use intellisense for third party libraries with PLS and Coc plugin: clangd and ccls. I tried with ccls and I was not able to make it work, so I stuck with clangd. After many tries I got to use Intellisense with Neovim for mongodb libraries
I did the same for Visual Studio Code:
I have used most of the time vi for code editing, but now we have more options, so I setup both nvim and Visual Studio Code. Nvim I like to use it for quick browsing, code editing. For something more complex I would use Visual Studio Code Editor.
Visual Studio Code vs Nvim advantages:
What I really like from Visual Studio Code is that I can jump to system libraries and third parties source code definition. I can do similar with ctags or rtags in Neovim but in Visual Studio Code is out of the box.
Extensions are more friendly in Visual Studio Code than the ones for the Coc plugin in Neovim. Setup is harder in Neovim.
Debugging is also out of the box with Visual Studio Code. When using only vim I’m used to use gdb.
How it goes with Visual Studio Code integrated debugger:
Setting up libraries and IDE for third party libraries in C++ is not easy. That is the C++ world! For the libraries setup
I watched LinkedIn training “DevOps Foundations” with Carlos Nunez instructor. In section 3 he shows the use of RSpec and Capibara. I’ll extend a little bit as that section assumes a lot of things from the instructor side.
Step number 1 launches a Docker container with the Nginx web server. That is ok. Then he starts a second container which is Selenium.
Both containers use docker-compose. Nginx is launched with a Docker file. Selenium is not, instead just a raw image is downloaded.
Instructor launches a third container, which contains Rspec and Capybara. This container is specified again with a docker file
What is omitted is an explanation of Selenium, Capybara and RSpec. So let’s start.
Selenium is a web browser instance with an API tailored to be run from a container. The image used here also has a VNC server which is useful when using containers.
Capybara is a Test Framework with support to multiple languages.
RSpec is the ruby DSL.
Why we are using this combo is not explained.
Let’s see my containerfs launched with docker-compose:
There is no doubt, coding is getting more complex nowadays. I have to code in Python, C and C++ and I have usually used vi for small edits. For production I have used PyCharm, for C, C++ Visual Studio.
Visual Studio Code is a great editor with multiple extensions to support different languages. Although, I am used to vim and I always tried to setup intellisense to support different languages.
I like to use Visual Studio Code, however, I feel more productive with vi editor. In this post I’m setting up NeoVim with Coc to code in my favorite languages. In the past I tried vim with different plugins to have code completion.
Finally, I think NeoVim plus Coc is a good option to use vim.
COC requires nodejs and yarn. So, first step is to install those tools:
I was used to SetUp VirtualBox Guests with a Network Bridge in order to have bidirectional access from Host to Guest or Guest to Host. In the simpler NAT mode, I was only able to ssh from my Host to Guest but not ssh from Guest to Host.
Most of the time I used the Bridge Network Mode in Virtual Box, then I switched from Virtual Box to KVM/qemu/libvirtd. Thanks to virt-manager or Gnome Boxes it was relatively easy to use those tools instead of VirtualBox.
When using virt-manager, you have the option to setup the network mode from GUI. Unfortunately there is not an option in drop box to select Network bridge. Instead we have to create the bridge from command line.
Use Network Manager Client to create “br0” bridge interface, in my case the physical Ethernet network interface (From a ThinkPad docking) is: enp0s20f0u2u1i5.
sudo nmcli con add ifname br0 type bridge con-name br0
sudo nmcli con add type bridge-slave ifname enp0s20f0u2u1i5 master br0
Bring down physical Ethernet interface and bring up bridge br0.
sudo nmcli con down "Wired connection 1"
sudo nmcli connection up br0
Setup xml file to be used by virsh:
sudo virsh net-define ./kvm_br0.xml
sudo virsh net-start br0
sudo virsh net-autostart br0
You will see bridge br0 in drop box from virt-manager
My host now has IP Address 192.168.0.104
My KVM guess has IP Address 192.168.0.105. Then, thanks to bridge I can ssh from Ubuntu Guest to my Fedora Host!
You can modify bridge IP address manually as well. For instance, use: