Is it helpful to know C? - TCL
This is a discussion on Is it helpful to know C? - TCL ; My C skills are much less than 133t at the moment--I've seldom had a
problem that Tcl couldn't solve. However, I'm curious: do others think C
is a good tool to have some proficiency in, even if Tcl remains the
...
-
Is it helpful to know C?
My C skills are much less than 133t at the moment--I've seldom had a
problem that Tcl couldn't solve. However, I'm curious: do others think C
is a good tool to have some proficiency in, even if Tcl remains the
first tool I reach for? Would knowing C make me a better Tcl programmer?
Are there truly some problems that are better solved at the C level than
the Tcl, and if so, what are they?
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-
Re: Is it helpful to know C?
Kevin Walzer schrieb:
> My C skills are much less than 133t at the moment--I've seldom had a
> problem that Tcl couldn't solve. However, I'm curious: do others think C
> is a good tool to have some proficiency in, even if Tcl remains the
> first tool I reach for? Would knowing C make me a better Tcl programmer?
> Are there truly some problems that are better solved at the C level than
> the Tcl, and if so, what are they?
>
C is helpful for some tasks, mostly to interface with existing libraries
or for extra performance in critical parts.
I doubt that knowing C makes you a much better Tcl programmer, other
than the typical effect of knowing more languages makes you a better
programmer in general.
Typical things where your better of with C is in the performance and
size domain, if you need something really small or really fast you
probably cannot reach that if you have to drag an interpreter along. But
most of those use cases get rarer and phones running Java are a sign of
it...
Using C to interface better with special OS APIs is a common usage, not
much magic there, just some glue, but its sometimes better to write your
own small C extension (or use critcl) instead of relying on swig or
ffidl to do the work.
Michael
-
Re: Is it helpful to know C?
On 15 Okt., 16:55, Kevin Walzer <k...@codebykevin.com> wrote:
> My C skills are much less than 133t at the moment--I've seldom had a
> problem that Tcl couldn't solve. However, I'm curious: do others think C
> is a good tool to have some proficiency in, even if Tcl remains the
> first tool I reach for? Would knowing C make me a better Tcl programmer?
Well, at least you can understand Tcl down to the finest details if
you can read the C sources.
> Are there truly some problems that are better solved at the C level than
> the Tcl, and if so, what are they?
Everything that takes too much time in Tcl is a candidate for trying
it in C instead. Say, if you really need Fibonacchi numbers :^), this
code snippet that should work in all three of the below hints, cuts
down runtime by a factor of 170 or more:
critcl::ccode {static int fib(int n) {return n <= 2? 1 : fib(n-1) +
fib(n-2);}}
critcl::cproc fib {int n} int {return fib(n);}
as compared with
proc fib0 n {
expr {$n <= 2? 1 : [fib0 [expr {$n-1}]] + [fib0 [expr {$n-2}]]}
}
You might look at the various packages that offer C "embedding" from
Tcl:
- Critcl http://wiki.tcl.tk/2523
- Odyce http://wiki.tcl.tk/20086
- tcltcc http://wiki.tcl.tk/20123
-
Re: Is it helpful to know C?
On Oct 15, 10:55 am, Kevin Walzer <k...@codebykevin.com> wrote:
> do others think C
> is a good tool to have some proficiency in, even if Tcl remains the
> first tool I reach for? Would knowing C make me a better Tcl programmer?
> Are there truly some problems that are better solved at the C level than
> the Tcl, and if so, what are they?
I believe that if one is developing for contemporary operating
systems, knowing C will likely provide you with several benefits. One
of the biggest is a better understanding of some Tcl functionality.
Some of the things that happen in Tcl is because Tcl was implmented in
C (for example, the whole "octal numbers" situation). Also, the reason
some Tcl functions operate the way they do (say - exec, or format) is
directly related to the C and Operating System APIs.
As for some of the other benefits for a Tcl developer - knowing C will
help when debugging some code - an extension or tcl itself have
occasional bugs and knowing C will help when you have to look at that
code. Also, knowing C better will help when you get the odd ball error
message when building code.
-
Re: Is it helpful to know C?
Kevin Walzer <kw@codebykevin.com> wrote:
> [...] However, I'm curious: do others think C
> is a good tool to have some proficiency in, even if Tcl remains the
> first tool I reach for?
My C's extremely rusty at the moment too. Where I notice it is when I'd
like to make use of a Tcl package but it's not got the platform support
I'd like or it's a bit stale.
> Would knowing C make me a better Tcl programmer?
Well, knowing C would mean you'd be free to write your own Tcl API to
any interesting C libraries you need. Given Apple seems to release a new
major API framework for each fashion season, I can see it being useful
for you :-).
> Are there truly some problems that are better solved at the C level than
> the Tcl, and if so, what are they?
Aside from accessing library functions, speed optimisation's the other
main reason you'd want to use C. However, one of the nice things about
Tcl is most of the things which need to be fast have already been made
binary packages anyway.
Similar Threads
-
By Application Development in forum C
Replies: 49
Last Post: 10-22-2007, 10:36 AM
-
By Application Development in forum RUBY
Replies: 2
Last Post: 08-16-2007, 12:54 PM
-
By Application Development in forum DOTNET
Replies: 6
Last Post: 05-15-2007, 07:10 AM
-
By Application Development in forum Java
Replies: 3
Last Post: 07-18-2006, 12:35 AM
-
By Application Development in forum Microsoft Money
Replies: 0
Last Post: 02-22-2005, 03:01 PM