Yes I am going to move from my comfortable laying position to move my hand up to open control center turn off rotation lock then sit up so I can turn my phone sideways and be able to read it
All so I can still struggle to read a line of badcode.
fn main(){
let mut line = String::new();
println!("Enter your name :");
let b1 = std::io::stdin().read_line(&mut line).unwrap();
println!("Hello , {}", line);
}
because I cut out some unnecessary lines from the linked example and didn't remove the assignment. the variable is referenced later in the original but you are correct it's not needed here.
Ruby is my favorite. It's so terse yet expressive, and much more widely used IRL.
Raku's grammars are really nice though.
In the end, I think it's just important to recognize that Code Golf is a fun exercise, but please don't try to write production code like that. I've seen people try to focus on always having the shortest code with the least repetition, and it can be needlessly difficult to maintain.
Yeah, generally golf code isn’t good code. You will sometimes learn tricks about the language you’re working in that help with writing better code.
For example, I first saw python’s * syntax for lists in the context of golf code. It’s stuff like that that tends to get left out of programming classes even though it’s very useful.
Kotlin also works for that. Strings can to the same thing as in the picture. Love the language and it’s features, but some are a double edged sword.
global variables
global functions and extension functions
a with() function that moves the code's scope into the given object
operator overloading on everything
variables/properties with no value that always call a getter function
variable name shadowing is allowed
you could technically write code without local variables if you misuse .run{}/.let{} enough (basically map for a single object, one in it’s scope one with the object as lambda parameter
with the groovy-like lambda system you can basically make a random DSL
What if you create a script that rids all the white spaces in a .ccp source file with conditions handling ' and ". Back up the readable code and use the processed file with compiling.
315
u/skantanio Mar 12 '23
FYI these one liner thin ass screenshots are cancer to view on mobile. Text wrap is a cool feature
28
u/Karma_Policer Mar 12 '23
That's why Rust doesn't allow you to put functions calls inside f-strings.
3
u/desci1 Mar 13 '23
Text code post >>> Human excrement >>> Image code post
108
u/Will_i_read Mar 12 '23
I love writing cursed python onliners. Not for production, but you can learn a lot from them
50
u/Rene_Z Mar 12 '23
8
u/desci1 Mar 13 '23
What are we saving here, storage?
14
u/[deleted] Mar 12 '23
This one-lines would be a way less cursed if there is some kind of composition:
Heh, technically it is no longer one-liner if it splitted into several lines fro readability...
6
u/crack-of-a-whip Mar 13 '23
What is your name? Josh
Hi, Josh! What is your age? 23
You are 23 age old.
What an incredible piece of code. Some might say life changing
5
u/[deleted] Mar 12 '23
Average onlinegdb.com user
3
u/Im_1nnocent Mar 13 '23
What if you create a script that rids all the white spaces in a .ccp source file with conditions handling ' and ". Back up the readable code and use the processed file with compiling.
Or maybe not.
2
u/shyamathur Mar 12 '23
Looks like one of those Clash of Code submissions
2
u/jjman72 Mar 12 '23
Got it on one line boss.
2
u/Bravo555 Mar 12 '23
Does it even save any bytes?
2
u/[deleted] Mar 14 '23
I mean If you add a // comment, IT coud be a Bit more readable
1
u/fnieidhfenmbvfekh Mar 25 '23
That’s a cool feature. I should do that sometime. I’m not being sarcastic.
1
u/fnieidhfenmbvfekh Mar 30 '23
You are 1 age old.