Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: one type less language |
| Date | 2015-06-08 09:42 +0000 |
| Organization | Freie Universitaet Berlin |
| Message-ID | <ctl6bfFm8ngU1@mid.uni-berlin.de> (permalink) |
| References | <ee5b4ddd-7a35-4bff-bc23-b04ec5abf25a@googlegroups.com> <4fc72288-16e5-41cc-a814-7b598cbc2c13@googlegroups.com> <cthdk0Fnjb7U2@mid.uni-berlin.de> <0132eb60-ad1e-45ca-8284-947863adb446@googlegroups.com> <ml25fu$ebr$1@dont-email.me> |
Bartc <bc@freeuk.com> wrote:
> On 07/06/2015 17:59, Malcolm McLean wrote:
> > On Sunday, June 7, 2015 at 12:21:46 AM UTC+1, Jens Thoms Toerring wrote:
> >>
> >> There are lots of languages that don't care much about types,
> >> Python is probably one of the most commonly used at the moment.
> >> But, while a more-or-less type-agnostic language can be very
> >> nice for rapid prototyping, it has also its disadvantages:
> >> not having to define new variables or "cast" in assignments,
> >> it allows for bugs that, in strongly-typed language would
> >> have been caught at some stage (either by the compiler or
> >> the interpreter).
> >>
> > The motive is to make the script interpreter easier to write.
> > You just bung in a hash table to allow indexing of dynamic type
> > elements by string identifier, and you don't care if "name"
> > returns a string, a structure with title, forename and surname
> > members, or a function that sets a name.
> Actually, it makes it a bit harder to write, and the bytecode compiler,
> if there is one, a bit easier. But writing source code becomes quicker
> and easier too, which is the advantage.
> The interpreter still needs to do type dispatching at runtime (you do
> need to care when about to multiply a list by a string for example),
> unlike one for a language with static types.
But the interpreter must follow certain rules. And some-
times it follows different rules from what you might have
expected. For example, in Perl you might attempt to ado
$a = ' 2.3 '; # that's a string, isn't it?
$a += ' 2 '; # this appends another string to it, doesn't it?
print "$a\n"; # guess what this will print...
Of course, this isn't a string concatenation (since in Perl
you'd have to use the '.' operator for that). But it's also
not a syntax error since the interpreter recognizes that
both strings contain something that can be interpreted as
numbers (disregarding the spaces) and thus adds these two
numbers. And the result is the number 4.3. So the mistake
of using '+' instead of '.', made because you had written in
Python or C++ for the last hours where '+' is used for string
concatenation, gives a completely different result from what
you probably intended.
My point is that in these languages you have to learn quite
a large set of rules of how the interpreter will behave in
all kinds of situations. And many things that in a strongly
typed language would be syntax errors may have unexpected
meanings. That's not meant as a criticism of these languages
but just an observation that certain, quite nice-to-have
features come at a prize. And given that many people already
moan about the complexities of type promotions in C it might
be a bit of an unexpected steep learning curve when so many
other things look that simple in these languages.
xRegards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
one type less language asetofsymbols@gmail.com - 2015-06-05 22:08 -0700
Re: one type less language David Kleinecke <dkleinecke@gmail.com> - 2015-06-06 09:35 -0700
Re: one type less language Richard Damon <Richard@Damon-Family.org> - 2015-06-06 13:10 -0400
Re: one type less language Les Cargill <lcargill99@comcast.com> - 2015-06-06 13:01 -0500
Re: one type less language Michael Angelo Ravera <maravera@prodigy.net> - 2015-06-07 13:03 -0700
Re: one type less language Les Cargill <lcargill99@comcast.com> - 2015-06-06 12:55 -0500
one type less language asetofsymbols@gmail.com - 2015-06-06 12:15 -0700
Re: one type less language Bartc <bc@freeuk.com> - 2015-06-06 20:23 +0100
Re: one type less language Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-06 20:28 +0100
Re: one type less language jt@toerring.de (Jens Thoms Toerring) - 2015-06-06 23:21 +0000
Re: one type less language Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-07 09:59 -0700
Re: one type less language Bartc <bc@freeuk.com> - 2015-06-07 20:20 +0100
Re: one type less language jt@toerring.de (Jens Thoms Toerring) - 2015-06-08 09:42 +0000
Re: one type less language Bartc <bc@freeuk.com> - 2015-06-08 11:28 +0100
Re: one type less language Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-06-08 05:10 -0700
Re: one type less language Mel <mel@zzzzz.com> - 2015-06-08 15:39 +0300
Re: one type less language "J. Clarke" <j.clarke.873638@gmail.com> - 2015-09-08 05:23 -0400
Re: one type less language Robert Wessel <robertwessel2@yahoo.com> - 2015-09-08 10:20 -0500
Re: one type less language Keith Thompson <kst-u@mib.org> - 2015-06-06 13:56 -0700
Re: one type less language luser droog <luser.droog@gmail.com> - 2015-06-07 23:20 -0700
Re: one type less language asetofsymbols@gmail.com - 2015-06-08 02:50 -0700
csiph-web