Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 10
 1 
 on: 2017-11-23 23:42:15 
Started by Zeldar - Last post by h.pernpeintner
I think missing operator overloading and extension functions is a remarkable plus in favor of Java.
I think those are two Bad examples for your otherwise probably correct view. The operator overloading in kotlin is also known as "Sane" operator overloading and can make your and your reader's live really much easier while it doesn't support the ugly stuff. Extension functions basically the same thing, no magic here.

The confusing thing is probably the functional style method chaining (lets be honest, most of the functional stuff ist bad from a typical Java programmer's point of View) in combination with those implicit receivers kotlin has where you "have multiple this". One should not overuse Any feature Just to make the code less symbols for the Sake of it. Nevertheless powerful tools for many situations where you can improve readabiliy a lot with them.

 2 
 on: 2017-11-23 22:40:57 
Started by Zeldar - Last post by KaiHH
Exactly. Code should be understandable by a sub-mediocre (your 9-to-5-don't-want-to-learn-new-stuff sort of) developer, since that is what the vast majority of the companies owning that code will have to work with.
You certainly DO NOT want any "cleverness" in your code which only you will be able to wrap your head around in a reasonable amount of time.
That is why I probably will never use Kotlin on a customer's site. Just like JavaScript it provides sooo many opportunities to have "cleverness" sleak its way into your code and have people tinker about how they would cleverly design every single code line. And then you are basically screwed.
Java has a very good way of giving you not many opportunities to be clever and to make your code less understandable. I think missing operator overloading and extension functions is a remarkable plus in favor of Java.

 3 
 on: 2017-11-23 22:09:19 
Started by Zeldar - Last post by Sickan
I prefer dumb code. Smart code requires brainpower to read and write. Dumb code is understandable at 12 AM, and that's what matters Wink

 4 
 on: 2017-11-23 17:32:38 
Started by elect - Last post by elect
And we also got it other languages, at least for the display part


 5 
 on: 2017-11-23 17:07:20 
Started by Zeldar - Last post by fenaryh
If you're using a Stage, I think you can use the class Actions.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
float numberOfSecondsToWait = 2.f //or any other number

Actions.delay(numberOfSecondsToWait, Actions.run(new Runnable({
       
       @Override
       run(){

              //your code here

       }

}));


But if your Action is really an Action, so you just need to call there:


1  
Actions.delay(numberOfSecondsToWait, Actions.yourAction());

 6 
 on: 2017-11-23 15:59:19 
Started by Zeldar - Last post by h.pernpeintner
Slowly you start giving people reasons to hate Kotlin again xD

 7 
 on: 2017-11-23 14:25:51 
Started by Zeldar - Last post by Zeldar
By adding two typealiases
1  
2  
typealias FontGen = FreeTypeFontGenerator
typealias FontPar = FreeTypeFontParameter

and by having a shorter method name (generateFont -> newFont) I can now have this
1  
2  
3  
private fun newFont(fontPath: String, params: FontPar.() -> Unit) = with(FontGen(Gdx.files.internal(fontPath))) {
    generateFont(FontPar().params()).also { dispose() }
}

 8 
 on: 2017-11-23 13:53:56 
Started by Zeldar - Last post by Zeldar
Oh nice one !  Smiley

 9 
 on: 2017-11-23 13:46:59 
Started by Zeldar - Last post by elect
Wanna play?
1  
2  
3  
4  
private fun generateFont(fontPath: String, params: FreeTypeFontParameter.() -> Unit) = 
    with(FreeTypeFontGenerator(Gdx.files.internal(fontPath))) {
        generateFont(FreeTypeFontParameter().params()).also { dispose() }
    }



 10 
 on: 2017-11-23 13:13:41 
Started by Zeldar - Last post by Zeldar
I think we can simplify even further the method
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
    }


to

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

        return generator.generateFont(parameter).also { generator.dispose() }
}


I'm pretty sure it works but I'm not home so I can't test rn

EDIT: After testing on the online compiler, this seems to work, and
1  
return generator.generateFont(parameter).also { generator.dispose() }

can even be replaced by
1  
return generator.generateFont(parameter).apply { generator.dispose() }

Pages: [1] 2 3 ... 10
 
xxMrPHDxx (21 views)
2017-11-21 16:21:00

xxMrPHDxx (14 views)
2017-11-21 16:14:31

xxMrPHDxx (16 views)
2017-11-21 16:10:57

Ecumene (114 views)
2017-09-30 02:57:34

theagentd (150 views)
2017-09-26 18:23:31

cybrmynd (260 views)
2017-08-02 12:28:51

cybrmynd (250 views)
2017-08-02 12:19:43

cybrmynd (247 views)
2017-08-02 12:18:09

Sralse (260 views)
2017-07-25 17:13:48

Archive (881 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!