Live data from Hacker News

Kotlin 1.0.5 is here

blog.jetbrains.com

61–70 of 111 posts

Re: Kotlin 1.0.5 is here

#61

Earlier quoted context omitted.

Yeah, I only included the link as a proof that we're actually using Kotlin in production :) 1. Kotlin issues: - Libraries that use reflection (such as Gson) can break some assumptions that Kotlin makes (for example, a read-only field may actually change). There's maybe 2 or 3 little things like that that may catch you by surprise, but once you figure them out it's easy to work around them. - Stack traces in lambdas a…

Also, using it with RoboGuice is a bit annoying. At the moment I use vals, but it still requires me to mark injected dependencies as nullable (and coerce them with !! on use), which feels like I'm fighting the type system. It would be really nice if there was some sort of "special" null that was of the non-nullable type, but could only be used when initializing variables.

People still use RoboGuice?

Re: Kotlin 1.0.5 is here

#62
post #42

Earlier quoted context omitted.

Er, you're eschewing Kotlin despite it's being open source because of your perception that it's controlled by a corporate entity, but in the same post you want it supported in another open source product (VS Code) backed by another corporate entity (Microsoft)?

>" Er... " VS Code is miles ahead of Jetbrains offerings and has no yearly subscription fee. MS was indeed one of my least favorite companies half a lifetime ago, but they've changed business models and are now pursuing a growth strategy (particularly wrt services) and have abandoned the fight to capture consumer surplus at all costs.

So charging for an IDE which requires hundreds of thousands of man hours of development and maintenance means they're evil and you won't use their products, open source or otherwise? Got it.

Re: Kotlin 1.0.5 is here

#63

Earlier quoted context omitted.

Yeah, I only included the link as a proof that we're actually using Kotlin in production :) 1. Kotlin issues: - Libraries that use reflection (such as Gson) can break some assumptions that Kotlin makes (for example, a read-only field may actually change). There's maybe 2 or 3 little things like that that may catch you by surprise, but once you figure them out it's easy to work around them. - Stack traces in lambdas a…

Also, using it with RoboGuice is a bit annoying. At the moment I use vals, but it still requires me to mark injected dependencies as nullable (and coerce them with !! on use), which feels like I'm fighting the type system. It would be really nice if there was some sort of "special" null that was of the non-nullable type, but could only be used when initializing variables.

[deleted]

Re: Kotlin 1.0.5 is here

#64
post #38

Earlier quoted context omitted.

I don't really get that. Kotlin is open source. You can write and compile Kotlin code without paying JetBrains a penny, it's not hard. There's even an Eclipse plugin - written by JetBrains. I'm not sure what more is required to make it truly open.

What non-Jetbrains IDE supports Kotlin well? What % of its contributions come from outside the Jetbrains ecosystem? Once Jetbrains no longer controls Kotlin's future and most Kotlin users are not Jetbrains customers, then I'd consider it truly open.

I think you're confusing language openness with freedom of choice for consumption.

Re: Kotlin 1.0.5 is here

#66
post #9

I have became a 100% Kotlin convert. Every single project I work on now is using Kotlin. I have also found that if you are using LibGDX Java game framework, it's very trivial to convert it to Kotlin. I have been doing that pretty extensively and it has been very pleasant. Feel free to check my GH for some examples. Most notably, the Bayesian Classifier. Also be sure to check out the Kotlin slack room. It is filled wi…

On the topic of using the JVM to make games, do you find yourself using the trick of not allocating any new objects (wither from Java or Kotlin) within the game loop? I've heard of that trick, and am considering using it because GC pauses are the main reason I'm considering avoiding the JVM for games.

Have worked on many games and game engines for several decades. Here's some quick advice that applies mostly regardless of the JVM.

1. Allocations of any kind are often the most expensive operation per frame, or at least some of the ones that are fixable (you can't just not have physics in some games). As such, avoid allocations per frame.

2. Notice transition screens, loading screens before levels, brief artistic animated overlays (things like ROUND 1 - READY!). These just aren't for fun or to hide just disk IO, they can actually be used as a time to do controlled allocations. Let's say you're doing a Metroidvania for instance - perfect time when changing areas to load new stuff.

3. Use fixed-sized data structures like arrays. Vectors, Lists, any kind of dynamically resizing data structures are generally your enemy. Sure you can use them in non-essential parts, but it's an easy thing most of the time. These help you control the amount of allocations, and moreover ensure that your game runs predictably, especially when pushed hard. You shouldn't be letting your game get into insane states that would allow allocating 5 billion bullet objects even if your vector and a machine with 64 gigs of rams can handle it. Obviously some exceptions, but there's sound reasoning.

4. Operate on fixed-sized data structures in sequence. It's harder on the JVM, but in most platforms you can start trying to use this to help the runtime optimize for you, or better yet, get things to fit nicely into cache lines. Things like "events" and "callbacks" may seem helpful, but they are actually your enemy, even on the JVM. You are better off using a queue or mailbox approach if you need more performance and less GC surprises.

5. Pool. But don't just pool and allocate, make sure you are pooling efficiently. On some platforms, this means tightly packed structures with no holes. One cheat you can do is actually use an ID system and work with that to index into an array-based pool by getting via index instead of a search. Using dicts/maps for this is the wrong approach for so many reasons. There's an older GDC presentation about this somewhere I can't remember, but it talks about this in relation to entity systems and uses the term prius a lot. Free list might be something else on your google for this.

6. Pack your textures when you can. Do things like use a sprite sheet. It's not just the GC pauses that are the enemy on the JVM, but also hitting the file system. This will help reduce it at the cost of potentially more memory for a single texture.

7. Don't go wild with classes. Try a data-based approach. This cuts down on GC and is the basis for some flexible architectures like entity systems. Of course you may still need classes as containers if you are using Java, but you'll end up with less ugliness and perhaps less classes and instantiations of those classes this way.

8. Check out your JVM flags and tweak things more if you must. Check out https://docs.oracle.com/cd/E40972_01/doc.70/e40973/cnf_jvmgc... for an example. Not the best guide, but my first google hit to just demonstrate. On a semi-related note, don't do stupid stuff like reflection or dynamically load in things that are just going to make the JVM angry. Simple is better than clever here.

9. Use a good time step for your game loop where you separate your sim time. It doesn't necessarily fix GC pauses, but it does ensure that if things are running slow you can respond and interpolate.

10. Related to the last point, try to do more per frame and don't assume all work is the classic game loop of render per tick. Naughty Dog did an interesting presentation on The Last of Us port to PS4 you can read about where they talk about optimizing the way they process frames. If your game permits similar approaches, it gives you a chance to squeeze out some performance this way.

I have many more tips, but this is just off the top of my head. Some of these might seem like micro-optimizations, but they actually end up shaping your game's architecture so it is definitely important to think about it early if you are serious about not putting yourself in a performance corner.

You can certainly develop games on the JVM. I personally don't recommend it unless it's for pleasure. C or C++ is still the way to go. I am sure you can have fun with Rust too doing it, but there's just so much ecosystem and people talent tied up in the former choices that it effectively makes anything else far behind. That said, you can write a good game in any language, and if you are just sane about your game it will be fine. Even with GC pauses, for some type games, ex: strategy that isn't real-time, your users would barely notice and it wouldn't effect gameplay. In short, be pragmatic no matter the language, stick to some of the above, and enjoy yourself and just get it built. Language is the least of your worries in the end, but still worth paying attention to on some level.

Re: Kotlin 1.0.5 is here

#67
post #42

Earlier quoted context omitted.

>" Er... " VS Code is miles ahead of Jetbrains offerings and has no yearly subscription fee. MS was indeed one of my least favorite companies half a lifetime ago, but they've changed business models and are now pursuing a growth strategy (particularly wrt services) and have abandoned the fight to capture consumer surplus at all costs.

So charging for an IDE which requires hundreds of thousands of man hours of development and maintenance means they're evil and you won't use their products, open source or otherwise? Got it.

No. I honestly can't tell if you're trolling or not at this point, but "Er" is a horrible way to open a comment. Assigning a strawman position to someone you disagree with is equally horrible.

I've gladly purchased Jetbrains products in the past (and other dev tools as well). Noticing that a company is intent on capturing all consumer surplus they possibly can and disliking them for it is not the same as deciding they're "evil" for charging anything to begin with. Before moving to their subscription / hostageware "pay up or be forcibly downgraded model", I happily broke out the credit card and paid for Jetbrains offerings. I don't begrudge them that they sell software.

They just got too greedy and consumer backlash like this is the inevitable result.

Re: Kotlin 1.0.5 is here

#68
post #38

Earlier quoted context omitted.

What non-Jetbrains IDE supports Kotlin well? What % of its contributions come from outside the Jetbrains ecosystem? Once Jetbrains no longer controls Kotlin's future and most Kotlin users are not Jetbrains customers, then I'd consider it truly open.

I think you're confusing language openness with freedom of choice for consumption.

I think you're confusing deduction with speculation. I'm fully aware of the difference between language openness and "freedom of choice for consumption". I just don't agree with the wisdom in tying my workflow to a company like Jetbrains.

Re: Kotlin 1.0.5 is here

#69
post #9

Earlier quoted context omitted.

On the topic of using the JVM to make games, do you find yourself using the trick of not allocating any new objects (wither from Java or Kotlin) within the game loop? I've heard of that trick, and am considering using it because GC pauses are the main reason I'm considering avoiding the JVM for games.

Have worked on many games and game engines for several decades. Here's some quick advice that applies mostly regardless of the JVM. 1. Allocations of any kind are often the most expensive operation per frame, or at least some of the ones that are fixable (you can't just not have physics in some games). As such, avoid allocations per frame. 2. Notice transition screens, loading screens before levels, brief artistic an…

Thanks for this awesome comment. Agree with everything you said. This could probably make a nice blog post. :)

Re: Kotlin 1.0.5 is here

#70

Earlier quoted context omitted.

Why not use Xamarin? it has a better lenguaje (C#) and is free.

Probably because IntelliJ is a superior IDE, Kotlin is a better language than C# and Xamarin apps look and perform like ass.

I like both, but why do you consider Kotlin better than C#?

I also don't get your point about how lame Xamarin apps look. Xamarin apps use native layout components (could be wrapped with lowest common denominator abstractions in case of Xamarin.Forms, but it's optional), so they're 100% capable of looking the same way your native app would.

Post reply on HN