Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iperov's GUI libraries #6

Open
dumblob opened this issue Dec 6, 2022 · 3 comments
Open

iperov's GUI libraries #6

dumblob opened this issue Dec 6, 2022 · 3 comments

Comments

@dumblob
Copy link
Owner

dumblob commented Dec 6, 2022

@iperov, let us continue the discussion about your library here.

The originating thread Immediate-Mode-UI/neonuklear#1 is meant as summarization of ideas but not really for exploration of these ideas. That is why I have diverted the discussion about your design choices in your GUI libraries elsewhere. Once your exploration is finished, you can happily summarize the outcomes in the originating thread.

So, first things first. Please present the code of your library so that I do not have to be too generic in explaining where all the error-prone vectors come from. You can link to your repo (or your Gist) or fork this repo and add it as a sub directory.

I hope we both will learn something new from discussing specific tangible things instead of pushing it into the generic realm.

Thanks!


Oh and btw. I am mostly a high-level guy (BOURNE sh, Python, Red, V, Julia, ...), so the C rant does not seem to apply to me 😉.

@iperov
Copy link

iperov commented Dec 9, 2022

I don't have GUI libraries.
I am currently experimenting with different GUIs and my own async library to make a framework for creating data-apps quickly.

@dumblob
Copy link
Owner Author

dumblob commented Dec 9, 2022

Whatever code you have, feel free to present it so that we can discuss it. Maybe begin with th code of your own async lib?

@iperov
Copy link

iperov commented Dec 12, 2022

Are you really interested in this, or do you want to troll?

My asynclib is not small. There is no documentation for it, but I already successfully use it in a real project.
The basic idea is to use python generator as Task, and create/switch threads using yield, thus we don't need Go-like channels. There is no need for main_loop control. Calling a function marked as task automatically creates and runs the task.
I have checked many languages. Apart from python, there is no language capable of implementing the same functionality, not even Rust.

some example

@easytask.taskmethod() 
def compute_task(n : int) -> easytask.Task[int]:
    # Each compute_task spawns its own physical python thread and switches to it
    sub_thread = easytask.Thread()
    
    try:
        yield easytask.yield_switch_thread(sub_thread)
        
        # Compute in sub thread and in a single task in this thread.
        
        yield easytask.yield_success(n*n)
    except easytask.ETaskDone:
        ...
        
    sub_thread.finalize()

@easytask.taskmethod() 
def main_task() -> easytask.Task: 
    # Run multiple tasks
    tasks = [ compute_task(i) for i in range(4) ]
    
    # Wait for all tasks in current task
    yield easytask.yield_wait(tasks)
    
    for task in tasks:
        print(f'Result: {task.result()}')
    """
    Result: 0
    Result: 1
    Result: 4
    Result: 9
    """

if __name__ == '__main__':
    t = main_task().wait() # wait Task in non-Task method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants