Re: Which book is better for a begainer to study C language?
- From: pdpi <pdpinheiro@xxxxxxxxx>
- Date: Thu, 21 May 2009 09:18:39 -0700 (PDT)
On May 14, 11:27 pm, Ben Bacarisse <ben.use...@xxxxxxxxx> wrote:
"JosephKK"<quiettechb...@xxxxxxxxx> writes:
On Wed, 06 May 2009 15:58:15 +0200, Richard <rgrd...@xxxxxxxxx> wrote:
Chris Dollin <chris.dol...@xxxxxx> writes:
It means it can compute anything computable (by a Turing machine or one
of its many equivalents). What it means in practice is more like "doesn't
have crippling theoretical restrictions"; if I recall correctly, matching
regular expressions doesn't require TC, so REs alone don't make a powerful
enough programming language.
I would not be too sure of that. Backus-Naur Form is Turing complete
is it not?
No. BNF describes context free grammars which define the languages
recognised by push-down automata. This is a larger set than the
regular languages recognised by REs, but is strictly smaller than the
set of languages recognised by Turing machines.
And no possible RE system is not representable in BNF.
I dont even understand that. With any language I have used before I
could write my own RE parser if necessary.
It is an attribute of the language, not one of the parser. I have yet
to meet a language (expressed in a LR script) that i could not write a
LALR(1) parser for. This includes C, C++, BASIC, ALGOL, FORTRAN,
COBOL, Ada, Pascal, FORTH, APL and every assembler i have seen. I
have heard reports that early FORTRAN and COBOL versions were not
Turing Complete, I do not know myself.
Tiny bit of on-topicness: neither C (nor C++) are LALR(1). They can
be fudged with a bit of fiddling so you can squeeze them though
automatic systems like YACC, but they are not technically LALR(1).
Its been a long time, but I suspect FORTRAN is even worse.
--
Ben.
And we've now gone from "what the hell is Turing completeness" to LALR
(1) grammars without actually explaining what a Turing Machine is.
In the simplest terms, a Turing Machine is something with arbitrarily
large amounts of memory (if you can't hit the upper bound, it's large
enough), that can do additions and can branch execution conditionally.
Essentially, if it can do increments, GOTOs, and IFs, it's a Turing
Machine. (This is _not_ an exact definition, but should be "good
enough").
A Turing Complete language is one in which you can express (and
compute) anything that you could do with a Turing Machine. Most modern
programming languages aim at simulating a Turing Machine with loads of
syntactic sugar. As in, a while loop is essentially a formalization of
"if something, goto top of loop", a for loop is a very specific case
of a while loop, etc etc.
Church's Lambda calculus is based on recursive functions, and the idea
that mostly "anything" can be computed as the composition of recursive
functions. For example, you can do x + y as: "if x = 0, return y, else
return (--x) + (++y)", and then build x * y on top as "if x = 1,
return y, else return (((--x) * y) + y)". The Church-Turing thesis
later proved the equivalence between Turing Machines and Lambda
Calculus. That is, what can be computed with one can be computed with
the other. LisP is basically an implementation of sugared-up Lambda
Calculus.
Also, all useful programming language are Turing Complete (some, or
perhaps most, markup languages, like HTML, CSS, etc etc are not).
Turing Completeness, when referring to actual languages you're liable
to use, is only useful when it's actually surprising: POV-Ray's SDL is
Turing Complete, whereas VRML is not. TeX is Turing Complete, versus
HTML, which is not.
Directly on topic, in my mind the question of whether C is a newbie-
friendly language can be answered thus: "it's a brilliant language if
you want to learn how computers work, it's crap if you want to learn
how to program". If you want to know about computers, dealing with
pointers, having absolutely no safety nets around buffer overflows,
etc. are all features. If you want to learn how to program, you
probably want a language that lets you worry about the logic rather
than fussing over the computer's innards (at least just yet).
Personally, I'd suggest Python (yes, indenting delineates blocks, but
you'd likely indent the code like that anyway), some academics would
lead you towards Scheme (which is a LisP dialect).
.
- Follow-Ups:
- Re: Which book is better for a begainer to study C language?
- From: Ben Bacarisse
- Re: Which book is better for a begainer to study C language?
- References:
- Which book is better for a begainer to study C language?
- From: Dingjiu
- Re: Which book is better for a begainer to study C language?
- From: Slow_Mind
- Re: Which book is better for a begainer to study C language?
- From: Ian Collins
- Re: Which book is better for a begainer to study C language?
- From: Slow_Mind
- Re: Which book is better for a begainer to study C language?
- From: Richard
- Re: Which book is better for a begainer to study C language?
- From: Chris Dollin
- Re: Which book is better for a begainer to study C language?
- From: Richard
- Re: Which book is better for a begainer to study C language?
- From: JosephKK
- Re: Which book is better for a begainer to study C language?
- From: Ben Bacarisse
- Which book is better for a begainer to study C language?
- Prev by Date: Re: 0/1 Knapsack problem, what am I doing wrong
- Next by Date: Re: Create a Copy of Files
- Previous by thread: Re: Which book is better for a begainer to study C language?
- Next by thread: Re: Which book is better for a begainer to study C language?
- Index(es):
Relevant Pages
|