27 Oct 2018
Git and Visual Studio Code
Visual Studio Code (https://code.visualstudio.com/
) has since it first public release in 2015 increased fast in popularity. Being a cross-platform editor and released as open source software, many software developers have downloaded it. The fact that Microsoft is behind Visual Studio Code means that programming languages like TypeScript, C#, and C++ are well supported.
Git has become the de facto standard for version control systems. In particular Git providers like Gitlab, Bitbucket, and Github have made it easy for software developers to set up Git repositories. Many developers are using Git directly from the command-line, but there exist also a good portion of graphical Git clients. Today, any code editor and any integrated development environment (IDE) must have some kind of Git support.
What is built-in?
Visual Studio Code has support for basic Git operations. This includes creating branches, checkout branches and pushing to and pull from remotes.
|Inline diffs are useful for quickly see changes|
On the status line, you can see which branch you are on. By clicking on the branch name, a list of existing branches will appear, and you can easily checkout another branch. Another option is to create a new branch.
Right to the line numbers in the editor, you can see if you have change a line: a marker is shown. If you click on the marker, the diff will be shown. The inline diff is useful when you are working together with someone else on the same branch.
Once you are ready to commit your changes, you can click on the source code icon (default: third icon from the top) or use SHIFT-CTRL-G
. You will see a list of all files you have changed or created. By clicking on a file in the list, the editor will split in two. You can now see the diff of the entire file. Clicking on the +-icon will add them to the commit. Type a message, and you have created a commit.
|Splitting the screen gives an overview of all the changes.|
Many more Git functionality can be found in Visual Studio Code.
) is a great extension to help you understand your code base better. It is in particular useful if you work on large code bases with many contributors. One way to explain GitLens is to say it is Git blame on steroids.
Once installed and enabled, you can see when and who change a line. Knowing who did the latest change to a line or block makes it easy to ask for help - you simply know who to ask right away. Of course, it is not the same as you will get a useful answer but that’s another story.
|Git blame for every line.|
|GitLens gives you a simple but power explorer|
GitLens also adds a new icon to the left menu. Clicking on the icon will open a Git explorer. You can now easily explore branches, tags, and stashes. Searching for old commits has never been easier.
Github issues and pull requests
It is not a bit secret - Microsoft has acquired Github. At the same time, Microsoft is the founding father of Visual Studio Code. Not surprisingly, Microsoft has developed a couple of extensions to make these two tools work better together.
First one to mention is Github Issues (https://marketplace.visualstudio.com/items?itemName=ms-vscode.github-issues-prs
- yes, Microsoft has open sourced the source code!). The extension adds an issue explorer, and you find it under the file explorer. It is a personal tool in the sense it will only know Github issues assigned to you. A click on an issue, and the issue will be opened in your web browser.
Another fine extension from Microsoft is Github Pull Requests (https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github
). This extension adds an pull request explorer in the Git explorer so you can get to by SHIFT-CTRL-G
. You can explore your pull requests; either the ones you have created or the ones which are assigned to you. Moreover, you can see the pull requests where you are asked for a review. Instead to doing the review in your browser, you can do it from within Visual Studio Code.
Still a console cowboy
I have recently moved to Visual Studio Code, and I am not yet a complete fanboy. But many aspects of it are good, and I keep exploring it.
After many years as a Git user, I still have the habit of doing many Git operations directly on the command-line. Simply because it has been part of my workflow for such a long time.
I have only scratch the surface by looking at a couple of extensions. If you go to Visual Studio Code market, you will be amazed by the number of Git related extensions.
04 Dec 2014
The second chapter is written in a very dense format using many bullet lists. You are probably going to read the chapter more than once to get all the information. The good news is that is a lot of information. Chapters 2-4 are a presentation of how to use promises, include error handling.
10 Dec 2013
Happy birthday, Grace
Yesterday, Grace Hopper
would have turn 107 years old. She was one of the first computer scientists. She worked on compilers but she is probably best known for her development of COBOL
. COBOL is one of the first high-level programming languages (FORTRAN is the other one). Back in the 1950s, computers were used as calculators, but COBOL and Grace Hopper shown us that computers can be used for much more that simple calculations. Today, COBOL is still wildly used.
As a tribute to Grace Hopper, I have played a bit with the OpenCOBOL
compiler. OpenCOBOL can translate COBOL source code to C and use a C compiler to generate a real executable program. The compiler is licensed under GNU General Public License (version 3), and the runtime is licensed under GNU Lesser General Public License (version 3). That is, OpenCOBOL is free software!
and Linux Mint
have packages for OpenCOBOL. Probably other Linux distributions and FreeBSD have packages as well but I haven't checked. The installation (using Linux Mint) is simple:
sudo apt-get install open-cobol
I haven't tried to write software in COBOL. The closest I ever came is that I worked on converting between 4th generation languages
(4GL) a few years ago. 4GL programs are often converted to COBOL. But I have written a short program in COBOL:
* Greeting to Grace Hopper
01 WS-TODAY PIC X(21).
01 WS-YEAR PIC 9(4).
MOVE FUNCTION CURRENT-DATE TO WS-TODAY.
MOVE WS-TODAY (1:4) TO WS-YEAR.
SUBTRACT 1906 FROM WS-YEAR.
DISPLAY "Happy birthday"
Compiling the program using OpenCOBOL is easy:
cobc -x greeting.cob
and running is easy:
I am not going to do a lot of COBOL programming in the future, but it seems to possible to replace old legacy operating systems with a modern platform like Linux.
10 Nov 2013
Review: Storm - real-time processing cookbook
Quinton Anderson has written a book on the analysis platform Storm
and published it at Packt
. I have worked a little with Hadoop
in the last couple of years, and it is only natural to take a look at the other big data processing platform. Hadoop is a batch processing platform, and Storm is for real-time processing and analysis of data. That means the two projects are not direct competitors, and they might complement each other.
When reviewing a technical book for the general public, it is important not to review the technology but the book. You can easily write a crappy book on excellent technologies while the opposite is very difficult. This review should be read in this context.
The author starts out by explaining how to set up Storm. Storm seems to be quite a complex beast, but Mr. Anderson gets nicely through it. I would have preferred to get an introduction to some of the concept before jumping into the many tasks. But it is my personal preference, and this is a cookbook and not a text book for a university course.
The first couple of chapters is about processing real-time data. Twitter and log files are the canonical examples in this area, and the book utilizes these as well.
One chapter are on how to use C++ and Qt in your real-time data processing. If you think that Qt is about graphical user interfaces, the book will show you that Qt is a lot more. The author is using Qt's non-GUI parts in his processing.
Another chapter is about machine learning. As part of the big data revolution, machine learning has become popular again. Machine learning is a topic that Mr. Anderson is passionate about, and he analyzes in great detail the problem before showing the recipe.
One of the major disadvantages of the book is that the assumptions about the reader are pretty hard. The reader is assumed to know at least about:
- Java development using and Maven and Eclipse
- Some functional programming
- Ubuntu or Debian (or any UNIX) command-line
- Data modelling experience
- A little about NoSQL
This problem does not really from the author but from Storm. But the author might have chosen other examples. The book is not a university text book, and therefore I would like many more references to text book and papers.
There is a lot of source code in the cook. You should really download the examples as some of them are longer than a page. It would be great if Packt would do some kind of syntax highlighting. Most programmers find it easier to read syntax highlighted code. In particular, electronic books (I have read the book as PDF) can easily be colorized!
One of the things I really like about the book is that the author has taken time to craft understandable diagrams. A well-composed diagram is worth many words, and he often sums up the key points in a diagram. In general the author writes in a rather dry or fact based language. But on page 111, you find that the author cannot suppress his humor: "... for automating Clojure projects without setting your hair on fire."
I'm not going to say that Storm is a crappy technology but Quinton Anderson has done the job well by writing a good cook book.