News for hackers. Stuff that matters.
Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Saturday March 30, 2013 @06:57AM (#5465038)
I'd actually blame it on idiots writing C myself.

You can't really have a totally safe systems programming language (correct me if I'm wrong here).

Re:Of Lisp Macros and Washing Machines (2011) by b6 on Saturday March 30, 2013 @07:29AM (#5465094)
> idiots

This is a million times wrong. It's not about humans being smart or stupid, it's about humans being bad at being careful millions and millions of times without error.

The answer isn't to tell them to be more careful. They can be more careful, but they are human, so they will still make mistakes. The answer is for them to use higher level languages that eliminate whole classes of errors.

Re:Of Lisp Macros and Washing Machines (2011) by S4M on Saturday March 30, 2013 @08:52AM (#5465250)
I think the GP is calling them "idiots" not because they use C in a dumb way, but because they keep using a language that is error-prone.
Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Saturday March 30, 2013 @02:30PM (#5466236)
You are wrong: I'm calling them idiots because they use C in a dumb way and don't stick it through valgrind etc.
Re:Of Lisp Macros and Washing Machines (2011) by mikeash on Saturday March 30, 2013 @09:40AM (#5465363)
"You can't really have a totally safe systems programming language (correct me if I'm wrong here)."

He doesn't seem to think that others would be better.

Re:Of Lisp Macros and Washing Machines (2011) by jdboyd on Saturday March 30, 2013 @07:42PM (#5467072)
A type system that isn't 100% safe can still be a massive improvement over C or even C++.
Re:Of Lisp Macros and Washing Machines (2011) by mikeash on Saturday March 30, 2013 @10:13PM (#5467417)
Sure, but from the overall tone of the comment, it seems clear that he's blaming the "idiots", not the "C", because his only statement about alternatives to C is that they'll have similar problems.
Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Monday April 01, 2013 @05:13AM (#5472116)
You are correct :)
Re:Of Lisp Macros and Washing Machines (2011) by yoklov on Saturday March 30, 2013 @08:51AM (#5465247)
You can't really have a totally safe systems programming language (correct me if I'm wrong here).

It depends what you mean by totally safe, but Cyclone (http://cyclone.thelanguage.org/) is a type and memory safe dialect of C. It works by adding additional information to the type of every pointer, e.g. if it can be NULL, if it's NUL terminated, if you know the length, the scope it was allocated in, the location on the stack it's from, etc...

This all happens at compile time, and it runs about the same speed as C, so I think it qualifies.

From what I've read, this has had more of an influence on programming language designers/implementers (rust, possibly c++11, probably more), than on anybody else, though.

edit: NULL -> NUL

Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Saturday March 30, 2013 @02:32PM (#5466240)
This sort of stuff works until you need to poke some registers in a graphics card or the language's MM has a bug or you need C's dynamic nature.
Re:Of Lisp Macros and Washing Machines (2011) by pjmlp on Saturday March 30, 2013 @06:37PM (#5466907)
What dynamic nature does C have that every other systems programming language in the world lacks?
Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Sunday March 31, 2013 @12:54PM (#5469226)
dynamic loading, arbitrary casts (it is what I tell you it is) etc etc.
Re:Of Lisp Macros and Washing Machines (2011) by pjmlp on Sunday March 31, 2013 @02:20PM (#5469571)
I can do that in Ada, Turbo Pascal, Delphi, Modula-2, Oberon, Oberon-2, Component Pascal, Active Oberon, Modula-3, Cyclon and many others, what is so special about C?
Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Sunday March 31, 2013 @05:30PM (#5470255)
It's not Ada or Pascal-like :)
Re:Of Lisp Macros and Washing Machines (2011) by pjmlp on Monday April 01, 2013 @01:52AM (#5471684)
You mean easy to write security exploits?
Re:Of Lisp Macros and Washing Machines (2011) by betterunix on Saturday March 30, 2013 @10:53AM (#5465554)
Sure, but there are two major classes of bugs we need to worry about these days:

* "Mechanical" issues like dangling pointers, buffer overflows, integer overflows, etc.

* Design errors

Unfortunately, C makes the first class exceedingly easy to create, and makes the second class exceedingly hard to prevent.

Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Saturday March 30, 2013 @02:26PM (#5466223)
C also makes memory access and device driver code very easy. The mechanical issues are a side effect of that.

As for design errors, they are hard to prevent anywhere.

Re:Of Lisp Macros and Washing Machines (2011) by betterunix on Saturday March 30, 2013 @03:02PM (#5466309)
"C also makes memory access and device driver code very easy. The mechanical issues are a side effect of that."

I have two problems with this reasoning. First, C is being used for more than writing device drivers; most programs written in C are not device drivers. Second, and more important, is that low-level memory access and the sort of bit-twiddling you are talking about can be done in Common Lisp, and I doubt that you would be shocked to know that the operating systems written in Lisp for Lisp Machines had device drivers. It is possible for any high-level language to expose a low-level pointer type, and doing so will not force programmers to use such low-level constructs in higher-level code.

"As for design errors, they are hard to prevent anywhere."

While true, they are much harder to prevent in C because of the complicated semantics, the enormous amount of undefined behavior, and the plethora of edge cases one must account for. When something as simple as incrementing a counter forces you to deal with edge cases and potentially undefined behavior, it is pretty hard to verify that a C program actually implements a design, even when that design was formally specified and checked. The lack of high-level features and constructs worsens this situation by inflating the number of lines of code in an implementation.

Re:Of Lisp Macros and Washing Machines (2011) by pjmlp on Monday April 01, 2013 @01:53AM (#5471690)
> C also makes memory access and device driver code very easy.

Like any systems programming language, nothing special about C.

Re:Of Lisp Macros and Washing Machines (2011) by coldtea on Saturday March 30, 2013 @07:37AM (#5465106)
>I'd actually blame it on idiots writing C myself.

Couldn't be more wrong though.

The people that wrote UNIX and its whole C userland were far from idiots -- more like geniuses. People like K&R, Bill Joy, etc (and until the 90s they weren't even that many, mainly people from elite computing schools and research centers).

It's not like some moron high school dropout, "Learn C in 24 hours"-reading people wrote UNIX and the common server stuff we use (Bind, Sendmail, etc).

Re:Of Lisp Macros and Washing Machines (2011) by miloshadzic on Saturday March 30, 2013 @09:14AM (#5465295)
I like that Unix, Smalltalk and Lisp have a similar idea of smaller things getting composed. They are all different but I wouldn't judge the ideas based on what we have today.
Re:Of Lisp Macros and Washing Machines (2011) by hp50g on Saturday March 30, 2013 @02:37PM (#5466250)
Agree here. My statement perhaps could be better written. I'm saying not that idiots write C, but idiots can write C badly and often do. Much as anyone can cross a road, idiots can do it and reliably get squashed every time.

I disagree about sendmail though - that was a stinking turd and I have been ever grateful since postfix arrived on the scene :)

Re:Of Lisp Macros and Washing Machines (2011) by pjmlp on Saturday March 30, 2013 @06:38PM (#5466911)
Problem is the majority of developers in the world are not elite, thus the security pain we have to endure nowadays.
Re:Of Lisp Macros and Washing Machines (2011) by alberich on Saturday March 30, 2013 @07:43AM (#5465117)
Totally safe I doubt there is. It seems there are safer languages (and OS designs).

However, there are pratical considerations (e.g performance impact and stuff like that) which make such approaches unattractive for production use.

Re:Of Lisp Macros and Washing Machines (2011) by pjmlp on Saturday March 30, 2013 @06:35PM (#5466902)
This is more FUD than anything else.

Languages like Ada and Modula-2, just to cite two examples from many, allow for safer coding while having similar performance.

The people that cite the performance impact of bound checking and other features, usually tend to ignore that they can be disabled if required for performance reasons, because it suits their arguments that no other language can achieve C like performance.

Or they like to forget that the industry has invested more in optimizing compilers for C than for other languages. So they end up discussing languages without regard for the implementations.

Re:Of Lisp Macros and Washing Machines (2011) by alberich on Sunday March 31, 2013 @10:11AM (#5468654)
I was referring to operating systems architectures, not only programming languages.

While I believe you could write an operating system in Haskell, for instance, I don't know nothing about it's performance. However, microkernels, even though are safer, have some performance drawbacks.

Re:Of Lisp Macros and Washing Machines (2011) by pjmlp on Sunday March 31, 2013 @03:05PM (#5469757)
And yet, one of the best real time operating systems (QNX) is micro-kernel based.