wenyan icon indicating copy to clipboard operation
wenyan copied to clipboard

Instant results for wenyan-lang

Open antfu opened this issue 5 years ago • 6 comments

From my point of view, wenyan-lang is extremely readable in ancient Chinese. Which also has great potential in education (especially for junior and high school students). It's sometimes hard to tell what's going on in some complex long programs. I would propose having an instant result system for ide and editor extensions like Quokka.js for Javascript.

Just a quick thought, feel free to leave comments below. Thanks

antfu avatar Jan 29 '20 01:01 antfu

I like the idea! I just tried Quokka.js a bit, and it looks pretty cool.

I do have a couple thoughts/concerns, but please do enjoy your vacation first! We can discuss more in detail later. :D

LingDong- avatar Jan 29 '20 04:01 LingDong-

Thoughts/concerns:

How to implement it so that it gives a nice user experience. Linters can easily be very annoying if they're not lightning fast. For example, when I'm halfway typing a variable name, and it suddenly kicks in and goes "Aha! x is not defined!". When I'm actually done typing, it just sits there with the old error message, only realizing that the problem no longer exists many seconds later. It disturbs me to see those red thingies on my screen, and I find myself constantly waiting for them to clear. And when this doesn't happen soon, I'm often left to wonder if I really did something wrong, or it's just the linter being exceptionally slow.

I'm also thinking whether instant results can lead to problems. For example, if I am trying to type exec("rm -rf somethingsomething"), and the moment I finish the exec("rm -rf")part the instant result kicks in it could be pretty terrible. Perhaps we need to restrict some features when in instant result mode.

And also, what should happen when there is a really big loop (Quokka seems to just hang)? What should happen if the code is very resource hungry, should it just keep rerunning it in the background?

I think this feature would definitely be very useful for learners of the language, we just need to take care not to make it become a confusing thing itself :)

LingDong- avatar Jan 30 '20 16:01 LingDong-

Yeah. I think we can do better than Quokka on these ways

When I'm actually done typing, it just sits there with the old error message, only realizing that the problem no longer exists many seconds late

  • Clear the result on user typed and appear once the executing is finished.
  • I think we may have something like "typing mode" (a threshold to wait for user stop typing) and during that mode, we can just show up a warning triangle on the left side of the editor to be less existential

Perhaps we need to restrict some features when in instant result mode.

Agreed. I am wondering how Quokka handles that. Will do some experiment later.

And also, what should happen when there is a really big loop (Quokka seems to just hang)? What should happen if the code is very resource hungry, should it just keep rerunning it in the background?

Maybe a timeout system or some limits that prevent instant execution from big loops. Maybe something like Maximum call stack size exceeded in js.

What do you think?

antfu avatar Jan 31 '20 01:01 antfu

All sound great!

I'm also thinking about the UI. Perhaps annotating the results within the source code can look a bit messy, how about we have a separate panel side by side with synchronized lines & scrolling, e.g. like Xcode swift playground:

image

I'm currently deeply stuck in the OCR generated font thing, but I can look into it too in a couple of days once I'm done with that :)

LingDong- avatar Jan 31 '20 02:01 LingDong-

Yeah I think we can make a core package that editor unrelated and can be reused by online ide and vsocde extension etc.

For the UI, how about the making the annotations right aligned?

And good luck with the OCR. Let me know if I can do some help :)

antfu avatar Jan 31 '20 04:01 antfu

I think right alignment sounds good. What happens if the line is already long though. I guess we can figure out these details as we progress.

I'm doing some final tweaking with the font, will make public soon :)

LingDong- avatar Feb 01 '20 00:02 LingDong-