
WebAssembly COBOL Pong - ColinEberhardt
https://moxon6.github.io/cobol-js-emscripten/
======
angrygoat
Neat! The actual COBOL is pretty minimal, just tracking where the balls and
paddles are and then calling out to update the DOM. It doesn't look anywhere
near as horrific as I would have expected :)

[https://github.com/moxon6/cobol-js-
emscripten/blob/master/co...](https://github.com/moxon6/cobol-js-
emscripten/blob/master/cob/main.cob)

~~~
Tade0
My take is that people who fear COBOL probably haven't seen pre-ES5[0]
JavaScript.

[0] While ES2015 was a major leap in and of itself, it wouldn't have happened
had ES5 not laid the groundwork by introducing "minor improvements" that we
now take for granted like JSON, strict mode and Function.prototype.bind to
name a few.

------
TurboHaskal
For player 2, 'J' goes up, while pressing 'L' goes to the left from the
perspective of the paddle. This feels like made in purpose to hurt vi users.

~~~
moxon6
[https://github.com/moxon6/cobol-js-
emscripten/commit/0278590...](https://github.com/moxon6/cobol-js-
emscripten/commit/0278590231932d9887250c7b13cea6b3d58fab02)

~~~
saagarjha
No :(

------
ianbooker
I love how this is a total geekery for fun project and one of the best quasi
job application in 2020.

~~~
tiborsaas
That's really cool Ian, now can we get back to this directed graph?

~~~
jacoblambda
This hurts me on an emotional, spiritual, and physical level.

------
esimov
Cute little project. Thumb up for selecting Cobol as the language of choice
for the implementation. I might feel nostalgic.

------
jgrahamc
See also, using COBOL with Cloudflare Workers (via WebAssembly):
[https://blog.cloudflare.com/cloudflare-workers-now-
support-c...](https://blog.cloudflare.com/cloudflare-workers-now-support-
cobol/)

~~~
DarthGhandi
That was an enjoyable read, thanks.

------
snowoutside
This is sweet! Interestingly it seems to only accept QWERTY input even when
the keyboard has an alternate mapping set. This makes sense though given the
positions of the keys chosen

------
gpm
The ball doesn't seem to bounce "properly" \- i.e. upwards if it lands towards
the top of the paddle and downwards if it lands towards the bottom of the
paddle.

------
kibebr
That's impressive!

How did you remove all the bloat generated after Emscripten's compilation?

I've coded a snake game in C and when I compiled, the app.js file itself was
~2mb.

~~~
azakai
Try Emscripten's new MINIMAL_RUNTIME option. You can often get js files of
just a few Kb.

------
hardmaru
I heard COBOL skills are in demand these days in the US.

~~~
tgv
And now you know why: to reboot Half Life in the browser, leveraging a well-
known, time-tested programming language with wide and deep support.

------
elpg454
When I view the source code, it's just a javascript file,

[https://moxon6.github.io/cobol-js-emscripten/cobol-
js/index....](https://moxon6.github.io/cobol-js-emscripten/cobol-js/index.js)

where is the cobol?

~~~
brainless
You mean this file?

[https://github.com/moxon6/cobol-js-
emscripten/blob/master/co...](https://github.com/moxon6/cobol-js-
emscripten/blob/master/cob/main.cob)

I am still looking around so may be wrong.

~~~
elpg454
I was looking to see how it is included on the actual website, do you
reference a web assembly file from javascript ?

------
ptx
Cool!

What's the deal with the _alternator_ function (in app.js)? Why should
keypresses be read only on every other attempt?

Also, is there some kind of implicit sleep or requestAnimationFrame somewhere?
Or is it busy-looping and polling for key presses as fast as it can?

~~~
moxon6
The emscripten JS will keep "prompt"ing for new input until it receives a null
(due to the user pressing escape on the dialog)

This is just a hack around that to simulate entering a value and then pressing
escape on the next prompt request

------
rdiddly
I do enjoy a good stunt, although it's also fun to play while I wait for my
bloated-ass executable to upload!

------
benatkin
[https://youtu.be/st6-DgWeuos](https://youtu.be/st6-DgWeuos)

------
imadfy
Can you get mobile browsers to open the keyboard? I can't play. :(

------
sandov
Right paddle controls are backwards compared to vim.

~~~
madballster
A hidden swipe at evil/vim fans by an emacs author?

~~~
saagarjha
No, it's clearly just more sane. Without any knowledge of keyboard escape
sequences, why should down come before up?

~~~
tasty_freeze
The existing mapping is ridiculous. A,D,J,L are all in a horizontal line, but
are mapped to vertical motions.

There are many choices, but for example, using A/Z for left player up/down and
J/M for right player up down would not require any mental work. Once you place
your fingers, up is up and down is down.

------
amelius
Next step: both users playing over the network?

------
ngcc_hk
It seems very hard :-) Not the COBOL.

