matz / streem

prototype of stream based programming language
MIT License
4.6k stars 237 forks source link

Typed #12

Open DAddYE opened 9 years ago

DAddYE commented 9 years ago

I know, I know, but In my opinion to achieve very fast performances I would opt for a typed and compiled language.

Something in the swift vein can be used for scripting and as well full featured programs.

What do you think?

DD

matz commented 9 years ago

Let me think about it. But it will not be explicit. Maybe some kind of type inference has chance.

alexispurslane commented 9 years ago

How about soft-typing? Such as, if types are defined, check the types, but if there are no types on the variable, make it dynamically typed? That would be very cool. I do not know how hard that would be to implement, but it seems like a good idea to me.

matz commented 9 years ago

@christopherdumas Indeed.

dennisdegreef commented 9 years ago

That is what HHVM's approach on PHP is as well, to be backwards compatible, but still gain the advantages of strongly typed variables if you would want to.

jamonholmgren commented 9 years ago

I've read that optionally typed languages suffer from an "all-or-nothing" problem, where the types are generally only beneficial if you make sure to type everything.

Dart has an interesting article about optional types: https://www.dartlang.org/articles/why-dart-types/

nickserv commented 9 years ago

I think it depends on whether this is meant to be more of a scripting language or an applications language, but if it's more of the latter, I think that static typing with type inference (how Go, Rust, and Swift do it) is pretty awesome.

DAddYE commented 9 years ago

@nicolasmccurdy 100% agree. I hope the direction will be on the latter (applications languages) since ruby mostly cover the former.

nickserv commented 9 years ago

@matz What's your opinion on doing static typing with type inference? Also, how much will streem focus on performance?

matz commented 9 years ago

I consider Streem as a DSL to build a data-flow pipeline. In that sense, having static typing is not 100% mandatory. I admit the benefit of static typing, and I will keep it in mind. But it isn't my top priority.

alexispurslane commented 9 years ago

Static Typing, even with the very best type inference, comes with a certain amount of verbosity. I find that not very likable for a language like streem, which is a scripting language and/or DSL (as far as I can tell). Dynamic typing would be nice, but then again, that comes with some bugs as well, and some amount of ambiguity. I think (as I said before) that dart-style soft-typing would come with some major benefits. That said, @jamonholmgren, many things in programming are often seen as an all-or-nothing thing: FP vs. OOP vs Prototypal, Static vs. Dynamic types, Logic vs declarative vs imperative programming, and so on. Many of these can be mixed (see JavaScript), and many of these are not mutually exclusive. Often, styles in programming (types of formatting and size of indentation.) And many, many things in programming are decided by

        A. The problem, or
        B. Taste, or
        C. Trends
luikore commented 9 years ago

Thinking in true dynamic typing is completely different from the static typing way. Type inference on forced static typing is just a syntax sugar and doesn't change how you think (you don't have to write it, but you still have to care about it). What's worse, to make type inference look good, you'll tend to add more implicitness, like implicit type conversions which makes it even harder to find documentation for some method, or, extend the inference to whole-program-analysis which makes compilation much much slower. Inference on dynamic/optional typing may help performance, but that's implementation issue after design.

Static typing is not the only way for good performance, providing easier ways for user to optimize will give better results than "we already optimized that for you".

JiechengZhao commented 9 years ago

What about the idea of static typed pipe and soft typed pipe. In static typed pipe everything shall be typed, and in soft typed pipe there is no type at all. Somehow, these two kinds of type of pipes can be chained together. Trying to mixing these two concepts in a higher scope, not only on variables.

dajoh commented 9 years ago

@christopherdumas: Static Typing, even with the very best type inference, comes with a certain amount of verbosity.

Does it really? A Hindley–Milner type system doesn't need any type annotations to infer the types of a program.

alexispurslane commented 9 years ago

Hmmm. That is true, @dajoh. I do sort of like that idea. Haskell's type system is perfectly unobtrusive when programming. Maybe that is the way to go!

nickserv commented 9 years ago

@dajoh Agreed, if you do type inference well it can eliminate almost all the verbosity. Variables won't be able to change types, but I personally feel that's not a very useful thing to do anyway, especially in a functional language.

alexispurslane commented 9 years ago

Agreed! I think it really should be typed, as long as we have good type inference. Like Haskell's. And if we accept my suggestion of using partial application in Streem, we could even use Haskell's function type syntax!