Why `fn` for function and `const` for constant

rust has fn keyword for declaring function, but it has const for declaring constant.

you have used f and n from function but used const from constant. why?

why you didn't use cn for declaring constant or why didn't you use funct or func for declaring function?

why? what's the point?

AFAIK mostly historic reasons. Keywords that have been around since the beginning tend to be only 2 or 3 letters, like fn, pub, mut, ref, mod. Don't quote me on this though, I have actually no idea how old the const keyword is.

Although there's probably no way to know for certain (unless graydon blogged about this in great detail), It's also pretty easy to justify retroactively: fn isn't "competing" with any other keyword using the same syntax, whereas const's typical usage is a modifier to fn or an alternative to let or let mut.

Or to put it another way, fn simply doesn't need any more letters to make its meaning obvious. const is also fairly obvious, but cn really isn't.

fn foo() {

cn foo = ...;

Anyone who's ever written code in any language can probably guess at a glance that fn means "function", but cn is a lot more puzzling.


I don't see the point in asking why certain syntax is the way it is. It just is, and it's not that important why, because it is so trivial. We could have just as easily had function or func instead of fn, but Gradon (original creator or Rust) didn't like that, so he chose fn.


This forum is for the development of Rust, both the language and its associated official tooling (compiler, etc.). Questions like these (of which you've asked a few) are of mild historical interest, and they don't have much to do with the ongoing development of Rust. Personally, I find these off topic in this forum.

That said, "fn" is an existing abbreviation for the word "function". "constant" doesn't have an already-established 2-letter abbreviation as far as I'm aware.


As I said in your most recent post regarding syntax:

My question is simple: What is the purpose of asking? Like it or not, that is the syntax, and there's no conceivable way it will ever change.

Please address this. If you're not able to do so, I am kindly asking you to stop posting this type of question. It serves no purpose and clutters IRLO.


For a less formal platform to talk about Rust on, there's for example the official Discord server, the subreddit or the community Discord server.

1 Like