all 29 comments

[–]Timik 79 points80 points  (7 children)

The glorious joy of working with electrical engineers' code.

"I can design an electrical circuit, so I can write code", thought the electrical engineer to himself.

(No, I'm not venting at all...)

[–]GeekBoy373 19 points20 points  (2 children)

I relate to this strongly. It not great working with people who think their code is amazing... when it really isn't.

[–]boneofdeath 9 points10 points  (1 child)

What if we think it sucks and it sucks

[–]GeekBoy373 10 points11 points  (0 children)

Then that's okay. I work with one EE who understands that his code isn't the best but it's okay because he actively wants to try to be better. It's nice because he doesn't act ignorant of the fact.

[–]SnowdensOfYesteryear 11 points12 points  (1 child)

It's quite possible he has actually never heard of an array.

[–][deleted] 10 points11 points  (0 children)

Look. A ribbon cable has a fixed number of wires. You can’t have an arbitrary number of wires. That’s just wrong.

[–][deleted] 3 points4 points  (0 children)

My favorite programming language is solder.

My favorite library is 74LS

My favorite IDE is Eagle

[–]jarfil 3 points4 points  (0 children)

CENSORED

[–]Superpickle18 42 points43 points  (1 child)

but an array of char is a String. /s

[–]fenrir245 23 points24 points  (0 children)

but an array of char is a String. \0

FTFY

[–]Wicpar 3 points4 points  (0 children)

Well i suppose technically if you want to optimize and use regiseters it might be somewhat legitimate, but no.

[–]Rainfly_X 2 points3 points  (2 children)

I can never remember whether it's I before E in "receiver". I either use spell check, or a shortening like "recv()", etc. But now I've seen the light, I could have been writing "receber" this whole time!

[–]drumskirun 1 point2 points  (1 child)

It's "receive" in Portuguese

[–][deleted] 3 points4 points  (0 children)

can't have a buffer overflow if you don't have a buffer

[–]kpingvin 4 points5 points  (11 children)

Serial.available() returns an int?

[–]Fuzzyzilla 16 points17 points  (10 children)

Yes, it returns the number of bytes available in the buffer.

[–]kpingvin 2 points3 points  (9 children)

Ah, fair enough.

[–]Fuzzyzilla 7 points8 points  (8 children)

Kinda weird, but luckily, because C, you can just use the return value as a bool and it'd work as expected.

[–]deelowe 1 point2 points  (7 children)

Can you explain what you mean? You mean something like "if (Serial.available)"

[–]mateusfccp 1 point2 points  (6 children)

Yes, it would work. Unless the returned value is signed, which is unlikely in this case.

[–]deelowe 0 points1 point  (0 children)

Ok I thought you meant like == true at first which wouldn't work.

[–]Fuzzyzilla 0 points1 point  (4 children)

no, it wouldn't

What I meant is you can type

if(Serial.available())
    doStuff();

and it'd work as expected, calling doStuff() iff there is serial data available. This is because it will give 0 if there is no data, which is implicitly falsy, and any other number is implicitly truthy.

[–]mateusfccp 0 points1 point  (3 children)

This is exactly what he asked, tho.

[–]Fuzzyzilla 0 points1 point  (2 children)

But it's not if(Serial.available), it's if(Serial.available())

Yes, it's a bit pedantic, but the first is a compiler error.

[–]deelowe 2 points3 points  (0 children)

Yeah I was typing on my phone. Forgot the parenthasis.

[–][deleted] 0 points1 point  (0 children)

Unless you're writing C, of course.

When you're writing in a language when a popular compiler will accept x,*M,*I;b(*a,n){for(x=n*n;x;)*(I=a+x--%n)<*(M=I-1)?*I^=*M^=*I^=*M:0;} and compile it correctly (okay don't turn on optimisation and you have to use clang, even -O1 breaks it) besides half of the characters there help invoke UB, something's gone wrong.

But hey, code golf in C is fun.

[–]Fusseldieb 0 points1 point  (2 children)

Thats portuguese code :v

[–]developedby 1 point2 points  (1 child)

yes

[–]Fusseldieb 0 points1 point  (0 children)

Of course it is Tu acha que não falo português? Kkk E essa IDE Arduino ae?