
Show HN: Single neuron neural network written in COBOL - atum47
https://github.com/victorqribeiro/perceptronCobol
======
atum47
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.

~~~
im3w1l
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?

~~~
atum47
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](http://www.csis.ul.ie/cobol/course/DataDeclaration.htm)

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

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

~~~
swebs
Yes, a single neuron is just logistic regression.

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

~~~
zengid
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...](https://www.mainframestechhelp.com/tutorials/cobol/cobol-array.htm)

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

~~~
smabie
I mean it has to die out at some point, whether it takes decades or centuries.

~~~
atum47
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

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

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

