JoshData/jot

window.ai

dataf3l opened this issue · 4 comments

jot/jot/diff.js

Line 143 in ebf8c61

var ai = a.map(function(item, i) { return i });

so this "var ai=" thing or using window.ai or setting this value, may have a problem with upcoming changes on the chrome browser and possibly also nodejs as it usually mimics browser apis precisely, as it hides window.ai maybe it should be renamed to prevent future potential conflicts to another name.

this is just speculation. but I think maybe google will want window.ai for itself.
so this code may break when interacting with other code in the future perhaps.
specially if done globally.

see this link for details.
https://developer.chrome.com/docs/ai/built-in

right now it's behind a flag but in the future this may change.

not clear on the timeline tho.

have an awesome day!

This variable is set within the function, so it shouldn't affect the global scope.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var

Besides, since the library is using CommonJS require, a bundler should encapsulate all global variables here (into ES Module, UMD or IIFE).

i think they are going to rename it so maybe let's just close this issue and not worry about it

I think the original post was some sort of AI-driven spam and not a sincere attempt to improve this project.

google releases the ai feature, this will change javascript forever, but it will break some existing code.
so we have 2 options, either we don't care, or we notidy authors about the breaking changes
so they don't break the variable.
how would you feel if netscape released "window.userAgent" back in 94 or so, and we had thousands upon thousands of
lines which already use the word userAgent somewhere, and you knew for a fact that google was about to break millions of projects.

A) would you do nothing?
B) would you choose to notify the authors shadowing upcoming variables so they don't do that? creating hard to debug bugs when ai is integrated later?
C) would you try to tell people about it?

if you feel this was spam, and that the first message was spam, I profusely apologize, but I figured maybe authors aren't even aware of the possibilities.

I for one envision a future where lots of websites have ai, even if it's basic and dumb ai, and it's only used for validation
for this future to take place, we need to let people know window.assistant.ai or window.ai or whatever is available to them, and we need to encourage them to experiment with it.

is that a honest attempt to improve the internet as a whole? yeah.
is that spam? we'll, that's up to you to decide.
am I a honest person? yes, yes I am.
was I honestly trying to "spam" the internet to have my name everywhere, and have my claim to fame? no, that wasn't my intention, as I'm sure it wasn't your intention to be famous, when you published this code.

I cannot predict the future, but I suspect using future-reserved words in our codes, is like, a bad thing.

for me, the main issue is awareness, do people know about it? what will they build with it? will they integrate it
with this project? if so, how? will that break stuff? what will break first? what are the limits of the tools? the possibilities?

this is what was on my mind, nothing more, nothing less.
but hey, feel free to ignore me, I'm just "some guy spamming your project" as it seems.