writing extensions in javascript, using class?

Hello,
Bokeh has been great so far and I am making my first foray into extending it. My javascript experience is limited—years ago I wrote some short web applications using old-school javascript.

My understanding is that modern browsers and nodejs support nice things like classes, super(), and other features.

The examples I have seen so far in the bokeh documentation (like at Extending Bokeh — Bokeh 2.4.2 Documentation)

use Coffeescript, which also has similar nice features, unfortunately with enough differences to be a bit confusing .

So I am left with a question:

Can we use modern javascript features in our extensions?

Is there a pure javascript version of the above example?

Many thanks

-Chris

Hi,

···

On Wed, Jul 5, 2017 at 9:11 PM, [email protected] wrote:

Hello,
Bokeh has been great so far and I am making my first foray into extending it. My javascript experience is limited—years ago I wrote some short web applications using old-school javascript.

My understanding is that modern browsers and nodejs support nice things like classes, super(), and other features.

It’s not that simple. Browsers and node.js support modern javascript (or ecmascript to be precise) to varying degrees. Some more, some less. That’s why we don’t depend on this and write bokehjs in languages that compile to javascript understood by all supported browser. Thus we use coffeescript and are slowly transitioning to typescript. We could write bokehjs in modern javascript, but we would still require a compilation step to generate common javascript. We could use babel for this purpose.

The examples I have seen so far in the bokeh documentation (like at http://bokeh.pydata.org/en/latest/docs/user_guide/extensions.html#userguide-extensions)

use Coffeescript, which also has similar nice features, unfortunately with enough differences to be a bit confusing .

So I am left with a question:

Can we use modern javascript features in our extensions?

We could by using babel, but currently it’s not supported, though it’s not hard to implement. However, we support typescript (and currently use a non-strict mode in extensions). Typescript uses modern javascript as its syntactical basis, so given non-strict mode, you can pretty much write modern javascript with it.

Is there a pure javascript version of the above example?

Currently not and I think we don’t have any examples of this kind with typescript or plain javascript. This will change soon, as we are replacing coffeescript across bokeh.

Mateusz

Many thanks

-Chris

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” 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].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/030b8b37-ef39-49b8-ba3d-b3b2433277e3%40continuum.io.

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

Thank you for the explanation! It also sounds like I’m catching things in the midst of a transition.

It sounds like we might be able to use Typescript now.

To do this, do we use something like

class MyNewWidget(LayoutDom):
implementation = “my_new_widget_implementation.ts”

``

and write the implementation file separately extending LayoutDomView etc.

···

On Wednesday, July 5, 2017 at 12:43:55 PM UTC-7, Christopher Lee-Messer wrote:

Hello,
Bokeh has been great so far and I am making my first foray into extending it. My javascript experience is limited—years ago I wrote some short web applications using old-school javascript.

My understanding is that modern browsers and nodejs support nice things like classes, super(), and other features.

The examples I have seen so far in the bokeh documentation (like at http://bokeh.pydata.org/en/latest/docs/user_guide/extensions.html#userguide-extensions)

use Coffeescript, which also has similar nice features, unfortunately with enough differences to be a bit confusing .

So I am left with a question:

Can we use modern javascript features in our extensions?

Is there a pure javascript version of the above example?

Many thanks

-Chris

Hi,

Hello,
Bokeh has been great so far and I am making my first foray into extending
it. My javascript experience is limited---years ago I wrote some short web
applications using old-school javascript.

My understanding is that modern browsers and nodejs support nice things
like classes, super(), and other features.

It's not that simple. Browsers and node.js support modern javascript (or
ecmascript to be precise) to varying degrees. Some more, some less. That's
why we don't depend on this and write bokehjs in languages that compile to
javascript understood by all supported browser. Thus we use coffeescript
and are slowly transitioning to typescript. We could write bokehjs in
modern javascript, but we would still require a compilation step to
generate common javascript. We could use babel for this purpose.

The examples I have seen so far in the bokeh documentation (like at

http://bokeh.pydata.org/en/latest/docs/user_guide/extensi
ons.html#userguide-extensions)
use Coffeescript, which also has similar nice features, unfortunately
with enough differences to be a bit confusing .

So I am left with a question:

Can we use modern javascript features in our extensions?

We could by using babel, but currently it's not supported, though it's not
hard to implement. However, we support typescript (and currently use a
non-strict mode in extensions). Typescript uses modern javascript as its
syntactical basis, so given non-strict mode, you can pretty much write
modern javascript with it.

Is there a pure javascript version of the above example?

Currently not and I think we don't have any examples of this kind with
typescript or plain javascript. This will change soon, as we are replacing
coffeescript across bokeh.

Here bokeh_ext_ts_or_es.py · GitHub is a
quick translation of the example in question. Notice that I need to wrap
CODE in TypeScript constructor, but in the code, I don't use any additional
features (like type annotations) on top of ES6.

Mateusz

···

On Wed, Jul 5, 2017 at 10:29 PM, Mateusz Paprocki <[email protected]> wrote:

On Wed, Jul 5, 2017 at 9:11 PM, <[email protected]> wrote:

Many thanks

-Chris

--
You received this message because you are subscribed to the Google Groups
"Bokeh Discussion - Public" 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].
To view this discussion on the web visit https://groups.google.com/a/co
ntinuum.io/d/msgid/bokeh/030b8b37-ef39-49b8-ba3d-b3b2433277e
3%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/030b8b37-ef39-49b8-ba3d-b3b2433277e3%40continuum.io?utm_medium=email&utm_source=footer&gt;
.
For more options, visit https://groups.google.com/a/continuum.io/d/optout
.

Hi,

Hello,
Bokeh has been great so far and I am making my first foray into
extending it. My javascript experience is limited---years ago I wrote some
short web applications using old-school javascript.

My understanding is that modern browsers and nodejs support nice things
like classes, super(), and other features.

It's not that simple. Browsers and node.js support modern javascript (or
ecmascript to be precise) to varying degrees. Some more, some less. That's
why we don't depend on this and write bokehjs in languages that compile to
javascript understood by all supported browser. Thus we use coffeescript
and are slowly transitioning to typescript. We could write bokehjs in
modern javascript, but we would still require a compilation step to
generate common javascript. We could use babel for this purpose.

The examples I have seen so far in the bokeh documentation (like at

http://bokeh.pydata.org/en/latest/docs/user_guide/extensi
ons.html#userguide-extensions)
use Coffeescript, which also has similar nice features, unfortunately
with enough differences to be a bit confusing .

So I am left with a question:

Can we use modern javascript features in our extensions?

We could by using babel, but currently it's not supported, though it's
not hard to implement. However, we support typescript (and currently use a
non-strict mode in extensions). Typescript uses modern javascript as its
syntactical basis, so given non-strict mode, you can pretty much write
modern javascript with it.

Is there a pure javascript version of the above example?

Currently not and I think we don't have any examples of this kind with
typescript or plain javascript. This will change soon, as we are replacing
coffeescript across bokeh.

Here bokeh_ext_ts_or_es.py · GitHub is
a quick translation of the example in question. Notice that I need to wrap
CODE in TypeScript constructor, but in the code, I don't use any additional
features (like type annotations) on top of ES6.

Well, actually the code uses trailing commas, which aren't supported in any
version of ES, but that's not a problem because typescript will generate
valid javascript anyway.

···

On Wed, Jul 5, 2017 at 10:49 PM, Mateusz Paprocki <[email protected]> wrote:

On Wed, Jul 5, 2017 at 10:29 PM, Mateusz Paprocki <[email protected]> > wrote:

On Wed, Jul 5, 2017 at 9:11 PM, <[email protected]> wrote:

Mateusz

Many thanks

-Chris

--
You received this message because you are subscribed to the Google
Groups "Bokeh Discussion - Public" 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].
To view this discussion on the web visit https://groups.google.com/a/co
ntinuum.io/d/msgid/bokeh/030b8b37-ef39-49b8-ba3d-b3b2433277e
3%40continuum.io
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/030b8b37-ef39-49b8-ba3d-b3b2433277e3%40continuum.io?utm_medium=email&utm_source=footer&gt;
.
For more options, visit https://groups.google.com/a/co
ntinuum.io/d/optout.

Yeah! My hero! Your gist is just what I was hoping for.
-C

···

On Wednesday, July 5, 2017 at 12:43:55 PM UTC-7, Christopher Lee-Messer wrote:

Hello,
Bokeh has been great so far and I am making my first foray into extending it. My javascript experience is limited—years ago I wrote some short web applications using old-school javascript.

My understanding is that modern browsers and nodejs support nice things like classes, super(), and other features.

The examples I have seen so far in the bokeh documentation (like at http://bokeh.pydata.org/en/latest/docs/user_guide/extensions.html#userguide-extensions)

use Coffeescript, which also has similar nice features, unfortunately with enough differences to be a bit confusing .

So I am left with a question:

Can we use modern javascript features in our extensions?

Is there a pure javascript version of the above example?

Many thanks

-Chris