# Pas2js with generics rocks (and makes Castle Game Engine for WebGL possible)

**URL:** <https://forum.castle-engine.io/t/pas2js-with-generics-rocks-and-makes-castle-game-engine-for-webgl-possible/193>\
**Category:** News\
**Created:** [July 20, 2020, 9:45pm UTC](https://forum.castle-engine.io/t/pas2js-with-generics-rocks-and-makes-castle-game-engine-for-webgl-possible/193 "2020-07-20T21:45:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [July 20, 2020, 9:45pm UTC](https://forum.castle-engine.io/t/pas2js-with-generics-rocks-and-makes-castle-game-engine-for-webgl-possible/193/1 "2020-07-20T21:45:44Z")

</div>

| [![pas2js-generics](https://castle-engine.io/wp/wp-content/uploads/2020/07/pas2js-generics-200x108.png)](https://castle-engine.io/wp/wp-content/uploads/2020/07/pas2js-generics.png "pas2js-generics") |
| [![pas2js-webgl1](https://castle-engine.io/wp/wp-content/uploads/2020/07/pas2js-webgl1-200x98.png)](https://castle-engine.io/wp/wp-content/uploads/2020/07/pas2js-webgl1.png "pas2js-webgl1") |
| [![pas2js-webgl2](https://castle-engine.io/wp/wp-content/uploads/2020/07/pas2js-webgl2-200x98.png)](https://castle-engine.io/wp/wp-content/uploads/2020/07/pas2js-webgl2.png "pas2js-webgl2") |

[pas2js](https://wiki.freepascal.org/pas2js) can translate modern Object Pascal to JavaScript, making it possible to run Pascal code in a WWW browser. In the past, pas2js didn’t support _generics_, which made porting CGE to it troublesome, as we use generics a lot.

This weekend I tested recent pas2js support for generics, in particular with containers from the `Generics.Collections` unit. I tested 4 examples from [my book about modern Pascal](https://castle-engine.io/modern_pascal_introduction.html#generic-containers-section). …And the result is that everything just works! 🙂

This means that pas2js supports generics at a level we need for _Castle Game Engine_, so in general should be able to handle CGE Pascal code. Pas2js also supports WebGL rendering since a long time, since it can just call JavaScript API in a browser.

**All this means that we have everything we need to port _Castle Game Engine_ to WebGL!** That is, your games could be recompiled to just run in a WWW browser. No installation, no extra steps for the user. Anyone can open your WWW page and the game works, with Pascal code being translated into simple JavaScript that browser can efficiently execute.

I will work on this feature intensively after CGE 7.0 release.
