this post was submitted on 31 Aug 2024
196 points (97.1% liked)

Linux

48363 readers
560 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

As far as I know there are these;

  • Camel case = coolFileName
  • Snake case = cool_file_name
  • Kebab case = cool-file-name
  • Pascal case = CoolFileName
  • Dot notation = cool.file.name
  • Flat case = coolfilename
  • Screaming case = COOLFILENAME

Personally I prefer the kebab/dot conventions simply because they allow for easy "navigation" with (ctrl+arrow keys) between each part. What are your preferences when it comes to this? Did I miss any schemes?

top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 74 points 2 months ago* (last edited 2 months ago) (4 children)

It depends a bit on the use case. I try to follow naming conventions within specific environments like Python. When just sorting some documents together, I usually do a mix of Kebab and snake case, where I split semantic parts with underscores and connect words with dashes like

2024-08-30_author_document-name_other-important-info.ext

[–] [email protected] 11 points 2 months ago

This is exactly what I do. It lends itself to something like 'prefix_specific-info_version' which is both sortable and easy to read.

[–] [email protected] 7 points 2 months ago* (last edited 2 months ago)

Yeahh that's the best IMO ! But I get most of the time stuck with some testOFtest001 files/directory... cause I'm lazy...

But I always ALWAYS regret it afterward... :/

load more comments (2 replies)
[–] [email protected] 50 points 2 months ago (1 children)

Snake case.

  • Starts with a lowercase, good for shell autocompletion
  • No spaces, so no worrying about spaces in shell commands
  • '_' is better than '-' because it shows the spaces between words more clearly
[–] [email protected] 33 points 2 months ago (3 children)

Counterpoint: you have to use Shift a lot

[–] [email protected] 23 points 2 months ago (1 children)

He probably uses vi. A few hundred more shift-key presses won't stand out.

load more comments (1 replies)
load more comments (2 replies)
[–] [email protected] 42 points 2 months ago (3 children)

I put an unnecessary amount of spaces in all my file names to break anyone who wants to use CLI tools on them

i use windows btw

[–] [email protected] 15 points 2 months ago

Using Windows is a true flex on Lemmy

[–] [email protected] 6 points 2 months ago (3 children)
load more comments (3 replies)
load more comments (1 replies)
[–] [email protected] 38 points 2 months ago (2 children)
[–] [email protected] 6 points 2 months ago (2 children)

10 PRINT "FARTS" 20 GOTO 10

load more comments (2 replies)
load more comments (1 replies)
[–] [email protected] 27 points 2 months ago (2 children)

Underscore to delineate different parts, hypen to delineate words.

Like: my-resume_draft.pdf

And to make it consistent and easier to reuse parts for project names and such, I have a command line utility written for it. It caches the parts and uses a template system (support for generating current datetime in parts)

Available here (is in AUR too):

https://github.com/Atreyagaurav/nameit

[–] [email protected] 12 points 2 months ago

You can go-to_hell.

[–] [email protected] 9 points 2 months ago

Thats what I do as well. It makes it easy to seperate between logical units.

[–] [email protected] 21 points 2 months ago (1 children)

I like Camel Case for code, but mostly because it's ingrained in my brain, coming from Java as my first language.

For folders and files, I like Kebab Case.

[–] [email protected] 7 points 2 months ago

Luckily, I was not ingrained by my first programming language like that, or my coworkers would strangle me.

I started with BASIC, which allowed only two letters for variable names...

[–] [email protected] 21 points 2 months ago (1 children)

SCREAMING_SNAKE_CASE just has the best name

[–] [email protected] 9 points 2 months ago

YES, I USE THIS TOO TO STAY CONSISTENT WITH SQL QUERIES

[–] [email protected] 18 points 2 months ago (3 children)

I am a fan of Python's or Rust's official conventions.

For package names, tho, I don't get why this-is-used over this_clearly_better_system, as I would expect a double click to select_the_whole_thing, whereas it does-not-happen-here.

load more comments (3 replies)
[–] [email protected] 13 points 2 months ago (1 children)

Camel case, but with a twist -- if the next word is about to start after a capital letter, I'll have it lower case.

topSecretFBIfile.txt for example

[–] [email protected] 22 points 2 months ago (1 children)

Interesting, I'd tend to demote the initialism, ie topSecretFbiFiles.tar.gz

load more comments (1 replies)
[–] [email protected] 13 points 2 months ago* (last edited 2 months ago) (1 children)

IT'S

COOLFILE.NAM

THERE IS ONLY 8.3 AND THERE IS ONLY UPPERCASE

load more comments (1 replies)
[–] [email protected] 12 points 2 months ago

I like to use my enterprise number and a UUID (all in lower case, for legibility). Here's an example:

.1.3.6.1.4.1.33230.0d456e46-67e6-11ef-9c92-7b175b3ab1f1

Now you might say that the UUID is already globally unique or at least pretty unlikely to turn up anywhere else, so why bother prefixing it with more stuff? To that I say: "I need to be absolutely or at least reasonably sure ... OK nearly sure".

Anyway, you maintain a database of these things and then attach documentation and meaning to them. An editor could abstract and hide that away.

I started this post as a joke. Not sure anymore. Why get your knickers in a twist with naming conventions for variables and constants. Programming is already a whopping layer of abstraction from what the logic gates are up to, another one wont hurt!

[–] [email protected] 12 points 2 months ago

For files, kebab case. For variables, snake case. For servers, megaman villains.

[–] [email protected] 11 points 2 months ago (2 children)

How about "cool file name"?

All my systems use modern file systems that are case sensitive and can contain any character except / and \0.

[–] [email protected] 10 points 2 months ago (10 children)

Using commands on that is still more annoying, so no way

load more comments (10 replies)
[–] [email protected] 7 points 2 months ago* (last edited 2 months ago)

True. Linux, Android, Windows all have no problems

Using dots in a file though...

[–] [email protected] 10 points 2 months ago (1 children)

I’ve never been to a naming convention but I have been to some comic conventions!

load more comments (1 replies)
[–] [email protected] 10 points 2 months ago (1 children)

The only correct answer is to be consistent with the code base you're working in or the language's conventions. If neither of these conventions exist, then someone has already failed you.

load more comments (1 replies)
[–] [email protected] 10 points 2 months ago (1 children)

Snake case. I find it the easiest to read.

[–] [email protected] 8 points 2 months ago* (last edited 2 months ago)

I'm starting to warm up to Pokemon case, which would simplify functions like

  • GottaCatchThemAll() to 🍚()

or

  • this to ⚡🐹IchooseU

which I think we can all agree is much easier to read

[–] [email protected] 10 points 2 months ago (3 children)

WIAT, Y R U CALLIN IT SCREAMING CASE THAT SOUNDS FKN DUM TBH

L8R DOODZ

-SP4SEM4N B1FF

load more comments (3 replies)
[–] [email protected] 10 points 2 months ago

For files? An unholy amalgam of snake, kebab and dot, depending on what exactly I'm trying to convey. (I still have much-ported files around with DOS 8.3 filenames, so they're truncated scream case (SCREAMIN.NAM), but I don't actively name files like that anymore.) The important thing is to separate the words/sections while using characters that are valid without escapes in both ext4 and vfat if at all possible.

For variable names, camel or Pascal case (depending on language convention) if I think anyone else is going to read it. Flat case for code I don't think anyone else is ever going to see (don't do this—it has left teethmarks in my ass from time to time and will do the same to you).

[–] [email protected] 10 points 2 months ago (5 children)

25% Camel case, 25% Pascal and 50% of the time flatcase. It drives me insane when I try and autocomplete a folder only to realise it was Downloads instead of downloads. I keep telling myself i will go through and make it all flatcase but I put it off because i tell myself i will rebuild my computer next week every week.

[–] [email protected] 6 points 2 months ago

Never thought about making the home folders flatcase, thanks, takes all of 2 minutes btw.
If anybody else wants to do it, remember to edit ~/.config/user-dirs.dirs with your new flatcase folders.

load more comments (4 replies)
[–] [email protected] 8 points 2 months ago

Random mix and match. I’m all for diversity!

[–] [email protected] 8 points 2 months ago

It really depends.

If I know I will never open the file in the terminal or batch process it in someways, I will name it using Common Case: "Cool Filename.odt".

Anything besides that, snake case. Preferably prefixed with current date: "20240901_cool_filename"

[–] [email protected] 8 points 2 months ago

Unless I can't, Kebab.

No need to hold Shift.

[–] [email protected] 8 points 2 months ago

Kebab. Not my favorite visually speaking but I had RSI issues for a while and I'm still very focused on limiting keystrokes (no shift key needed with kebab).

[–] [email protected] 8 points 2 months ago

Kebab or snake for ease of parsing through them.

[–] [email protected] 7 points 2 months ago* (last edited 2 months ago) (1 children)

Depending on environment/language and policies. As long as its consistent throughout the project.

load more comments (1 replies)
[–] [email protected] 7 points 2 months ago

Snake case, but I'm the World's second worst programmer and just name files like this because I was alive when spaces were not allowed.

[–] [email protected] 7 points 2 months ago* (last edited 2 months ago) (2 children)

Rfc3339 plus kebab case for many things

2024-09-01_lname-fname-resume.pdf

load more comments (2 replies)
[–] [email protected] 7 points 2 months ago

I've got a personal convention that file names get snake case, directory names get Pascal case.

[–] [email protected] 6 points 2 months ago

Depends. Java-like languages ofc camel/pascal case.
Bash, Python, etc., snake case, with constants as uppercase.
Filenames: I prefer snake case.

[–] [email protected] 6 points 2 months ago

IWRITELOTSOFBASH

[–] [email protected] 6 points 2 months ago

I like snake, but in some interfaces the underscores blend into the text line or are not rendered properly, so it becomes eaaier to discern if the filename has spaces or separators by using kebab.

[–] [email protected] 6 points 2 months ago* (last edited 2 months ago)

A mix of snake and camel case. Sometimes I mix it in the same project and I hate myself for it

load more comments
view more: next ›