ByteCode.News
Submit RSS Atom Sign in

Back to the channels

#java

  1. * five618480339176 joined #java
  2. * kusanagi joined #java
  3. * hiredman joined #java
  4. * domicron joined #java
  5. * Flow joined #java
  6. * fgarcia joined #java
  7. * michele joined #java
  8. * vobar joined #java
  9. * lostlazy joined #java
  10. * julemand101 joined #java
  11. * sponkz joined #java
  12. * hwpplayer1 joined #java
  13. * jreicher joined #java
  14. * MikeBux joined #java
  15. * Afroboy joined #java
  16. * Gaz7051122720067 joined #java
  17. * mixfix41 joined #java
  18. * leppard joined #java
  19. * GreenResponse joined #java
  20. * Afroboy joined #java
  21. * szkl joined #java
  22. dreamreal https://bytecode.news/posts/2026/06/what-s-old-is-old-again
  23. javabot dreamreal's title: "What's Old is Old Again | bytecode.news"
  24. Para I have special price offer for that work, it's zero. As in, normal rate but with one zero added.
  25. dreamreal I haven't gotten any work from that particular mode yet, it'll be interesting to see what happens when I do.
  26. * Aedil joined #java
  27. * jamezp joined #java
  28. * hwpplayer1 joined #java
  29. * metalmaniac joined #java
  30. * leppard joined #java
  31. * leppard joined #java
  32. * Afroboy joined #java
  33. * wedr joined #java
  34. wedr Helloooo. this stumped me badly... I didn't know if a non-empty string contains an empty string, this is evaluated to be true.
  35. wedr https://onecompiler.com/java/44t9567gk
  36. nevet Java Online Compiler
  37. javabot wedr's title: "Java Online Compiler"
  38. wedr Is this for real??
  39. dreamreal Well, what does "contains" mean?
  40. wedr The contains() method
  41. dreamreal I know. But what does teh contains() METHOD imply?
  42. dreamreal It says "this sequence can or cannot be found in the instance being referred to," yeah?
  43. wedr From the doc, it says "Returns true if and only if this string contains the specified sequence of char values."
  44. dreamreal It takes a CharSequence, is called on a String. Right?
  45. wedr Yes
  46. dreamreal Okay, what does it say ABOUT THE SPECIFIED SEQUENCE?
  47. wedr An empty string implies that it is a non-null CharSequence object?
  48. Para wedr: FWIW you can as an exercise implement contains, substring and a few other basic operations using char arrays and as simple as possible constructs (for loops with manual index management and such) and you'll kinda see why the things behave like they do.
  49. Para And yes, "" indeed is not null :)
  50. wedr Ugh, I gotta go back and fix a 6 years old bug.
  51. fizzie Here's one way to think about it, if you like: a.contains(b) is true iff a.substring(x, y).equals(b) for some x, y.
  52. dreamreal There you go. Does "foo" contain a valid but empty "" sequence? yes.
  53. Para Been poking at code from 2017 myself lately...
  54. dreamreal wedr: always fun to realize you left out a constraint, innit :/
  55. wedr * wedr is baffled.
  56. dreamreal thankfully, it's never happened to ME! ... pardon me while I check a shedload of codebases to scrub
  57. dreamreal for, uh, something else entirely, surely
  58. dreamreal it'd not baffling! Any nonempty string contains an empty-but-valid sequence
  59. dreamreal it's indexOf() in the end, although codepages factor in
  60. Para This reminds me of a discussion I see every now and then - not commonly but still - where someone doesn't quite get why empty collection is not the same as null. Different problem entirely, but there's some logical overlap.
  61. fizzie "foo" contains "" in four different places, even.
  62. Para fizzie: regex split agrees
  63. wedr oh no, I now see why, but goddamnit it's not that intuitive until you see it.
  64. dreamreal hmm, I can understand that
  65. dreamreal I don't know that I AGREE with it, but I can understand it
  66. wedr anyway, we have so many string checks throughout the code, so I will have to check them all.
  67. Para And another overlap, with URIs the path segment of URI is handled in sort of similar way. This is why path "/" is different than "", or "foo/" has two segments while "foo" has just one.
  68. Para This latter part is also why it's potentially a security defect to do URI rewrites involving trailing path.
  69. Para And people do that a lot as cargo culting because back in the day Apache directory serving used that to sniff whether you mean foo-the-dir or foo-the-file.
  70. * Drixtan joined #java
  71. * hwpplaye` joined #java
  72. * mwnaylor left #java (ERC 5.6.0.30.1 (IRC client for GNU Emacs 30.2))
  73. * JazzJackalope joined #java
  74. * acidsys joined #java
  75. * sponkz joined #java
  76. * m2 joined #java
  77. * llanhmock joined #java
  78. * hwpplayer1 joined #java
  79. * Drixtan joined #java
  80. * tomboy64 joined #java
  81. * ztevoz joined #java
  82. * keb joined #java
  83. * nimaje joined #java
  84. * ferdna joined #java
  85. * Odyss3us joined #java
  86. * magla joined #java
  87. * Betal joined #java
  88. * Ragnor joined #java
  89. * nimaje joined #java
  90. * henbruas joined #java
  91. * magla joined #java
  92. * akaWolf1 joined #java
  93. * akaWolf1 joined #java
  94. * nimaje joined #java
  95. * nimaje joined #java
  96. jreicher I think the term "empty string" could be confusing, and is probably a misnomer. It kind of suggests there's no string there, but there is of course still a (zero-length) string.
  97. jreicher It's not like "empty list", because a list is a collection. A string isn't really a collection in some ways.
  98. * nimaje joined #java
  99. Maxdamantus How is it different? "empty set", "empty list", "empty string", "empty sequence" .. I think these are all understood in pretty much the same way.
  100. Maxdamantus There is a set/list/string/sequence, and the fact that it's empty means its length is 0.
  101. dreamreal heh. What's the intersection of the ['a', 'b', 'c'] and [] sets?
  102. Maxdamantus Just like how an empty bottle has 0 contents in it.
  103. Maxdamantus []
  104. jreicher By people who understand them, yes. But I think people who don't are getting caught by the fact that a String (the java object) is not a collection.
  105. dreamreal at what position is the [] set in the first set?
  106. Maxdamantus sets don't have positions.
  107. jreicher You can interpret as a string as a collection (of chars), but you need that interpretation
  108. dreamreal yeah, but those aren't JAVA sets, assume they're ordered
  109. Para I suspect at least some of the confusion I mentioned earlier has caused by teachers wanting to overfeed functional programming theory as the only way to see programming.
  110. jreicher But it is... :p
  111. Para Like cool, Set(3) is also identity of 3 in a set...and no one cares.
  112. Maxdamantus Well, a string is a thing that has a length or size. That's what allows it to be conceptually empty.
  113. Maxdamantus gtg
  114. dreamreal I'm still very vaguely annoyed that teachers don't start with actual ML
  115. dreamreal on, like, eight bit processors
  116. jreicher Oh, come on. Nobody says "empty distance", do they?
  117. Para GenZ slang is kinda like that, apparently.
  118. Para Anyway. One issue that I've seen a few time is that people really don't understand that the collection itself has functionality and properties tied to its type. Like set and its ordering.
  119. Para They'll just blank on "how can identy of nothing be unordered" kind of mismash.
  120. Para (I meet a person like this maybe once every few years, mind you)
  121. Para So, about monads...
  122. jreicher You mean enchiladas.
  123. Para mmm, those would be nice
  124. Para Can't really get good ones over here.
  125. jreicher Good Mexican food is very good food.
  126. * nimaje joined #java
  127. * nimaje joined #java
  128. * nimaje joined #java
  129. jreicher I had the wrong control codes before but I think this channel strips them anyway. Was trying to do italics
  130. * five618480339176 joined #java
  131. * polyrob joined #java
  132. * mindCrime joined #java
  133. * LtHummus joined #java
  134. * metalmaniac joined #java
  135. * kathadris joined #java
  136. * marcel1 joined #java