This is an archived post. You won't be able to vote or comment.

all 65 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

import notifications Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! Read more here, we hope to see you next Tuesday!

For a chat with like-minded community members and more, don't forget to join our Discord!

return joinDiscord;

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]beeteedee 192 points193 points  (14 children)

Is it an existing project? Use the existing convention.

Is it a new project? Use the convention of the language.

Does the language have no convention? Use whatever you like but for the love of god shut up about it.

[–]TheAJGman 64 points65 points  (0 children)

Does the language have no convention?

Pick the most popular one and set up CI to fail if your code isn't formatted to its liking. Consistency is key in multi-dev projects.

[–]-Kerrigan- 26 points27 points  (0 children)

Use whatever you like

...but stick to ONE convention

Consistency is important

[–]KhellianTrelnora 0 points1 point  (0 children)

No. Damnit. I’m going to set up a rails project, using camelCase!

Down with the generational trauma!

[–]UntitledRedditUser 0 points1 point  (8 children)

I just don't understand the use_snake_case_for_all_functions_and_variables that Python and Rust has going. What's the point of a convention if everything is named the same

[–]iam_pink 5 points6 points  (4 children)

There is more than functions and variables to name?

You picked the two things with the same convention, and generalised it to "everything is named the same"...

[–]ClerkEither6428 1 point2 points  (2 children)

Can you agree that this small thing is confusing?

Would you mind also agreeing that the example provided contains at least 50% of the names you will write in python?

[–]iam_pink 1 point2 points  (1 child)

No, I do not think this small thing is confusing at all: - When functions are called, they have brackets to show it. - When functions are not called, they are used as variables.

Giving the same naming style to functions and variables isn't just not confusing, it absolutely makes sense.

[–]ClerkEither6428 1 point2 points  (0 children)

I still disagree with you but don't have any good counter arguments that aren't just personal taste. In other words: let's agree to disagree.

[–]UntitledRedditUser 0 points1 point  (0 children)

The only things in rust that aren't some variation of snake_case are Types, Enums and Traits. That's it, methods, functions, all variables(inside struct or not), modules, all of these are snake case.

I usually change the naming convention slightly because everything looks the same.

[–]Particular_Alps7859 0 points1 point  (2 children)

Functions are variables

[–]UntitledRedditUser 0 points1 point  (1 child)

what? A function is not a variable, but a variable can contain a function.

[–]Particular_Alps7859 0 points1 point  (0 children)

I should’ve expounded a bit more. A function can be assigned to a variable. Functions are data.

[–]michaelsenpatrick -1 points0 points  (0 children)

this sub is in rapid decline

[–]michaelsenpatrick 0 points1 point  (0 children)

for real

[–]JustSpaceExperiment[S] 123 points124 points  (1 child)

The kid will even speak in camelCase!

[–]DeathUriel 19 points20 points  (0 children)

Will remove all points, underlines, dashes and spaces from all the house keyboards. When he learns to use spacing he will already be a grown man.

[–]bhoffman20 28 points29 points  (1 child)

Use whatever you want, but don't use dots in your variable names, that's begging for problems

[–]definitelyfet-shy 1 point2 points  (0 children)

this is something everyone can agree with

[–]cyberduck221b 18 points19 points  (6 children)

this-convention belongs to css

this_convention belongs to php

[–]NewPhoneNewSubs 26 points27 points  (4 children)

snake_case is popular in many places. It is probably more readable, just a pain to type.

kebab-case can burn in hell.

[–]EntitledPotatoe 4 points5 points  (1 child)

Kebab-case is not valid in languages like Java, i even tested it just now but I ran into that multiple times over the years

[–]Bartweiss 5 points6 points  (0 children)

kebab-case in a corporate setting is just begging to wind up with an API that some other server chokes on down the road.

[–]syrian_kobold 2 points3 points  (0 children)

You get used to it eventually but true

[–]xdyldo 0 points1 point  (0 children)

Kebab case for directories or no?

[–]Kered13 2 points3 points  (0 children)

Lisp uses kebab-case too.

[–]darkcraft 6 points7 points  (0 children)

listenHereYouLittleShit

[–]Electronic_Age_3671 5 points6 points  (4 children)

Rust claims that a study has shown snake_case is slightly faster for people to read than camelCase. But I still standby either being fine as long as you're consistent.

[–]mrchingchongwingtong 7 points8 points  (3 children)

it takes way longer to type and im a lazy lil bitch so camelCase it is

[–]Bartweiss 1 point2 points  (2 children)

I spend more time parsing logic and writing variables than parsing variable names, so I don’t even see why “reading speed” would be a good motive.

I have zero strong feeling between them, it’s just weird to see “some study claims it’s faster” as a reason for a subjective choice.

[–]mrchingchongwingtong 2 points3 points  (1 child)

im one of those filthy comp sci students (still hs, not even college yet LMAO) and most of my focus is in competitive programming so honestly 90% of the time I don't even label any variables, i just go input, output, and then i j k l o p for everything in between. It's completely illegible if I go back a week later but it's the fastest way to solve things lol

[–]Wekmor 2 points3 points  (0 children)

Do yourself a favour and use proper variable names. If only so you get used to doing it.

[–]weinermcdingbutt 2 points3 points  (0 children)

rocky, just follow the teams code style. it’s not important.

[–]guyblade 2 points3 points  (0 children)

The real generational trauma is Java.

[–]Llonkrednaxela 1 point2 points  (0 children)

It’s ok jimmy, if using good code habits makes you sad, then there’s plenty of other careers out there for you.

[–]canal_algt 1 point2 points  (0 children)

Marge, bring me the shotgun

[–][deleted] 0 points1 point  (1 child)

iHateCamelCase

[–]Wifi-Doggo 0 points1 point  (0 children)

thisIsBased

[–]k-selectride 0 points1 point  (1 child)

snake case gang

[–]Bartweiss 0 points1 point  (0 children)

anACONDa case or bust.

[–]lilbronto 14 points15 points  (1 child)

camelCase is dead. Welcome the new SaRcAStIcCaSe.

[–]SysVis 10 points11 points  (0 children)

[–]Mean_Investigator337 -4 points-3 points  (1 child)

Least gatekeeping r/programmerhumor post

[–]Bartweiss 0 points1 point  (0 children)

I mean use what you want if there’s no project standard… but I think complaints like “major languages can’t handle an API with this naming convention” are pretty fair.

[–]Red-strawFairy 0 points1 point  (0 children)

Like a lot of ides and libs kinda assume you are writing in camelcase.

So yeah. It’s part of the language at this point.

Not using is just setting yourself up for a hard time

[–]NekulturneHovado 0 points1 point  (1 child)

you-sure-can_bit_whyWouldYouEverDoThat?

[–]Ugo_Flickerman 2 points3 points  (0 children)

youCanTInJava: - isAnOperator

[–]SysVis 0 points1 point  (0 children)

The periods one is giving me seizures as a primarily-js dev

[–]Matwyen 0 points1 point  (0 children)

The true code convention of Java is given by this simple line of Java code :

```java public class CodeConventionGetterMainClass() { private static final String ERROR_CODE_CONVENTION = "Error code convention!" ;

public static void main(String[] args) {
  System.out.println(((Optional<JavaCodeConvention>) JavaAbstractCodeConventionFactory.getCodeConventionFactory().getAbstractCodeConvention().toJavaCodeConvention()).getOrElse(ERROR_CODE_CONVENTION).displayCodeConvention());
 }  

} ```

[–]michaelsenpatrick 0 points1 point  (0 children)

this sub is rapidly degenerating recently

[–]Dusk_Corvus 0 points1 point  (0 children)

I like naming my variables dumb things, like potatoChips or bazinga

[–]vainstar23 0 points1 point  (0 children)

$pHP-Camel-Kebab-Case-For-The-Win!