Live data from Hacker News

So you think you know C? (2016)

wordsandbuttons.online

281–290 of 344 posts

Re: So you think you know C? (2016)

#281
post #245

Earlier quoted context omitted.

map/filter/reduce is simpler, but it takes some getting used to. Loops have worn a deep rut in my brain.

As someone who was introduced to programming via map/filter/reduce, for loops are incredibly more complicated. I don’t think I’ve ever written one correctly on first try.

Unfortunately, loops still seem to be the easiest way to iterate over two collections simultaneously.

Re: So you think you know C? (2016)

#282
I posted this in the embedded C-shop I work, under the comment that exactly in this place all should pass this test. Sadly only 1 in 5 passed the test (yours truly). Admittedly, this test was binary: either you pass or fail all of the questions (which is also sort of a give-away).

In the end this test proved to be a really valuable, because the "I don't know" drove the point home, specially for smart folks who don't like to answer any test, ever, with "I don't know".

Re: So you think you know C? (2016)

#283
At least for the third question (char a = ' ' * 13;) XCode warns "Implicit conversion from 'int' to 'char' changes value from 416 to -96".

And for the fifth (return i++ + ++i;) it warns "Multiple unsequenced modifications to 'i'".

I would not skip those warnings.

Re: So you think you know C? (2016)

#287
post #286

Could someone explain why in question 5 i = 0; return i++ + ++i; Could produce different results?

There's explanations at the bottom after you click the button.

I read it but I still don’t understand. Isn’t it 0 + 2 vs 1 + 1? How would it produce something other than 2?

Re: So you think you know C? (2016)

#288
post #226

Earlier quoted context omitted.

Apple says the future is C++ and Swift. Microsoft says the future is a mix of constrained C++ (Core Guidelines), Rust and AOT C#. Google says the future is C++ and Java (as of Treble) on Android, with Go, C++ and Rust on ChromeOS and Fuchsia. ARM says C++ on mbed. GenodeOS says C++ and Ada. Newton, Symbian, Bada and BeOS used C++. C is married with UNIX, they were born to each other, other OSes have long followed oth…

Minor point, but isn't Android moving to Kotlin? I don't think they see Java being a sustainable choice for the long term.

Yes they are, but in what concerns Treble and platform libraries, they plan to keep their Java 8 variant around.

Apparently they are also adding support for desugaring Java 10 language features (yep 10 not 12) that don't rely on new JVM bytecodes (as per Google IO talk about state of Android tooling).

At least for now.

Re: So you think you know C? (2016)

#289

My score is 3/5. One immediate redflag I have noticed is using "int", "char", "short" as if they have a definite size. They don't. C standard only guarantees a minimum size. For example, many PDPs are 36-bit. Assuming the size of a variable is a common practice nowadays, but at least one should use uint8_t, int32_t, etc. from stdint.h. But I was still tricked, it should be obvious in hindsight, 12 years of schooling…

4/5 here. In fact after the third question provided "I don't know" as an answer I started to suspect something was up — especially since the author said only one answer was the right one ... why even provide "I don't know" then, I wondered?

I knew "int" was sort of platform-dependent (was 16-bits generally when I was learning to code, later 32-bit became more typical) — so combined with that niggle and all the "I don't knows", I (correctly) reevaluated by first couple of answers.

Still, didn't realize the last one was compiler-dependent.

Re: So you think you know C? (2016)

#290
post #286

Earlier quoted context omitted.

There's explanations at the bottom after you click the button.

I read it but I still don’t understand. Isn’t it 0 + 2 vs 1 + 1? How would it produce something other than 2?

How do you get 0 + 2?

I could imagine the post-increment happening after the sum: giving 0 + 1…

Post reply on HN