Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 3 4 [5] 6
  ignore  |  Print  
  Move to Kotlin?  (Read 29017 times)
0 Members and 1 Guest are viewing this topic.
Offline nsigma
« Reply #120 - Posted 2017-11-16 09:34:45 »

Man did I really not mention that virtual type rendering from the IDE? I should have.

@spasi did.  I personally like var / val, but I think you're missing the point others were making - a language shouldn't need a specific IDE to be adequately grokked (it's like there's a link between Kotlin and Intellij or something!  Grin )


Nice!  Does remind me of one thing I really dislike though - I hate removal of
new

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #121 - Posted 2017-11-16 10:13:17 »

I don't mind the removal of new at all but I find myself asking, why do we even need the var / val keywords? BASIC never needed them for starters, and what is the purpose of const when you've got val? Or does const mean "immutable"?

Switching on types the "java way" would bother me because it's asking for maintenance woes later on. Add a class and boom! The only recourse you have is a default case. What switching on types needs is a construct that looks exactly like try/multi-catch.
1  
2  
3  
4  
5  
6  
switch (clazz) {
case Camera | Light: // Union type
...
case RootNode:
...
}

or somesuch.

Cas Smiley

Offline CoDi^R
« Reply #122 - Posted 2017-11-16 10:27:21 »

a language shouldn't need a specific IDE to be adequately grokked (it's like there's a link between Kotlin and Intellij or something!  Grin )

I beg to differ. I started to look into building some small DSL with Kotlin, and I find it incredibly helpful to get that much assistance.

Robotality - steamworks4j - @code_disaster - codi^r @ #java-gaming
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline elect

JGO Knight


Medals: 60



« Reply #123 - Posted 2017-11-16 10:34:48 »

a language shouldn't need a specific IDE to be adequately grokked (it's like there's a link between Kotlin and Intellij or something!  Grin )

Kotlin wins over Scala (and Clojure) also (or I'd say especially) because of this

You never had, in the computer programming history, a brand new language with a first class IDE support.

Be careful to not underestimate it, an excellent support decreases the learning curve, easiers the usage and helps learning it fast.

That's why I think Kotlin will emerge, because Jetbrains has the whole pipeline under his hands: from the IDE to the language, that's really powerful and incredible if you think about it.

I don't mind the removal of new at all but I find myself asking, why do we even need the var / val keywords? BASIC never needed them for starters, and what is the purpose of const when you've got val? Or does const mean "immutable"?

Switching on types the "java way" would bother me because it's asking for maintenance woes later on. Add a class and boom! The only recourse you have is a default case. What switching on types needs is a construct that looks exactly like try/multi-catch.
1  
2  
3  
4  
5  
6  
switch (clazz) {
case Camera | Light: // Union type
...
case RootNode:
...
}

or somesuch.

Cas Smiley

Princec, seriously, this continuous rant (no offense, eh) doesnt bring any of us anywhere  Wink

If you want to evaluate Kotlin honestly, you should simply try it.

Because judging if a language will suit you without trying is, I repeat, quite pointless.

And I repeat, dont lose yourself the possibility to learn something you could fall in love with.

Invest some of your time, you wont regret. In the best case, you'll come back to us thanking on your knees  Cheesy, in the worst case, you would have lost only some of your time.

Don't you think is it worth giving it a try?
Offline elect

JGO Knight


Medals: 60



« Reply #124 - Posted 2017-11-16 10:57:05 »

And btw, you have the perfect candidate for that test, princec: your parser.

Give it a try, convert it to Kotlin and have fun  Smiley
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #125 - Posted 2017-11-16 11:02:50 »

I know there's a ton of support for Kotlin but seriously, I'm more interested in Ceylon, which I find to be far less jarring and different for different's sake.

Cas Smiley

Offline nsigma
« Reply #126 - Posted 2017-11-16 11:04:24 »

a language shouldn't need a specific IDE to be adequately grokked (it's like there's a link between Kotlin and Intellij or something!  Grin )

I beg to differ. I started to look into building some small DSL with Kotlin, and I find it incredibly helpful to get that much assistance.

That noise was the point swishing past your head!  Wink  Yes, IDE's exist to make life easier, no doubt about that.

You never had, in the computer programming history, a brand new language with a first class IDE support.

a ha ha ha ha ... hubris ... Smalltalk comes to mind for a start, had this in the 70s!

... because Jetbrains has the whole pipeline under his hands: from the IDE to the language, that's really powerful and incredible if you think about it.

So does (did) Snoracle with Java!  But having other peoples' solutions around too is a healthy thing.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #127 - Posted 2017-11-16 11:14:00 »

Musing anecdote: the reason I got into Java so fast and wholeheartedly is that I found myself in a contract where they were using IBM VisualAge... the precursor to Eclipse. And originally developed for SmallTalk.

Cas Smiley

Offline Sickan
« Reply #128 - Posted 2017-11-16 11:20:00 »

It's a shame Ceylon is so underused, I really like union and intersection types. Ceylon's approach to null safety is years ahead of Kotlin's, but I suppose Kotlin has a gentler learning curve.

For what it's worth, here's an example of using LWJGL in Ceylon: https://github.com/gavinking/ceylon-examples-lwjgl/blob/master/source/eg/lwjgl/run.ceylon
Offline elect

JGO Knight


Medals: 60



« Reply #129 - Posted 2017-11-16 11:21:09 »

Ok ok, I went too far, let's say than since what.. 2000? I'm too young for you guys ^^
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #130 - Posted 2017-11-16 11:46:15 »

It's worth mentioning that Ceylon has first-class language support in Eclipse. And IMO is much easier to come to from Java than Kotlin as it remains lexically very similar.

Cas Smiley

Offline Spasi
« Reply #131 - Posted 2017-11-16 12:30:57 »

Sounds like there's a correlation between people liking/disliking Kotlin and choice of favorite IDE.

Ceylon's approach to null safety is years ahead of Kotlin's

I'm curious to learn more, please explain.
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #132 - Posted 2017-11-16 12:39:34 »

Sounds like there's a correlation between people liking/disliking Kotlin and choice of favorite IDE.
See also: the suspicious schism that exists between Java and C# amongst Visual Studio programmers.

Cas Smiley

Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #133 - Posted 2017-11-16 12:40:14 »

https://blog.jooq.org/2016/03/15/ceylon-might-just-be-the-only-language-that-got-nulls-right/

Cas Smiley

Offline Spasi
« Reply #134 - Posted 2017-11-16 12:53:29 »

That article doesn't say anything about how Ceylon's null handling is better, in practice. It's implemented with union types, which Kotlin does not support. What does that get me?
Offline elect

JGO Knight


Medals: 60



« Reply #135 - Posted 2017-11-16 12:56:17 »

In Kotlin you may actually simulate union by custom setter and getter
Offline h.pernpeintner

JGO Ninja


Medals: 106



« Reply #136 - Posted 2017-11-16 13:10:27 »

If you ask the Scala guys, Optional is the only answer to nullability, if you ask C++ guys they start explaining you the differences between references and pointers, if you ask Ceylon people, they start talking about how great union types are....

The point is: Union and intersection types may be an elegant construct, that Kotlin lacks. Some claim that - like strucutral typing - the chance is high that this feature harms your codebase, because you lose track of your class hierarchy over time (of course, only the others do ...). Fixing an existing, crappy API from someone else is very nice with this feature though, that's probably the reason why TypeScript has it Tongue I don't know in which situations Ceylon's solution would be better than Kotlin's, but when writing extension functions, it's very convenient to be able to type Type?.bla() instead of something like (NULL|Type).bla(). Can anyone tell what Ceylon code looks like from Java when union types are used? I doubt it will say Object, but does it search for the most specific common superclass of all types?

EDIT: Or can you use String? as a shortcut for NULL|String literally everywhere in Ceylon?
EDIT2: AFAIK Ceylon makes heavy use of their own metafile-based implementation of reified generics, for example to make variance with this type system usable. I guess that this is pretty imperformant, so one of my first questions would be if using nullable type in Ceylon harms performance.
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #137 - Posted 2017-11-16 13:29:53 »

Yes, String? is shorthand for String | Null.

The devil is in the details but I think Ceylon is currently still the design winner.

Cas Smiley

Offline phunni

Senior Newbie


Exp: 17 years



« Reply #138 - Posted 2017-11-16 14:45:20 »

How flexible is Kotlin in terms of coding styles/approaches etc.?  What I mean is - is there any pressure to design your code in a particular way?

One of the things I found most vexing about .Net was that it forced me to take a particular approach to the flow of my application.  For example, if I were writing a web application, in Java I tended to make one page submit to a second page to process the data and render a response.  .Net pushed very hard to get me to make pages submit to themselves. I think it may have been possible to get it to work the way I wanted to, but it wasn't easy.  There was an attribute you could set that was supposed to do it, but the framework was so wired to work in a particular way that changing that attribute wasn't enough.

Anyway, what I'm getting at with all of this is will Kotlin allow me to design my applications the way I want, or does it push you to use certain patterns/approaches/mindsets?
Offline princec

« JGO Spiffy Duke »


Medals: 1060
Projects: 3
Exp: 20 years


Eh? Who? What? ... Me?


« Reply #139 - Posted 2017-11-16 14:52:56 »

That's nothing really to do with the language or even platform at all, but all about what APIs you're using.

Cas Smiley

Offline h.pernpeintner

JGO Ninja


Medals: 106



« Reply #140 - Posted 2017-11-16 15:25:02 »

Anyway, what I'm getting at with all of this is will Kotlin allow me to design my applications the way I want, or does it push you to use certain patterns/approaches/mindsets?

As princecc said, it's mostly about the framework and API you are using, how you have to do the architecture of your application. There are some limiations/common workarounds for problems other platforms don't suffer that are related to the JVM, but I won't emphasize this too much now.

As for your question: Yes, you are totally free, within the bounds of Kotlin of course. Since Kotlin is a objectfunctional language at its core, you have the well-known foundation of object orientation. Additionally, there are first class functions and a strong std lib for functional stuff. If you want to design your application in a very pure functional way, than there might be better alternatives out there. Even if you always want to use the most complex programming patterns to solve every problem with absolute perfection...than maybe the whole JVM is not your best choice. If you only talk about web frameworks, with Kotlin you can pretty much use everything Java can use, so you have concepts like function as a server, servlet apis, spring for good old mvc applications, Sinatra-like web frameworks...and Kotlin is very useful for DSL stuff, if you would want to be that flexible.
Offline h.pernpeintner

JGO Ninja


Medals: 106



« Reply #141 - Posted 2017-11-16 15:43:08 »

what is the purpose of const when you've got val? Or does const mean "immutable"?

Const indicates a compiletime constanct. For example you could share a String between annotations, which isn't possible in Java. Shamelessly taken from the Kotlin docs:
1  
2  
3  
const val SUBSYSTEM_DEPRECATED: String = "This subsystem is deprecated"

@Deprecated(SUBSYSTEM_DEPRECATED) fun foo() { ... }


To prevent the next question Smiley : Const is a soft keyword that has a meaning in a context. It can't stand alone and isn't a reserved keyword in that meaning.
Offline nsigma
« Reply #142 - Posted 2017-11-16 21:18:42 »

For example you could share a String between annotations, which isn't possible in Java.

What makes you think you can't use String constants with annotations in Java?

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline h.pernpeintner

JGO Ninja


Medals: 106



« Reply #143 - Posted 2017-11-16 23:22:40 »

You are right, i was confused here. What does const actually do at all Cheesy someone knows?

Edit: ah okay, const is used to not let the value become a property i think.
Online cygnus
« Reply #144 - Posted 2017-11-17 01:33:57 »

Quote
Edit: ah okay, const is used to not let the value become a property i think.
?
It just means the value of the statement is determined at compilation time and thus is able to be used in other things that are determined at compilation time, like annotations.
Offline h.pernpeintner

JGO Ninja


Medals: 106



« Reply #145 - Posted 2017-11-17 08:13:15 »

Yes, that's clear, but what would be the reason to it not just be a val, if val is final too? I think it's because val and var are always properties and there are not field semantics, don't you think?
Online cygnus
« Reply #146 - Posted 2017-11-17 19:15:28 »

They are both final but val is not given a value at compile time, whereas const is, so you can't use a non const val in an annotation (or another similar application). I'm not sure what you mean by field semantics, too :p
Offline Zeldar
« Reply #147 - Posted 2017-11-23 10:03:00 »

Well I moved to Kotlin about 2 weeks ago and I certainly don't regret it ! Just look at this method I made to create BitmapFonts

1  
2  
3  
4  
5  
6  
7  
8  
9  
    private fun generateFont(fontPath: String, params: FreeTypeFontParameter.() -> Unit): BitmapFont {
        val generator = FreeTypeFontGenerator(Gdx.files.internal(fontPath))
        val parameter = FreeTypeFontParameter().apply { params() }
        val result = generator.generateFont(parameter)

        generator.dispose()

        return result
    }

Now with this method I can elegantly create fonts objects like so
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
val fontTitle: BitmapFont = generateFont("Jukebox_HUD/Franklin Gothic Book.ttf") {
        size = 14
        color = Color.RED
        borderColor = Color.BLACK
        borderWidth = 0.4f
}

val fontDirectory: BitmapFont = generateFont("Jukebox_HUD/Franklin Gothic Demi Cond.ttf") {
        size = 18
        color = Color.BLUE
}


Ok the string parameter may not be elegant (enum would be better I guess) but you get the point of what I want to show !
Offline h.pernpeintner

JGO Ninja


Medals: 106



« Reply #148 - Posted 2017-11-23 11:53:09 »

Very nice indeed Smiley

I think you could change
1  
val parameter = FreeTypeFontParameter().apply { params() }

to
1  
val parameter = FreeTypeFontParameter().params()


The extension function is available via dot notation on any instance of the extension function's class Smiley
Offline Zeldar
« Reply #149 - Posted 2017-11-23 13:02:54 »

Very nice indeed Smiley

I think you could change
1  
val parameter = FreeTypeFontParameter().apply { params() }

to
1  
val parameter = FreeTypeFontParameter().params()


The extension function is available via dot notation on any instance of the extension function's class Smiley

Oh right ! I'll test that tonight !
Pages: 1 ... 3 4 [5] 6
  ignore  |  Print  
 
 

 
hadezbladez (336 views)
2018-11-16 13:46:03

hadezbladez (180 views)
2018-11-16 13:41:33

hadezbladez (336 views)
2018-11-16 13:35:35

hadezbladez (83 views)
2018-11-16 13:32:03

EgonOlsen (2177 views)
2018-06-10 19:43:48

EgonOlsen (2205 views)
2018-06-10 19:43:44

EgonOlsen (1378 views)
2018-06-10 19:43:20

DesertCoockie (2011 views)
2018-05-13 18:23:11

nelsongames (1655 views)
2018-04-24 18:15:36

nelsongames (2300 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!