Any time I found myself blindly typing if, I pause for a while and talk to my internal rubber duck (her name is Jess, btw.) "Jess, is there any way to avoid if clause here?"
cmqv ยท 13 points ยท Posted at 14:08:56 on May 23, 2018 ยท (Permalink)
However, perhaps I've misunderstood the point of this sub. If this sub merely exists as a way for anonymous cowards to attack the work of people who are trying to affect change - even if it's change in this community's favor - then I'm at a loss for words. If that's what it is, I suppose I should just categorize this sub as another wart outgrown from 4chan's asshole - despite the enjoyment I derived from my initial time here. There's a difference between real hackers and whack trolls. Feel free to enlighten me to which this sub intends to cater. Real hackers do real thangs, and trolls need to seek therapy.
All our control flow is done by indirection through vtables. The cost of this is stack size, but the benefit is that everything is significantly more maintainable.
r2d2_21 ยท 69 points ยท Posted at 18:26:06 on May 22, 2018 ยท (Permalink)
Sometimes [Jess] responds โno,โ itโs a perfect use-case for an if, like yesterday when I was to implement a function producing a string representation of current time for an American audience. I ended up with
if hours < 12 then 'AM' else 'PM'
lol not doing an integer division by 12 and looking for the option in an array or map.
if isn't okay except half of the times you think it is
wewlad
/uj
I do agree though that some people use and abuse nested ifs when a match case/pattern match would simplify it a lot. But this guy has completely outjerked it
[deleted] ยท 8 points ยท Posted at 05:19:23 on May 23, 2018 ยท (Permalink)
[deleted]
iopq ยท 3 points ยท Posted at 11:06:25 on May 23, 2018 ยท (Permalink)
Well, of course, the point is to have code that is easy to maintain. Whenever you have extra conditions, you end up doing boolean algebra eventually like if A {} else if B && !C {} else if B && C ...
There is no filtered() in today's Rust, but there is a filter() iterator method.
Remember that all non-consuming iterator methods are lazy. So filter() itself will never execute the callback(), let alone do or not do_shit(). However, when consumption happens, the next() method will be called, which indeed has an if.
Move 42 to the register named al, move the value of .answer variable into the register ah, compare values and jump to .answer_errinstruction if values are not equal. If this is not a poetry, I donโt know what is.
I never would have thought I'd find the next Keats on dev.to. Anyone know how to get in touch with Harold Bloom? He won't be able to believe the aesthetic splendor of this paragraph
Do you have a moment to talk about our lord and saviour, Smalltalk?
idobai ยท 8 points ยท Posted at 06:57:58 on May 23, 2018 ยท (Permalink)
We donโt think like โif I want an apple, Iโll eat it, otherwise I wonโt.โ
Oh, lizard people...
[deleted] ยท 8 points ยท Posted at 11:46:35 on May 23, 2018 ยท (Permalink)
I consider code to be a code smell. We should all just stop writing code and insist on nothing less than building all applications as complex compositions of various Docker containers other people wrote.
[deleted] ยท 7 points ยท Posted at 04:46:10 on May 23, 2018 ยท (Permalink)
Transcript show: ((useNormalLanguage) ifTrue: ["good"] ifFalse:["lol, no OOP if"])
Because, you know, I am not writing my PhD anymore and I donโt work on Saturdays. Not in the office, at least.
I could have guessed!
Ps: Norton Disk Editor wasn't written in machine code. They probably wrote the ASM out and then hand converted it to bytes.
I would try and read the book to see if this is true, but it looks like it was foundational in making this guy a giant deep and i don't want to risk that.
Specially considering it could have been rewrote as a switch case and the when clauses in the pattern matching are just syntactic sugar for conditional evaluation anyways
Saved comment
๐๏ธ isthistechsupport ยท 83 points ยท Posted at 17:55:00 on May 22, 2018 ยท (Permalink)
I, too, like to do my control flow with only
movssimon816 ยท 40 points ยท Posted at 21:38:12 on May 22, 2018 ยท (Permalink)
Ah the ol' movfuscator
๐๏ธ isthistechsupport ยท 16 points ยท Posted at 21:46:50 on May 22, 2018 ยท (Permalink)
mfw
According to the readme, any program that compiles down to LLVM can be compiled with it. That gives me ideas...
dnkndnts ยท 7 points ยท Posted at 09:28:10 on May 23, 2018 ยท (Permalink)
Is your idea to compile something down to LLVM and then use the movfuscator?
emdeka87 ยท 12 points ยท Posted at 23:11:38 on May 22, 2018 ยท (Permalink)
Welp at least no branchy Code smell
๐๏ธ isthistechsupport ยท 5 points ยท Posted at 15:55:31 on May 23, 2018 ยท (Permalink)
You don't need 2D diagrams when your 1D line is long and convoluted enough to simulate 2D anyways
LEmp_Evrey ยท 2 points ยท Posted at 11:42:21 on May 23, 2018 ยท (Permalink)
Don't forget
reductio.TheFearsomeEsquilax ยท 13 points ยท Posted at 18:57:34 on May 22, 2018 ยท (Permalink)
What's this about cmov?
๐๏ธ isthistechsupport ยท 7 points ยท Posted at 20:07:21 on May 22, 2018 ยท (Permalink)
Paging /u/cmqv for the Navy Seal copypasta
cmqv ยท 13 points ยท Posted at 14:08:56 on May 23, 2018 ยท (Permalink)
However, perhaps I've misunderstood the point of this sub. If this sub merely exists as a way for anonymous cowards to attack the work of people who are trying to affect change - even if it's change in this community's favor - then I'm at a loss for words. If that's what it is, I suppose I should just categorize this sub as another wart outgrown from 4chan's asshole - despite the enjoyment I derived from my initial time here. There's a difference between real hackers and whack trolls. Feel free to enlighten me to which this sub intends to cater. Real hackers do real thangs, and trolls need to seek therapy.
casino_r0yale ยท 4 points ยท Posted at 08:01:28 on May 23, 2018 ยท (Permalink)
Itโs actually GNU/copypasta
pcopley ยท 5 points ยท Posted at 14:43:02 on May 23, 2018 ยท (Permalink)
Or as I've come to call it, GNU + copypasta
haskell_leghumper ยท 6 points ยท Posted at 07:42:37 on May 23, 2018 ยท (Permalink)
All our control flow is done by indirection through vtables. The cost of this is stack size, but the benefit is that everything is significantly more maintainable.
๐๏ธ isthistechsupport ยท 5 points ยท Posted at 15:56:48 on May 23, 2018 ยท (Permalink)
Code is always more maintainable when you're planning on quitting right after you release it anyways
bumblebritches57 ยท 3 points ยท Posted at 02:55:52 on May 24, 2018 ยท (Permalink)
Good lord.
axalon900 ยท 70 points ยท Posted at 19:24:21 on May 22, 2018 ยท (Permalink)
๐๏ธ isthistechsupport ยท 47 points ยท Posted at 20:07:44 on May 22, 2018 ยท (Permalink)
lol redundancy
0x564A00 ยท 24 points ยท Posted at 22:16:23 on May 22, 2018 ยท (Permalink)
Redundancy redundancy = new Redundancy("oop","shit");
furrthur ยท 32 points ยท Posted at 22:43:39 on May 22, 2018 ยท (Permalink)
[deleted] ยท 6 points ยท Posted at 03:31:08 on May 23, 2018 ยท (Permalink)
lol not composing functions calls using pipe operator from functional languages
saulmessedupman ยท 4 points ยท Posted at 11:32:30 on May 23, 2018 ยท (Permalink)
He forgot to show the disassembled object code.
r2d2_21 ยท 69 points ยท Posted at 18:26:06 on May 22, 2018 ยท (Permalink)
lol not doing an integer division by 12 and looking for the option in an array or map.
๐๏ธ isthistechsupport ยท 26 points ยท Posted at 20:11:32 on May 22, 2018 ยท (Permalink)
wewlad
/uj
I do agree though that some people use and abuse nested ifs when a match case/pattern match would simplify it a lot. But this guy has completely outjerked it
optimal_substructure ยท 14 points ยท Posted at 00:39:15 on May 23, 2018 ยท (Permalink)
Yeah, insufferable article, but pattern matching is definitely under utilized
[deleted] ยท 11 points ยท Posted at 04:42:59 on May 23, 2018 ยท (Permalink)
Hard to utilize something that doesn't exist in language of your choice.
That raises a question why you choose that language to begin with, but some questions better left unanswered as world is not ready for the truth yet.
๐๏ธ isthistechsupport ยท 3 points ยท Posted at 16:11:22 on May 23, 2018 ยท (Permalink)
Or we can skip to the logical conclusion and just rewrite it in Rust
parabol443 ยท 23 points ยท Posted at 01:07:52 on May 23, 2018 ยท (Permalink)
10AM
11AM
12PM
13PM
lol no time type
r2d2_21 ยท 8 points ยท Posted at 04:08:26 on May 23, 2018 ยท (Permalink)
But how does the time type implement its logic? ๐ค
๐๏ธ isthistechsupport ยท 3 points ยท Posted at 16:13:08 on May 23, 2018 ยท (Permalink)
What matters is that you don't write the word
if, so you don't have to cut short your superior jerk[deleted] ยท 3 points ยท Posted at 21:33:43 on May 23, 2018 ยท (Permalink)
You said
if! You're out!just-one-more-thing ยท 9 points ยท Posted at 07:29:50 on May 23, 2018 ยท (Permalink)
(char) (80 + (15 * Math.floor(time / 12))) :P
pcopley ยท 4 points ยท Posted at 14:44:45 on May 23, 2018 ยท (Permalink)
lol_no_generics ยท 9 points ยท Posted at 07:51:04 on May 23, 2018 ยท (Permalink)
B R A N C H L E S S
tetroxid ยท 12 points ยท Posted at 05:35:48 on May 23, 2018 ยท (Permalink)
lol no 24 hour clock
pcopley ยท 6 points ยท Posted at 14:44:22 on May 23, 2018 ยท (Permalink)
This dumb fuck is showing AM/PM on a 24 hour clock.
pyosbarbos ยท 48 points ยท Posted at 20:59:32 on May 22, 2018 ยท (Permalink)
Oh, I get it.
Nice, my code is now readable, maintainable, and extendable.
McGlockenshire ยท 17 points ยท Posted at 03:18:37 on May 23, 2018 ยท (Permalink)
oh man I wonder if perl's
unlesscounts as an ifdozniak ยท 7 points ยท Posted at 08:08:11 on May 23, 2018 ยท (Permalink)
unless it doesn't
Tysonzero ยท 2 points ยท Posted at 00:11:51 on May 24, 2018 ยท (Permalink)
Or Haskell's.
compscigurl ยท 2 points ยท Posted at 16:13:51 on May 23, 2018 ยท (Permalink)
ahhhh synonyms..
PM_ME_IRL ยท 42 points ยท Posted at 20:38:58 on May 22, 2018 ยท (Permalink)
Who are these 10E-7'xers who still use if instead of abstract strategy factory beans
brool ยท 14 points ยท Posted at 05:05:01 on May 23, 2018 ยท (Permalink)
Sheesh, if by now you donโt have a factory for your abstract strategy factory then youโre basically banging rocks together.
zero_operand ยท 8 points ยท Posted at 06:05:34 on May 23, 2018 ยท (Permalink)
2008 called - it wants it's jerking material back
๐๏ธ isthistechsupport ยท 3 points ยท Posted at 16:14:07 on May 23, 2018 ยท (Permalink)
What's next, jQuery jerking?
Pimpus ยท 32 points ยท Posted at 18:34:58 on May 22, 2018 ยท (Permalink)
No, YOU'RE a code smell.
๐๏ธ isthistechsupport ยท 15 points ยท Posted at 20:08:09 on May 22, 2018 ยท (Permalink)
no u're mom gai
FuckingRageAccount ยท 32 points ยท Posted at 01:23:20 on May 23, 2018 ยท (Permalink)
3 if statements
mfw
hosp3s ยท 20 points ยท Posted at 02:12:51 on May 23, 2018 ยท (Permalink)
Welp, better add 20 lines of ruby shit to make it super maintainable!
๐๏ธ isthistechsupport ยท 8 points ยท Posted at 16:15:32 on May 23, 2018 ยท (Permalink)
Oh, so he's gonna use a
switch, makes senseYes, I'd like to delete someone else's post
hosp3s ยท 6 points ยท Posted at 16:25:14 on May 23, 2018 ยท (Permalink)
Hmm a switch, that's not enough boilerplate to be maintainable
likeboats ยท 23 points ยท Posted at 00:41:18 on May 23, 2018 ยท (Permalink)
Lol ruby devs
hurkle ยท 22 points ยท Posted at 06:30:43 on May 23, 2018 ยท (Permalink)
never refers to it again
hexasquid ยท 21 points ยท Posted at 20:34:05 on May 22, 2018 ยท (Permalink)
jtayloroconnor ยท 18 points ยท Posted at 23:37:12 on May 22, 2018 ยท (Permalink)
elseโs are punishable by death
dozniak ยท 8 points ยท Posted at 08:09:55 on May 23, 2018 ยท (Permalink)
They are perfectly replaceable with
if (someverylongexpr) { do_shit(); } if (not someverylongexpr) { do_else_shit(); }[deleted] ยท 7 points ยท Posted at 08:32:30 on May 23, 2018 ยท (Permalink)
[deleted]
amirmikhak ยท 4 points ยท Posted at 04:50:54 on May 24, 2018 ยท (Permalink)
Make the expression a call to a method in a service that memorizes the result?
dozniak ยท 3 points ยท Posted at 07:37:04 on May 25, 2018 ยท (Permalink)
Javascript has a feature to bypass the computation stage and compile directly into result, so it's cheap!
(this is a joke, btw)
jtayloroconnor ยท 2 points ยท Posted at 12:02:38 on May 23, 2018 ยท (Permalink)
a pattern of beauty
thejuror8 ยท 13 points ยท Posted at 02:37:44 on May 23, 2018 ยท (Permalink)
This actually made me mad.
iopq ยท 12 points ยท Posted at 02:47:53 on May 23, 2018 ยท (Permalink)
Actually, my FizzBuzz has ZERO if statements in it. It was a specific design goal.
https://www.reddit.com/r/programmingcirclejerk/comments/8k8iad/fizzbuzz_can_finally_be_implemented_in_stable_rust/
[deleted] ยท 8 points ยท Posted at 05:19:23 on May 23, 2018 ยท (Permalink)
[deleted]
iopq ยท 3 points ยท Posted at 11:06:25 on May 23, 2018 ยท (Permalink)
Well, of course, the point is to have code that is easy to maintain. Whenever you have extra conditions, you end up doing boolean algebra eventually like
if A {} else if B && !C {} else if B && C ...TheLastMeritocrat ยท 5 points ยท Posted at 12:53:16 on May 23, 2018 ยท (Permalink)
/uj
There is no
filtered()in today's Rust, but there is afilter()iterator method.Remember that all non-consuming iterator methods are lazy. So
filter()itself will never execute thecallback(), let alone do or notdo_shit(). However, when consumption happens, thenext()method will be called, which indeed has anif.bumblebritches57 ยท 2 points ยท Posted at 02:59:32 on May 24, 2018 ยท (Permalink)
Thanks for stating the obvious.
TheFearsomeEsquilax ยท 10 points ยท Posted at 18:56:37 on May 22, 2018 ยท (Permalink)
I never would have thought I'd find the next Keats on dev.to. Anyone know how to get in touch with Harold Bloom? He won't be able to believe the aesthetic splendor of this paragraph
SelfDistinction ยท 20 points ยท Posted at 19:40:16 on May 22, 2018 ยท (Permalink)
Do you have a moment to talk about our lord and saviour, Smalltalk?
idobai ยท 8 points ยท Posted at 06:57:58 on May 23, 2018 ยท (Permalink)
Oh, lizard people...
[deleted] ยท 8 points ยท Posted at 11:46:35 on May 23, 2018 ยท (Permalink)
I consider code to be a code smell. We should all just stop writing code and insist on nothing less than building all applications as complex compositions of various Docker containers other people wrote.
[deleted] ยท 7 points ยท Posted at 04:46:10 on May 23, 2018 ยท (Permalink)
Transcript show: ((useNormalLanguage) ifTrue: ["good"] ifFalse:["lol, no OOP if"])nishanths ยท 8 points ยท Posted at 12:42:58 on May 23, 2018 ยท (Permalink)
dev.to is cancer.
Poddster ยท 6 points ยท Posted at 06:53:16 on May 23, 2018 ยท (Permalink)
I could have guessed!
Ps: Norton Disk Editor wasn't written in machine code. They probably wrote the ASM out and then hand converted it to bytes.
I would try and read the book to see if this is true, but it looks like it was foundational in making this guy a giant deep and i don't want to risk that.
๐๏ธ isthistechsupport ยท 9 points ยท Posted at 15:46:32 on May 23, 2018 ยท (Permalink)
I'm guessing "If Statement Considered Harmful" wasn't as appealing to his thesis advisor as he thought it'd be
FR_STARMER ยท 10 points ยท Posted at 04:42:42 on May 23, 2018 ยท (Permalink)
I get the point but going from 9 loc to more destroys said point
๐๏ธ isthistechsupport ยท 13 points ยท Posted at 04:45:37 on May 23, 2018 ยท (Permalink)
Specially considering it could have been rewrote as a
switch caseand thewhenclauses in the pattern matching are just syntactic sugar for conditional evaluation anywayst0mRiddl3 ยท 3 points ยท Posted at 05:36:55 on May 23, 2018 ยท (Permalink)
Period
RAKtheUndead ยท 5 points ยท Posted at 09:27:29 on May 23, 2018 ยท (Permalink)
Ternary statement or GTFO.
fableal ยท 3 points ยท Posted at 16:04:58 on May 23, 2018 ยท (Permalink)
๐๏ธ isthistechsupport ยท 3 points ยท Posted at 16:06:12 on May 23, 2018 ยท (Permalink)
...and other reasons why this shit is cancer
wavy_lines ยท 3 points ยท Posted at 07:30:12 on May 26, 2018 ยท (Permalink)
Replaces very simple and straight forward code with spaghetti and multiple levels of indirection, then calls it maintainable and readable.
Tysonzero ยท 2 points ยท Posted at 00:13:52 on May 24, 2018 ยท (Permalink)
Why use if statements when you have
bool.{-# LANGUAGE Unjerk #-}Why use if statements when you have
bool.tpgreyknight ยท -9 points ยท Posted at 19:54:17 on May 22, 2018 ยท (Permalink)
Error: UnableToJerkException: message="this but unironically"