▲ 427 ▼ Infallible Code (feddit.uk) submitted 1 year ago by sirico@feddit.uk to c/programmerhumor@lemmy.ml 122 comments fedilink hide all child comments
[–] Sibbo@sopuli.xyz 89 points 1 year ago* (5 children) else print("number not supported"); permalink fedilink source hideshow 5 child comments replies: [–] sirico@feddit.uk [S] 7 points 1 year ago* (4 children) As we're posting examples I'll add how lovely it is in Elixir. Elixir def not putting the fun in programmer memes do. One reason I picked it because I can't be trusted to not be the meme. def is_even?(n) do rem(n, 2) == 0 end permalink fedilink source parent hideshow 4 child comments replies: [–] balsoft@lemmy.ml 11 points 1 year ago* (3 children) I mean, it would be almost this exact thing in almost any language. fn is_even(n: i64) -> bool { n % 2 == 0 } even n = n `rem` 2 == 0 def is_even(n): return n % 2 == 0 etc permalink fedilink source parent hideshow 3 child comments replies: [–] vinnymac@lemmy.world 4 points 1 year ago (2 children) Personal preference, but elixir just strikes a balance that doesn’t make me feel like I’m reading hieroglyphs so I’m actually happy to see it praised. permalink fedilink source parent hideshow 2 child comments replies: [–] fushuan@piefed.blahaj.zone 4 points 1 year ago I would have preferred for the function to be called mod, since it's the modulo operation, which in math is represented with a percentage or "mod". Most programming languages use a percentage because of that, so do a lot of calculators. permalink fedilink source parent [–] balsoft@lemmy.ml 2 points 1 year ago Yeah, I agree that Elixir is a fine language for some tasks. I personally find the readability somewhat average, but it's very maintainable (due to how it enables clear program structure), the error handling is great, and the lightweight process system is amazing. permalink fedilink source parent
[–] sirico@feddit.uk [S] 7 points 1 year ago* (4 children) As we're posting examples I'll add how lovely it is in Elixir. Elixir def not putting the fun in programmer memes do. One reason I picked it because I can't be trusted to not be the meme. def is_even?(n) do rem(n, 2) == 0 end permalink fedilink source parent hideshow 4 child comments replies: [–] balsoft@lemmy.ml 11 points 1 year ago* (3 children) I mean, it would be almost this exact thing in almost any language. fn is_even(n: i64) -> bool { n % 2 == 0 } even n = n `rem` 2 == 0 def is_even(n): return n % 2 == 0 etc permalink fedilink source parent hideshow 3 child comments replies: [–] vinnymac@lemmy.world 4 points 1 year ago (2 children) Personal preference, but elixir just strikes a balance that doesn’t make me feel like I’m reading hieroglyphs so I’m actually happy to see it praised. permalink fedilink source parent hideshow 2 child comments replies: [–] fushuan@piefed.blahaj.zone 4 points 1 year ago I would have preferred for the function to be called mod, since it's the modulo operation, which in math is represented with a percentage or "mod". Most programming languages use a percentage because of that, so do a lot of calculators. permalink fedilink source parent [–] balsoft@lemmy.ml 2 points 1 year ago Yeah, I agree that Elixir is a fine language for some tasks. I personally find the readability somewhat average, but it's very maintainable (due to how it enables clear program structure), the error handling is great, and the lightweight process system is amazing. permalink fedilink source parent
[–] balsoft@lemmy.ml 11 points 1 year ago* (3 children) I mean, it would be almost this exact thing in almost any language. fn is_even(n: i64) -> bool { n % 2 == 0 } even n = n `rem` 2 == 0 def is_even(n): return n % 2 == 0 etc permalink fedilink source parent hideshow 3 child comments replies: [–] vinnymac@lemmy.world 4 points 1 year ago (2 children) Personal preference, but elixir just strikes a balance that doesn’t make me feel like I’m reading hieroglyphs so I’m actually happy to see it praised. permalink fedilink source parent hideshow 2 child comments replies: [–] fushuan@piefed.blahaj.zone 4 points 1 year ago I would have preferred for the function to be called mod, since it's the modulo operation, which in math is represented with a percentage or "mod". Most programming languages use a percentage because of that, so do a lot of calculators. permalink fedilink source parent [–] balsoft@lemmy.ml 2 points 1 year ago Yeah, I agree that Elixir is a fine language for some tasks. I personally find the readability somewhat average, but it's very maintainable (due to how it enables clear program structure), the error handling is great, and the lightweight process system is amazing. permalink fedilink source parent
[–] vinnymac@lemmy.world 4 points 1 year ago (2 children) Personal preference, but elixir just strikes a balance that doesn’t make me feel like I’m reading hieroglyphs so I’m actually happy to see it praised. permalink fedilink source parent hideshow 2 child comments replies: [–] fushuan@piefed.blahaj.zone 4 points 1 year ago I would have preferred for the function to be called mod, since it's the modulo operation, which in math is represented with a percentage or "mod". Most programming languages use a percentage because of that, so do a lot of calculators. permalink fedilink source parent [–] balsoft@lemmy.ml 2 points 1 year ago Yeah, I agree that Elixir is a fine language for some tasks. I personally find the readability somewhat average, but it's very maintainable (due to how it enables clear program structure), the error handling is great, and the lightweight process system is amazing. permalink fedilink source parent
[–] fushuan@piefed.blahaj.zone 4 points 1 year ago I would have preferred for the function to be called mod, since it's the modulo operation, which in math is represented with a percentage or "mod". Most programming languages use a percentage because of that, so do a lot of calculators. permalink fedilink source parent
[–] balsoft@lemmy.ml 2 points 1 year ago Yeah, I agree that Elixir is a fine language for some tasks. I personally find the readability somewhat average, but it's very maintainable (due to how it enables clear program structure), the error handling is great, and the lightweight process system is amazing. permalink fedilink source parent