user6077173
user6077173

Reputation:

Questions about Type Inference Languages

I've got few questions about Type Inference languages. By saying type inference, I refer to all those languages where the datatype need not be explicitly declared in code.

I think these languages give greater flexibility to developers, but I would like to have answers for the below questions.

  1. Do these languages consume more time at runtime to infer the actual data types?

  2. Can these languages be used for development of enterprise applications? Do they support maintainability and reusability?

Upvotes: 0

Views: 62

Answers (2)

svick
svick

Reputation: 244757

Do these languages consume more time at runtime to infer the actual data types?

Many languages with type inference use a compiler. The compiler does all the work required for type inference, so there is no runtime cost.

Can these languages be used for development of enterprise applications?

You're asking if a large, varied group of languages can be used for a large, varied domain. I don't think asking that question makes much sense. But generally speaking, yes, languages with type inference can be used to develop enterprise applications.

Do they support maintainability and reusability?

That's a very nebulous question. I'd say that you can write manitainable and reusable code in any mainstream language, including those with type inference.

Upvotes: 0

sepp2k
sepp2k

Reputation: 370082

First of all let's clarify some terminology:

  • A statically typed language is one where types are known statically, i.e. without running the program
  • A dynamically typed language is one where types may be unknowable until run time
  • Type inference is the process of statically determining types in code that does not contain explicit type annotations.

So when we talk about languages that don't require explicit type annotations, there are basically two categories:

  • Dynamically typed languages
  • Statically typed languages that figure out the types through type inference rather than type annotations

Dynamically typed languages generally require additional type checks at runtime and have less room for optimizations (because optimizers can optimize more things when they know the types). So there's some performance drawbacks to dynamic typing. However it is possible, depending on the language, to compensate for some of this by applying type inference to figure out the types statically where possible. There certainly are enterprise applications written in dynamically typed languages.

Statically typed languages with type inference don't perform any differently at runtime than statically typed languages without them. Only the compile times may be longer.

Upvotes: 1

Related Questions