And minor features: do-while, break/continue/return to labels
What Fantom has and Kotlin has not
A far-greater API (as far as I can see, Kotlin doesn't seem to have a dedicated API but uses the Java API)
Javascript and C# support
The dynamic-invoke operator
A weaker null-safety
The compiler already exists and works
As much as I like Fantom, many features of Kotlin are really tempting. In particular, Here are the Kotlin's features I'd really like to have in fantom (in order of preference): "Generics", "More primitive types and optimized array", "If expression", "Extension functions" and "Built-in delegation" in Fantom.
But the great API and the Javascript/C# support are really the killer features of Fantom for me, which will definitely make me stay on the Fantom-side.
I think it might be interesting to look at the choices they've made (in particular for generics, I haven't read this in details, but their approach seems interesting).
tonskyWed 20 Jul 2011
I agree with MoOm that API is a valuable part of what makes Fantom such a useful language. One thing: you should also add stronger immutability support to What Fantom has... part.
But I disagree on what would be cool to see in Fantom in future. I personally like syntax support for tuples and pattern-matching (autocast implied). Instead of Kotlin’s extension functions one can inherit from mixins in Fantom.
eliah_lakhinWed 20 Jul 2011
I'm not familiar with Fantom, but as far as I know, Kotlin provides lightweight way of injection new functions/methods into exist classes without violation of class encapsulation, whereas similar construction in the Fantom may be implemented using typecast overloading only.
In Kotlin it is possible to define new functions in the exist class using such construction as: fun List<Int>.swap(x : Int, y : Int). In the function body "this" refers to the public interface of the modified class, which is protected from illegal state modification.
When I saw Kotlin yesterday I was shocked on how similar it is to Fantom, especially syntax wise ... (except function definitions and the val/var thing, for which I prefer Fantom's way).
They will surely benefit from being pushed with IDEA and obviously will have great support for at least one IDE.
I realize languages are evolutions of each others but this one sure seems to borrow a LOT from Fantom !
rfeldmanWed 20 Jul 2011
Seems like a Git/Mercurial situation to some extent - both seem to be targeting many of the same shortcomings in the Java/Scala/Groovy status quo, and with a similar overall strategy for addressing those shortcomings.
Except there's a way bigger gap here than between Git and Mercurial. Fantom seems to be more ambitious, richer, better designed, and further along to boot. The things Kotlin currently sports that Fantom does not offer are 95% things I don't care about, and in many cases would make the language clunkier if Fantom added them.
Considering JetBeans makes money from tooling and seems to have invented Kotlin primarily to build an IDE for it, it's sad they didn't just start promoting Fantom and building tooling around it instead. Everyone could have won.
(Although, to be fair, I would not be surprised to see an uptick in traffic for fantom.org this week based on the number of people posting "Hey, wait a minute..." on Twitter, Facebook, G+, etc.)
brianWed 20 Jul 2011
I think the emergence of yet another JVM language deserves a blog posting (one coming...)
Although I think a direct response to what Fantom lacks compared to Kotlin is warranted (along with some other comments):
Extension functions
Yes I think this is good, and I've talked about adding this to Fantom in the same style as C# did
Built-in delegation
I do like this and I believe Gosu has it too. But at the same time I am not sure it warrants a new feature when mixins pretty much solve the same problem.
Generics
Obviously a controversial topic :-) But based on forum discussion and the general thoughts of community, I think user defined generics will be added to the platform. I am planning to renew discussion after fanr is up and running (which I considered a more important part of the platform).
If expression
Don't see how this is any better than C/Java style cond ? t : f expression
Stronger null-safety
I think Fantom has hit the sweet spot here. We have great compile time annotations and checks which is a giant leap up from languages like Java/C#. But I don't think we have taken the point of being annoying (only extensive use can determine this fuzzy line).
Automatic cast
I think implicit casting under if (x is Foo) is probably a useful feature, but not really a fundamental semantic issue. I think bigger issue is basic philosophy of the role of the type system (which I think Fantom and Kotlin are miles apart on)
Pattern matching
More of a syntax sugar feature than a core language thing. I don't think we have talked it about it much on forum which is why think it has never received a lot of attention.
More primitive types and optimized arrays
I think having primitives in the language is bad - it creates a very complicated disjoint type system. That said, I think Fantom library that has optimized stuff for math usage would be great.
The dynamic-invoke operator
I think I saw there were going to add something like C# dynamic type. Although I have blogged about that before - I think Fantom's approach is better than the C# design.
They will surely benefit from being pushed with IDEA and obviously will have great support for at least one IDE.
Yes likely this language have great tooling in IDEA. Luckily we already have pretty good Eclipse and NetBeans support already :-) But tooling will continue to be a critical aspect of Fantom's success.
DanielFathWed 20 Jul 2011
Yeah, I kinda miss the do{}while. Using break to escape out of while loop is so... outlandish :P As for delegation and other things. I admit I kinda like if else as expression but in all seriousness it would just replace ternary operator and add more verbosity.
i := a ? b : c //currently
i := if(a) b else c
Not sure if Brian would be up for such a tradeoff. Not to mention they somewhat hard to read
Case matching was actually rather interesting, but I can definitely see a few hurdles - if switch returns multiple types what type it is? Or what if there are multiple matches (I'm assuming the topmost is processed first)? But other than tat there isn't a reason we couldn't use in keyword as a shortcut for contains (like list, range etc.)
As for extensions, Brian was talking about them, he wants them in, just not sure in what way or form or when
Personally my feature list for Fantom would go like this
Collections (Set and Tuples added)
More efficient cross platform arrays, primitives (we currently have high speed platform specific type) - this includes Char which is something brian was against inclusion.
Generics
More powerful case matching
Minor annoyances (do while), making and, or, xor methods into respective same name operator x.or(y.and(z.shift(2))) instead of x or (y and z.shift(2)) Also I found the open class/class' quite consistent with their stance on virtual/override i.e. all classes are final by default and all fields are non-virtual by default.
MoOmWed 20 Jul 2011
@brian
Built-in delegation: I do like this and I believe Gosu has it too. But at the same time I am not sure it warrants a new feature when mixins pretty much solve the same problem.
Agreed, it looks a lot like mixins. The only advantage I can see is if you want to change implementation at runtime (which might be handy for mocking in unit-tests)
If expression: Don't see how this is any better than C/Java style cond ? t : f expression
Problem with ternary expression is that the operands have to be a simple expression. Now if I want something more complex, I'm stuck with the if/else statement, which does not work well with non-nullable variable and type-inference. Let me give you an example:
String? displayName
if (!contact.firstName.isEmpty)
displayName = contact.firstName
else if (!contact.lastName.isEmpty)
displayName = contact.lastName
else
{
loadContactPhoneNumbers(contact)
if (!contact.phoneNumers.isEmpty)
displayName = contact.phoneNumbers.first
else
displayName = "No name"
}
In this case, in Fantom, I have to declare displayName as nullable and I can't use type-inference. If "if/else" was an expression, I could write:
displayName := if (!contact.firstName.isEmpty)
...
The nullable part could be solved with definite assignment analysis, which would definitely work for me and would be a more-generic solution than the if/else expression thing.
More primitive types and optimized arrays: I think having primitives in the language is bad - it creates a very complicated disjoint type system. That said, I think Fantom library that has optimized stuff for math usage would be great.
Sorry, I didn't mean "primitive types" but "value types". As I've already said, I think that not having Int32/Int16/Int8/Float32/Char types and native arrays in Fantom is what I miss the most from Java. As soon as you need to write some optimized code, you need to implement native methods, which makes you loose platform-indepedancy.
If we had these in Fantom, I guess that a large part of the sys pod could be written directly in Fantom which would be great for portability.
On the other points, I agree with you.
@DanielFath
Collections (Set and Tuples added)
I think this would come for free as soon as we have generics.
Also I found the open class/class' quite consistent with their stance on virtual/override i.e. all classes are final by default and all fields are non-virtual by default.
The open keyword is probably one of the feature I dislike the most about Kotlin. But I guess this feature can only work with a language supporting extension functions.
DanielFathWed 20 Jul 2011
@MooM
I think this would come for free as soon as we have generics.
I'd prefer if they had proper syntax. Something like (1,2,3) for Tuples and {{ 1,2,3 }} for Sets. Brian had some idea about sets being some kind of Unique lists, but I don't know if theoretically that is possible since Sets shouldn't be sorted.
MoOm Wed 20 Jul 2011
Jetbrains has just announced their new JVM language called Kotlin. And it looks a lot like Fantom...
Here is a quick Fantom to Kotlin comparison:
What Kotlin has and Fantom has not
What Fantom has and Kotlin has not
As much as I like Fantom, many features of Kotlin are really tempting. In particular, Here are the Kotlin's features I'd really like to have in fantom (in order of preference): "Generics", "More primitive types and optimized array", "If expression", "Extension functions" and "Built-in delegation" in Fantom.
But the great API and the Javascript/C# support are really the killer features of Fantom for me, which will definitely make me stay on the Fantom-side.
I think it might be interesting to look at the choices they've made (in particular for generics, I haven't read this in details, but their approach seems interesting).
tonsky Wed 20 Jul 2011
I agree with MoOm that API is a valuable part of what makes Fantom such a useful language. One thing: you should also add stronger immutability support to What Fantom has... part.
But I disagree on what would be cool to see in Fantom in future. I personally like syntax support for tuples and pattern-matching (autocast implied). Instead of Kotlin’s extension functions one can inherit from mixins in Fantom.
eliah_lakhin Wed 20 Jul 2011
I'm not familiar with Fantom, but as far as I know, Kotlin provides lightweight way of injection new functions/methods into exist classes without violation of class encapsulation, whereas similar construction in the Fantom may be implemented using typecast overloading only.
In Kotlin it is possible to define new functions in the exist class using such construction as:
fun List<Int>.swap(x : Int, y : Int)
. In the function body "this" refers to the public interface of the modified class, which is protected from illegal state modification.More detailed examples are presented here: http://confluence.jetbrains.net/display/Kotlin/Extension+functions.
tcolar Wed 20 Jul 2011
When I saw Kotlin yesterday I was shocked on how similar it is to Fantom, especially syntax wise ... (except function definitions and the val/var thing, for which I prefer Fantom's way).
They will surely benefit from being pushed with IDEA and obviously will have great support for at least one IDE.
I realize languages are evolutions of each others but this one sure seems to borrow a LOT from Fantom !
rfeldman Wed 20 Jul 2011
Seems like a Git/Mercurial situation to some extent - both seem to be targeting many of the same shortcomings in the Java/Scala/Groovy status quo, and with a similar overall strategy for addressing those shortcomings.
Except there's a way bigger gap here than between Git and Mercurial. Fantom seems to be more ambitious, richer, better designed, and further along to boot. The things Kotlin currently sports that Fantom does not offer are 95% things I don't care about, and in many cases would make the language clunkier if Fantom added them.
Considering JetBeans makes money from tooling and seems to have invented Kotlin primarily to build an IDE for it, it's sad they didn't just start promoting Fantom and building tooling around it instead. Everyone could have won.
(Although, to be fair, I would not be surprised to see an uptick in traffic for fantom.org this week based on the number of people posting "Hey, wait a minute..." on Twitter, Facebook, G+, etc.)
brian Wed 20 Jul 2011
I think the emergence of yet another JVM language deserves a blog posting (one coming...)
Although I think a direct response to what Fantom lacks compared to Kotlin is warranted (along with some other comments):
Yes I think this is good, and I've talked about adding this to Fantom in the same style as C# did
I do like this and I believe Gosu has it too. But at the same time I am not sure it warrants a new feature when mixins pretty much solve the same problem.
Obviously a controversial topic :-) But based on forum discussion and the general thoughts of community, I think user defined generics will be added to the platform. I am planning to renew discussion after fanr is up and running (which I considered a more important part of the platform).
Don't see how this is any better than C/Java style
cond ? t : f
expressionI think Fantom has hit the sweet spot here. We have great compile time annotations and checks which is a giant leap up from languages like Java/C#. But I don't think we have taken the point of being annoying (only extensive use can determine this fuzzy line).
I think implicit casting under
if (x is Foo)
is probably a useful feature, but not really a fundamental semantic issue. I think bigger issue is basic philosophy of the role of the type system (which I think Fantom and Kotlin are miles apart on)More of a syntax sugar feature than a core language thing. I don't think we have talked it about it much on forum which is why think it has never received a lot of attention.
I think having primitives in the language is bad - it creates a very complicated disjoint type system. That said, I think Fantom library that has optimized stuff for math usage would be great.
I think I saw there were going to add something like C# dynamic type. Although I have blogged about that before - I think Fantom's approach is better than the C# design.
Yes likely this language have great tooling in IDEA. Luckily we already have pretty good Eclipse and NetBeans support already :-) But tooling will continue to be a critical aspect of Fantom's success.
DanielFath Wed 20 Jul 2011
Yeah, I kinda miss the
do{}while
. Using break to escape out ofwhile
loop is so... outlandish :P As for delegation and other things. I admit I kinda likeif else
as expression but in all seriousness it would just replace ternary operator and add more verbosity.Not sure if Brian would be up for such a tradeoff. Not to mention they somewhat hard to read
Case matching was actually rather interesting, but I can definitely see a few hurdles - if switch returns multiple types what type it is? Or what if there are multiple matches (I'm assuming the topmost is processed first)? But other than tat there isn't a reason we couldn't use
in
keyword as a shortcut for contains (like list, range etc.)As for extensions, Brian was talking about them, he wants them in, just not sure in what way or form or when
Personally my feature list for Fantom would go like this
and
,or
,xor
methods into respective same name operatorx.or(y.and(z.shift(2))) instead of x or (y and z.shift(2)) Also I found the
open class/class' quite consistent with their stance onvirtual/override
i.e. all classes arefinal
by default and all fields are non-virtual by default.MoOm Wed 20 Jul 2011
@brian
Agreed, it looks a lot like mixins. The only advantage I can see is if you want to change implementation at runtime (which might be handy for mocking in unit-tests)
Problem with ternary expression is that the operands have to be a simple expression. Now if I want something more complex, I'm stuck with the if/else statement, which does not work well with non-nullable variable and type-inference. Let me give you an example:
In this case, in Fantom, I have to declare
displayName
as nullable and I can't use type-inference. If "if/else" was an expression, I could write:The nullable part could be solved with definite assignment analysis, which would definitely work for me and would be a more-generic solution than the if/else expression thing.
Sorry, I didn't mean "primitive types" but "value types". As I've already said, I think that not having Int32/Int16/Int8/Float32/Char types and native arrays in Fantom is what I miss the most from Java. As soon as you need to write some optimized code, you need to implement native methods, which makes you loose platform-indepedancy.
If we had these in Fantom, I guess that a large part of the
sys
pod could be written directly in Fantom which would be great for portability.On the other points, I agree with you.
@DanielFath
I think this would come for free as soon as we have generics.
The
open
keyword is probably one of the feature I dislike the most about Kotlin. But I guess this feature can only work with a language supporting extension functions.DanielFath Wed 20 Jul 2011
@MooM
I'd prefer if they had proper syntax. Something like
(1,2,3)
for Tuples and{{ 1,2,3 }}
for Sets. Brian had some idea about sets being some kind of Unique lists, but I don't know if theoretically that is possible since Sets shouldn't be sorted.