Re: [LAU] OT: C or C++?

From: Erik de Castro Lopo <mle+la@email-addr-hidden-nerd.com>
Date: Thu Oct 14 2010 - 23:14:31 EEST

Joshua Boyd wrote:

> On Thu, Oct 14, 2010 at 12:10:46PM +1100, Erik de Castro Lopo wrote:
> > If you get serious about programming, its important to
> > know more than just C and C++. For many tasks, garbage
> > collected languages with stricter type systems than C
> > and C++ are a better fit. Langauges like Python, Ruby,
> > Ocaml and Haskell. Even Java!!!
>
> You say stricter type system, then Python and Ruby in the next
> sentence. Does not compute. ;)

Python and Ruby do have a strict type system, its just that
the types are checked at run time. In these dynamically typed
languages, *every* value is an object that caries around with
it its type.

For instance this in Python:

    Python 2.6.6 (r266:84292, Aug 29 2010, 12:36:23)
    [GCC 4.4.5 20100824 (prerelease)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1
>>> y = [ 1 , 2 ]
>>> x + y
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: unsupported operand type(s) for +: 'int' and 'list'

The run time type checker is telling you that adding an integer to
a list does not make sense.

In (strict) statically typed languages like Ocaml and Haskell this
is a compile time error.

Erik

-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user
Received on Fri Oct 15 00:15:05 2010

This archive was generated by hypermail 2.1.8 : Fri Oct 15 2010 - 00:15:06 EEST