Running awk deterministic [closed] - awk

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm looking for a way to run awk in a verifiably deterministic way, that is to say: result should be determined by input only. In other words, given that a program has output, I want to know that it is repeatable.
This would mean removing access to non-deterministic sources of input, such as the system time or files with changing content such as /dev/random.
I have looked at the sandbox flag in gawk, which I don't think will help, and ZeroVM.

I don't think it is possible in general. For example, this script will print different values when run even though it doesn't depend on any input file
awk 'BEGIN{print systime()}'
However, you can write your scripts in a functional, repeatable way to only depend on the input file and have a predefined output order (the array order iteration is not predictable), don't make system calls or use random.

ZeroVM would indeed be a way to do what you want: it sandboxes applications and removes all non-deterministic system calls. As an example, there are no threds (since their scheduling ineviatable leads to non-determinism) and the time starts at Jan 1 1970 on every execution (the time is then advanced by certain system calls).
I don't have a system with ZeroVM installed any longer, but it shouldn't be difficult to compile awk for it. Infact, I remember that busybox was running in ZeroVM, and busybox has some form of awk.

Related

How does a computer processes each and every command given to it? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
If I type in some command let be as simple as possible like print numbers from one to ten in BlueJ. Now since I have given a main command the computer processes the command and gives the output, but my question is how each and every number is printed by the computer is there any particular code integrated within the software of the computer which processes and prints each and every number each and every time the above code is ran?
This depends upon the operating system. Here are two approaches:
I. In eunuchs variants the command interpreter is just a program. There is nothing special about it except that it processes commands. For the most part, commands simply map to programs. If you type "xyx" the command interpreter searches for an executable (or script) named xyz to execute. An environmental variable "PATH" defines the directories to search for the file.
II. In the VMS system, the command interpreter resides in a protected area of the process address space. For an interactive process, the command interpreter sits in the background while a program is running. Commands are defined by a table. If you type XYZ, the command interpreter looks for the XYZ command, figures out what the options to that command are, and runs the appropriate program. The actual program could be ABC and it is even possible that the same command could invoke different programs, depending upon the options supplied.

How to improve the performance of the package [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have been asked to improve the package performance without affecting the functionality.How to start with optimisation ?Any suggestions
In order to optimize PL/SQL programs you need to know where they spend time during execution.
Oracle provide two tools for profiling PL/SQL. The first one is DBMS_PROFILER. Running a packaged procedure in a Profiler session gives us a breakdown of each program line executed and how much time was spent on each line. This gives us an indication of where the bottlenecks are: we need to focus on the lines which consume the most time. We can only use this on our own packages but it writes to databases tables so it is easy to use. Find out more.
In 11g Oracle also gave us the Hierarchical Profiler, DBMS_HPROF. This does something similar but it allows us to drill down into the performance of dependencies in other schemas; this can be very useful if your application has lots of schemas. The snag is the Hprofiler writes to files and uses external tables; some places are funny about the database application writing to the OS file system. Anyway, find out more.
Once you have your profiles you know where you need to start tuning. The PL/SQL Guide has a whole chapter on Tuning and Optimization. Check it out.
" without affecting the functionality."
Depending on what bottlenecks you have you may need to rewrite some code. To safely change the internal workings of PL/SQL without affecting the external functionality(same outcome for same input) you need a comprehensive set of unit tests. If you don't have these already you will need to write them first.

Does Zerobrane provide an "include" mechanism? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
To Zerobrane users, since this is not a question on lua :
I use Zerobrane for editing lua programs that are to be used with LuaLatex. Very nice !
I make all tests there before using the developments in LuaLatex. So, at the beginning, the programs are run there. I need to tidy up this part, on ZeroBrane, by making files hierarchical, with a master file and slave files around.
Once again, it is a question about ZeroBrane, not about how I use the file within LuaLatex (I know enough about doFile, luaexec and co)
Does this exist ?
I saw PaulK passing by, if he could drop a line, it would be appreciated ...
An "include mechanism" as you call it is usually a language feature, not some feature of an IDE.
Lua provides various functions for running code from other files.
dofile, load, loadfile, require, ...
The most convenient and common is require which will find a file by its name in a given set of directories and execute its contents.
Read this:
https://www.lua.org/manual/5.3/manual.html#6.3
https://www.lua.org/pil/8.1.html
https://www.tutorialspoint.com/lua/lua_modules.htm

Why would a Scripting language be made 'purposefully Turing non-complete'? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So, I was reading about Bitcoin Script on their official documentation and found this line: "Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops." I tried to reason hard but couldn't understand why would someone make a language "purposefully non Turing-complete". What is the reason for this? What happens if a language become Turing Complete?
And extending further, whether "with no loops" has anything to do with the script being non-Turing Complete?
possible reasons:
security: if there is no loops program will always terminate. user can't hang up the interpreter. if, in addition there is a limit on size of the script you can have pretty restrictive time constraints. another example of a language without loops is google queries. if google allowed loops in , users would be able to kill their servers
simplicity: no loops make language much easier to read and write by non-programmers
no need: if there is no business need for it then why bother?
The main reason is because Bitcoin scripts are executed by all miners when processing/validating transactions, and we don't want them to get stuck in an infinite loop.
Another reason is that according to this message from Mike Hearn, Bitcoin script was an afterthought of Satoshi to try to incorporate a few types of transactions he had had in mind. This might explain the fact that it is not so well designed and and has little expressiveness.
Ethereum has a different approach by allowing arbitrary loops but making the user pay for execution steps.

How do you decide which API function documentations to read and how seriously? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Suppose that you are writing or maintaining a piece of code that uses some API that you are not 100% familiar with.
How do you decide whether to read the documentation of a certain call target, and how much time to spend reading it? How do you decide not to read it?
(Let's assume you can read it by opening the HTML documentation, inspecting the source code, or using the hover mechanism in the IDE).
Ideally you should read all of it, but we know that's a pain in the... you know. What I normally do on those cases (and I did that a lot while I worked as a freelancer) is weight some factors and depending on the result, I read the docs.
Factors that tell me I shouldn't read the docs:
What the function does is easy to guess from the name.
It isn't relevant to the code I'm maintaining: for example, you are checking how some code deletes files, and you have some function that obviously does some UI update. You don't care about that for now.
If debugging: the function didn't change the program state in a way meaningful to the task at hand. As before, you don't want to learn what SetOverlayIcon does, if you are debugging the deletion code because it's dying with a file system error.
The API is just a special case of an API you already know and you can guess what the special case is, and what the special arguments (if any) do. For example, let's say you have WriteToFile(string filename) and WriteToFile(string filename, boolean overwrite).
Of course, everything depends on the context, so even those rules have exceptions.