>
> Python's classes are more sclerotic than we might like, a point that 
> Vitalije has made.


I was using functional programming style in Python for a long time but in 
very limited way. Main limiting factor was the fact that I used to write 
class for everything and everywhere. After I have used a bit of scala, 
clojure and clojurescript, I realized that very often my classes were 
standing in the way.

While learning about clojure, I saw some video where the speaker was 
talking about main complains people make about clojure syntax. One of the 
biggest is that clojure uses too many parentheses. He has pointed out that 
the syntax difference is just about where we put the parentheses:
(println "hello")
vs
println("hello")

And this point was a really surprising for me. A true revelation. It opened 
my eyes and I realized that there was nothing really stopping me to write 
exactly the same functional code using any other language.

My point is that Leo's code can be simplified using functional programming 
style, while keeping Python as the implementation language.

A constant need for reloading is caused by the fact that we don't use 
immutable data types. The main cost of using immutable data types is the 
memory cost. That cost is considerably reduced these days by using some 
nice techniques. But even with the most consuming - naive implementation, 
this cost doesn't matter at all, because memory has become very cheap.

To achieve code completion, there is an interesting idea behind Nightlight 
<https://sekao.net/nightlight/> editor. His author turned an editor into a 
library. Users do not install editor, but rather they list it in the 
project development dependencies. Using build tool this editor starts a 
small http server inside the project folder and displays the editor inside 
web browser allowing user to edit source code and run REPLs inside the 
project. That way editor server knows about names in the project and in the 
currently edited file.

Using web browser as a GUI makes changing Leo's appearance on the fly easy. 
In modern web client frameworks the page is usually redrawn 60 times per 
second which means any and all changes in the state of the application (no 
matter how big those changes are), are displayed in the very next frame (in 
less than 16ms).

Nightlight editor is written in Clojure/ClojureScript but as I said before, 
we can look at its code just as a Python code with some parenthesis moved 
to the left and some commas removed. Theoretically, we could take 
Nightlight's clojure code, then move few parentheses one word to the right 
after the function name and add some commas where Python expects them, and 
we'll get the working Python code. Naturally, we need to adjust few things 
to use Python libraries instead of Java and Clojure ones, but that also 
should not be very hard. There are about 1600 lines / 60k characters in 
Nightlight code, and yet it gives fully functional code editor, few types 
of REPLs, auto-complete function, a live app preview (when developing web 
applications) and almost zero installation.

I am not suggesting replacing Leo with the Nightlight. There are some 
valuable ideas behind Nightlight, Clojure and ClojureScript that Leo might 
benefit from.
 
Vitalije

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to