10 ms·
Cloudflare Workers now supports COBOL
- cntlzw 7y agoart
- nathancahill 7y agoOh hi ArtDecider.
- shp0ngle 7y ago> Our work can be used by anyone wanting to compile COBOL to WebAssembly future is now
- dmm 7y agoThis reminds me of another classic: http://www.coboloncogs.org http://www.coboloncogs.org
- pantalaimon 7y agoI thought of https://github.com/azac/cobol-on-wheelchair https://github.com/azac/cobol-on-wheelchair
- marktangotango 7y agoGnu Cobol is an interesting project, they support a lot of dialects. One big draw back is the generated code isn’t thread safe so cgi is about the only option for server side apps. Maybe someone more familiar with the project could comment on that?
- e12e 7y agoIt's kind of funny that you mention "only cgi" as a drawback on an article discussing "edge workers" - not sure if they're like "serverless functions" (new vm pr request) - but I'm assuming they're heavier than "just" new process pr request :)
- jdub 7y agoMost implementations of "serverless" functions are just long-running processes handling requests, like an HTTP server.
- tomByrer 7y agoCloudflare Workers is really a Chromium "browser service worker" that runs on their servers. Since Chromium makes each browser tab isolated as possible, each instance does indeed act as a mini-VM, & AFAIK usually is created/destroyed per HTTP request. Most deployed code uses JavaScript/TypeScript, but also can run WebAssembly, which is how they got COBOL to run there. I've also seen RUST, GoLang, & other sources run on Cloudflare Workers. Shameless self-plug here: https://github.com/tomByrer/awesome-cloudflare-workers https://github.com/tomByrer/awesome-cloudflare-workers
- deleted 7y ago[deleted]
- steveklabnik 7y agoThey’re much, much lighter than a process. They’re a V8 Isolate, basically a VM thread.
- e12e 7y ago
- deleted 7y ago[deleted]
- Gys 7y agoNext: Microsoft Basic
- sp332 7y agoGORILLAS.BAS.museum
- m463 7y agoI think DONKEY.BAS is more famous https://en.wikipedia.org/wiki/DONKEY.BAS https://en.wikipedia.org/wiki/DONKEY.BAS
- chrismorgan 7y agoI don’t recognise the name DONKEY.BAS, but I spent plenty of time in my youth with GORILLAS.BAS and have heard it mentioned from time to time since then.
- m463 7y agoI should clarify DONKEY.BAS was (probably) not famous for gameplay as much as the author.
- lmkg 7y agoThere's currently an experimental project to host the .NET runtime on wasm. So you could run VB.NET on top of that.
- PopeDotNinja 7y agoI can't wait for MUMPS!
- llarsson 7y agoThis was a higher-effort post than I had expected. The Game of Life implementation pushes itself into my Back-button browser history, which is rather annoying, but it was very cool to see some COBOL besides the obligatory Hello World. I hardly think anyone maintaining crusty old systems will be allowed to move to Cloudflare Workers, but it is rather amazing and funny to see that it could technically now be done. Great job and great post!
- pgt 7y agoI think you’d be surprised how eager the owners of crusty mainframe systems are to stop managing ancient infra and how heavily they have been sold on serverless / “the cloud”.
- marktangotango 7y agoI think it's important to note that this isn't an option to "get off the mainframe". Gnu Cobol doesn't support CICS, nor some other things the mainframe provides. There are "rehosting" options, both free and for pay, this isn't one. To clarify some more, rehosting options range from "pick up and drop source files and data to the new system" to "we can do it but it's almost as much effort as rewriting the whole thing".
- jonny_eh 7y agoI can't imagine it's easier to port mainframe cobol to Cloudflare, instead of rewriting it in TypeScript or whatever.
- mywittyname 7y agoI'm sure most places have tried numerous times before and failed.
- nabla9 7y agoAt this point most systems that are easier and more cost effective to operate on cloud are already there. If you need the IBM Z level cryptography, security and reliability it's trying to replicate same with other hardware is very costly.
- ebiester 7y agoSo, was this a delayed April Fools joke/project that had to wait until the anti-April Fools backlash of 2020 subsided? I wonder how many other projects like this were cancelled or delayed.
- jgrahamc 7y agoThis is not a joke at all. We are serious about WebAssembly in our serverless platform and showing that it can support languages like COBOL is important.
- StavrosK 7y agoThe hardest part about WebAssembly that I found is that very few projects document their ABIs. For example, I want to write a Rust WebAssembly program to do whatever with CloudFlare workers (literally anything, just to try it). Is there a page listing all the functions I can import and call? IIRC I had only managed to find some "hello world" examples, ran them, they did indeed say hello world, and then I thought "well okay, now I know how to return stuff and nothing else" and gave up because I couldn't find documentation on other calls.
- steveklabnik 7y agoSo, to take a few steps back, maybe you know some of this: First off, you write some wasm. You export some functions from the wasm. How you do this is up to your Rust code. wasm-bindgen would be the low-level details here. Then, in your worker, you import the wasm. This shouldn't change from the templates, really. What signatures the imported functions have depends on how you exported them. There's no inherent restrictions about what you can call, it's about knowing what you've exported and then calling them with the appropriate stuff. So for example, https://github.com/jRiest/the-best-goats https://github.com/jRiest/the-best-goats is a little Rust wasm app. This app was built before wrangler existed, so it's got some strangeness, but it does work. https://github.com/jRiest/the-best-goats/blob/master/src/lib.rs#L518 https://github.com/jRiest/the-best-goats/blob/master/src/lib... is the main. I am not entirely sure how jake did this, but it looks like he compiled it to wasm, and then added https://github.com/jRiest/the-best-goats/blob/master/index.js#L737-L749 https://github.com/jRiest/the-best-goats/blob/master/index.j... at the bottom. Wrangler would make this a bit easier, of course. Regardless, you can see how these lines, which are the standard Worker entry point, calls into the main defined in wasm. Does that help at all? It is certainly true that this is not as well documented as it could be. Lots of work still to do.
- kyberias 7y agoThat page generates an entry in my browser back history every second.
- therealchi 7y agoyeah, that site is cancer...
- vikramkr 7y agoYeah I'm very glad I opened it in a new window.
- jgrahamc 7y agoYeah, sorry about that. We'll change it. Edit: Done.
- steveklabnik 7y agoI almost got Pascal working, but ran into a compiler bug.
- ancarda 7y agoIs there a list of languages Cloudflare Workers supports? From what I can tell, it's JS, Rust, C, C++, and now COBOL. So... no PHP then? Seems like it would be a good fit, no?
- k__ 7y agoIf they use V8 it doesn't no. At least not with the state of WASM right now. Manual memory management and JS it is.
- steveklabnik 7y agoWe do use V8, yes.
- gameswithgo 7y agoany GC language could in theory be supported only if you can compile that language and the runtime it needs into a sufficiently small package.
- simonw 7y agoThe linked article talks about the importance of keeping size under control. PHP ships with literally hundreds of built-in functions, which I imagine makes it harder to optimize for the size constraints of Cloudflare Workers.
- steveklabnik 7y agoThe officially supported languages are: * JavaScript (and TypeScript) * C and C++ * Rust Other languages may work, and we we won't stop you from using them, but you may run into problems. The main issue with getting most languages to work is that we support JavaScript and WebAssembly, which means any other language needs support for compiling to wasm before it's even possible. Once it is, we have a one megabyte limit for the size of a worker, and so many other languages won't work because their minimal wasm output is too large. We'd like to support more in the future. It takes a lot of work.
- 7y ago
- fortran77 7y agoThere's a related thread about the "discovery" of the source of the Terminator COBOL from a few days ago--and the original author is still alive and well and programming mostly in CUDA/C++, Erlang and Elm according to his Twitter. https://news.ycombinator.com/item?id=22857531 https://news.ycombinator.com/item?id=22857531
- 1996 7y agoA very practical question: I am language agnostic. Lots of people have commented about COBOL and FORTRAN performance for purely mathematical problems, given the amount of man-hours that went into the libs used by these languages when computing resources were scarce. That caught my eye. Because for what I do, every little bit of performance matters. There are no hiring constraints - I will get whoever and whatever I need, as long as it can be shown to increase performance - mostly latency, but also speed of computation on given hardware. Can I expect practical gains in a COBOL implementation of mathematical algorithms? (mostly matrix inversion and multiplications, but not just that)
- ecshafer 7y agoI've done some programming in Fortran in school doing computational physics. From what I can tell it isn't necessarily that the languages are super fast, compared to any other compiled language. You can get similar speed out of Fortran as C or C++ by doing the normal performance conscious practices of not allocating a lot of memory during calculations, optimizing loops, etc. Fortran has a lot of scientific packages that have been optimized very heavily, and those are linkable from other language, that is whay Scipy in Python is essentially. The Cobol I have touched isn't really that optimized I think, mostly just business code. But its fast due to no abstractions and being compiled. I don't think you would get gains from Cobol per se, and it might not be worth it compared to just writing C or C++ in a high performance manner.
- cygx 7y agoFortran as a language had some advantages over C for high-performance numeric code (eg more restrictive aliasing rules or stack-allocated variable-length arrays). C99 addressed this.
- pjmlp 7y agoC99 kind of addressed it, unless one manually takes the effort to properly place restrict in the correct places, and not mistakenly misuse it (possibly triggering UB), it won't match what optimizing Fortran compilers are capable of without any additional effort from the programmer.
- eska 7y agoOff-topic, but I hadn't seen the xkcd comic and it actually brought a tear to my eye. What a beautiful homage!
- viktsys 7y agoAt first, I thought this was a 1st April joke. It's impressive what can be done inside the CF workers using the WebAssembly feature of V8. Now I can learn a 60 years old lang to run on the closest CF datacenter :3
- m3kw9 7y agoI’m still not understanding what it means for their workers to support COBOL?
- alphazino 7y agoI'm pretty sure cloudflare has a service called "Workers" and that this doesn't literally mean that their employees support COBOL.
- steveklabnik 7y agoThis is correct, yes.
- chx 7y agoSo I guess you could use https://github.com/azac/cobol-on-wheelchair https://github.com/azac/cobol-on-wheelchair and develop your entire app in a Worker. Great!
- pjmlp 7y agoWhile a nice achievement for WebAssembly, it is nothing new as concept. Cobol on the JVM: MicroFocus https://www.microfocus.com/documentation/visual-cobol/VC40/EclWin/GUID-DEAFFCA6-6D75-4AEA-A3B6-6DF0BDCF3E2F.html https://www.microfocus.com/documentation/visual-cobol/VC40/E... Fujitsu https://software.fujitsu.com/jp/manual/manualfiles/m150010/b1wd3373/01enz200/b3373-00-03-02-01.html https://software.fujitsu.com/jp/manual/manualfiles/m150010/b... Cobol on the CLR: MicroFocus https://www.microfocus.com/documentation/extend-acucobol/1011/BKITITDOTNU001.html https://www.microfocus.com/documentation/extend-acucobol/101... Cobol on the CLR and Azure: GT Software / Fujitsu https://www.gtsoftware.com/products/netcobol/netcobol-for-net/ https://www.gtsoftware.com/products/netcobol/netcobol-for-ne...