Re:Typed Python: new Mypy release
by symlinkk on Friday May 06, 2016 @05:33AM
(#11642712)
is there such thing as a typed interpreted language? I mean one with a REPL, not Java.
[ Parent
| on HN ]
> is there such thing as a typed interpreted language?
Of course. Examples:
▶ ocaml
OCaml version 4.02.3
# 9;;
- : int = 9
▶ ghci
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> 9
9
Prelude> :t 9
9 :: Num a => a
Prelude>
▶ drracket
Welcome to DrRacket, version 6.3.0.2--2015-10-28(-/f) [3m].
Language: typed/racket; memory limit: 128 MB.
> 9
- : Integer [more precisely: Positive-Byte]
9
▶ scala
Welcome to Scala version 2.10.4 (OpenJDK 64-Bit Server VM, Java 1.8.0_91).
Type in expressions to have them evaluated.
Type :help for more information.
scala> 9
res0: Int = 9
There are even interpreters for C (http://www.drdobbs.com/cpp/ch-a-cc-interpreter-for-script-co...).tl;dr: you can have a REPL in both statically and dynamically typed languages.
Python (and many others) is a typed interpreted language. It's not statically typed, but it is typed.
Re:Typed Python: new Mypy release
by ericfrederich on Friday May 06, 2016 @10:16AM
(#11644106)
Not just typed, Python is strongly typed.
Julia: http://julialang.org/
(Typing is optional)
Re:Typed Python: new Mypy release
by logicchains on Friday May 06, 2016 @05:42AM
(#11642739)
OCaml and Haskell both have interpreters.
Scala is strongly, statically typed with a REPL.
There is Typed Racket. It's essentially a scheme with static type checking, which works from the REPL. http://docs.racket-lang.org/ts-guide/index.html
Re:Typed Python: new Mypy release
by Xophmeister on Friday May 06, 2016 @08:54AM
(#11643600)
Presumably, ultimately, all languages are typed in some way. Otherwise, how would the interpreter (or whatever execution environment is relevant) deduce what binary data was what?
I think the question you mean -- which I'm also interested in the answer to -- is: How can a dynamically typed language be statically type checked? Presumably Hindley-Milner style inference doesn't/can't work. Do static analysers such as Mypy therefore trace the execution of the code until it finds something that conflicts? Are there cases where this approach won't work, either technically or practically?
Forth is what I would consider an untyped language. It deals with numbers on a stack in a way that it is totally up to the programmer to decide what they represent. One number may be a IEEE 754 number, an unsigned integer, a signed integer, the address of a string, a fixed-point number, a couple of ASCII characters etc.
Re:Typed Python: new Mypy release
by RodgerTheGreat on Friday May 06, 2016 @12:00PM
(#11644823)
Same deal with most forms of assembly language- the values you work with are just numbers, and the operations to which you apply them are what give them a particular meaning at a particular point in time- addresses, offsets, integers, booleans, etc. It's possible to argue that such languages are "unityped" rather than "untyped", but I think to do so is to produce such a loose interpretation of "types" as to be uninteresting.
> Otherwise, how would the interpreter (or whatever execution environment is relevant) deduce what binary data was what?
Via runtime tags, which are not the same as types.
Java has a repl: https://github.com/albertlatacz/java-repl
Java is actually getting a REPL with Java 9.
I think most (S)ML implementations have a repl.
So does GHC AFAIR. It's really not uncommon :)
Those were missing: Most lisps, perl6, cperl, php 7, ruby 3
Kotlin has a repl
Re:Typed Python: new Mypy release
by lacksconfidence on Friday May 06, 2016 @11:42AM
(#11644698)
php7