News for hackers. Stuff that matters.
Re:The descent to C by csmithuk on Tuesday January 28, 2014 @03:46AM (#7136078)
In some cases we don't want safety. C can be safe or unsafe depending on how you approach a problem.
Re:The descent to C by userbinator on Tuesday January 28, 2014 @07:29AM (#7136662)
In some cases, we want freedom... and that's something that has been neglected a bit too much with new programming languages IMHO. Safety/security feels like it's the latest of the dumbing-down "let's treat programmers like idiots" fad.
Re:The descent to C by scott_s on Tuesday January 28, 2014 @10:08AM (#7137434)
I think the approach of languages like Rust, which enforce strict safety by default, but allow "unsafe" regions of code, is the correct way to go.

See http://static.rust-lang.org/doc/master/rust.html#unsafety

Re:The descent to C by Allan_Smithee on Wednesday January 29, 2014 @02:14AM (#7142466)
Or if you have any sense of history, languages like Modula-2/2+/3. (And undoubtedly a few (dozen?) others I'm unaware of.)

Nothing new in software development. All the "new" shinies are decades (!) old.

Re:The descent to C by pjmlp on Wednesday January 29, 2014 @02:30AM (#7142508)
Somehow young developers seem to think only C and C++ offer native features.

I wonder how we got sidetracked like that.

Re:The descent to C by Allan_Smithee on Tuesday January 28, 2014 @09:51AM (#7137331)
I submit as evidence 99.44% of software that has been released that programmers are, in fact, idiots.
Re:The descent to C by deletes on Tuesday January 28, 2014 @06:06AM (#7136418)
Can you give an example where you don't want safety and you aren't trying to hack? //curious
Re:The descent to C by csmithuk on Tuesday January 28, 2014 @07:10AM (#7136602)
Few of the top of my head:

1. Performance reasons. For example: zero copy data structures, mutable data structures, controlling data locality.

2. Direct memory mapped hardware access. For example: device drivers, kernel, embedded systems, microcontrollers.

3. Bitwise and machine specific conversions. For example: endianess conversions.

4. Structure type coercion. For example: object systems, tagged data structures etc.

Re:The descent to C by fanf2 on Tuesday January 28, 2014 @03:49PM (#7139606)
If you are doing unsafe or machine-dependent endurance conversion code, you are almost certainly doing it wrong. http://commandcenter.blogspot.co.uk/2012/04/byte-order-falla...
Re:The descent to C by deletes on Tuesday January 28, 2014 @05:02PM (#7140079)
Thank you for that link.

#leaves to check some old code

.

.

.

#comes back

Apparently my younger self knew what he was doing. ( The conversion is done correctly :shocked: )

Re:The descent to C by mcguire on Wednesday January 29, 2014 @11:38AM (#7144930)
Sometimes I wonder about Rob.

"In fact, C may be part of the problem: in C it's easy to make byte order look like an issue. If instead you try to write byte-order-dependent code in a type-safe language, you'll find it's very hard. In a sense, byte order only bites you when you cheat."

Re:The descent to C by csmithuk on Wednesday January 29, 2014 @04:55AM (#7142989)
That's a great article - thanks for posting.
Re:The descent to C by fanf2 on Wednesday January 29, 2014 @06:05PM (#7147779)
"endurance"?! Damn you, autocorrect.
Re:The descent to C by pjmlp on Tuesday January 28, 2014 @08:18AM (#7136842)
All of those examples are possible in safe systems programming languages like Modula-2 and Ada, with the difference that only the tiny spot where it matters is marked explicitly unsafe.

Whereas in C there is no way to distinguish between unsafe and safe code.

Re:The descent to C by numeromancer on Tuesday January 28, 2014 @10:08AM (#7137432)
2. Direct memory mapped hardware access. For example: device drivers, kernel, embedded systems, microcontrollers.

Of course doing this usually means your code isn't portable, sometimes not even to other versions of the same compiler. I often wish C had a defined order for bitfields, for example.

One of the things I do to help debug & test embedded code is to factor out code which isn't dependent on the hardware platform (eg communication protocols) into a library, and compile it for, and write test programs to test them on, the host. So even embedded code is often best written to be as portable as possible.

Re:The descent to C by mcguire on Wednesday January 29, 2014 @11:47AM (#7144989)
Oddly enough, I've spent the last week playing around with type-agnostic garbage collection.