What does the new scala Dynamic type do? [duplicate] - scala

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Practical uses of a Dynamic type in Scala
It has just been tweeted that Martin Odersky has just added Dynamic into trunk. Apparently, this is HUGE. Why?

Dynamic adds developer driven dynamic binding (dynamic dispatch) and gives a subset of the features of dynamic typing to Scala.
See this pastie from Jorge Ortiz:
http://pastie.org/1469174

Related

What is the difference between should and must in scala testing? [duplicate]

This question already has an answer here:
In ScalaTest is there any difference between `should`, `can`, `must`
(1 answer)
Closed 6 years ago.
Both scalatest and Specs2 have separate matchers for should and must.
However, I cannot find any explanation for why you would use one or the other.
What exactly is the difference?
There is no difference, this is purely a syntactic preference. I personally prefer to use must in specs2 because I think that should can make people think that an expectation is optional.

Why does Kotlin compile faster than Scala? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
When we read the wikipedia description of the Kotlin programming language, it is stating that:
JetBrains lead Dmitry Jemerov said that most languages did not have the features they were looking for, with the exception of Scala. However, he cited the slow compile time of Scala as an obvious deficiency.[4] One of the stated goals of Kotlin is to compile as quickly as Java.
How did they achieve that goal? And why is Scala compile time so slow that it was unacceptable for the Kotlin creators? Or - in other words - which features of the Scala compiler make it slower than the Kotlin compiler?
Although I think the question is not well suited for Stack Overflow as it will tend to produce primarily opinion based answers, here is one attempt: You have two different languages, especially concerning the type system, and two completely independent implementations of compilers. So to expect them to have the "same" kind of compilation speed is already a fallacy. I have linked in my comment to another question that examines the speed of the Scala compiler. Basically, it depends on many factors, for example the amount of work that the type inferencer and implicit resolution required by a specific code base.
Nevertheless, I ran a very quick example: I compiled some Project Euler solutions in Kotlin and Scala. This gave me for a fresh re-compile of the whole project:
6 seconds in Kotlin (down to 5 seconds in successive re-builds)
10 seconds in Scala (down to 7 seconds in successive re-builds).
Origin of the source code:
I took this code for Kotlin, changed a lot of imports because apparently the Kotlin standard library changed in the meantime, in order to make it compile.
I took this code for Scala, and converted it into an sbt project with each problem wrapped in an object pXY extends App { ... } and placed it in a package euler.
Then I removed the files for which only one solution existed, ending up with 26 problems. Both projects were compiled with IntelliJ IDEA 15 CE using Rebuild Project.
To give another perspective on this business, I ran wc (word count) on the sources:
// lines words bytes
931 3603 33087 total // Kotlin
261 1166 6472 total // Scala
So now you can either argue that the Kotlin compiler needed to process "more source code" or that the Scala code was "more dense" :)

Java interface equivalent in Perl [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Can I create Java-like interfaces in Perl?
How the Java like interfaces is supported in Perl?
http://en.wikipedia.org/wiki/Interface_(Java)
If you're using Moose, you could create role with nothing but a requires statement.

Why does objective C does not support overloading? [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
Why Objective-C doesn't support method overloading?
I was going through this link which has the answer to my question. But I was not able to understand what the right guy is trying to say. It will be really great if someone can simplify and provide an explanation.
In C++ the compiler has type information and can choose between several methods based on the types. To do the same in Objective C it would have to be done at run-time, because the compiler knows little about object types due to the dynamic nature of the language (i.e. all objects are of type id). While this seems possible, it would be very inefficient in practice.
I think it's a historical artifact. Objective-C is derived from C and Smalltalk, and neither of them support overloading.
If you want overloading, you can use Objective-C++ instead. Just name your sources with the ".mm" extension instead of just ".m".
Just be careful to be sure you know what you are doing if you mix C++ and Objective-C idioms. For example Objective-C exceptions and C++ exceptions are two completely different animals and cannot be used interchangeable.
What he is trying to say is that method overloading is not possible with dynamic typed languages since in dynamic typed languages the information about each of the object is not known until run time. In a statically typed during compile time the overloading can be resolved. You will just create the same functions with same names but the compiler would have enough information to resolve the ambiguity between various calls which it gets. But in dynamic typed languages since the objects are resolved only during run time it is not possible to resolve between the various calls.

Objective C - Difference Between VARType* vt and VARType *vt [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Placement of the asterisk in Objective-C
What is the differenct between the following:
(Assume we have a class calculator)
Calculator* calc;
Calculator *calc;
Also what is the need for pointers? Is it not possible to omit the star?
There is no difference between those two declarations, you could also do Calculator * calc if you're feeling adventurous.
As far as if you can omit the star, no, you cannot. It is a carry over from C and shows that calc is a pointer to a Calculator, and not a Calculator itself.
There is no difference between the 2 declaration is just an preference for typing.
Every thing on computers uses pointers. You need pointers java, c#, etc use pointers.
No is not posible to omit the star.