LFortran compiles fpm

(lfortran.org)

37 points | by wtlin 2 days ago

3 comments

  • wrs 2 hours ago
    It's such an odd little subcultural quirk that Fortran (really HPC) people call programs and libraries "codes". Most software folks refer to "code", as if it was a substance like sand or water, and use other words for specific units of "code" (programs, libraries, modules).
    • pmcgoron 36 minutes ago
      If you want to peer into an alternative reality / funhouse mirror of programming terms, you should look at ALGOL 68. For instance, types are called "modes".

      https://jemarch.net/a68-jargon/

      (There are also "incestuous unions", which is the actual term used in the spec.)

    • certik 34 minutes ago
      Author of the blog post. It's just being a non-native speaker and writing the blog post by hand shows these little mistakes. I've been using the terms "code" and "codes", but you might very well be right that my usage is not entirely correct. I'll ask native speakers what the proper usage is here.
    • dented42 1 hour ago
      I guess when you’ve been calling it that before everyone else you’re allowed. Sort of how Common Lisp calls threads ‘processes’.
      • Jtsummers 3 minutes ago
        > Sort of how Common Lisp calls threads ‘processes’.

        Can you point to any documentation on that? It's not in the hyperspec and it doesn't seem to be in Common Lisp the Language, 2nd Edition (using the index)

      • pjmlp 1 hour ago
        As does Smalltalk and Erlang, and to make things more interesting, all three mean something not exactly the same.
    • stackghost 1 hour ago
      >Fortran (really HPC) people call programs and libraries "codes".

      I think it's a European engineering thing that just sort of caught on, actually. For example when I was in undergrad, my 4th-year computational fluids prof made us use "Code Aster"[0] and "Code Saturne"[1] which are both made by a French lab, I believe. Most of the usage of "code as a countable noun" that I've encountered has origins in English-as-a-second-language projects.

      [0] https://code-aster.org/

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

      • jraph 57 minutes ago
        The uncountable aspect of many English words is highly unintuitive to many of us.

        Information. Code. Software. Hardware.

        I suspect many people don't even know they are uncountable.

        I suppose for software we should just use programs or applications. But that's slightly more specific than software!

        In French we can have both: le logiciel as some uncountable mass, or un/des/N logiciels if you need to count them.

        Why the hell do I need to cut information into pieces to count it?

        Both English and French are cursed languages, but English loses on this one.

        And then there's the trousers. And now you need to say "a pair of" to talk about one unit of them. Though to be completely fair we have that for the glasses (lunettes) and the scissors as well.

        • Joker_vD 39 minutes ago
          > I suspect many people don't even know they are uncountable.

          Well, most English speakers may not know the term, but they can feel the concept just fine.

          > In French we can have both: le logiciel as some uncountable mass, or un/des/N logiciels if you need to count them.

          This mostly works in English (and other European languages) as well, e.g. "Two teas/beers, please" etc. But in English this turn of phrase is much more restricted which is indeed a shame.

          And let's not even start with pluralia tantum.

    • webdevver 1 hour ago
      in the ngspice user manual, they call circuit descriptions an "input deck"

      https://ngspice.sourceforge.io/docs/ngspice-manual.pdf

    • briaoeuidhtns 1 hour ago
      [dead]
  • auvi 1 hour ago
    I am curious to know why there are two Fortrans (i.e. LFortran and LLVM Flang) both targeting the LLVM backend?
    • certik 40 minutes ago
      Author of LFortran here. The historical answer is that both LFortran and Flang started the same year, possibly the very same month (November 2017), and for a while we didn't know about each other. After that both teams looked at the other compiler and didn't think it could do what they wanted, so continued on their current endeavor. We tried to collaborate on several fronts, but it's hard in practice, because the compiler internals are different.

      I can only talk about my own motivation to continue developing and delivering LFortran. Flang is great, but on its own I do not think it will be enough to fix Fortran. What I want as a user is a compiler that is fast to compile itself (under 30s for LFortran on my Apple M4, and even that is at least 10x too long for me, but we would need to switch from C++ to C, which we might later), that is very easy to contribute to, that can compile Fortran codes as fast as possible (LLVM is unfortunately the bottleneck here, so we are also developing a custom backend that does not use LLVM that is 10x faster), that has good runtime performance (LLVM is great here), that can be interactive (runs in Jupyter notebooks), that creates lean (small) binaries, that fully runs in the browser (both the compiler and the generated code), that has various extensions that users have been asking for, etc. The list is long.

      Finally, I have not seen Fortran users complaining that there is more than one compiler. On the contrary, everybody seems very excited that they will soon have several independent high-quality open source compilers. I think it is essential for a healthy language ecosystem to have many good compilers.

      • fc417fc802 31 minutes ago
        I appreciate the usecase you're describing but I feel like "that has good runtime performance (LLVM is great here)" is at odds with the rest of that list. I don't see that as a problem though. I think it's useful to have a very fast lightweight compiler for development and prototyping (both of projects and the compiler itself) and a slower one for highly optimized production releases.
        • certik 22 minutes ago
          Yes, that's one answer. But I actually think you can absolutely have both in the same compiler. But you need to have two backends, as I described. You use the custom backend for development (fast to compile) and you use LLVM for release (fast to run).
          • fc417fc802 4 minutes ago
            Well yes, but at that point aren't you effectively writing two compilers in one? It seems to me that would be at odds with wanting it to be fast to compile itself (you said under 30s) and would make it more difficult for the uninitiated to contribute to.

            I don't mean to discourage and I don't disagree with the aims. I just have the (possibly mistaken) impression that compilers inevitably fall on a continuum from simple and fast to complex and slow.

  • stackghost 1 hour ago
    I've always had a soft spot for Fortran, even though I rarely use it any more.

    When I was in undergrad, so sometime around 2006 or so, I read somewhere that Fortran was actually faster than C in some cases, due I believe to the compiler and certain choices it makes regarding aliasing arrays and whatnot.

    I am an aerospace engineer and avid flight simmer, mostly WWII combat sims, and a huge part of the hobby involves arguing with other people about WWII piston aircraft and their performance. Pages upon pages of forum threads replete with PDFs of historical documents in German, Russian, etc. In order to win arguments more effectively, I decided to write a parametric "flight sim" that would accept a set of maneuvers as an input (e.g. "start at 10000m, dive until speed reaches X km/h indicated, zoom climb back up" or "turn in a circle at Y km/h indicated") so that I had something to compare the in-game results and historical data with.

    I decided to write the whole thing in Fortran 2003 (the 2008 revision was still a draft, as I recall), because fast.

    I bought a copy of Stanley Hooker's book "The Performance of a Supercharged Aero Engine" from the Rolls-Royce heritage press, implemented the method therein. Implemented a numerical vortex panel method for the lifting surfaces, the whole shebang. It was actually a really fun project and it worked pretty well. Fortran is a neat, quaint language and I look back on that project fondly but ultimately I don't miss Fortran. The syntax is needlessly verbose. I/O is a chore. String manipulation is a pain. If you ask me, C++ (despite its many flaws) is superior in every way.

    • certik 28 minutes ago
      Author of LFortran here. LFortran is written in C++, because I knew I will be able to fully deliver the project in it. So I know C++ and Fortran very well. I can say for sure that C++ is not superior in every way. It's slower to compile, hard to deal with dependencies (that's more of a tooling issue), it's more complex, and specifically for numerical array-oriented computing C++ is actually much more verbose and harder to read. For non-numerical computing, such as compiler development, C++ is not a bad choice, that's why I chose it. The slow compilation of C++ is truly a major problem for me, and after we deliver LFortran we'll see if maybe moving to C might be worth it, just to get 10x faster compilation of the C/C++ sources of LFortran itself (the speed of LFortran I think would be similar, we already use arenas and other tricks for performance, which can be done in C just as easily).