Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Programming "only" in an environment of C and it's friends - Being a toolsmith

Reply
Thread Tools

Programming "only" in an environment of C and it's friends - Being a toolsmith

 
 
Kaz Kylheku
Guest
Posts: n/a
 
      05-27-2012
On 2012-05-27, John Reye <(E-Mail Removed)> wrote:
> Example: Could Unix (or Linux) system administration be done without
> Perl and shell-scripting, but using only C. What consequences would
> that have?


The consequences that a loon will be replaced by a normal thinking sysadmin.
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      05-28-2012
On 05/28/12 07:32 AM, John Reye wrote:
> Hi,
>
> in writing computer code, the language C has obvious advantages over
> other languages ("fads"):


Some of those "fads" have grey hair and grandchildren.

> It's close to hardware. It's perfect for operating system interfacing.
>
> You can do anything with it.
> Of course this often means creating tools and "programs that write
> programs".
>
> A good example is lex or equivalents for lexical analysis, etc.
>
> See http://foldoc.org/toolsmith
>
>
> I'd rather write C code than Perl-scripts or Python.


Scripting languages often have existing libraries that can save you a
lot of time.

> But on the other hand I do believe C does require a lot of work, for
> which other languages such as Python have already got a lot of built-
> in facilities.
> I guess that C and tools and a desire for "power" will automatically
> lead to C++. C has a notorious lack of GUI libraries (or can you tell
> me a good equivalent to something like FLTK and qt?)


GTK and the Gnome desktop is written in C.

> My question:
> Is it feasible to do everything in C?


Yes, but...

> Example: Could Unix (or Linux) system administration be done without
> Perl and shell-scripting, but using only C. What consequences would
> that have?


A lot of wasted time. Not all Unix commands have a public interface, so
it is often easier to invoke them from a script (yes I know you could
use system(), but why bother?). There are also commands that are
written in other languages (like Solaris' package management which is
written in Python).

> What languages do you use, and how do you decide what to use?


Bash, PHP and Python for small command line tools (especially text
processing) or anything platform neutral and mainly C++ for heavyweight
applications. JavaScript for GUIs.

> And how does C fit into the picture?


Places without C++ runtime support, such as kernel modules.

--
Ian Collins
 
Reply With Quote
 
 
 
 
nick_keighley_nospam@hotmail.com
Guest
Posts: n/a
 
      05-28-2012
On Sunday, May 27, 2012 8:32:50 PM UTC+1, John Reye wrote:

> in writing computer code, the language C has obvious advantages over
> other languages ("fads"):
> It's close to hardware.


this is a double edged sword. When you don't need to be close to the machine its a disadvantage. you don't spend your time in higher level languages worrying about memory leaks and pointer arithmatic errors. You also know howbig an array is.

> It's perfect for operating system interfacing.


I think taht's a bit of a coincidence

> You can do anything with it.


amazing. It's Turing Complete. This is trivially true of pretty much all programming languages. The question is not "can it do anything?" but "can it do something easily?". The reason for the existence of multiple languages is the answer in "no", for *all* languages

> Of course this often means creating tools and "programs that write
> programs".


see Greespans 10th Law

> A good example is lex or equivalents for lexical analysis, etc.
>
> See http://foldoc.org/toolsmith
>
> I'd rather write C code than Perl-scripts or Python.


Using C to do what Perl does is frankly a pain in the ass. Python's collection of tools ***shipped with it*** make it a nice environment to knock up tools in. I also quite like Python as a language. Perl's a bit of a mess.

> But on the other hand I do believe C does require a lot of work, for
> which other languages such as Python have already got a lot of built-
> in facilities.


quite. The Turing Tarpit and all that.

> I guess that C and tools and a desire for "power" will automatically
> lead to C++.


I don't see why. C++ is equally impoverished for built in tools.

> C has a notorious lack of GUI libraries (or can you tell
> me a good equivalent to something like FLTK and qt?)
>
> My question:
> Is it feasible to do everything in C?


is it sane?

> Example: Could Unix (or Linux) system administration be done without
> Perl and shell-scripting, but using only C.


the lack of an interpreter would be a bit of a pain. There are many conveniences in shell languages that have no C equivalent. Though their syntax is often mind-boggeling crazy and inconsistent.

Quick: I want to read a data file match certain patterns and output a reformtted version. That's about 10 lines of Perl (and I'm a crap Perl programmer). Basically I've finished the job in less time tahn it would take me to choose which regexp library to use. Let alone download it, read the documentation find out it doesn't do anchored matches find another package...

> What consequences would that have?


piles of ugly unnecessary C? SysAdmins fighting compilers?

> What languages do you use,


Perl, Python, C, C++. Scheme

> and how do you decide what to use?


Perl as a super-Awk. Python for quick tools, C or C++ for applications. Scheme mostly playing at the moment.

> And how does C fit into the picture?

 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      05-28-2012
On 05/28/12 08:51 AM, jacob navia wrote:
> Le 27/05/12 21:32, John Reye a crit :
>>
>> What languages do you use, and how do you decide what to use?
>> And how does C fit into the picture?
>> Thanks.

>
> Look, I use C for most of my programming. Fatter languages will give you
> this or that, but they have huge problems, that C avoids.


What "huge problems" would say Python or PHP have for programming
utilities? I didn't mention Perl because all C programmers know it is a
write only language.

> What is nice in C is that there isn't a "preconceived" ata type or
> way of doing things.


That can be a bit of a double edged sword, can't it? Yes you have the
freedom, but a programmer unfamiliar with code has to learn both the
code and its idioms. One of Java's strengths was probably its homogeneity.

> C++ has (besides other big drawbacks) OO as a fundamental paradigm.


OO amongst many. The only real drawback for libraries is linkage, but C
interoperability comes to the rescue there. For self contained
applications there aren't any real drawbacks. If you are familiar with
C++, you may as well use it.

> Lisp has lists, Fortran has numeric applications in view, C# and java
> compete for the business market, (both being OO centric).
>
> C is nothing. That's the incredible freedom that it provides. It is
> up to you to use it or misuse it.


It isn't nothing, it is at the heart of just about every operating
system. Even those apparently written in another language will sill
have C or assembly at the driver level.

C still dominates in drivers and kernels.

> This is a C group. You will find here people that will be pressed to
> tell you that C is not the best, that C++ is better (like Mr Richter
> above, for example). Who cares?
>
> C is a good language, with some problems that I have tried to
> solve in my system.


Problems which have been addressed portably in other languages...

> But this is also a question of personal philosophy. I like above all
> simplicity, lack of unnecessary features, minimal surface but greatest
> power. There was a book some centuries ago that put that in a single
> sentence:
>
> Small is beautiful.


Small language or small code? Not a lot can beat the the concise nature
of a few lines of Perl or Awk.

--
Ian Collins
 
Reply With Quote
 
BartC
Guest
Posts: n/a
 
      05-28-2012
"David T. Ashley" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Sun, 27 May 2012 12:32:50 -0700 (PDT), John Reye



> Interpreted scripting languages (bash, Python, PHP, Tcl, Perl) are
> very convenient.


But also much slower, otherwise no-one would be using languages such as C or
especially C++; they are hard work!

> There is typically no compile phase, and the error
> trapping is excellent so you can know immediately where the problem in
> the source code is.


That's an implementation issue. There's no reason why a development
environment for C can't also be made fast with a transparent compilation
phase and with additional error checking.

Especially as typical scripts are small, and so would the corresponding C
program, once the necessary support libraries have been created and put into
a separate (not statically linked) library.

Interpretation can also be used, unless the task makes that impractical. But
if a scripting language would be feasible, then perhaps so would an
interpreted C (bearing in mind the scripting language would have a core
written in a low-level language that is not interpreted).

> It wouldn't be convenient to write everything in C.
>
> It would, however, be possible.


As soon as you write a C utility that accepts a series of instructions from
a command line, then you've almost created a new language anyway.

--
Bartc

 
Reply With Quote
 
Malcolm McLean
Guest
Posts: n/a
 
      05-28-2012
בתאריך יום ש*י,28 במאי 2012 10:16:53 UTC+1, מאת Bart:
>
> Interpretation can also be used, unless the task makes that impractical. But
> if a scripting language would be feasible, then perhaps so would an
> interpreted C (bearing in mind the scripting language would have a core
> written in a low-level language that is not interpreted).
>

tcc (tiny C compiler) has an intepreted mode. If you just give your C script a shebang (#! /usr/bin/tcc in the first line) it can run as a Linux / Unix shell script.

However it hasn't caught on. The problem is probably the libraries. Just using stdlib, you have to write too much logic to do simple things like checkfilename extensions. Use soemthing other than stdlib and you can't be sureyour script will work everywhere.




 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      05-28-2012
On 05/28/12 09:16 PM, BartC wrote:
> "David T. Ashley"<(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> On Sun, 27 May 2012 12:32:50 -0700 (PDT), John Reye

>
>
>> Interpreted scripting languages (bash, Python, PHP, Tcl, Perl) are
>> very convenient.

>
> But also much slower, otherwise no-one would be using languages such as C or
> especially C++; they are hard work!


Not all applications require speed. A significant number of OS
utilities spend most of their time waiting on I/O. The Solaris package
management utilities (written in Python) are one large example. The
kernel statistics display utility (written in Perl) is another.

>> There is typically no compile phase, and the error
>> trapping is excellent so you can know immediately where the problem in
>> the source code is.

>
> That's an implementation issue. There's no reason why a development
> environment for C can't also be made fast with a transparent compilation
> phase and with additional error checking.
>
> Especially as typical scripts are small, and so would the corresponding C
> program, once the necessary support libraries have been created and put into
> a separate (not statically linked) library.


As an interpreted language, C looses its main advantage - speed.

>> It wouldn't be convenient to write everything in C.
>>
>> It would, however, be possible.

>
> As soon as you write a C utility that accepts a series of instructions from
> a command line, then you've almost created a new language anyway.


Or the interpreter for one.

--
Ian Collins
 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      05-28-2012
jacob navia <(E-Mail Removed)> writes:
>It took the systems engineers of Sun Corp SIX MONTHS to find a memory
>leak in their Java system. The problem is that the GC will not
>forget that if you have a single bad reference to an object it will NOT
>release it, making for a slowly accumulating memory leak.
>If you think that horrible bugs happen only in C THINK AGAIN.


It is well possible that this GC /was/ written in C.

After all, you are not talking about Code written /using/ Java,
but code written to /implement/ Java.

Usually, it is much more easy to write code without memory
leaks in a GCd language.

 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      05-28-2012
Ian Collins <(E-Mail Removed)> writes:
>C still dominates in drivers and kernels.


still dominates in drivers and kernels when it has the
/overall/ rank as number 1 in several different evaluations,
like for example

http://www.tiobe.com/content/paperinfo/tpci/index.html

, with +1.18% since may 2011?

Some quotes:

=head2 What language is Parrot written in?

C.

=head2 For the love of God, man, why?!?!?!?

Because it's the best we've got.

http://www.davidcole.net/msie/notes/...4/docs/faq.pod

Here's the thing: C is everywhere. Recently Tim Bray
made basically the same point; all the major operating
systems, all the high-level language runtimes, all the
databases, and all major productivity applications are
written in C.

http://girtby.net/archives/2008/08/23/in-defence-of-c/

OTOH,

perl -p -i -e 's/a/b/g' *

will replace all occurrences of the regular expression a
with the pattern b in all of the files in the current
directory. Now show me that in C! There is not even a
portable way to read a directory in C.

When one does some AI-style programming with a graph where
multiple objects link to each other in a very dynamic way,
memory management can become hard, so this is also easier to
code in GC languages.

Expressions in functional languages often involve transfer of
ownership or sharing of ownership of run-time allocated objects
and can't really be written in C. Apart from some simple cases,
one cannot write in a pure functional style in C.

One can emulate OOP in C, but it sometimes needs some more
complicated wording. The need for manual memory management can
become distracting.

So, C is a multi-paradigm language only to some extend.

 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      05-28-2012
Malcolm McLean <(E-Mail Removed)> writes:
>The problem is probably the libraries.


See also

http://www.purl.org/stefan_ram/pub/c..._extensions_en

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Friends Don’t Let Friends Do IE6 Lawrence D'Oliveiro NZ Computing 33 02-11-2010 10:14 AM
hello friends...wanna make friends visit nicki C Programming 0 10-13-2008 11:51 AM
MEET UR SCHOOL & COLLEGE FRIENDS. UR FRIENDS ARE WAITING FOR U.. sai.sri206@gmail.com C++ 0 10-28-2007 08:43 PM
Friends don't let friends drink and fly through space =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 6 07-29-2007 03:52 AM
member functions as friends - friends of each other? bipod.rafique@gmail.com C++ 2 07-16-2005 10:55 AM



Advertisments