💾 Archived View for gemini.hitchhiker-linux.org › gemlog › re:_programming_languages.gmi captured on 2024-08-31 at 12:04:12. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-06-14)

-=-=-=-=-=-=-

Re: Programming Languages

2022-07-25

Blippy writes:

The Pi0 is a slow machine, so compiling Go code is actually pretty painful, despite the language having a reputation for fast compile times.

Blippy: Programming Languages

He goes on to list a few C "competitors" and asks if there are any more. He mentioned most of what I would have, although I would point out that (as much as I love it) Rust has terrible compile times. I can only speak to languages that I have some experience with, so I'll share one modern and one old that are worth considering.

Nim

Nim transpiles to C, so it runs pretty much at C speeds. It's most striking feature is the Python-like syntax, which a lot of people will appreciate. But there are a number of other novel features that I liked about it when I tried it out. It has what is known as Universal Function Call syntax, which means that I can treat a function which takes a certain type as it's first argument as if it were a method on that type.

// this...
myfunc(a: sometype)
// can be called like this...
a.myfunc()

I also appreciated the fact that a program's entry point isn't automatically main, so you can write a program that will function as a standalone binary if it is compiled alone, or as a library if it is compiled as part of a larger program. Compile times are pretty good. C interop is easy.

Nim language homepage

Fortran

I'm not kidding, check out Fortran. It compiles pretty damn quickly and runs on par with C for speed. It's quite a different syntax if you're coming from, well, pretty much anything else, but even as old as it is and with as small as the core language is, I've found it complete enough for getting things done.

Interesting, there is an effort underway to modernize the language and attract new users. They now even have a Cargo and Npm inspired package manager, fpm, which I found works flawlessly. There is no "standard library", only a small collection of compiler builtins, but they're enough to get a lot done. Fpm has also led to a growing ecosystem of useful libraries to pick and choose from. Concurrency is possible, and the compiler GFortran theoretically supports all of the targets that GCC does.

Fortran language homepage

Bonus: FreeBasic

This is a nostalgia inspired bonus. My first computer, like a lot of kids growing up in the 80's, was a Tandy TRS-80. It was primitive, ugly, and gave me a headache if I stared at the screen for too long. That said, I had a lot of fun abusing GOTO in order to write choose your own adventure style games in Basic.

FreeBasic is surprising. Like Nim, it transpiles to C and then from there compiles to native code. And yes, you can actually write usable programs this way - the compiler itself is written in FreeBasic. While I'm offering this as a bit of a tongue in cheek answer, it's still pretty cool.

FreeBasic homepage

Home

All posts

All content for this site is licensed as CC BY-SA.

© 2022 by JeanG3nie

Finger

Contact