Can using a math interpreter be potentially dangerous? [closed] - security

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 1 year ago.
Improve this question
I want the user to be able to write their own math functions in my program. And these functions could possibly be shared with someone else, and run natively on their machine. Algebra is Turing complete. Does it mean I should warn users of my program about potential danger of running math? Sorry if this is a silly question :)
Edit:
I am making a simple diary, but the entries have dynamically calculated properties. I am thinking of using bc for running the user defined functions. It's rather easy to fix things for user if the expression does not end since they can modify the expression outside of the program. But let's say user A sends user B their diary. Should I warn user B that it's not safe to open their diary?

For example, you can have a Turing-complete language with recursion, but limit the stack size and run time (to kill the busy beavers) for each user script. If it's implemented as some kind of a VM it'll be very easy to do. You can also have a total functional language to ensure termination (but that won't solve the busy beavers problem).

Related

What is the best way to generate and run concurent threads from a for loop over an Arc<Mutex<Vec>>? [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 1 year ago.
Improve this question
Im running both a uni and multi threaded version of an application. There is no speed advantage. That said, what is the best way to access an Arc<Mutex<Vec>> and process each entry concurrently?
You cannot process an Arc<Mutex<Vec<T>>> concurrently - the mutex wraps the entire vector, so no other thread other than the one that locked it will be able to access it.
If you know the number of elements up front, you can use an Arc<Vec<Mutex<T>>>. This has a mutex per-element, so threads will lock only the elements. However you won't be able to grow or shrink the Vec since its shared.
There are also more specialized structures in the Concurrency section of http://lib.rs, with varying semantics, that may fit your needs.

what is the best practice for multiple threads writing to one file [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 6 years ago.
Improve this question
I'm writing a multi-threaded program and all these threads should write their data to a single file.
these threads only writing different strings for some kind of append-only logging
whats the best practice for sharing a file between threads for out put?
For logging (for future questions, make sure you put that information into the question rather than just a comment) there's a strong preference to not have the threads do file access they don't have to; as it means that logging negatively impacts performance for the rest of that thread.
For that reason, NathanOliver's suggestion of having the threads write to a shared container and then one dedicated to dumping that container to file would probably be the best option for you.

What would be the consequences of semi-asynchronous exception handling in GHC? [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 6 years ago.
Improve this question
I'm worried that approach to asynchronous exceptions in GHC might be a net-loss for many applications.
While the paper explains the design to a great detail, it's too complex for average programmers to tell whether this approach provides any benefits at all in their daily work.
Section 2 lists four reasons for current approach (speculative computation, timeouts, user interrupt and resource exhaustion). In my opinion, three are about ability to cancel computations and one is about ability to recover from resource exhaustion which I find questionable (is there any publicly available code that demonstrates this?).
In particular, as mentioned in the paper, Java deprecated Thread.stop() because aborted computation would result in undefined state. Aren't IO actions in GHC subject to the same? Add laziness and the API becomes much more complex in comparison for no clear benefit to most applications.
To summarize, if GHC used the same approach as Java (safe-points, interrupt polling) what would be the consequences to the ecosystem?

Skill needed to do advance level sas programming [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 8 years ago.
Improve this question
what is the best procedure to increase advance level SAS programming skill when there is no such requirement to use those concepts. Most of the time I complete my task using basic SAS concepts like set function, merge function or some other basic function. What is your suggestion if one wants to increase the programming capabilities.
I'm not going to venture a single 'best' option, but here are a few ideas:
I haven't gone down this route myself, but you could look into studying for the SAS certifications to broaden your SAS knowledge.
If you don't already know any SQL, that's something that's probably worth learning, as it's more transferable than most other SAS-related knowledge.
If you find yourself writing lots of very similar bits of code, learn how to use arrays and write macros (and when not to write macros).
If your code is taking a long time to run, read up on optimisation techniques and see if you can find faster ways of doing the same things. E.g. hash objects, indexes and parallel processing.

How PLINQ is better than traditional threading? [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 8 years ago.
Improve this question
Currently I have n suppliers web service which gives me search result for particular product. I am creating n threads myself and merging the final results returned by supplier. I have just come to know about PLINQ. I want to know if it would help the performance. If yes, how.
Better? Depends on what that means for you. PLINQ is definitely cleaner and more maintainable code for a lot of use cases. On the performance side depends on what you compare it against.
In your case if you are creating n threads by hand i would say you might be slower because PLINQ will use the threadpool and avoid some thread creation overhead.

Resources