ByteCode.News
Submit RSS Atom Sign in

Back to the channels

#java

  1. dreamreal morning
  2. pengu1nx Hello, can someone recommend me a library to use for a game?
  3. dreamreal what kind of game, what kind of library are you needing
  4. dreamreal I guess the actual answer to your question is "maybe"
  5. pengu1nx Open to the kind of game, it should have a simple API and be cross platform (Linux/Mac/Windows) though
  6. dreamreal What kind of API
  7. pengu1nx To use the library, no?
  8. dreamreal I mean, you can write simple games with pure java, no library at all
  9. dreamreal nevet has hangman, 21 matches, safecracker built in and they could be done with console
  10. dreamreal no library at all
  11. pengu1nx I meant with a UI though, not CLI
  12. dreamreal so I don't know what you'd use the library FOR. Window control? (Why? JavaFX and Swing are built-in.) OpenGL? There are opengl libraries for java, designed for games, but you haven't said you needed one. Is multiplayer a concern?
  13. dreamreal See what I mean? You asked a VERY open-ended question :D Now at least we have a clue you mean something with a UI
  14. pengu1nx Multiplayer isn't a concern, I suppose OpenGL would be ideal
  15. dreamreal ~lwjgl
  16. javabot dreamreal, lwjgl is the Lightweight Java Game Library (lwjgl.org). [LWJGL] is a solution aimed directly at professional and amateur Java programmers alike to enable commercial quality games to be written in Java. It provides direct access to crossplatform libraries such as OpenGL and OpenAL, as well as controllers such as Gamepads,Steering wheel and Joysticks.
  17. dreamreal ~javafx
  18. javabot JavaFX, or OpenJFX, is a set of APIs for writing rich client applications in Java. It's more fully-featured and capable than Swing. For more information see https://openjfx.io . To get started, simply add as a dependency in your build script: https://openjfx.io/openjfx-docs/#maven . Also see ~scenebuilder
  19. nevet https://openjfx.io "JavaFX" || https://openjfx.io/openjfx-docs/#maven "Getting Started with JavaFX"
  20. pengu1nx I'll check it out, thanks
  21. pengu1nx lwjgl references libGDX, is that just a sorta extension?
  22. dreamreal it's the underlying library that provides the opengl access
  23. dreamreal it's cross-platform, if minecraft can run on your systems, you're good
  24. dreamreal note that javafx might be just as good
  25. dreamreal I can't give you a whole lot of information beyond this, though: I don't do opengl stuff, so my experience is quite limited here
  26. dreamreal others may be able to fill in the gap
  27. pengu1nx I see, regarding a build system, it seems Maven and Gradle are the two big ones. Which one would you say is easier to learn?
  28. Para lwjgl is moving to vulkan, I think, so that's going to be an option possibly as well
  29. Para Best part is that you as developer probably don't have to care.
  30. dreamreal I'd say maven between the two
  31. dreamreal gradle's more expressive but harder to predict
  32. dreamreal maven's mostly copy-paste to get it to work: it's verbose but ^C/^V is SOOOOO hard
  33. pengu1nx Expressive as in the configs contain less keywords?
  34. pengu1nx Like strange keywords
  35. Bombe Also, don’t “learn” build systems. Use them, pick up what you need, be done.
  36. Bombe The optimal amount of time spent on a build system is 0.
  37. pengu1nx To pick up what you need one still has to learn about it
  38. Bombe Yeah, in the same way that you have to “learn” a website in order to find the “download” button.
  39. pengu1nx Not really, if something doesn't work or if you have to use it more often then you have to understand it better, you can't just keep resorting to copy pasting
  40. Bombe Right, but you don’t do that before you work on a project. Same way you don’t read about all the ways a website can offer a navigation menu before you want something from that site.
  41. dreamreal pengu1nx: a gradle build is typically MUCH shorter than an equivalent maven build. But the FIRST thing you learn as a gradle user is "lock down the version did you lock down the version OH GOD LOCK DOWN THE VERSION KILL IT WITH FIRE" because gradle's publicly not committed to version stability
  42. dreamreal if you USE the reasons you'd use gradle, you're engaging with specifics that are not guaranteed to be constant from version to version
  43. pengu1nx That is interesting, thanks.
  44. dreamreal gradle is great as long as you work with it. It's got a good blend of convention vs configuration (you can configure it in ways that maven makes "interesting") and if you NEED to do that, well, there you are!
  45. dreamreal But MOST builds don't need it; developers choose gradle because they have a build file with 40 lines instead of 180 that they copy-pasted
  46. dreamreal and maven developers get SURPRISED when a build fails due to maven changing; gradle developers don't get those surprises because they've got scars that remind them to LOCK DOWN GRADLE VERSIONS WITH THE WRAPPER
  47. dreamreal and a lot of maven users don't even know it HAS a wrapper
  48. Tenchi ./mvnw wrapper:wrapper
  49. Tenchi for a long time i thought the maven-wrapper-plugin was needed in order to use maven wrapper, and i avoided maven wrapper because i thought it was a stupid chicken egg thing
  50. Tenchi after a long time of avoiding it and looking at how it actually worked, i THEN discovered the plugin's only used to generate the wrapper script if you don't already have it
  51. Tenchi 🤷‍♂️
  52. Tenchi dreamreal: do you still make use of fabrikt ?
  53. dreamreal not if I can help it. (Actually, no: that was for $work and getting it to work was proprietary: they didn't let me contribute back to the project.)
  54. dreamreal I think it's still usable if you constrain the inputs really tightly
  55. dreamreal how come?
  56. Tenchi i'm wondering if it's massively different than the last time i used it... like 2 years ago
  57. dreamreal I'm going to bet that's a pretty strong "no."
  58. dreamreal It's better than openapi-generator but that's a pretty low bar to have to clear.
  59. Tenchi i'm actually putting together a demo comparing openai generators against LLM-based code assistants heh
  60. dreamreal oh, my
  61. dreamreal Tenchi: would you, uh, do me a huge favor?
  62. dreamreal PM?
  63. Tenchi maybe haha
  64. Tenchi yeah you can PM
  65. Tenchi the frickin fabrikt docker image isn't even retrievable
  66. * Tenchi rolls up his sleeves and prepares to lay hands on gradle 🙄
  67. dreamreal I had to run it locally
  68. dreamreal and TBH I heavily modded it
  69. saml how can I interpolate JsonNode (jackson) to string template? interpolate("\{foo} \{bar}", jsonNode); jsonNode is supposed to be {"foo": "abc", "bar": 24, ...}
  70. Para Java doesn't really have string templates. Various formatter methods and such, sure.
  71. Tenchi https://velocity.apache.org/ 🤣
  72. javabot Tenchi's title: "The Apache Velocity Project"
  73. Tenchi "Velocity separates Java code from the web pages, making the web site more maintainable over its lifespan and providing a viable alternative to Java Server Pages (JSPs) or PHP."
  74. Tenchi ~php
  75. javabot Tenchi, php is the solution of choice for relaying mysql errors to web users. For more info, please read http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
  76. Para Velocity was kinda fun back in the day.
  77. saml yeah maybe i'm doing something wrong
  78. Para saml: Well, we don't know what you're trying to do so... :)
  79. saml wanted to create a new endpoint by adding a yaml file that has template string + json schema for input variables
  80. saml idea was no java code to add new functionality. just a yaml file
  81. saml POST /llm/php.yaml where php.yaml defines llm prompt, tools, input/output json schema
  82. Para JSON Schema for input variables? As in for the incoming request body?
  83. saml yup
  84. Para Why bother with YAML :P It's an ass format anyway.
  85. Para Now that that's been said, hm.
  86. saml configuration can be in json.. or whatever format. just wanted to let users add simple llm features easily without coding in java and recompiling
  87. jbosmans code-wise it doesn't sound too crazy, however i'd make "something" do generic json parsing for you to some object, so you can skip the low level parsing
  88. Para Jackson can do YAML as well, but as said, YAML is an ass format so it won't be convenient to use.
  89. jbosmans i tend to agree
  90. Para ~yaml
  91. javabot Para, yaml is short for YAML Ain't Markup Language and is a human friendly data serialization standard for all programming languages. See http://yaml.org for an explanation of the format, and http://bit.ly/1LZV5Zt for a library to marshall YAML into and out of POJOs. ~jackson also has a dataformat provider for yaml available.
  92. nevet - YAML Ain't Markup Language
  93. Para Heh, the bot hasn't been injected with opinions for that one.
  94. jbosmans it happens (?)
  95. Para https://github.com/cblp/yaml-sucks
  96. jbosmans imho yaml as primary input format sounds bad, it could be an input format "plugin"
  97. saml POST /llm/a.json {"user_id": 123} given this, and a.json has {"prompt": "find mcdonalds near user's house where user_id is \{user_id}", "tools": ...}
  98. jbosmans i guess i'd want something predictable
  99. Para Yeh
  100. Para Claude actually uses XML :D
  101. Para Because obviously the more structure you can introduce, the less guesswork and misses and weird undefined behavior you have.
  102. jbosmans nothing wrong with XML, a means to an end
  103. jbosmans exactly
  104. jbosmans saml, sounds good !
  105. jbosmans even if burger king > mcdo
  106. Para (other burger chain may be available)
  107. jbosmans :-D
  108. jbosmans saml, it sounds pretty simple on the java side
  109. jbosmans integration-wise, i'd say use something like spring ai or ..
  110. dreamreal What's the question?
  111. dreamreal What's being asked? Don't listen to morons!
  112. jbosmans i remember mashing up a stupid recipe app with structured data in like an hour iirc
  113. Para Some kind of superprompter 7000
  114. dreamreal wait, are you trying to TALK TO an llm, saml ?
  115. saml i'll try to use spring-boot-starter-thymeleaf. I'm constructing llm prompt. I was gonna use java21 string template. But that doesn't seem to easy to work with jackson json
  116. dreamreal saml: oh god
  117. dreamreal no
  118. jbosmans thymeleaf isn't relevant for llm interaction
  119. dreamreal saml: do not do this
  120. saml i'm using spring ai for llm part
  121. dreamreal okay, so... what does thymeleaf do here?
  122. jbosmans saml, thymeleaf is for generation html from whichever you'd want
  123. saml I have a config: {"prompt": "... {{user_id}} ..."} and user input {"user_id": 123} I want to interpolate
  124. jbosmans i guess you'd want a tool to tell you where the user is
  125. saml "foo {{user_id}} bar {{user_id}} baz" + {"user_id": 123} => "foo 123 bar 123 baz"
  126. saml I can change the variable syntax from {{user_id}} to whatever
  127. dreamreal saml: well, err... why not send the data to the tool per se
  128. jbosmans okay, so now it's just a string templating thing
  129. dreamreal this sounds like an intermediate incorrect solution, where the way you're working your way TO a solution is breaking it
  130. jbosmans which is pretty simple :-)
  131. Para As I understood it, saml wants to create an API which takes a bit of data describing a prompt with some variables (why not preformatted prompts, who knows), runs that through spring ai, and returns whatever. And a bit of schema to make the input and output have a known structure.
  132. saml yeah tool calling is done as well. but some variables are better be interpolated into the prompt instead of tool calling
  133. Para Which is...a lot, why not just grab ?prompt=eat+my+shorts but what am I to judge :)
  134. saml I'm building prompt template API (if it is a thing)
  135. jbosmans saml, it's just replacing things in a text, you could use a template engine or write it yourself
  136. saml instead of accepting any prompt, only taking parameters of existing prompt templates
  137. Para But if the user provides the prompt template, that doesn't really add anything?
  138. dreamreal ~template
  139. javabot Popular templating engines include ~thymeleaf, ~freemarker, ~qute, ~velocity, ~stringtemplate, ~pebble, ~rocker, and ~handlebars . ~jtwig exists but looks like it's unmaintained.
  140. Para Oh no, I can't do "sing {songname}", I'll just prompt "sing happy birthday" ...?
  141. dreamreal so you've got thymeleaf, why not populate the thymeleaf context with your JSON values, just iterate through as a map and interpolate
  142. jbosmans String template = "my name is _THIS_IS_MY_NAME_"; String result = s.replaceAll("_THIS_IS_MY_NAME_", "myActualName");
  143. jbosmans I'm thinking/hoping Pattern.quote() isn't needed here :')
  144. saml thanks i'll try these
  145. saml because copilot can't figure things out
  146. saml i wonder if claude code can fix my coading skillz
  147. * dreamreal mourns
  148. jbosmans well, today i cancelled openai and switched to anthropic
  149. jbosmans for reasons i was unaware of before a few days ago :)
  150. Para saml: LLMs can't really make you smarter if you don't know what to ask. You can't run before learning how to walk and all that.
  151. dreamreal saml: you're saying ... copilot can't figure out template interpolation in thymeleaf?
  152. Para Which of the 27 copilots even is this :P
  153. dreamreal ~gpt how do I populate a thymeleaf template from a map
  154. javabot To populate a Thymeleaf template from a Map in Java, you need to pass the Map object to the model of your Spring MVC controller. Then in your Thymeleaf template, you can access the values using Thymeleaf's ${...} expressions. Java: ```java @GetMapping("/template") public String getTemplate(Model model) { Map<String, String> map = new HashMap<>(); map.put("key1", "value1"); map.put("key2", "value2"); model.addAttribute("map", map); return
  155. javabot <p th:text="${map['key1']}"></p> <p th:text="${map['key2']}"></p> ``` In the above code, the values "value1" and "value2" will be inserted into the <p> elements respectively.
  156. Chronos wait, people use copilot? non-ironically?
  157. * dreamreal weeps
  158. Para On tangent, Windows 12 will require an NPU and is AI first for everything, check your favorite tech news site for more.
  159. Para My conservative hunch is that Apple's gonna sell about a billion Macbook Neos.
  160. Chronos Para: Are those requirements real, or debunked like some of the other claims made recently about Windows 12?
  161. dreamreal saml: I think you just iterate through the JSON and populate the thymeleaf context directly without the ${map} crap but what would I know, I'm only human
  162. Chronos Para: Sadly, the base MacBook Neo comes with woefully insufficient RAM, 8 GiB. Such a shame.
  163. Para Chronos: Everything's a rumor until it isn't. But it's ridiculous that such even is a rumor.
  164. dreamreal Chronos: 8GB in apple silicon is not the same as 8GB in an intel processor
  165. Para Chronos: It's a Chromebook, really. But iBook was already used years ago.
  166. dreamreal don't make that mistake, the 8GB in apple silicon is *much* more efficient than in intel
  167. Chronos Remember, it's unified memory — take a chunk out for video.
  168. dreamreal I'm not saying 8GB is the same as 16GB or anything like that, because usage patterns matter, but even so
  169. dreamreal Chronos: yes, BUT the apple silicon compresses *in the CPU* so it doesn't have the same pipeline limits
  170. Chronos dreamreal: We have Windows and macOS in the house. This is one of those hills I'll die on: 8 GiB isn't enough for macOS (in my opinion). I know normals that blow past 8 GiB with just 3 or 4 web pages open.
  171. dreamreal it's far more efficient
  172. dreamreal Chronos: Right, I'm not saying "8GB is enough for anyone!"
  173. Para And the use case is basically web browser based things and text messaging and other similar light tasks.
  174. geenvoud compresses what?
  175. dreamreal I'm just saying it's not an apple-to-apples comparison
  176. jbosmans dreamreal, not sure if thymeleaf is (by default) recommended for non-html string templating
  177. dreamreal jbosmans: what does HTML have to do with this
  178. dreamreal moustache would be the same thing
  179. jbosmans dreamreal, err thymeleaf ?
  180. Chronos For those people where 8 GiB is enough, I'd strongly suggest they use a Chromebook instead.
  181. dreamreal jbosmans: what about it? It's a template engine
  182. dreamreal that's it
  183. dreamreal people use it for HTML, woo
  184. jbosmans yeah i know what it is
  185. dreamreal I use a dry-erase marker for art
  186. dreamreal I know you know what it is
  187. GreenResponse I’m on 8GiB computer and found the ways to use it efficiently
  188. Chronos (I've got a Chromebook in the house, too — they are, frankly, wonderful machines)
  189. jbosmans why propose it for simple scenarios?
  190. dreamreal jbosmans: because he's already using it, it sounds like, and it's right there
  191. dreamreal he has a nail, he's holding a hammer, do the math
  192. Tenchi i have an m1 mac mini w/ 16gb of ram running latest sequoia and apple intelligence enabled... and it uses 7GB when it's booted up and I haven't done anything yet
  193. Chronos Tenchi: ouch
  194. jbosmans dreamreal, i see what you mean but they're not using it for simple string templating i'm guessing?
  195. Tenchi fire up idea and brave browser and it's using 13GB
  196. dreamreal Tenchi: I record my drums in a measly 8GB M1, running 16 audio tracks and recording multiple tracks on the fly, I should be PUNISHING that thing but it's FINE
  197. Para The Macbook Neo doesn't simply have a lot of the "fancy" stuff like AI in it.
  198. dreamreal jbosmans: right, but *why not* if it's right there
  199. Tenchi load up a few web sites and a java or kotlin project and i'm at 16GB
  200. jbosmans dreamreal, because it's html oriented?
  201. dreamreal jbosmans: but... it's not
  202. dreamreal people use it for html, but so what
  203. Para It's what Apple considers barebones; it's not meant for developers running a copy of their company infra, it's for the kids and grannies.
  204. Tenchi Para: i have no idea what the neo's all about or how 8GB suffices
  205. jbosmans dreamreal, th:text or whatever?
  206. dreamreal this is like complaining that a housewife shouldn't be using a craftsman hammer just to hang a painting
  207. jbosmans it's really not :-)
  208. dreamreal "that hammer's too good for a simple nail being driven into drywall, y'all!"
  209. dreamreal it really is
  210. dreamreal I understand what you're saying, but ...
  211. Para My mom basically migrated to an iPad this winter for most the things she needs a computer for. It sucks at some tasks, but that really is the thing, if 90% of what average person needs to get done can be done with a lot less hardware, then don't overdo it.
  212. jbosmans agreeing to disagree
  213. * dreamreal shrugs. Okay.
  214. Para I kinda wanna try painting with a hammer.
  215. jbosmans dreamreal, happy to continue btw :)
  216. Para Like...punch small balloons filled with paint on a canvas, or something.
  217. Para punch/hit/hammer/slam
  218. jbosmans Thymeleaf is a tool for creating natural and elegant HTML templates that can be used in web and standalone environments.
  219. jbosmans it *could* be used for other things, i use it for html email templates as well
  220. Chronos Para: iPads and Chromebooks are amazing for a lot (perhaps most) people
  221. dreamreal jbosmans: why? I mean, you're saying that a tool whose design was template replacement shouldn't be used for template replacement because the tool's got specialization for html. It's got a text mode so it can be used for, uh, hold on, checking the references, carrying the 2, dividing by zero... OH TEXT
  222. jbosmans but for simple text templating?
  223. dreamreal `The TEXT template mode will allow the use of a special syntax for templates of a non-markup nature. Examples of such templates might be text emails or templated documentation. Note that HTML or XML templates can be also processed as TEXT, in which case they will not be parsed as markup, and every tag, DOCTYPE, comment, etc, will be treated as mere text.`
  224. dreamreal That's from their docs
  225. dreamreal copied
  226. dreamreal I mean, why argue at this point, if you think the text mode is insufficient for use with text, what can I say? I am not here to win an argument, you should feel what you feel regardless of what I think of it
  227. jbosmans I know you're not here to win an argument, nor am i
  228. jbosmans thymeleaf is the best template engine i know of, but it's html focused which makes sense, it's great at it
  229. dreamreal see? no problem. And while it has HTML specializations, the docs suggest "html focused" might be a bit much
  230. jbosmans for simple text templating it's an overkill
  231. jbosmans worst case the String.replaceAll() needs a Pattern.quote()
  232. dreamreal so: moustache. Unless he already has thymeleaf in his classpath already.
  233. jbosmans actually, i always do that i guess
  234. dreamreal but at this point this is proceeding beyond not-my-problem.
  235. Para Moustache was good. Wish it was still common.
  236. dreamreal it's still pretty popular because it's so freaking fast
  237. jbosmans i think i used what came after in javascript world, like long ago
  238. jbosmans mustache right?
  239. dreamreal You used what came after moustache? ... what was that? Because I've used moustache in JS (and java, and python) relatively recently
  240. jbosmans or maybe that's what i know/knew
  241. jbosmans https://mustache.github.io/
  242. jbosmans ah handlebars, that's the one i had to use quite a bit like 10 years ago
  243. jbosmans long story short, for simple scenarios i'd always prefer simple String.replaceAll() over pulling x dependencies. If it's about HTML tho, that would be dumb(ish)
  244. jbosmans these replaceAll() call could be chained over a text block in recent java version
  245. jbosmans dreamreal, am I making sense here or not at all? I'd love to hear it
  246. dreamreal jbosmans: not enough scope to answer. If it works for you, that's what you should do.
  247. dreamreal Working code > everything else
  248. jbosmans i do tend to agree :-)
  249. jbosmans given i care/try to look at if my "actions"/responses are worthwhile, are they?
  250. jbosmans forgot the highlight @ dreamreal
  251. jbosmans &&
  252. jbosmans saml, how's it going?
  253. dreamreal I mean... I dunno, I don't know of your code
  254. dreamreal if you're satisfied with it, why wouldn't I be satisfied with it, too?
  255. jbosmans ~dreamreall++
  256. nevet ~dreamreall now has karma of 1.
  257. javabot dreamreall has a karma level of 1, jbosmans
  258. jbosmans ;-)
  259. jbosmans mm that's an 'l' too much
  260. jbosmans *many
  261. jbosmans ~dreamreal++
  262. nevet ~dreamreal now has karma of 1.
  263. javabot jbosmans, what does that even *mean*?
  264. jbosmans all is good then :)
  265. jbosmans <-
  266. dreamreal ?
  267. jbosmans something about karma and for whom it does or does not work
  268. jbosmans "<-" means "leaving" which i obviously messed up :)
  269. jbosmans and/or "going out" i guess
  270. dreamreal well, I'm remarkably hard to assign karma to
  271. jbosmans so it appears
  272. dreamreal not sure why but it might be my utter disdain for karma personally
  273. jbosmans it might be hardcoded i guess
  274. jbosmans on another note i switched from openai to anthropic today
  275. jbosmans and it still works pretty well for what i use it for \o/
  276. jbosmans (or better)
  277. dreamreal I find claude a lot better than chatgpt for code myself
  278. jbosmans agree so far
  279. jbosmans gemini pretty good as well
  280. jbosmans if only money weren't an issue :)
  281. jbosmans things can get expensive pretty quickly