gimite / web-socket-js

HTML5 Web Socket implementation powered by Flash
BSD 3-Clause "New" or "Revised" License
2.73k stars 489 forks source link

3rd party source vs swc lib discussion #85

Closed ghost closed 13 years ago

ghost commented 13 years ago

There was a thread on using 3rd party as embedded src vs using a 3rd party lib swc (as is typical).

3rd party code may already be used by larger projects, for example hurlant, normally as a swc. This makes it likely that the there are 2 instances of the same classes - possibly a different version. Which class will get loaded? This is non-deterministic.

Ideally all 3rd party closes is a .swc lib. At minimum put 3rd party code in a different src folder, ex: 3rdparty-src.

Also, some of these libs have evolved all-ready, possibly with bug fixes. This project needs to update to the latest Hurlant, etc.

gimite commented 13 years ago

I see. But we use only a few libraries, so library conflict is not an issue for now. I may reconsider when we use more libraries.

Also, some of these libs have evolved all-ready, possibly with bug fixes. This project needs to update to the latest Hurlant, etc.

Yeah if the libraries have any updates, it would be good to update them.

ghost commented 13 years ago

The issue is not that this project uses 3 libraries.

The issue is for the end user of this library that may also use one of the 3 libraries, they are quite common. If I am end user of this library(the swc) and I also use other libraries - most people use many libraries as the same time. If one of the other libraries also uses Hurlant for example, but a different version of it. Now for the end developer there are 2 versions of Hurlant classes. Which version of the Hurlant class gets loaded is non-deterministic.

3 ways to deal with it.

  1. use swc for 3rd party.
  2. repackage from com.hurlant to net.gimite.
  3. create another source (3rdparty-src) for dependencies. This only hints to a developer about the issue, some developers are not aware that they will create an intermittent issue.
ghost commented 13 years ago

For example a video player library may use hurlant also embedded in it's .swc.

gimite commented 13 years ago

I see. I have one question:

Suppose both web-socket-js and a video player library uses hurlant. Both libraries provide swc (WebSocket.swc and VideoPlayer.swc) which includes hurlant.swc. If a user includes both WebSocket.swc and VideoPlayer.swc, I guess the version conflict you mentioned still happens, even though we use swc for third-party library. How do people solve this issue? Do they rebuild WebSocket.swc (and VideoPlayer.swc) without hurlant, and include WebSocket-without-hurlant.swc, VideoPlayer-without-hurlant.swc, hurlant.swc instead?

ghost commented 13 years ago

Yes that is a common way, to distribute depenecies. It's a 'link library external flag' in ant or mxmlc. That is only an issue for lib/swc.

The other way is to repackage your hurlant classes from com.hurlant folder to org.gimite.hurlant folder.

There's pluses/minuses for each approach. For example, if there's a bug fix in one of the dependencies upstream related to security. Or if it breaks compatibility.

gimite commented 13 years ago

Submitted: https://github.com/gimite/web-socket-js/commit/80c91d84bc3e84f684f53172e8eb7cad81795fb1 to move third party .as files into flash-src/third-party, and add rule to build.xml to generate swc file with/without third-party files. So now you should be able to link your own third party libraries.

I'm not familiar with compc options, and I just checked that these swc files compiles. So I'm not very sure these file works as expected. Please let me know if it doesn't.

ghost commented 13 years ago

I tested the build, it works for me. I have not used it yet. Thank you, I think that should make it clear to people as to any issues. It be nice feature to upgrade to the current version of hurlant.

ghost commented 13 years ago

I have now used it (swc) and it works. ( w https://github.com/puppetMaster3/Gamina-Core/tree/master/as/src/org/gamina/srv to node websocket)