#BabelOfCode 2024
Week 4
Language: FORTRAN

Confidence level: High

PREV WEEK: https://mastodon.social/@mcc/113867584791780280
NEXT WEEK: https://mastodon.social/@mcc/113975448813565537
RULES: https://mastodon.social/@mcc/113676228091546556

I was very excited about doing TCL this week, but I told myself the first time I get a two-dimensional array problem I'd go FORTRAN, so I guess this week is FORTRAN.

A friend of mine who did AOC2024 in December noted the early challenges this year were *very* easy. Today's definitely is. I wonder if part 2 will have any depth.

I went into this thinking: C is basically cleaned up FORTRAN, right? I know C? This should be easy, right? Right off the bat I find there will be a lot of difficulties entirely not of the kind I'm used to in programming. After a brief adventure with accidentally naming my file .f and not .f90 causing horrific and baffling errors, I run a hello world off the Internet. There's a space before the printout. Hm, how do I turn that off?

https://stackoverflow.com/a/31236043

Oh my fuck, *what*?

How to get rid of unwanted spacing in Fortran's print output?

It may look like a trivial issue, but I couldn't find any answer through googling. I have this little program : Program Test_spacing_print Integer:: N Real:: A,B N=4; A=1.0; B=100.0 prin...

Stack Overflow

I get frustrated with C all the time for being fundamentally a 70s language. It may be I'm about to learn the pain of using a *50s language*.

(Alternately, I hear modern FORTRAN has all kinds of fancy niceties like operator overloading and might not resemble traditional FORTRAN all that much. But then I have the problem if I pick up a random tutorial it's hard to guess which *decade's* standard it's teaching me from, or if it's the GNU extension, if the GNU extension is that different, etc.)

Just learned FORTRAN has an aint() function

Don't that just beat all

@mcc does it have a y'all function? Because if so, I'm switching immediately

@foone pretty sure no

I assume that the "y'all" keyword would be a standin for every variable in scope. So you say

y'all += 4

and it adds 4 to all variables.

It might be possible to implement this in userspace in Python.

@mcc @foone yeah i can do this in python, one sec

@whitequark @mcc @foone
Nice!

That hard-coded `int` type is bugging me, though

For one thing, `yall += 4` should also increment float, Decimal and Fraction variables, as well as third-party types like NumPy arrays and ORM proxy objects

There's also no reason to disallow `yall += "!"` or `yall += [4]`

I don't know how to design it better, though. Maybe increment all variables regardless of type, possibly excluding `self`? Not sure

@sabik @mcc @foone hasattr("__iadd__") and ignore exceptions?
@whitequark @mcc @foone
Maybe, but ignoring exceptions doesn't feel pythonic
@sabik @whitequark @mcc @foone query: does {implicitly altering every variable defined in the local scope} feel pythonic?
@catgirl_so @whitequark @mcc @foone
implicitly altering every variable defined in the local scope is the joke; it's not meant to be pythonic
@catgirl_so @whitequark @mcc @foone
Like in fiction, you're allowed to have unrealistic elements, people changing into animals when that's the plot of the movie; you shouldn't mess up the phase of the moon for no reason
@sabik @catgirl_so @mcc @foone this is an extreme level of overthinking and i'm here to enjoy it