Hacker News new | past | comments | ask | show | jobs | submit login
WebAssembly COBOL Pong (moxon6.github.io)
181 points by ColinEberhardt on May 15, 2020 | hide | past | favorite | 33 comments



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...


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.


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.



No :(


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


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


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


My first reaction was that this must have been some kind of plot to make young people interested in COBOL using the type of games the current demographic of this language knows best.


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


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


That was an enjoyable read, thanks.


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


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.


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.


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


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


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.


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

https://moxon6.github.io/cobol-js-emscripten/cobol-js/index....

where is the cobol?


That's the JS generated by emscripten for linking in the WASM, which is `index.wasm`

`index.wasm` is built using the build scripts in the source repo

`main.cob` contains the main logic used to generate `index.wasm`

https://github.com/moxon6/cobol-js-emscripten/blob/master/co...


You mean this file?

https://github.com/moxon6/cobol-js-emscripten/blob/master/co...

I am still looking around so may be wrong.


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


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?


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


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



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


Right paddle controls are backwards compared to vim.


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


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


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.


Next step: both users playing over the network?


It seems very hard :-) Not the COBOL.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: