News for hackers. Stuff that matters.
Re:Show HN: Single neuron neural network written in COBOL by atum47 on Thursday September 03, 2020 @09:15PM (#24370807)
Hi everyone, I made this a while ago just for fun. Perceptron was one of the first algorithms I wrote back in college when I was taking machine learning classes. So I thought how cool would be to write something fairly modern (not really) like a neural network using old tech like cobol. Hope you like it.
Re:Show HN: Single neuron neural network written in COBOL by ryan_j_naughton on Thursday September 03, 2020 @10:15PM (#24371100)
Interestingly, perceptrons and Cobol are almost the same age.

"The perceptron algorithm was invented in 1958"[1]

"COBOL was designed in 1959 by CODASYL and was partly based on the programming language FLOW-MATIC designed by Grace Hopper."[2]

[1] https://en.wikipedia.org/wiki/Perceptron

[2] https://en.wikipedia.org/wiki/COBOL

Re:Show HN: Single neuron neural network written in COBOL by atum47 on Thursday September 03, 2020 @10:17PM (#24371114)
yeah, when I was writing the comment I remember my teacher telling us that neural networks were invented a long time ago and now (2017 when I took the class) they were coming back. that's why I wrote (not really)
Re:Show HN: Single neuron neural network written in COBOL by im3w1l on Thursday September 03, 2020 @10:21PM (#24371134)
When classifying it's often a good idea to feed the prediction into a sigmoid-function.

I have never seen cobol code before, only heard about it so thanks for posting some. What do rows like "01 ERR PIC S99V9999." mean?

Re:Show HN: Single neuron neural network written in COBOL by __palo_alto__ on Thursday September 03, 2020 @10:43PM (#24371225)
I think the perceptron algorithm does not include a sigmoid, just a stepwise activation. https://en.wikipedia.org/wiki/Perceptron
Re:Show HN: Single neuron neural network written in COBOL by atum47 on Thursday September 03, 2020 @10:27PM (#24371162)
ERR is the name of my variable "error" S indicates that this value is signed 99 is two digits V is a decimal separator and the other 9999 are 4 decimal places

http://www.csis.ul.ie/cobol/course/DataDeclaration.htm

Re:Show HN: Single neuron neural network written in COBOL by jecel on Thursday September 03, 2020 @10:53PM (#24371262)
And the 01 at the start of the line is the level number as explained in the link. It is how Cobol declared nested records, which Fortran and Algol lacked but became popular through PL/I, Pascal and C.
Re:Show HN: Single neuron neural network written in COBOL by bbunix on Thursday September 03, 2020 @10:29PM (#24371172)
I think 01 line number ERR what you think it means PIC S99V9999 is like a printf format for the number field
Re:Show HN: Single neuron neural network written in COBOL by pjmlp on Friday September 04, 2020 @09:19AM (#24374667)
Re:Show HN: Single neuron neural network written in COBOL by canjobear on Thursday September 03, 2020 @09:34PM (#24370903)
This is really cool! It's great to see a simple but nontrivial program to get a feel for how a language like this works. Reading through and knowing no COBOL, it looks like this is logistic regression on four input features.
Re:Show HN: Single neuron neural network written in COBOL by swebs on Friday September 04, 2020 @04:10AM (#24372821)
Yes, a single neuron is just logistic regression.
Re:Show HN: Single neuron neural network written in COBOL by atum47 on Thursday September 03, 2020 @09:41PM (#24370944)
yes, perceptron is a linear separable classifier. glad you liked it
Re:Show HN: Single neuron neural network written in COBOL by klipt on Thursday September 03, 2020 @11:06PM (#24371328)
So COBOL has no array concept, you have to name every input feature FEAT1, FEAT2 etc? Ouch. I can see why the language is dying out.
Re:Show HN: Single neuron neural network written in COBOL by zengid on Friday September 04, 2020 @12:16AM (#24371664)
There are arrays, or tables, which I like to think of as being what an array of structs would be in C:

https://www.mainframestechhelp.com/tutorials/cobol/cobol-arr...

Also, cobol will probably never completely die. No enterprise is going to pay to rewrite systems that have been their backbone for decades. (Disclosure: I work in Logistics industry, and we have a lot of cobol that isn't going anywhere.)

Re:Show HN: Single neuron neural network written in COBOL by smabie on Friday September 04, 2020 @12:47AM (#24371778)
I mean it has to die out at some point, whether it takes decades or centuries.
Re:Show HN: Single neuron neural network written in COBOL by exdsq on Friday September 04, 2020 @01:39AM (#24372045)
Sure, all things do. But will it die out before Python?
Re:Show HN: Single neuron neural network written in COBOL by pjmlp on Friday September 04, 2020 @09:21AM (#24374679)
Many people that bash Cobol aren't aware that the language keeps being improved to follow up on newer trends,

https://www.microfocus.com/en-us/products/visual-cobol/featu...

Latest ISO revision is from 2014.

Re:Show HN: Single neuron neural network written in COBOL by atum47 on Friday September 04, 2020 @12:52AM (#24371795)
when I shared this on reddit someone said something along the lines: in one hand this is cool but on the other hand I just wish Cobol would just die
Re:Show HN: Single neuron neural network written in COBOL by wruza on Friday September 04, 2020 @01:44AM (#24372068)
COBOL seems to be very translatable to any modern language, e.g. Pascal or BASIC. Real world reasons against "why not just translate it then" are understandable, but at some point that could become economical.
Re:Show HN: Single neuron neural network written in COBOL by shakna on Friday September 04, 2020 @02:50AM (#24372379)
COBOL's numeric stack doesn't directly translate to many modern languages, which makes the translation introduce all sorts of fun edge cases that are extremely difficult to track down.

IEEE 754, which most of our modern languages are mostly compatible with, came about in '87. Long after COBOL had standardised itself on how numbers were expected to behave.

Re:Show HN: Single neuron neural network written in COBOL by pjmlp on Friday September 04, 2020 @09:24AM (#24374699)
Beside AOT compilation to native code, Fujistsu and Micro Focus have Cobol compilers with .NET and Java backends, and I wouldn't be surprised if they eventually come up with WebAssembly support as well.

Also don't forget that languages like C and UNIX are just 10 years younger than COBOL.

Re:Show HN: Single neuron neural network written in COBOL by atum47 on Friday September 04, 2020 @01:55AM (#24372120)
yeah, I wrote a neural network a while back to run both in front and back end. to the front end I used JavaScript and for the back python. apart from matrix multiplications (python I used numpy, JavaScript I wrote my own class) the code is almost identical.

that got me wondering that I could write a program to translate a language to another. a large company could commission a (bunch of) programmer(s) to do this

Re:Show HN: Single neuron neural network written in COBOL by atum47 on Friday September 04, 2020 @12:21AM (#24371683)
yeah, I was getting in fintech when I wrote this. A lot of banks also use Cobol to this day.
Re:Show HN: Single neuron neural network written in COBOL by tapland on Friday September 04, 2020 @01:54AM (#24372113)
COBOL is everywhere. Banks, insurance companies, infrastructure. Something like 90+% of all payment transactions are still processed using COBOL.

The language is fine, but it’s the rest of the mainframe that is a pain in the ass to learn.

Oh, and killing ‘awesome’ modern text editors by just opening a 80k LoC file and doing basic regex searches. VS Code works well but Atom not so much.

Re:Show HN: Single neuron neural network written in COBOL by rovr138 on Thursday September 03, 2020 @11:10PM (#24371339)
There are "tables" in COBOL. My COBOL is rusty, but I know that it can be done.

This is cool nonetheless.

Re:Show HN: Single neuron neural network written in COBOL by atum47 on Friday September 04, 2020 @01:47AM (#24372088)
thank you, glad you liked it
Re:Show HN: Single neuron neural network written in COBOL by atum47 on Thursday September 03, 2020 @11:12PM (#24371347)
yeah, please don't take this code like is good COBOL code, haha, I learned it just for this experiment.
Re:Show HN: Single neuron neural network written in COBOL by klyrs on Friday September 04, 2020 @01:19AM (#24371931)
I was taken with how readable it is, personally. I'd say "like python but next level" but I know at least that much history.
Re:Show HN: Single neuron neural network written in COBOL by forgotpwd16 on Friday September 04, 2020 @08:20AM (#24374269)
What resources you used to learn?
Re:Show HN: Single neuron neural network written in COBOL by atum47 on Friday September 04, 2020 @11:33AM (#24375845)
just Google