Subject: Re: Your "when C is the best tool" article

From: Shlomi Fish <[email-masked]>
Date: Mon, 9 Apr 2007 14:52:01 +0300

Hi Aur! (and all)

On Monday 09 April 2007, SonOfLilit wrote:
> Hi Shlomi,
>
> This is Aur (from Israel.rb).
>

Israel.rb == Ruby-IL.

> I've read your "When C is the best tool for the job" article.
>

Just for the record it is here:

http://www.shlomifish.org/philosophy/computers/when-c-is-best/

> My impression is that after promising to deal with the list of claims:
> (1)    * "Java and/or .NET are better than C in every way.".
> (2)    * "Perl/Python/PHP/Ruby/Tcl are better than C."
> (3)    * "LISP is better than C".
> (4)    * "If you need speed, use O'Caml or Haskell - don't bother with C."
> (5)    * "C is for kernels."
> , you only deal with (1), (2), (5).

Actually, these and many similar claims are encountered times and again on the 
Net. I tried to address the common theme.

>
> By giving an example of data crunching code that benefits from speed,
> you rule out Java and scripting languages.

I gave up Freecell Solver as an example, but it may not have been the best 
example. I also regret the fact that:

<<<<<<<<
I explained why the Freecell Solver code will be slower in Java, but not why 
it will also *feel wrong* in Java.

( http://www.shlomifish.org/philosophy/computers/when-c-is-best/ )

I should also note that OSNews have done me a dis-service by linking to the 
raw HTML page of the article itself instead of the cover page, because the 
cover page contains a vital correction and some links. I've learned from this 
mistake and now try to make sure my articles are part of the site flow.

>
> You don't rule out high level compiled languages. You say nothing at
> all about how would the code be written in them.
>
> Why not write this code in Haskell? OCaml? APL? Lisp?
>

Because:

1. They often tend to have implementation problems. C just works, and gcc 
works extremely well. Almost everything of importance nowadays is C or 
C-hosted. Compare it with ghc (the standard Haskell compiler) that requires a 
recent enough version of itself to compile.

2. They are often not as straightforward to program in than C. I know that 
when I tried to implement an algorithm using Haskell with an array map for 
Primes (a variation of Arthostenes' Sieve) it didn't work alright and did not 
scale, while in Perl and C - it ran perfectly fine. (I suppose O'Caml would 
be better.)

A hash also doesn't work quite right in Haskell. The two prominent projects I 
know that are written in Haskell: darcs and pugs are both very slow, and 
consume a lot of memory. Moreover, it takes a long time to compile pugs. You 
may think it doesn't matter, but people like things to compile quickly so 
they can develop faster, not be distracted to do something else for a long 
time, and get over with it quickly. This is also an argument against funky 
C++ code (like KDE's) using g++.

3. They tend to consume much more memory than C. I once thought O'Caml could 
be a good substitute for Forth for satellites until I discovered that some 
types of satellites can use only 128 KB of memory. 

4. They're still an abstraction and an abstraction is not always what you 
want. Sometimes you want to be close to the machine.

5. They tend to be much more buggy than gcc.

6. Some UNIXisms (or Win32isms) in them are harder to do in them, or otherwise 
fell non-native than in C.

7. If you want to implement a virtual machine, then C is your best bet. perl5, 
python, php, ruby, io, lua, clisp, most Scheme implementations, java, Mono 
and Microsoft .NET, etc. are all written in C. To say nothing of C compilers.

8. You obviously cannot use Lisp or O'Caml for kernel code. However, one 
should note that the amount of things you can do in user-land is growing. On 
Linux (and other systems) nowadays, file systems, USB drivers, protocol 
implementations, serial or parallel port controllers, etc. in high-level 
languages, including Perl and friends.

However, some things are still too-level, too real-time or need to be too-fast 
for that.

------------------

This is just off the top of my head.

I'm not saying you can't use higher-level languages than C for many domains 
where once C or before that Assembly dominated the market. However, some 
things still require C. 

Some criticisms of the article said that similar opinions were voiced when C 
started to become popular and people wrote things that said it won't 
completely displace Assembly. Well, while C has become more popular than 
Assembly, there's still a lot of code written in Assembly nowadays. So I 
believe higher-level languages won't completely displace C either.

Regards,

	Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish      [email-masked]
Homepage:        http://www.shlomifish.org/

If it's not in my E-mail it doesn't happen. And if my E-mail is saying
one thing, and everything else says something else - E-mail will conquer.
    -- An Israeli Linuxer

---

From: Shlomi Fish <[email-masked]>
Date: Mon, 9 Apr 2007 19:29:24 +0300

On Monday 09 April 2007, SonOfLilit wrote:
> So you basically say nothing more than "Haskell has a buggy
> implementation and the OSes I use are C so it's easier to communicate
> with them in C, no need for FFIs"?
>
>
> Aur
>

Hi Aur!

Please don't take it the wrong way, but you are annoying and you completely 
mis-interpret me. I gave many reasons, but you only focus on one. I have a 
policy against emails sent to me in private:

http://www.shlomifish.org/meta/FAQ/#should_i_email

Please IM me ( http://www.shlomifish.org/me/contact-me/ ) if you want to 
continue this discussion.

Regards,

	Shlomi Fish

> On 4/9/07, Shlomi Fish <[email-masked]> wrote:
> > Hi Aur! (and all)
> >
> > > (4)    * "If you need speed, use O'Caml or Haskell - don't bother with
> > > C." (5)    * "C is for kernels."
> > Actually, these and many similar claims are encountered times and again
> > on the Net. I tried to address the common theme.

---

From: Tal Kelrich <[email-masked]>
Date: Tue, 10 Apr 2007 15:01:41 +0300

On 09 Apr 2007 09:43:49 -0700

> Hi Aur!

Could you please keep your off list discussions off the list?

Regards,
	Tal Kelrich
	Practicing Discordian

-- 
Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F  CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
----
Your goose is cooked.
(Your current chick is burned up too!)
----

---

From: Tzahi Fadida <[email-masked]>
Date: Tue, 10 Apr 2007 21:00:37 +0300

> Could you please keep your off list discussions off the list?

It is not Off-Topic.
This is list is all about hacking and your average off-topic on any other 
linux/FOSS/computers mailing list.

-- 
Regards,
        Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS:  see at 
http://members.lycos.co.uk/my2nis/spamwarning.html

---

From: Tal Kelrich <[email-masked]>
Date: Wed, 11 Apr 2007 09:30:12 +0300

On 10 Apr 2007 12:45:36 -0700
Tzahi Fadida <[email-masked]> wrote:

> This is list is all about hacking and your average off-topic on any
> other linux/FOSS/computers mailing list.
> 
> 

I didn't say it was Off Topic (although, IMHO it was).
It was a private message to someone to continue the discussion off
list, such things are best sent directly. especially when the entire
discussion was off the list in the first place (only here in this case,
because someone felt the need to CC it to the list).

Regards,
	Tal Kelrich
	Practicing Discordian
	Episkopos of the Black Cat Cabal

DISCLAIMER:
Opinions represented within (or without), explicitly, implicitly, or
in some other way are my opinions, although you may share them, if you
like.

-- 
Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F  CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
----
Living in LA is like not having a date on Saturday night.
		-- Candice Bergen
----

---

From: Shlomi Fish <[email-masked]>
Date: Thu, 12 Apr 2007 09:25:58 +0300

Hi Tal! (and everybody)

> because someone felt the need to CC it to the list).

Just for the record, I'd like to note that:

1. Aur sent me a message privately.

2. Since I found the reply of value to a mailing list and since I hate a lot 
of handling such private email, I emailed him back asking for permission to 
CC my reply here.

3. He said it's OK.

4. I posted my reply.

5. He replied to me in private (by accident) with the top-posted, laconic and 
off-tangent reply, that only addressed one of my arguments. After talking 
with him on IM, I found out that he wanted to address each point one by one 
and started a discussion.

However, that was not the proper way to do it. 

-------------------

Now I have a policy against people writing me in private as replies to my 
mailing lists' posts. From now on, most of them will end up in my ham folder 
unreplied. (You have been warned).

If you have any comments regarding my original posting to this list (= the 
reply to Aur's mail) please do. Otherwise, let's stop this useless discussion 
about Netiquette.

Regards,

	Shlomi Fish