comp.lang.ada
 help / color / mirror / Atom feed
* Who said strong typing is a benefit?
@ 2002-10-13  1:18 steve_H
  2002-10-13  2:53 ` Jim Rogers
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: steve_H @ 2002-10-13  1:18 UTC (permalink / raw)


since many Ada programmers mention as one of Ada benefits is its 
strong typing, I thought some here might find the following 
'interesting' to read.

I guess this is an argument of '4GL' vs '3GL'. The following seems
to imply that not having to declare variables and having the ability to
mix any variable with any in an expression is a 'benefit'. I am not sure
I agree with this, on the other hand, one can not deny that one can
write code faster in matlab than in a strongly typed language such as Ada
specially for scientific applications where arrays and matrices are
heavily used.

I wish there was a 'matlab like' environment based on an Ada like language.

from 

http://www.mathworks.com/company/digest/sept02/accel_matlab.pdf

 
"MATLAB Type Handling
An important benefit of MATLAB is that users do not have
to declare variables to be of certain data types, as is required
with 3GLs. In MATLAB, any variable can be assigned a
value of any type, and that type can be changed implicitly
at will because of an assignment to a new value of a different
type.As a result, the MATLAB interpreter is prepared to
deal with the most complicated data types (such as an ndimensional
array of complex doubles) and is capable of
performing operations no matter what the actual data
types turn out to be at run-time"



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  1:18 Who said strong typing is a benefit? steve_H
@ 2002-10-13  2:53 ` Jim Rogers
  2002-10-13 18:27   ` Jeffrey Carter
  2002-10-13  3:24 ` Richard Riehle
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 15+ messages in thread
From: Jim Rogers @ 2002-10-13  2:53 UTC (permalink / raw)


steve_H wrote:

> since many Ada programmers mention as one of Ada benefits is its 
> strong typing, I thought some here might find the following 
> 'interesting' to read.
> 
> I guess this is an argument of '4GL' vs '3GL'. The following seems
> to imply that not having to declare variables and having the ability to
> mix any variable with any in an expression is a 'benefit'. I am not sure
> I agree with this, on the other hand, one can not deny that one can
> write code faster in matlab than in a strongly typed language such as Ada
> specially for scientific applications where arrays and matrices are
> heavily used.
> 
> I wish there was a 'matlab like' environment based on an Ada like language.
> 
> from 
> 
> http://www.mathworks.com/company/digest/sept02/accel_matlab.pdf
> 
>  
> "MATLAB Type Handling
> An important benefit of MATLAB is that users do not have
> to declare variables to be of certain data types, as is required
> with 3GLs. In MATLAB, any variable can be assigned a
> value of any type, and that type can be changed implicitly
> at will because of an assignment to a new value of a different
> type.As a result, the MATLAB interpreter is prepared to
> deal with the most complicated data types (such as an ndimensional
> array of complex doubles) and is capable of
> performing operations no matter what the actual data
> types turn out to be at run-time"
> 

Please be sure you do not confuse dynamically typed languages with weakly
typed languages. Ada a statically typed, strongly typed language. Perl is
a dynamically typed, weakly typed language. Lisp is a dynamically typed,
strongly typed language.

The benefits of each of these approaches is a matter of taste or need.
Perl is most useful when development speed for text manipulation problems
is your major concern. Lisp is beneficial for general data grouping and parsing
problems. Ada is a beneficial when you must be able to determine code
correctness before running the program.

I have contracted for a not to be named telecom company that treated all
software as a disposable commodity. They were more interested in redoing bad
programs than writing them correctly the first time. They believed they needed
to get *something* to market, and that was more important than getting
*quality* to the market. If that is your goal then Ada offers you very little.
If your goal is to get a correct, high quality product to market quickly then
Ada provides some genuine benefits.

Jim Rogers




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  1:18 Who said strong typing is a benefit? steve_H
  2002-10-13  2:53 ` Jim Rogers
@ 2002-10-13  3:24 ` Richard Riehle
  2002-10-13  7:10 ` tmoran
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Richard Riehle @ 2002-10-13  3:24 UTC (permalink / raw)


steve_H wrote:

> since many Ada programmers mention as one of Ada benefits is its
> strong typing, I thought some here might find the following
> 'interesting' to read.
>
>
> "MATLAB Type Handling
> An important benefit of MATLAB is that users do not have
> to declare variables to be of certain data types,

    [ snipped some of the original text ]

Although Ada is designed to be type-safe, this is not a problem
for anyone who has no need of type-safety.   It is so easy to
circumvent type-safety, if you really want to do that.   We start
with a default of type-safe and simply relax that default as
much as we wish.

More important, it is rare for anyone to have difficulties with
Ada's type model.   Any practical programmer understands
the notion of type and can write code accordingly.  So what
is the problem, then?

More programmers have trouble with the Ada visibility rules
than any other single aspect of the language.   The type model
supports the visibility rules.   With this observation, I include
the accessibility rules, which are simply a variation on
visibility.  In my experience, once programmers understand
the visibility rules and learn to use them to their advantage,
instead of fighting them at every turn, they become comfortable
with Ada and begin to enjoy using it.   The visibility rules
are a benefit of the language design, not a curse, but it is
hard to see that in the early stages of using the language.

Richard Riehle







^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  1:18 Who said strong typing is a benefit? steve_H
  2002-10-13  2:53 ` Jim Rogers
  2002-10-13  3:24 ` Richard Riehle
@ 2002-10-13  7:10 ` tmoran
  2002-10-13 13:00   ` Jim Rogers
  2002-10-13 15:33   ` steve_H
  2002-10-13 17:14 ` Larry Kilgallen
  2002-10-14  1:21 ` Dmitry A.Kazakov
  4 siblings, 2 replies; 15+ messages in thread
From: tmoran @ 2002-10-13  7:10 UTC (permalink / raw)


> write code faster in matlab than in a strongly typed language such as Ada
asdfghjkl;'
Bet you can't write code faster than dragging your finger across the
keyboard.  And I could make an interpreter that did something as a
result.  But the real question is not how fast you can write, but
how fast you can write a program that does what you want.  Strong
typing helps do *that* fast.
  As already pointed out, there's also the little matter of the difference
between weak vs strong typing and static vs dynamic typing.

> performing operations no matter what the actual data
> types turn out to be at run-time"
  What does the interpreter do when you add a 3D vector to a 2D vector,
or do "if A > B" where A and B are complex, etc.  I don't doubt that
it will "perform operations no matter what" - I'm just curious what
those operations might turn out to be.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  7:10 ` tmoran
@ 2002-10-13 13:00   ` Jim Rogers
  2002-10-13 13:30     ` Florian Weimer
  2002-10-13 19:31     ` steve_H
  2002-10-13 15:33   ` steve_H
  1 sibling, 2 replies; 15+ messages in thread
From: Jim Rogers @ 2002-10-13 13:00 UTC (permalink / raw)


tmoran@acm.org wrote:

>   What does the interpreter do when you add a 3D vector to a 2D vector,
> or do "if A > B" where A and B are complex, etc.  I don't doubt that
> it will "perform operations no matter what" - I'm just curious what
> those operations might turn out to be.
> 

My favorite response to this kind of question is "what will Matlab do
when you take the square root of a string?"

Jim Rogers






^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13 13:00   ` Jim Rogers
@ 2002-10-13 13:30     ` Florian Weimer
  2002-10-13 17:28       ` Michael Bode
  2002-10-13 19:53       ` steve_H
  2002-10-13 19:31     ` steve_H
  1 sibling, 2 replies; 15+ messages in thread
From: Florian Weimer @ 2002-10-13 13:30 UTC (permalink / raw)


Jim Rogers <jimmaureenrogers@worldnet.att.net> writes:

> My favorite response to this kind of question is "what will Matlab do
> when you take the square root of a string?"

>> sqrt ('@Q')

ans =

     8     9

>> 

Ugh.  Consistent, but useless.

However, you get an error if you try to use a string as a matrix
index.  But you can use a matrix as an index for a vector (and Matlab
programmers constantly do this!)



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  7:10 ` tmoran
  2002-10-13 13:00   ` Jim Rogers
@ 2002-10-13 15:33   ` steve_H
  1 sibling, 0 replies; 15+ messages in thread
From: steve_H @ 2002-10-13 15:33 UTC (permalink / raw)


tmoran@acm.org wrote in message news:<%%8q9.21249$rz6.2550@sccrnsc02>...
 
> 
> > performing operations no matter what the actual data
> > types turn out to be at run-time"

>   What does the interpreter do when you add a 3D vector to a 2D vector,
> or do "if A > B" where A and B are complex, etc.  I don't doubt that
> it will "perform operations no matter what" - I'm just curious what
> those operations might turn out to be.


� threeD=zeros(2,2,2); twoD=zeros(2,2);
� threeD

threeD(:,:,1) =

     0     0
     0     0


threeD(:,:,2) =

     0     0
     0     0

� twoD

twoD =

     0     0
     0     0

� threeD+twoD
??? Error using ==> +
Number of array dimensions must match for binary array op.

� threeD>twoD
??? Error using ==> >
Number of array dimensions must match for binary array op.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  1:18 Who said strong typing is a benefit? steve_H
                   ` (2 preceding siblings ...)
  2002-10-13  7:10 ` tmoran
@ 2002-10-13 17:14 ` Larry Kilgallen
  2002-10-14  1:21 ` Dmitry A.Kazakov
  4 siblings, 0 replies; 15+ messages in thread
From: Larry Kilgallen @ 2002-10-13 17:14 UTC (permalink / raw)


In article <8db3d6c8.0210121718.25cf55e4@posting.google.com>, nma124@hotmail.com (steve_H) writes:
> since many Ada programmers mention as one of Ada benefits is its 
> strong typing, I thought some here might find the following 
> 'interesting' to read.
> 
> I guess this is an argument of '4GL' vs '3GL'. The following seems
> to imply that not having to declare variables and having the ability to
> mix any variable with any in an expression is a 'benefit'.

Typically the product or idea that the writer is trying to "sell"
is declared to be the better way to do it.  This is exemplified
by the two points of view on the topic of gun control.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13 13:30     ` Florian Weimer
@ 2002-10-13 17:28       ` Michael Bode
  2002-10-13 22:07         ` Florian Weimer
  2002-10-13 19:53       ` steve_H
  1 sibling, 1 reply; 15+ messages in thread
From: Michael Bode @ 2002-10-13 17:28 UTC (permalink / raw)


Florian Weimer <fw@deneb.enyo.de> writes:

> However, you get an error if you try to use a string as a matrix
> index.  But you can use a matrix as an index for a vector (and Matlab
> programmers constantly do this!)

So if I have a vector 

[ 1 ] 
[ 2 ]
[ 3 ]
[ 4 ] 

which would be element 

[ 0.3   1    ]
[ pi  sqrt(2)] 

of this vector?



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  2:53 ` Jim Rogers
@ 2002-10-13 18:27   ` Jeffrey Carter
  0 siblings, 0 replies; 15+ messages in thread
From: Jeffrey Carter @ 2002-10-13 18:27 UTC (permalink / raw)


I'm always amazed by the willingness of cla readers to respond to a troll.

-- 
Jeff Carter
"You empty-headed animal-food-trough wiper."
Monty Python & the Holy Grail




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13 13:00   ` Jim Rogers
  2002-10-13 13:30     ` Florian Weimer
@ 2002-10-13 19:31     ` steve_H
  1 sibling, 0 replies; 15+ messages in thread
From: steve_H @ 2002-10-13 19:31 UTC (permalink / raw)


Jim Rogers <jimmaureenrogers@worldnet.att.net> wrote in message news:<3DA96E28.9090104@worldnet.att.net>...
> tmoran@acm.org wrote:
> 
> >   What does the interpreter do when you add a 3D vector to a 2D vector,
> > or do "if A > B" where A and B are complex, etc.  I don't doubt that
> > it will "perform operations no matter what" - I'm just curious what
> > those operations might turn out to be.
> > 
> 
> My favorite response to this kind of question is "what will Matlab do
> when you take the square root of a string?"
> 
> Jim Rogers



� format long g
� s=' i am a string'

s =

 i am a string

� sqrt(s)

ans =

  Columns 1 through 3 

          5.65685424949238          10.2469507659596          5.65685424949238

  Columns 4 through 6 

           9.8488578017961          10.4403065089106          5.65685424949238

  Columns 7 through 9 

           9.8488578017961          5.65685424949238          10.7238052947636

  Columns 10 through 12 

           10.770329614269          10.6770782520313          10.2469507659596

  Columns 13 through 14 

          10.4880884817015          10.1488915650922



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-14  1:21 ` Dmitry A.Kazakov
@ 2002-10-13 19:42   ` steve_H
  0 siblings, 0 replies; 15+ messages in thread
From: steve_H @ 2002-10-13 19:42 UTC (permalink / raw)


Dmitry A.Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<aobrip$ksn5j$1@ID-77047.news.dfncis.de>...

> steve_H wrote:
> 
> > I wish there was a 'matlab like' environment based on an Ada like
> > language.
> 
> I think it is still possible to get Ada 83 code from MatLab [if MathWorks 
> did not cancelled this feature]. 
> 
 
You mean from simulink, not matlab proper. matlab S-functions in Ada, yes, 
but your normal matlab .m files, when compiled, they generate C or C++ code,
these are the only 2 options. Then an external C/C++ compiler is used to 
compile and link to a .exe

"-lang <language> Override language choice implied by file extensions.
                     <language> is either 'c' (for C) or 'cpp' (for C++)."



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13 13:30     ` Florian Weimer
  2002-10-13 17:28       ` Michael Bode
@ 2002-10-13 19:53       ` steve_H
  1 sibling, 0 replies; 15+ messages in thread
From: steve_H @ 2002-10-13 19:53 UTC (permalink / raw)


Florian Weimer <fw@deneb.enyo.de> wrote in message news:<87lm52eaa9.fsf@deneb.enyo.de>...
> Jim Rogers <jimmaureenrogers@worldnet.att.net> writes:
> 
> > My favorite response to this kind of question is "what will Matlab do
> > when you take the square root of a string?"
>  
> >> sqrt ('@Q')
> 
> ans =
> 
>      8     9
> 
> >> 
> 
> Ugh.  Consistent, but useless.
> 
 
When not sure if the variable is string or not, use:

"� help ischar

 ISCHAR  True for character array (string).
    ISCHAR(S) returns 1 if S is a character array and 0 otherwise.
 
    See also CHAR."

When using anything other than the basic data type in matlab (which is
a double), then things do not look so pretty any more. But almost 
everything in matlab is a double (ok, except strings). from the simple 
loop counter variable to the 20 MB sparse matrix to the index into an 
array of only 5 elements, they are all of type double as default.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13 17:28       ` Michael Bode
@ 2002-10-13 22:07         ` Florian Weimer
  0 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2002-10-13 22:07 UTC (permalink / raw)


Michael Bode <m.g.bode@web.de> writes:

> So if I have a vector 
>
> [ 1 ] 
> [ 2 ]
> [ 3 ]
> [ 4 ] 
>
> which would be element 
>
> [ 0.3   1    ]
> [ pi  sqrt(2)] 
>
> of this vector?

Values are truncated to obtain integer indices, and an entry n in the
matrix is replaced with the nth component of the vector. Your example
gives an error (zero index).

Nice error message, BTW:

??? Capitalized internal function PI; Caps Lock may be on.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Who said strong typing is a benefit?
  2002-10-13  1:18 Who said strong typing is a benefit? steve_H
                   ` (3 preceding siblings ...)
  2002-10-13 17:14 ` Larry Kilgallen
@ 2002-10-14  1:21 ` Dmitry A.Kazakov
  2002-10-13 19:42   ` steve_H
  4 siblings, 1 reply; 15+ messages in thread
From: Dmitry A.Kazakov @ 2002-10-14  1:21 UTC (permalink / raw)


steve_H wrote:

> I wish there was a 'matlab like' environment based on an Ada like
> language.

I think it is still possible to get Ada 83 code from MatLab [if MathWorks 
did not cancelled this feature]. 

> "MATLAB Type Handling
> An important benefit of MATLAB is that users do not have
> to declare variables to be of certain data types, as is required
> with 3GLs. In MATLAB, any variable can be assigned a
> value of any type, and that type can be changed implicitly
> at will because of an assignment to a new value of a different
> type.As a result, the MATLAB interpreter is prepared to
> deal with the most complicated data types (such as an ndimensional
> array of complex doubles) and is capable of
> performing operations no matter what the actual data
> types turn out to be at run-time"

All this can be easily achived in Ada. Just derive all your types from the 
same tagged base and use smart pointers to the objects.

The reverse cannot be achived. I.e. with MatLab one cannot develop systems 
of same scale, maintainability, performance and safety as one could do in 
Ada.

-- 
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-10-14  1:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-13  1:18 Who said strong typing is a benefit? steve_H
2002-10-13  2:53 ` Jim Rogers
2002-10-13 18:27   ` Jeffrey Carter
2002-10-13  3:24 ` Richard Riehle
2002-10-13  7:10 ` tmoran
2002-10-13 13:00   ` Jim Rogers
2002-10-13 13:30     ` Florian Weimer
2002-10-13 17:28       ` Michael Bode
2002-10-13 22:07         ` Florian Weimer
2002-10-13 19:53       ` steve_H
2002-10-13 19:31     ` steve_H
2002-10-13 15:33   ` steve_H
2002-10-13 17:14 ` Larry Kilgallen
2002-10-14  1:21 ` Dmitry A.Kazakov
2002-10-13 19:42   ` steve_H

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox