|
IIRC, the original P-Code compiler for Pascal only allowed a range of 64 to create its jump table. I worked on the compiler for my final year project at Uni (a long time ago) but concentrated on the expression evaluator so never got around to seeing what happened in the range exceeded that amount.
|
|
|
|
|
|
I mean, that's what I mean. The point is, there's no way that I know of for CIL to have the requisite jmp table to do it properly.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: The point is, there's no way that I know of for CIL to have the requisite jmp table to do it properly. The point may be that you are spending more time writing elaborate essays on the structure of labyrinthine conjectures than on keenly analyzing the design, and outcomes, of experiments you can carry out to test what is possible ... to refine the problem space and narrow the scope of what must be accomplished.
You may not believe this, given my cantankerous history with you ... but, mutatis mutandis, I have come to appreciate your obvious technical gifts, and, I hypothesize that you may be a "Neo" who could actually make generating code for complex business rules from "higher level" abstractions possible for mere mortals.
"If not you, who ? If not now, when" attributed in various forms to Hillel the Elder, and often misattributed in distorted forms to others,
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
I'd argue that in this case my experiments are what led to the essay. It was through experimentation that I found the issue I'm writing about.
BillWoodruff wrote: "Neo" who could actually make generating code for complex business rules from "higher level" abstractions possible for mere mortals.
Years ago, I did this for a company I worked for. It could generate about 2.5 tiers of a 3 tier web application and supported rest/JSONP before most frameworks. The other half a tier would be the web design part, although you could define the UI elements themselves by attributing the business entities with default appearances that could be overridden on the actual design end.
It wasn't quite for non-developers, but you could define all three (2.5 really) tiers through attributed XSD.
Real programmers use butterflies
|
|
|
|
|
Cool ! Why not do it here, utilizing all you've learned to optimize it ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
I don't think it's possible to optimize my code much further under .NET. I'd have to rewrite it in C++, and that takes scarcely any intellectual effort - just porting.
Real programmers use butterflies
|
|
|
|
|
Wow.. this level of performance investigation is beyond me...
I couldn't help but wonder though... have you considered what kind of native code Ryujin (native compiler) ultimately produce, eventually?
Other than that I have to admit the C# doesn't produce the ultimate performance than C++ allegedly produce. I say allegedly because it is, apparently, quite hard to produce consistently.. but doable nonetheless.
|
|
|
|
|
C++ doesn't support the full range of case statements you find in VB.Net (and now in C#). The limited support in C++ lends itself to jump tables. The full range unfortunately needs to be compiled to a slew of if then elseif then elseif then else endif statements.
|
|
|
|
|
What I think to remember is, that you are very familiar with code generating. Therefore creating/generating a class for each state maybe will help
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
In C# I typically use a class to represent a state in a state machine. However, when the code gets generated it either resolves to an array instantiation with the appropriate state machine information (fastest option under .NET) or it can resolve to series of gotos (can't really switch case here unless you were to have goto case all over the place in which case you may as well just use goto). The latter option doesn't perform as well as the array/table driven approach. In C++ however, the latter would be faster - and I'd be using a switch to make sure the compiler was generating jmp tables.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: In C# I typically use a class to represent a state in a state machine. Fair enough. But if you activate anything as complex as a class mechanism to serve for state value (which in most simpler state machines is nothing more than a scalar value), then I do not understand why you are worried about the compiler using hash tables rather than simple jump tables in a small set of cases where it might have saved you some small fraction of a microsecond.
|
|
|
|
|
> where it might have saved you some small fraction of a microsecond.
Microseconds add up.
Lexing is inner inner loop stuff - it's absolutely critical for this codepath to be as efficient as possible. Like Microsoft's hashtable dictionary implementation, performance is key.
Most of the time it's not. Typically my state machine code is.
Real programmers use butterflies
|
|
|
|
|
Yet you involve a class mechanism to hold the state? That is what surprises me.
|
|
|
|
|
The classes don't exist in the compiled code. The class instances simply hold data used to compile the machine. The compiled code uses no state classes
Real programmers use butterflies
|
|
|
|
|
I'm not a python dev. I have written exactly zero bits of software in it.
That said, even I know you can do practically anything with it, and a lot of complicated things can be shockingly easy to do in python.
I'm guessing that's probably why it's so popular with the AI crowd.
The thing that keeps me away from it is the significant whitespace in the grammar** and my general distaste for scripting. I know both of those things are just me being nit picky but we all have our preferences.
**I'm deeply concerned about this as it raises a lot of questions. Is 4 spaces read the same way as a tab? Is my editor going to destroy my sourcecode if it reformats the document? etc. I really don't like this.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: Is 4 spaces read the same way as a tab?
No. A tab is one whitespace character, four spaces are four - so the compiler looks at identical looking code in your editor and thinks that it's differently indented.
There have been quite a few question this year where that has been the problem.
And that's one of the reasons I really don't like Python.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Another problem with whitespace is which definition of whitespace. Python scopes by a subset of whitespace characters. I guess this subset is defined in a language spec, but there is only one way to be reasonably sure to avoid problems: Whenever anyone says "whitespace", read it as "a space character".
|
|
|
|
|
I agree though I'll say I've written enough parsers and grammars that I guess I expect it to be a language specific subset of whitespace (the JSON standard grammar has a similar issue) but that's me. It's rare that I've found languages that accept literally any whitespace you can throw at it. I think C# is an exception in that it can handle it (but I'd have to look to be certain)
Real programmers use butterflies
|
|
|
|
|
So, refusing to use a hammer to take care of a nail just because the handle is pink coloured instead of wooden coloured ?
|
|
|
|
|
More because the handle is invisible, if we're extending the analogy to whitespace
Real programmers use butterflies
|
|
|
|
|
AND that the accuracy of the hammer differs depending on the size of the handle. Which is kind of a terrible analogy, since it is indeed that way in reality
|
|
|
|
|
When there are better looking hammers, yes.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
this
Real programmers use butterflies
|
|
|
|
|
I usually need a bigger hammer.
I think we all tend to look at something newish as a replacement for our current "hammer".. I find python to be very handy to work out what someone really wants. A friend has a bunch of (older) IoT controllers in an office building. The interface is via a built in web server in each controller. He wants to collect the data remotely. Turns out that these things will contact a syslog server if you configure it. Wrote the initial server in python to figure out what data he wanted to parse out and how to format it. Then rewrote it in C++ (runs on a W7 system). Reason to rewrite? Since the controllers are independent, and clashes are probable, performance was high priority... Windows is not an RTOS. Do they miss an occasional event? Probably, how would we know?
Lou
--
Give a man a fish; you have fed him for today.
Teach a man to use the Internet and he won't bother you for weeks, or even months unless you give him your email address.
¯\_(ツ)_/¯
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|