Is your program a function or a service?

Andy Balaam from Andy Balaam's Blog

Maybe everyone knows this already, but for my own clarity, I think there are really two types of computer program:

  • A function: something that you run, and get back a result. Example: a command-line tool like ls
  • A service: something that sits around waiting for things to happen, and responds to them. Example: a web server

How functions work

Programs that are essentially functions should:

  • Validate their input and stop if it is wrong
  • Stop when they have finished their job*
  • Let you know whether they succeeded or failed

*The Halting Problem shows that you can’t prove they stop, so I won’t ask you to do that.

Writing functions is relatively easy.

How services work

Programs that are services should:

  • Start when you tell them to start, even when things are not right
  • Keep running until you tell them to stop, even when bad things happen
  • Tell the user about problems via some communication mechanism

Writing services seems a little harder than writing functions.

What about UIs?

I suggest that programs with UIs are just a special case of services. Do you agree?

What about let-it-crash?

I think that let-it-crash is a good way to build services, but when you build a service that way, I consider the whole system to be the real service: this means the code we are writing, plus the runtime. In this case, the runtime is responsible for keeping the service running (by restarting it), and telling the user about problems.

In effect, let-it-crash allows us to write programs that look like functions (which I claim is easier), and still have them behave like services, because the runtime does the extra work for us. Erlang seems like a good example of this.

What are the implications?

If you are writing a service, your program should start when asked, and keep running until it is asked to stop, even if things are bad.

For example:

  • a service that relies on a data source should keep running when that data source is unavailable, and emit errors saying that it is unable to work. It should start working when the data source becomes available. (Again, if you implement this behaviour by using a runtime that allows you to write in a let-it-crash style, good for you.)
  • a service that relies on the existence of a directory should probably create that directory if it doesn’t exist.
  • a service that needs config might want to start up with sane defaults if the config is not supplied. Or maybe it should complain loudly and poll for the file to be created?

Why not stop when things are wrong?

  • Using this approach, it doesn’t matter the order of starting services. The more services we have, the more painful it is to have an order we must follow.
  • It’s nice when things are predictable. We expect services to keep running under normal circumstances. Using this approach, our expectations are not wrong when things go wrong.

What are the down sides?

  • You must pay attention to the error reporting coming from running services – they may not be working.
  • Services will still stop, due to bugs, or at least due to hardware failures, so you still have to pay attention to whether services are running.

More: 12 Fractured Apps

Visual Lint 7.0.10.329 has been released

Products, the Universe and Everything from Products, the Universe and Everything

This is a recommended maintenance update for Visual Lint 7.0. The following changes are included:

  • The ${eclipse_home} and ${software_location} project variables are now defined when parsing S32 Design Studio for ARM projects.

  • Any project variables of the form ${VARNAME} which Visual Lint cannot expand will now be converted to the standard OS format (i.e. %VARNAME%) before any properties referencing them are written to a PC-lint or PC-lint Plus project indirect (project.lnt) file. This allows the values of Eclipse project variables to be defined as system environment variables and (for example) injected using the PC-lint/PC-lint Plus -setenv() directive if necessary.

  • Fixed a bug in the generation of PC-lint/PC-lint Plus command lines for projects containing per-file preprocessor definitions.

  • Fixed a bug in the generation of analysis command lines containing preprocessor definitions whose values contain quotes. The bug affected analysis command lines for PC-lint, PC-lint Plus and CppCheck.

  • Fixed a bug which could prevent VisualLintGui code editor views from reflecting changes to files which have been externally modified.

Download Visual Lint 7.0.10.329

Visual Lint 7.0.10.329 has been released

Products, the Universe and Everything from Products, the Universe and Everything

This is a recommended maintenance update for Visual Lint 7.0. The following changes are included:

  • The ${eclipse_home} and ${software_location} project variables are now defined when parsing S32 Design Studio for ARM projects.

  • Any project variables of the form ${VARNAME} which Visual Lint cannot expand will now be converted to the standard OS format (i.e. %VARNAME%) before any properties referencing them are written to a PC-lint or PC-lint Plus project indirect (project.lnt) file. This allows the values of Eclipse project variables to be defined as system environment variables and (for example) injected using the PC-lint/PC-lint Plus -setenv() directive if necessary.

  • Fixed a bug in the generation of PC-lint/PC-lint Plus command lines for projects containing per-file preprocessor definitions.

  • Fixed a bug in the generation of analysis command lines containing preprocessor definitions whose values contain quotes. The bug affected analysis command lines for PC-lint, PC-lint Plus and CppCheck.

  • Fixed a bug which could prevent VisualLintGui code editor views from reflecting changes to files which have been externally modified.

Download Visual Lint 7.0.10.329

Configuring MongoDB Java driver logging from Clojure using timbre

Timo Geusch from The Lone C++ Coder's Blog

I’ve mentioned in the past how you can configure the MongoDB Java driver output from Java. Most Clojure applications that use MongoDB use a database driver that wraps the official MongoDB Java driver. I personally use monger for a lot of my projects, but also occasionally created my own wrapper. The methods described in this […]

The post Configuring MongoDB Java driver logging from Clojure using timbre appeared first on The Lone C++ Coder's Blog.

What impact might my evidence-based book have in 2021?

Derek Jones from The Shape of Code

What impact might the release of my evidence-based software engineering book have on software engineering in 2021?

Lots of people have seen the book. The release triggered a quarter of a million downloads, or rather it getting linked to on Twitter and Hacker News resulted in this quantity of downloads. Looking at the some of the comments on Hacker News, I suspect that many ‘readers’ did not progress much further than looking at the cover. Some have scanned through it expecting to find answers to a question that interests them, but all they found was disconnected results from a scattering of studies, i.e., the current state of the field.

The evidence that source code has a short and lonely existence is a gift to those seeking to save time/money by employing a quick and dirty approach to software development. Yes, there are some applications where a quick and dirty iterative approach is not a good idea (iterative as in, if we make enough money there will be a version 2), the software controlling aircraft landing wheels being an obvious example (if the wheels don’t deploy, telling the pilot to fly to another airport to see if they work there is not really an option).

There will be a few researchers who pick up an idea from something in the book, and run with it; I have had a couple of emails along this line, mostly from just starting out PhD students. It would be naive to think that lots of researchers will make any significant changes to their existing views on software engineering. Planck was correct to say that science advances one funeral at a time.

I’m hoping that the book will produce a significant improvement in the primitive statistical techniques currently used by many software researchers. At the moment some form of Wilcoxon test, invented in 1945, is the level of statistical sophistication wielded in most software engineering papers (that do any data analysis).

Software engineering research has the feeling of being a disjoint collection of results, and I’m hoping that a few people will be interested in starting to join the dots, i.e., making connections between findings from different studies. There are likely to be a limited number of major dot joinings, and so only a few dedicated people are needed to make it happen. Why hasn’t this happened yet? I think that many academics in computing departments are lifestyle researchers, moving from one project to the next, enjoying the lifestyle, with little interest in any research results once the grant money runs out (apart from trying to get others to cite it). Why do I think this? I have emailed many researchers information about the patterns I have found in the data they sent me, and a common response is almost completely disinterest (some were interested) in any connections to other work.

What impact do you think ‘all’ the evidence presented will have?

Configuring MongoDB Java driver logging from Clojure using timbre

The Lone C++ Coder's Blog from The Lone C++ Coder's Blog

I’ve mentioned in the past how you can configure the MongoDB Java driver output from Java. Most Clojure applications that use MongoDB use a database driver that wraps the official MongoDB Java driver. I personally use monger for a lot of my projects, but also occasionally created my own wrapper. The methods described in this post should be applicable to other Clojure MongoDB drivers as long as they wrap the official MongoDB Java driver.

I bought the first computer I ever wrote a program on

Timo Geusch from The Lone C++ Coder's Blog

I don’t usually do Happy New Year posts, but given how “well” 2020 went I thought it was appropriate to start 2021 with a whimsy post.  This post is probably going to date me since it’s been a few years – OK, decades – since these were current. Well, it’s not the actual computer, but […]

The post I bought the first computer I ever wrote a program on appeared first on The Lone C++ Coder's Blog.

Smooth Operator – a.k.

a.k. from thus spake a.k.

Last time we took a look at linear regression which finds the linear function that minimises the differences between its results and values at a set of points that are presumed, possibly after applying some specified transformation, to be random deviations from a straight line or, in multiple dimensions, a flat plane. The purpose was to reveal the underlying relationship between the independent variable represented by the points and the dependent variable represented by the values at them.
This time we shall see how we can approximate the function that defines the relationship between them without actually revealing what it is.

I bought the first computer I ever wrote a program on

The Lone C++ Coder's Blog from The Lone C++ Coder's Blog

I don’t usually do Happy New Year posts, but given how “well” 2020 went I thought it was appropriate to start 2021 with a whimsy post.  This post is probably going to date me since it’s been a few years - OK, decades - since these were current.

Well, it’s not the actual computer, but the same model. I was first exposed to computers during the personal computer heyday of the early 1980s. Back then, my school had two computers, one TRS 80 Model 3 and one Sinclair ZX81. The ZX81 was used to teach pupils rudimentary programming. I wouldn’t be surprised if one of the teachers actually built it from a kit as that was the cheapest way to get into one.

Keep in mind that I grew up in Europe where computers like the Apple ][ were very expensive and didn’t gain much traction in the educational field. Or with hobbists, either. Yes, there were some around but you saw a lot more VIC20s, C64s or Ataris. A lot of schools including mine bought European manufactured computers like Sinclairs and later, Amstrad/Schneider CPC 464s.