Lift JS AST stuff

28 views
Skip to first unread message

Joe Barnes

unread,
Aug 19, 2015, 10:12:24 AM8/19/15
to Lift
Yesterday I had to use some of our JS AST type stuff to get my clustering example working, and I had forgotten how difficult I sometimes find it.  I know what JS I want in my head, and it takes a bit of effort to remember what I need in Lift to produce it.  Using JsRaw is always an option, but that always feels more like I'm quitting and losing any type checking I could otherwise have.  

Have any of you been thinking about ways to improve this?  I'm curious if string interpolation would work well here.  I feel that quasiquotes are a strong indicator that it can work well.  The biggest challenge of course will be actually parsing the JS string, but maybe Nashorn/Rhino has some capabilities we could leverage.  Perhaps we could have a jsexp interpolater that checks that the string is parseable and a jscmd that checks that the string is a full command.

Thoughts?

Joe

Antonio Salazar Cardozo

unread,
Aug 19, 2015, 1:35:49 PM8/19/15
to Lift
I have a way I've improved this: “don't”.

IMO, if you want to write JS, write JS. Use a minimal abstraction layer to communicate
from Lift—whether those are events on `document` or the streaming promises David put
into Lift 3, either way. Or use, a full abstraction like Scala.js (zero experience here). But
trying to do properly-typed JS the way that our JsExp stuff currently does is, IMO, simply
adding cognitive overhead where it's not needed by trying to shoehorn JS into a state
it doesn't want to exist in.

Then again, I'm a strong “separation of concerns” advocate, and I'm a strong “let your
environment guide you to the truth” advocate, and so I think keeping JS in JS helps
enforce the separation of browser vs server concerns very effectively.
Thanks,
Antonio

Joe Barnes

unread,
Aug 19, 2015, 1:45:29 PM8/19/15
to lif...@googlegroups.com
I agree in that one should write very little JS in your Scala/Lift code.  It should just call functions you otherwise have written in JS.

My idea is to cover the cases when you do embed JS code.  I guess another take on it is that we should do it so little and infrequently it isn't worth having String Interpolation to help.

Joe


--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to a topic in the Google Groups "Lift" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/liftweb/_QHMnQJ6qs0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Pollak

unread,
Aug 19, 2015, 3:49:48 PM8/19/15
to liftweb
+1

The Js abstractions never really jelled... I use JsRaw most places.

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Lift, the simply functional web framework http://liftweb.net
Reply all
Reply to author
Forward
0 new messages