Q:

Efficiency of nameless functions

The current trend seems to be to use lambda type function in languages that can take that syntax.  Is this just a trendy thing or is actually more efficient?  eg in javascript, you can get stuff like
var x = ((aa,bb) => {
    ....
    aa((xyz) => {...}
    }).then((aa, bb) => {
    ...
    }).doit

Is it actually more efficient for the javascript interpreter to execute code like this or is it more efficient for the coder to define separate functions and call them.  This is also happening a lot in C#.

A:

Anonymous (unnamed) functions are as efficient as named functions. However, nested functions have a slight overhead if they refer to local variables of an enclosing function (such nested functions are called “closures”). The most efficient way to implement this involves one additional pointer indirection for each non-local variable access. This is equivalent to the cost of accessing an instance member / field of an object. It is therefore never more efficient to replace an anonymous function with an object that provides the same functionality through a method.
The only notable drawback of anonymous functions is debuggability – a stack trace cannot refer to the name of the anonymous function since it doesn't have one. If debuggability is more important than keeping related code closely together, extracting the anonymous function may be sensible.
Also, nested functions cannot be tested directly, independently of named/unnamed or closure status of the nested function. If the nested function has individual meaning (and isn't just part of the ordinary control flow – you wouldn't test the body of a for-loop individually), then extracting the nested function to make it testable may be sensible.
But those points have to be weighed on a case-by-case basis. Since nested functions are an integral part of JavaScript and C#, it is not reasonable or even possible to go without them.

A:

This isn't directly an answer about the efficiency of anonymous functions, but more about the coding style, since I get the impression that this is what the OP really cares about. (Especially pre-edit, the question seemed to be more "I think this style is unreadable, so people must be doing it for efficiency, am I right?")
There is a balance to be struck in all code between verbosity and conciseness. They are opposites, but neither is all good; they both have disadvantages.
Code that is too verbose is hard to read because reading code takes time, time in which you forget what you previously read. In addition, verbose code tends to contain additional information (such as the name of a non-anonymous function) that competes for space in your short-term memory with other information. Finally, it can introduce non-locality, e.g. if you introduce another function that you now have to go look for in order to understand the code.
Code that is too concise is hard to read because you have to keep to many details in your head without having a moniker to refer them by, and because lots of concise code clumps up, making it easier to lose your place in the code while reading. And it requires you to understand all the details of the code, whereas a well-named extracted function can often be treated as a black box.
Somewhere in the middle is the point of maximum readability.
Here's an example that just involves mathematical calculations. Let's say I have a function that calculates something simple, like celsius to fahrenheit conversion:
function celsiusToFahrenheit(celsius) {
  return celsius * (9.0/5.0) + 32;
}

Clear and simple. There's a scaling factor and an offset. Some purists might argue that these should be named constants, but I don't see the point; the function is a one-liner and the purpose of these numbers is obvious, and they're not going to change.
However, I could write it more verbosely:
function celsiusToFahrenheit(celsius) {
  let scaledCelsius = celsius * (9.0/5.0);
  return scaledCelsius + 32;
}

Here I took an intermediate result of the calculation and assigned it a name. I shifted more towards verbosity. Did it improve readability? You now have more code to read, and I had to invent an additional name which you have to remember while reading the code. I'd say readability got worse.
Here's a different example. This formula calculates an approximation of radio signal pathloss from a transmitter antenna to a point in space, tuneable with a bunch of user-specified coefficients. This is a simplification of the real formula.
function pathloss(heightAntenna, heightDevice, distance, frequency, coefficients) {
  // formula uses log scale
  frequency = log10(frequency);
  heightAntenna = log10(heightAntenna);
  distance = log10(distance * 0.001);
  return
    (coefficients.A0 + coefficients.A1 * frequency - coefficients.A2 * heightAntenna) -
    ((coefficients.a0 * frequency - coefficients.a1) * heightDevice -
    coefficients.a2 * frequency + coefficients.a3) +
    coefficients.C0 * pow(frequency - coefficients.C1, 2) - coefficients.C2 +
    (coefficients.B0 - coefficients.B1 * frequency) * distance;
}

I think you'll agree that this is completely unreadable. Here, splitting it up in parts really helps.
function pathloss(heightAntenna, heightDevice, distance, frequency, coefficients) {
  // formula uses log scale
  frequency = log10(frequency);
  heightAntenna = log10(heightAntenna);
  distance = log10(distance * 0.001);
  // names are somewhat weird, that's the way they're written in the
  // reference book this is based on
  let a = (coefficients.a0 * frequency - coefficients.a1) * heightDevice -
    coefficients.a2 * frequency + coefficients.a3;
  let A = (coefficients.A0 + coefficients.A1 * frequency -
           coefficients.A2 * heightAntenna) - a;
  let C = coefficients.C0 * pow(frequency - coefficients.C1, 2) - coefficients.C2;
  let B = (coefficients.B0 - coefficients.B1 * frequency) * distance;
  return A + C + B;
}

This is still mathematically challenging, but at least it's broken up into chunks, making it much easier to keep track of which parts are added to which, something that required careful tracking of parentheses in the original version.
Anonymous functions are subject to the same trade-off. Using them improves locality. Overusing them (especially nesting them) makes program flow hard to track. It's up to you to find a balance.

A:

No, it is typically less efficient.
When you use an inline function, you end up creating a function object. The construction of that object will typically take up some resources. In fact, there is an optimization sometimes applied to javascript to move the inline functions out when we can prove that would be equivalent.
The benefit is to avoid writing one-off functions all the time, let's compare:
function foo() {
   let males = _.filter(people, (person) => person.male);
}

function is_male(person) {
     return person.male;
}

function foo() {
     let males = _.filter(people, is_male);
}

The inline function syntax is useful, because it lets me filter easily over any criteria I want. Otherwise, I'd have to write out a seperate function every single time I used filter.
Of course, some people probably take this too far. Sometimes calling a named function is clearer then writing an inline function, especially if the logic gets complicated. But properly used, it can aide readability (at least, once you've gotten use to it)


Sustained release of isomazole from matrix tablets administered to dogs.
Isomazole matrix tablet formulations, with various concentrations of hydroxypropyl methylcellulose (HPMC) hydrogel, were prepared and tested for sustained-release activity. Sustained-release activity was determined by administering isomazole test formulations orally to conscious dogs, instrumented with an indwelling left ventricular pressure transducer, and monitoring cardiac inotropic changes for 12 h thereafter. The HPMC hydrogel incorporated into the tablets at a concentration of 20-30% did not significantly change the magnitude of inotropic response or duration of action. Increasing the HPMC concentration to 40 and 42.5% in the formulations decreased the peak LVdP/dt60 response (cardiac inotropic activity) to isomazole, increased the response duration, and maintained the area under the curve (AUC) of LVdP/dt60 versus time. Higher concentrations of HPMC decreased both LVdP/dt60 peak activity and AUC without producing a sustained response. A very narrow range of HPMC concentration in the matrix tablet is thus required to achieve isomazole sustained-release activity.


var step = 8;
var padding = 10;

function progressBarUpdate(id, percent) {
	var total = document.getElementById("progressBar" + id).style.width;
	total = Math.round(total.substring(0, total.length-2))-padding;
	var onePercent = total / 100;
	var progress = Math.round(onePercent*percent);
	if (progress % step == 0 || percent > 99) {
		document.getElementById("progressBar" + id + "_indicator").style.width = progress;
	}
}

function progressBarUpdateLabel(id, text) {
	document.getElementById("progressBar" + id + "_text").innerHTML = text;
}

function progressBarTest(id, percent) {
	progressBarUpdate(id, percent);
	progressBarUpdateLabel(id, percent + '%');
	if (percent < 100) {
		percent++;
		setTimeout("progressBarTest('" + id + "', " + percent + ")", 100);
	}
}


Organisers of the Asian Le Mans Series have confirmed the race format set to be used when the category touches down at The Bend Motorsport Park next January.

Announced last week, the Asian Le Mans will host its first Australian event next year at the South Australian venue, with the remainder of the calendar expected to be released this weekend.

Speaking with Speedcafe.com, category boss Cyrille Taesch-Wahlen confirmed that the event will host a four-hour race, in line with what the series has run throughout its 2018/19 calendar, with planning having already begun.

“It’s going to be a four-hour race,” Taesch-Wahlen confirmed.

“We are going to announce the full 2019/2020 season calendar (this weekend) in Sepang, within the context of the last Asian Le Mans event for the ongoing season.

“We also need to start working on the organisation of The Bend event next year, so with 11 months now ahead of us, it’s a good time, I think.”

The timing of the event was a deliberate move by organisers, who have positioned it two weeks before the Bathurst 12 Hour’s usual date.

It’s hoped teams looking to take part in the 12 Hour could use the Asian Le Mans outing as a warm up, while at the same time offers GT teams visiting from Asia the opportunity to share travel costs between the two events.

“Not only a warm up for Bathurst but also it’s an opportunity for many,” Taesch-Wahlen agreed.

“It’s an opportunity for Asian Le Mans, it’s an opportunity for The Bend, it’s an opportunity for Australian drivers.

“We have quite a lot of Australian drivers competing in Asian Le Mans Series since we started, and it’s obviously an opportunity for the Australian teams that are going to be interested in joining the 2020 LMP3 Cup Australia.

“It’s a nice opportunity for GT in Australia to join Asian Le Mans and to enjoy it for a race within the ACO racing environment, I would say.

“When you organise an international series, whatever the size of your championship, you also have to take care of what the others do, not only for the sake of protecting them or you, but also for the teams and the ability to join both events at once,” Taesch-Wahlen added.

“Since ACO took over Asian Le Mans Series, we always try to avoid clashing with other major international events in Asia Pacific, including Bathurst of course.

“Two years ago, we couldn’t do so because of the date of Chinese New Year and logistical constraints, but otherwise for us it’s obvious that we cannot clash with Bathurst, and the same for the Macau GP, for instance, or WEC events.

“So, it’s always kind of a challenge to set up a calender when you have to take into account the weather in Asia, because you can’t race, for instance, in Japan, that late in the winter,” he added.

“You have to take into very serious consideration the ETD and ETA time for shipping and the time it takes to ship a container from venue A to venue B.

“So it’s a kind of a nice challenge, I would say, and the date that we have agreed together with The Bend is the one that fits best the 2019/2020 Asian Le Mans calendar as a whole, and of course, I think pretty much fits with the Australian season”

The 2018/19 Asian Le Mans Championship concludes at Sepang this weekend.


Q:

How to teach steady state in queueing (if at all?)

I am teaching an undergraduate course in Operations Research to business students (they are not: maths students). I want to check, if and how teaching the steady state makes any sense.
As in the semesters before, the challenge of this term was to make the concept of "steady state" plausible. Thus we wrote a very simple M/M/1 queueing simulation, repeated it, produced histograms of the queue lengths of the repeated simulation over time, analysed time-regions, where these histograms did not change very much and finally calculated the "ideal steady-state histogram" by solving simple systems of linear equations.
This made the concept of "steady state" clearer and brought in more joy as an exploratory task than just a calculation task or formula. However, the question came up: where in the real world would a real planner in a real application (and by "real" the students mean: real-real) put that much focus on what is the steady state of a queue?
Some ideas from my side (counterarguments in brackets):
*the planner would try to discover, at which time his system stabilises - the supermarket opens, 20 people waiting outside, when will the cashpoints be in their "normal"/average state? (well, wouldn't a simple measure like variance in the simulation suffice to just explore, when a system swang in?)
*the planner could use the steady state for more strategic tasks - what happens e.g. if the incoming behaviour of the queue changes e.g. during night shifts? (But still: the planner could just simulate that, calculate averages and never touch his operations-research-concept steady state again, right?).
Someone's up for more realistic ideas - and how to teach these? Or should we rather defocus the concept of steady state when teaching a few weeks of basic queueing theory?

A:

This is a stretch as it is far from my area, but my understanding is that steady-state histograms play a "real" role in Internet packet traffic analyses.
Here is one suggestive figure from a paper cited below (the blue histogram
is steady-state buffer distribution).

The OP would know better than I if one could make a case for packet queues
that would be more resistant to counterarguments.

Hernández-Orallo, Enrique, and Joan Vila-Carbó. "Network performance analysis based on histogram workload models." Modeling, Analysis, and Simulation of Computer and Telecommunication Systems, 2007. MASCOTS'07. 15th International Symposium on. IEEE, 2007.