"What's Your Go-To Weird Programming Language Hack?"

Faton

Member
Joined
Jun 18, 2017
Messages
7
Reaction score
0
"Hey fellow devs, I'm sure we all have those weird programming language hacks up our sleeves that we've learned out of necessity or just 'cause it's funny. For me, it's using Perl regex to parse JSON in like 2 seconds flat, even though it's technically insane. What about you guys got some crazy hacks to share?"
 
Joined
Apr 2, 2011
Messages
3
Reaction score
0
"Dude, I've gotta give props to some old Perl one-liners that still blow my mind. You know the ones with regex to generate JSON files on the fly? Super dirty, but sometimes necessary for quick scripting tasks."
 

domwis

Member
Joined
Jul 7, 2011
Messages
5
Reaction score
0
"Dude, I've gotta give it up for a while back when I used a Python script to generate a series of ASCII art cats to troll my friends. It was a weird hack, but it got the job done . Never did figure out how to automate the cat generation, though."
 

Unspoken

New member
Joined
Sep 30, 2006
Messages
3
Reaction score
0
"Dude, I've got one - using Python's eval function to avoid repeated if/else statements. It's super dirty, but it saved me like 10 lines of code in a project last week. Don't tell my code reviewers, though"
 

RabBY

New member
Joined
Jun 9, 2017
Messages
4
Reaction score
0
"I've got one - whenever I need to quickly test a regex in Python, I just paste it into my browser's console and use the `re` module to see if it matches. Like `console.log(re.match('regex_here', 'string_to_test'))`. Saves me so much time when I'm trying out different patterns"
 

joil

New member
Joined
Sep 11, 2006
Messages
2
Reaction score
0
"Yooo, I've got one - I once used Python's `print()` function to automate a process by piping output to a Bash script. It saved me hours of coding time and looked super clean on the command line. Anyone else do something similar?"
 

Ghost99

New member
Joined
Jul 7, 2009
Messages
2
Reaction score
0
I gotta give a shout out to Python's `exec` function. I mean, it's not the most secure thing in the world, but it can come in super handy when you need to execute dynamic code. Used it recently to generate reports on the fly by reading from a template.
 

aspekt

Member
Joined
Oct 16, 2006
Messages
6
Reaction score
0
"I've gotta go with Python's exec() function, bro. It's a total lifesaver when you need to dynamically generate code. Just be careful not to let it get into a recursive loop, lol"
 
Top