What does the code of a mathematician look like?

Are there any talented mathrmaticians turned programmers? How efficient is there code comparitively to their colleagues?

Attached: maths-royen-proof_1024-800x415.jpg (800x415, 123K)

Other urls found in this thread:

amazon.com/Algebraic-Statistical-Monographs-Computational-Mathematics/dp/0521864674
en.wikipedia.org/wiki/Relationship_between_mathematics_and_physics
pedantry.blogspot.com/2003_07_20_pedantry_archive.html
opoudjis.net/Play/antichomsky.html
aclweb.org/anthology/W/W09/W09-0104.pdf
lel.ed.ac.uk/~gpullum/CreationMyths.pdf
grsampson.net/ATin.html
en.wikipedia.org/wiki/Nikolai_Durov
twitter.com/NSFWRedditVideo

Mathematicians tend to code like shit. I worked with some of them on some 3D image reconstruction project, where I am responsible for turning their shitty C code into a CUDA application, and they all are horrible programmers, but with an excellent understanding of the algorithm.

Usually, they prototype the algorithm in matlab and then try to convert it into C code, which is awful and completely void of architectural understanding (for example optimizing for linear memory accessing for cache prefetching or using SIMD instructions for matrix operations).

The worst coders are hobby mathematicians (most likely at least somewhat autistic) who go into computers from the logical angle.
They tend to write cryptic as fuck code with no regard for efficiency, readability or usability.
No error handling. No usable status messages. And often using the most ass-backwards approaches to solve problems instead of using pre-defined functionality, which leads to verbose as fuck code that's also cryptic.

We have one such guy at our company, he's doing some auxiliary work and using shit like Arduinos and Raspberry Pis to solve problems. I once had to troubleshoot one of his scripts and the first thing I had to do was rewrite basically the entire thing so that it would even give me an indication of whether it's working or not.
(His original approach was "if the text box comes up instantly, it hasn't worked". Also, the text box was outputting the value of some arcane variables, but not in a usable way)

What did you say to him?

>ass backward approaches
>cryptic code
That makes me wonder if hes just doing most of it in his head and assuming everyone else will too.

I fixed the underlying issue, which was a misconfigured net config on the system. Then he later abandoned the script as it was too flaky in its behavior, which I could have told him instantly. The lack of feedback caused workers to toggle the system without knowing its current state.

I'm not bothering to correct him because programming is clearly not his profession and the shit that he does doesn't intersect with the IT department's work. In fact, him being there saves us some work, even if he's a fucking hack - he's the one who's getting the support calls, not us, so I don't give a fuck if he's making work for himself.

Not a mathematician, but I work with a colleague that has a PhD in physics. HR and our boss was impressed by his CV and education, but they guy is just a fucking hack. Even though we tried to explain to him many times, he still doesn't understand the difference between code running on the client and code running on the server, and he frequently hardcodes his own IP address into the code, so of course, when he demos it for the CTO everything works, but when someone else try to run it, it just breaks down.

The juvenile assumption that for whatever reason mathematicians would code differently (and better) than software engineers who have studied the hows and whys of what makes good code and large scale programming. Learn how the world works kid

I'm a mathematics PhD/programmer and pay attention to vector instructions, cache access, and compiler optimization. My job is to implement internal research papers into highly optimized and maintainable code to run on large clusters with 20k GPUs / 200k nodes.

I know very well exactly the type of person you're talking about. Some world-class tier mathematicians/physicists take a concept and optimize it mathematically, taking a theoretical problem that would take the age of the universe to solve, and turn it into to something that might be conceivably solvable.
On average, if you give them an existing algorithm, they can spend 4 weeks on it and deliver it back to you 10,000 times faster than any other method. However, their work is criticized as being slow because they write C++ like a math function, ignoring memory access and optimization that programmers would find trivial. They simply give it to a programmer, who gains a 4x speedup and wants everyone to congratulate himself for mucking around in someone's horrible code. But the real hero is the mathematician who doesn't care about the final optimization bit, because he/she is already lightyears ahead of existing research. Programmers have no idea how their code works so they pass it off as bad code, when in reality, it's a genius algorithm that you'd also need a PhD to understand.

1/2

2/2


An example of the pipeline is the following:
- You need to solve a multi-scale physics problem, but it would take 10^20 CPU hours using any available method.
- Mathematician discovers spectral basis that when transformed into, the series can be truncated to 0.1% the problem size while still being 99.9% accurate.
- 10^16 CPU hours is still too slow, so the mathematician mixes in the work of an existing surrogate method, which uses a 100TB precomputed table of simulated data but reduces the problem size by 1,000,000. Solution is still 99.9% accurate.
- Mathematician delivers code to computer science division that takes 10^10 hours.
- Computer scientists speed it up by 10 by inverting a couple "for" loops.
- Algorithm runs in 10^9 CPU hours, they announce they are self-proclaimed heros.
- Some organization funds the simulation to be run, and a couple research papers are a result.

What I'm saying is that while most mathematicians do write horrible code, it can be excused because they're indispensable to the team and final code optimization and organization isn't what they should be wasting their time on.

Math and programming go hand in hand.

I'm sure their PhD was hard work back in the days, but some minor incremental improvement to an existing algorithm (cough cough SIFT cough) that one of their graduate students did anyway is not really something they should be applauded for, IMO. Usually, the algorithms they come up with make unreasonable assumptions about memory layout or efficiency anyway, but since all that is just "implementation details" to them, I spend several weeks and basically rewriting their mathematical functions and algorithms to something that actually works and end up looking entirely different anyway.

t. disgruntled scientific programmer

Exactly what I was thinking of, thank you. So it seems like there is a lot of distance between people in either field, but when used seperately they can really benefit each other.

Using a lot mod and div operators, single letter functions or variables, prefer copy and paste code over use generics,class or orden files.

>thank you for confirming the views I already held, I will ignore every other post in this thread
See kids, this is called boomer confirmation bias.

mathematicians are good at
* designing algorithms
* doing runtime analysis of algorithms
the actual implementation (which is often language/hardware/framework/etc dependent) is the job of dirty code monkeys and pahjeets

mathematicians like pure and abstract constructs, as soon as it goes towards anything "applied" (even theoretical physics is "applied math" to a pure mathematician), the chad mathematician furrows his brow, sips his coffee and politely declines to partake in such tomfoolery

Attached: inter-universal_teichmüller_theory.png (1114x550, 88K)

There's also a lot of distance between humanities and physics, pairing them up does not necessarily mean good results.

>* doing runtime analysis of algorithms
nvm, what I meant was complexity analysis. anything relating to actual code running on actual computers, mathematicians are horrible at

/thread

Perhaps knowledge of memory layout and more importantly node topology layout would be helpful to them, but without that knowledge, I can assume they've spent an equal time learning some weird analysis for a year that programmers can't come close to understanding, so I'll let them do their thing. I'm about 50% math, 50% programming, so while I've never submitted a patch to GCC's optimizer, I can understand the thinking behind the mathematicians' code (although not how they came up with it).

Also, correction to my first post. 200k nodes should be 200k cores. I'm sure there are machines with 200k nodes that are unlisted on Top500 (since they only test machines that are somewhat open-access), but they're typically designed to run one and only one code for either national security or cryptography. You don't run brand cutting-edge research on them usually.

writing code is essentially an engineering problem.

it's like, einstein found the basic idea for atom bombs, but to actually build one is another thing altogether. you need a lot of hands-on technical know-how to pull it off

2/2
In other words, code optimization is "cheap". You just hire a couple masters' CS students for 80k salary with 20 years experience between them. If the project manager required the mathematicians to do it, they'd be paying them 200k for a job that would take 2x longer.

FPBP

Not necessarily. Modern CS would be decades behind without the work of Chomsky on Linguistics. Every modern textbook on compilers builds on Chomsky's work.

You read Algebraic Geometry and Statistical Learning Theory today Jow Forums?

amazon.com/Algebraic-Statistical-Monographs-Computational-Mathematics/dp/0521864674

Oh yeah? Go visit

Tbh I feel that the single biggest culprit in Mathematicians writing unreadable code is Matlab.

Mathematicians who have learned Haskell and functional programming tend to write much more readable code, because at least the paradigm is close enough to the way they think, rather than half math and half terrible programming.

MATLAB is for failing math students and engineers, no place for that software in serious industry. Python's Numpy/Scipy is better in all aspects.

They are the worst to work with because you have so much effort to put into understanding their code.

It even starts at variable naming, their code (if it works) looks like minified js-webdev code.

Half of the variables are single letter, if they rarely make comments it's just the name of their formula.
Because of this you actually have to google the shit out of it and understand what the formula should be doing.

However, it rarely ever is correct. To be honest, most of the time it seems like they just used some obscure new formula and think yeah nobody is going to realise that they have no fucking clue whats going on.

Fuck them.

>Exactly what I was thinking of, thank you. So it seems like there is a lot of distance between people in either field, but when used seperately they can really benefit each other.
At these levels of specialisation and autism people really focus almost entirely on their competence at the expense of everything else. Even longer running 'clash' is between physicists and mathematicians where former would come up with (seemingly) insane concepts that will need years for mathematicians to make a complicated solution for so the whole thing can be tested.
>There's also a lot of distance between humanities and physics, pairing them up does not necessarily mean good results.
Linguistics is a good example, it advanced a lot when mathematical analysis was applied. Economics are defined as social studies but rely on mathematic concepts to function and even tho there is some mishmash in that field it's on of the most important ones for the past decade.

Of course not. Why would I want to read a book that disparages beautiful AG with applications?

Attached: Grothendieck-Riemann-Roch.jpg (969x717, 190K)

It looks like absolute trash and barely works at all. t. worked with mathematicians on math software. Example: they implement matrices as non-contiguous arrays of pointers and cast individual rows to that. Then they rely on the specific behavior on their system at the time to decide it works.

It's crap. Most Matlab code I've read doesn't even have proper indentation.

String theory was mistake

Maybe in your case it's because they're actually lazy, but in industries I've been, letter-variable-names are common because mathematicians want the names to match their published paper if another person wants to compare it to their code.

There was a computer science review guy that asked my colleague

>What's this variable C_g1? Could we call it something better? It's not descriptive, so nobody will know what it is. What is it?

>Well, it's the third term of the expansion coefficient in the basis we came up with of the Fourier transform of this 'g_1' function, which is the series expansion of the function that we defined to appoximate the volume element near the high-energy flux shockwave instability of the material we've studying.
>The variable is referenced in many places in user (2016).

>Okay, let's just call it C_g1 then.

In the sense that the mathematician should be disallowed by law to write a single character of code, sure. Love how you only read the response you wanted to read which comes from someone with 0 experience in the matter though.

I agree, without chomsky's cs work, cs would be behind. Chomsky was a great computer scientist.

Most programmers assume the code they're working with is like

int numberOfToes = 10;

but in the real world, most variables aren't given names because they represent incredibly abstract concepts.

Okay, I'd love to work with people like this who know their stuff. Sadly it seems like it's exactly like you stated:

>Maybe in your case it's because they're actually lazy

Hopefully, I'll get luckier in the future.

>mathematicians like pure and abstract constructs, as soon as it goes towards anything "applied" (even theoretical physics is "applied math" to a pure mathematician), the chad mathematician furrows his brow, sips his coffee and politely declines to partake in such tomfoolery
>en.wikipedia.org/wiki/Relationship_between_mathematics_and_physics
>mathematics has already been described as "an essential tool for physics"[4] and physics has already been described as "a rich source of inspiration and insight in mathematics".
>The creation and development of calculus were strongly linked to the needs of physics
Chad physicist vs virgin mathematician.

Attached: seees.jpg (500x427, 36K)

50% of mathematicians are applied mathematicians.

Over 85% of percentage-format statistics are fabricated on the fly.

>(His original approach was "if the text box comes up instantly, it hasn't worked". Also, the text box was outputting the value of some arcane variables, but not in a usable way)
Is he just following The UNIX Philosphy™?

usually idiots that code in C# because they 'heard it was good for academia'

Actually it's 72.3%

>Not necessarily. Modern CS would be decades behind without the work of Chomsky on Linguistics. Every modern textbook on compilers builds on Chomsky's work.
Not really.

>Chomsky's work built on the legacy of mathematical logicians who were in parallel also influencing computer scientists. If Chomsky wasn't there slurping down DoD funds, they would discover what he did before.
>Most mentions of Chomsky's work in CS textbook is just a short mention of the Chomsky hierarchy.
>I should also mention how his influence in linguistics has retarded the field massively, with every new iteration of his theory creating new crufty epicycles to cover up it gaps and flaws. Any serious work in psycholinguistics, computational linguistics or applied linguistics (i.e. anything useful) just ignores Chomsky's work and the work of his followers for the most part.

did you copypaste this from that hack luke smith or what? kys

:( this is how I unironically code

no need for errors or exceptions - if it works it works and if it doesn't I know what I changed or broke. mostly everything is mapped out in my head. My variable names are all random letters and numbers like a_6 or zd_23.

I manage a Dev team at a hedge fund

Undecipherable garbage, all variables have single letter names.

"Computer" "Science" is 90% memes so i decided to study pure mathematics at college, i just finished my first year and i enjoyed it. I'm reading SICP and i finished the book "The Elements of Computing Systems". I plan to learn advanced algorythms and Haskell in the future. I literally know more things than many "computer scientists" because they are literally learning shitty things like java because modern university want to make codemonkeys.

>> I literally know more things than many "computer scientists" because they are literally learning shitty things like java because modern university want to make codemonkeys.

If current unis just want to churn out codemonkeys why do so many on Jow Forums complain about having to do extra work outside of uni like personal projects and internships to even get a codemonkey job.

Ironically only a codemonkey would believe an introductory choice of language defines your career and study

when "works on my machine" is no longer meme

You need to do extra works to compete with the others millions codemonkeys and NO, java should not be taught as an introductory language for computer science, this is just stupid.

>study pure mathematics
>just finished my first year
You won't study pure mathematics until your MSc and you won't be a mathematician until you have attained you PhD. Right now you're just learning lower mathematics.
>plan to learn advanced algorythms and Haskell in the future
Which means you will never do it. If you wanted to do it, you'll started already.
>I literally know more things
You literally are an idiot thinkig he's smart.
>learning shitty things like java
You just parrot stuff you read. Java is fine when used by competent programmers. As for unis it is probably used as for doing homework in an object-oriented course.

i once worked with a very smart guy, ive league math kinda programmer. he was really into category theory. category theory seems like it's kinda nice, but has limited usability, and makes code harder to understand for people who don't know it (>99% of programmers).

his code wasn't horrible, but it was a bit sloppy. hard to refactor, not written for testability, kinda hard to read. he would insist on writing mathematical algorithms by hand rather than importing a library which would have taken far less work and would probably run more efficiently.

>did you copypaste this from that hack luke smith or what? kys

No. He just has a lot of good company. See:

pedantry.blogspot.com/2003_07_20_pedantry_archive.html
opoudjis.net/Play/antichomsky.html
aclweb.org/anthology/W/W09/W09-0104.pdf
lel.ed.ac.uk/~gpullum/CreationMyths.pdf
grsampson.net/ATin.html

>You won't study pure mathematics until your MSc
Yeah right, group theory is applied mathematics, thank you for your information faggot.
>Which means you will never do it. If you wanted to do it, you'll started already.
I can't learn everything in one month user.
>You literally are an idiot thinkig he's smart.
I'm indeed smarter than the average "computer scientist" student talking basedboy games at university. i'm talking with "computer scientists" after their first year and they know little about programming, they don't know what is a pointer, they don't know higher-order procedures they only know how to do some loops with conditions and import libraries. Of couse i'm not a genius but it's not difficult to have more knowledge than an average computer science freshman.
>You just parrot stuff you read. Java is fine when used by competent programmers. As for unis it is probably used as for doing homework in an object-oriented course.
No, java is not a good language to learn for "computer science" especially in first year. Scheme is so much better as a first language.

Are you retarded? Go on projecteuler, solve some problems, and look at the solutions by other people. Why do you think asking Jow Forums will provide you with useful information?

Kek

Don't mind me, l looking for the get

>math phd student and programmer
>0 experience
kill you'reself

that's category theory you brainlet

he's an undergrad but at least he isn't an absolute faggot like you who doesn't know anything about anything yet feels the need to comment like he does.
any undergrad math major at a reputable university engages in pure mathematics before they graduate. the better the institute and student, the earlier the exposure.
the meme that if he hasn't already started doing something he is interested in he will never do it is just you projecting your insecurities and failures. some people actually have study plans and schedules.
>You literally are an idiot thinkig he's smart.
this irony is so delicious

t. math phd student who understands the perspective of that undergrad

p.s. mathematicians, by and large, are horrendous programmers (barring SOME applied mathematicians)

tl;dr: mathematicians code like shit

Being a good programmer is not something you learn in University, even as a CS Student, so why should the average mathematician be a good programmer?
Being smart doesn't make you a good programmer either.
I know really smart people who kind of suck at programming, and they even know they suck themselves.

Nikolai Durov

en.wikipedia.org/wiki/Nikolai_Durov

The guy is literally a genius

not a mathematician, but a grad student in pure math who spends a lot of time with mathematicians

they all code like shit

>No, java is not a good language to learn for "computer science" especially in first year. Scheme is so much better as a first language.

tell us why user.

Just look at DJBs code

mathematicians are good at solving little pet autist problems written on paper, but they tend to be shit at solving anything else in the real world

too nerdy

I think they'd be less concerned about efficiency and more concerned about accuracy (unless one of their main gripes about math is about how to do the same thing more efficiently, in which case they're not really mathematicians, but programmers).

FPBP

This is the average case, although I do work with a guy who is both a mathematician and a great coder. Thing is, he WANTED to be good a software dev and paid his dues in study. Most math guys are "self taught" but don't really get far or keep their skills up to date. I also have to work with another math guy who moans for two months every time I touch a line of code even with good reason.

Attached: 1314068635137.jpg (554x527, 60K)

As an ass backwards cryptic programmer, I can confirm.

Don't get me wrong, we know we suck. We just can't be bothered to change our ways.

based

Like shit but his algos are pretty neat.