Hof Examples Discussion Two

last modified: March 13, 2013

Moved from SummaryOfHofExamples because it's intended to be a summary.


(Regarding multiple independently-refreshing GUI panel example.)

for i=1 to getParameter("panelCount")
  print out panel HTML or DOM-appender code using i for ID
end for

.

You're quibbling here. I've given the actual requirements. You're making up non-requirements.

YOU started the quibbling. I and readers have no way to verify they are actual requirements. Even if the written requirements state "must have ability to have unlimited panels", it likely would not be practical in practice. I would expect the reasoning and utility behind having so many actually stated. That's part of scenario presentation.

Like it or not, that's what it is and those are the requirements. It's used to monitor user activity on some sort of collaboration/communications thing and there can be any number of users. I think it's for troubleshooting when things misbehave, not 24x7 monitoring, so it's a reasonable UseCase to have a lot of panels and scroll up and down looking at the overall pattern and red peaks. Furthermore, it is clearly undesirable to choose a facility that requires higher CPU and power consumption (eval) than one that requires lower CPU and power consumption (HOFs), regardless how many panels are needed. That's true even if the number of panels is 1, if the 'eval' expression needs to be evaluated repeatedly. I think that rules out 'eval'.

That's not how you monitor peaks. Sounds like a bad project design to me. And you are hogging network bandwidth and other resources by putting so much activity in the non-visible portions (out of scrolling range). HOF's help you do the wrong thing faster? Lovely.

Beware of conflating HOFs with your personal objections toward the application requirements and/or design. That would be like blaming 'while' loops for awkward font management in Microsoft Word. The scenario is not a VU meter, so peaks aren't being "monitored" in the usual "ride the levels" sense. Once again, you're quibbling about the requirements. They are what they are. If you expect to change the requirements, why not change them to not require the application in the first place? We certainly don't need HOFs (or anything else) in an application that doesn't exist. As for shutting down activity in areas that scroll outside of the viewing area to save bandwidth, I could easily do that but there's no need -- the link I provided is to a simplified demo, not the actual product.

I have no way to verify your claim about the requirements. Usually with something this involved, there are multiple ways to achieve similar results. One can often go to the customer and say, "This approach gives you sufficient alerts, yet goes with the flow of our existing tool-set and skills/experience such that the project will go smoother." It's called "negotiation". The requester often hasn't thought out all possible ways to achieve a similar result because they are not IT experts or haven't had time to think about it more. Now I will agree that in some cases one is stuck with fitting the requirements exactly as written because it's a signed contract, and in that case one may have to gut it out and/or even switch tool-sets to achieve exactly what's written. But usually there's some flexibility. Before signing the contact, a smart contractor will point out that non-visible elements may be taxing the network and other servers for no purpose such that the requirements should be reworked. I would probably not recommend a web browser for heavy-duty GUI work and instead suggest perhaps a C++ Windows or Delphi client. Browsers are flaky when too much is going on at the same time. You've come down with BrowserAbuseSyndrome.

Yet again, you're quibbling about the requirements. You'll have to accept that the requirements, as given, are accurate and that there's nothing to negotiate. As for shutting down activity in areas that scroll outside of the viewing area to save bandwidth, I could easily do that but there's no need -- the link I provided is to a demo, not the actual product. You are squirming desperately to avoid using HOFs, and you're not presenting arguments against using HOFs that are based in programming, ComputerScience, or SoftwareEngineering. Your arguments don't even appear to have a reasonable business case, because the apparent claim that HOFs require some leap in "tool-set" (we're using Javascript, which supports HOFs) or "skills/experience" (HOFs are easy) is unsustainable. If you were assigned this project, I suspect your responses would result in the boss and the client getting rather irritated. Meanwhile, I've delivered the solution that was requested and it works as intended -- a happy boss and a happy client are the result. I get a bonus, you get a disciplinary.

YOU are the one squirming desperately by making up goofy requirements out of your ass to force-justify them via mass exaggeration. Eval's or frames would probably work just fine, despite your drama-queening about them and anointing HOF's magic ivory tower knighthood. Lisp lost the Great FP Civil War in the 80's because they invited just enough Sandy Hook programmers to create frankencode for job security purposes or GoldPlating boredom. You had your chance to introduce realistic examples and choked, relying on browser design flaws. Stop reenacting the Civil War! The HOFsouth lost! Now Fuckhoff!

[There haven't really been any new requirements added since the example was introduced on ArrayDeletionExample, if I'm not mistaken. Your emotional attack on Lisp is completely off-topic, considering this application uses only JavaScript. -DavidMcLean]

You never said the panels go beyond the visible screen. You kept increasing the quantity. And HOF's were one of the allegedly selling points of the Lisp fad.

[No, we didn't say the panels did that. You did, and then we said this design could handle it. It wasn't actually specified, as a requirement or otherwise, until you brought it up. -DavidMcLean]

So you are admitting you added to the original requirements.

[No, I'm accusing you of adding to the original requirements. ;) ]

I just asked a question to figure out what you were talking about.

[Being able to support an arbitrary number of panels, whether it's one, ten, or a hundred, has been both a requirement and supported by the example from the start. Screen sizes and the number of panels the screen can hold, by contrast, haven't really been a consideration. (Also, the "Lisp fad" and Lisp's following collapse have no relation to higher-order functions. It's about the AiWinter, for the most part.) -DavidMcLean]

It's impossible to support an arbitrary number of panels. Even if written in machine language, a 100k active refreshing panels would bring both clients and servers to a halt. (And you may get arrested by DHS for initiating a DOS attack.) Perhaps what the customer meant was that your API didn't impose an arbitrary limit software-wise. That's NOT the same as being practical at gazillion panels performance-wise and usability-wise. For example, I may ask for a GUI engine that in theory could open a million windows. I put that in the specification to avoid unnecessary surprise limits. But that doesn't mean I'm asking it to actually support a million windows machine-resources-wise. That's because I want my hardware to be the actual bottleneck, if I decide to push it that hard, and not have software limits to be the bottleneck, such as a predefined array dimension of say 500 windows.

And the AI push did make Lisp and FP the "in thing" for a while even outside of AI.

[Obviously the number of concurrent panels is limited by hardware. This system only doesn't impose a software limit, so it hypothetically could operate with an arbitrary number of panels. Since higher-order function techniques require less CPU processing than an equivalent eval-based technique, it'll also have a higher upper bound imposed by hardware. -DavidMcLean]

By that argument, assembly language would probably be better than HOF's. In most CBA software, the database or the network is the bottleneck, not CPU. In a typical CBA setting, I doubt what "they are actually monitoring" would cause the CPU to be the bottleneck. Most likely those panels would be querying a few databases, and having 50 or so queries going on every few seconds would be too much for a database doing real work. Your example just smells suspicious. If it's a factory, then they'd probably use industrial grade UI's and monitors and not a web browser for such. Web browsers are not designed for that kind of use and are probably not well-tested for that kind of load.

[This is a client-server arrangement, and we've already discussed that the client may be a mobile device with poor CPU capability. We want to minimise CPU processing on that system, both because the CPU is poor and because it increases battery life to use it less. -DavidMcLean]

If it's a mobile app, then then network is also going to be a bottleneck, not just CPU. Thus, either you only have a few panels visible and active (since mobile apps have small screens), which is not going to be an Eval problem, or you have bunches of panels outside of scroll range hogging network bandwidth, and CPU. You can't have your cake and eat it also.

[Eval will be a problem on a mobile device even if there's only one panel, because it uses more CPU and therefore more battery power. This was already pointed out above. -DavidMcLean]

Pfffft. Fine, I concede that HOF's are 0.0001% more efficient for that example IF we are stuck using the HtmlStack. Put a microfeather in your cap.

[Higher-order functions are more efficient than eval() for every example, whether we're "stuck using the HtmlStack" or not, because they don't do any parsing at runtime. Parsing is slow. -DavidMcLean]

We've argued the "speed thing" already somewhere else. I'll LetTheReaderDecide whether speed is the overriding concern. Again, in the vast majority of CBA's, the CPU is not the bottleneck, and in such situations, I place code readability and maintenance above speed.

[Again, in this example, we're talking about a mobile device, and we want to minimise CPU usage to maximise battery life. The overhead of parsing is a definite showstopper for eval()-based solutions on this platform. -DavidMcLean]

Processing about 2 eval's a second isn't going to make a shit of difference to a human observer. You are quibbling over dust. If mobile apps cared so much over such small grains, then why do they spend CPU on bouncy scrolling, cursor shadows, and other 3D-like shading?

[Not at all. An observer will find their battery life shortened, potentially significantly.]

Bullshit!

[A very eloquent response. I commend you.]

Show me the math.

[Sure thing. http://moduscreate.com/javascript-performance-tips-tricks/ From this benchmarking, we see that eval()'d code runs at about 97 ops/sec; compare and contrast with basically any other benchmark there, all of which are at least 20k ops/sec. This is because eval() is significantly more CPU-intensive, so it consumes more CPU cycles and hence more battery power. -DavidMcLean]

Eval-ing a function call (name) is only one operation. Thus, if we average 2 a second for the mobile device (per above), and take your 97 figure, then that will only slow it down about 2%, which a user wouldn't typically notice. If performance is that important, then it should be written as a native device app anyhow, not HtmlStack.

[Yes, there's no visibly noticeable application slowdown in this two-eval()s-per-second scenario. Again, we're talking about a mobile device, and it's the device's battery power we're concerned with, which will be impacted. Also, you've imagined the two-eval()s-per-second requirement. The example we're working from wouldn't need two eval()s per second; it has thirty panels, and each one triggers four times a second. If it were using eval()s, it'd need to perform over a hundred eval()s per second. -DavidMcLean]

What the hell are you monitoring that needs to be updated four times a second? I've never seen anything that needed to even be close to that frequency accept heavy-duty industrial equipment, which wouldn't hire a general CBA to produce their monitors. That's not what browsers are meant for. If you are lucky enough to get one to work, that's wonderful, but risky.

[No idea. That's what the original example does, though, and it does it competently. Can your solutions compete? -DavidMcLean]

So you have "no idea" what it's used for, yet are submitting it as a "representative" CBA example???

[I didn't submit it. It's not my example. I believe the original source of the example did discuss what it monitors. -DavidMcLean]

I can't re-find the original link. Do you remember where it was? The demo uses local "internal" dummy functions to generate values. That's not necessarily the conditions of the real world.

not today

.


Loading...