sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.16k stars 212 forks source link

deprecation: remove all coffeescript from cocalc #6377

Open williamstein opened 1 year ago

williamstein commented 1 year ago

Motivation: Coffeescript is dangerous, as compared to Typescript.

What remains:

~/cocalc/src/packages$ git ls-files |grep -e cjsx$ -e coffee$
database/filesystem-bucket.coffee
database/postgres-base.coffee
database/postgres-blobs.coffee
database/postgres-ops.coffee
database/postgres-server-queries.coffee
database/postgres-synctable.coffee
database/postgres-user-queries.coffee
database/postgres-user-query-queue.coffee
frontend/assistant/actions.coffee
frontend/assistant/body.cjsx
frontend/assistant/common.coffee
frontend/assistant/dialog.cjsx
frontend/assistant/footer.cjsx
frontend/assistant/header.cjsx
frontend/assistant/legacy.cjsx
frontend/assistant/main.coffee
frontend/assistant/store.coffee
frontend/console.coffee
frontend/course/test/project-upgrades.coffee
frontend/editor.coffee
frontend/editor_history.coffee
frontend/editor_jupyter.coffee
frontend/printing.coffee
frontend/sagews/3d.coffee
frontend/sagews/d3.coffee
frontend/sagews/interact.coffee
frontend/sagews/sagews-eval.coffee
frontend/sagews/sagews.coffee
frontend/syncdoc.coffee
hub/access.coffee
hub/api/handler.coffee
hub/auth-token.coffee
hub/blobs.coffee
hub/client.coffee
hub/local_hub_connection.coffee
hub/metrics-recorder.coffee
hub/p.coffee
hub/password.coffee
hub/projects.coffee
hub/sign-in.coffee
hub/smc-manager.coffee
hub/user-query-stats.coffee
hub/user-remember-me.coffee
project/blobs.coffee
project/client.coffee
project/common.coffee
project/exec_shell_code.coffee
project/kucalc.coffee
project/port_manager.coffee
project/print_to_pdf.coffee
project/read_write_files.coffee
project/sage_session.coffee
project/watcher.coffee
util/test/defaults.coffee
util/test/key-value-store.coffee
util/test/misc-test.coffee
util/test/types.coffee

And the same, but with line counts, sorted from largest to smallest:

~/cocalc/src/packages$ git ls-files |grep -e cjsx$ -e coffee$
~/cocalc/src/packages$ git ls-files |grep -e cjsx$ -e coffee$ | xargs wc -l |sort -nr
   26969 total
    2947 database/postgres-server-queries.coffee
    2484 frontend/sagews/sagews.coffee
    2072 hub/client.coffee
    1888 frontend/editor.coffee
    1763 database/postgres-user-queries.coffee
    1494 frontend/editor_jupyter.coffee
    1139 database/postgres-base.coffee
    1041 util/test/misc-test.coffee
    1014 frontend/console.coffee
     964 frontend/sagews/3d.coffee
     887 database/postgres-blobs.coffee
     716 hub/local_hub_connection.coffee
     627 frontend/printing.coffee
     604 database/postgres-synctable.coffee
     591 frontend/editor_history.coffee
     589 project/client.coffee
     577 frontend/syncdoc.coffee
     478 frontend/sagews/interact.coffee
     352 hub/password.coffee
     327 hub/sign-in.coffee
     323 frontend/assistant/actions.coffee
     321 project/sage_session.coffee
     273 project/kucalc.coffee
     256 frontend/assistant/body.cjsx
     238 frontend/sagews/d3.coffee
     218 database/postgres-user-query-queue.coffee
     193 frontend/course/test/project-upgrades.coffee
     181 hub/metrics-recorder.coffee
     171 hub/api/handler.coffee
     168 database/postgres-ops.coffee
     163 util/test/types.coffee
     131 frontend/assistant/dialog.cjsx
     123 project/read_write_files.coffee
     122 hub/auth-token.coffee
     110 frontend/assistant/header.cjsx
     107 hub/projects.coffee
     103 util/test/defaults.coffee
     100 project/print_to_pdf.coffee
     100 frontend/assistant/store.coffee
      97 frontend/sagews/sagews-eval.coffee
      89 frontend/assistant/footer.cjsx
      81 hub/user-query-stats.coffee
      77 hub/access.coffee
      74 project/watcher.coffee
      73 hub/smc-manager.coffee
      70 project/blobs.coffee
      66 hub/blobs.coffee
      58 util/test/key-value-store.coffee
      51 project/exec_shell_code.coffee
      49 frontend/assistant/main.coffee
      48 database/filesystem-bucket.coffee
      45 hub/user-remember-me.coffee
      36 project/port_manager.coffee
      36 frontend/assistant/legacy.cjsx
      28 frontend/assistant/common.coffee
      21 project/common.coffee
      15 hub/p.coffee

It's still around 20K lines of code (or about 10% of the cocalc codebase):

~/cocalc/src/packages$ git ls-files |grep -e cjsx$ -e coffee$ | xargs cat | wc -l
   26969
~/cocalc/src/packages$ git ls-files |grep -e cjsx$ -e coffee$ | xargs cat | sort | uniq | wc -l
   17864
~/cocalc/src/packages$ git ls-files |grep -e ts$ -e tsx$ | xargs cat | sort | uniq | wc -l
  160965
williamstein commented 1 year ago

I asked ChatGPT for better code for counting non-blank non-comment lines of code in all our coffeescript files and it suggested this, which may be useful for keeping track of our status:

~/cocalc/src$ git ls-files | grep '\.coffee$' | xargs cat | grep -vE '^\s*$|^\s*#' | wc -l
20117
williamstein commented 1 year ago

Status after @haraldschilly did a ton of work on decaf of the project:

~/cocalc/src/packages$ git ls-files | grep '\.coffee$' | xargs cat | grep -vE '^\s*$|^\s*#' | wc -l
19256
haraldschilly commented 1 year ago

yes. next up is a "final push" for the project, then removing coffeescript itself from it, etc. IMHO the next logical step after this is to transcribe some coffee files in the hub, which are calling code in the project.