182 karma · joined August 24, 2017
Generic erasure is a giant pain in the rear. C# doesn't do this. You don't actually keep any information about generics in the bytecode, however some of the metadata is present. BUT IT COULD BE FULL OF LIES.
There's also a huge amount of syntactic sugar in later java versions - take for example switch expressions.
https://www.benf.org/other/cfr/switch_expressions.html
and OH MY GOD FINALLY
I, for one, look forward to the contracting gigs fixing garbage code. :)
The pull back on this will be brutal.
It often feels to me that in the last several releases all that's been done is apply more and more lipstick to a pig that's already 90% lipstick.
I recently fired up excel 2003 on a whim (yep, I'm that much of a party animal.)
MY GOD. It was blazingly fast. Beautiful. Usable. (If you ignore the fact that the one good change in the last 2 decades is the XLOPER12, allowing >255 rows and lots of columns). (X)
(X) Yes, Lambda looks interesting, but HOF aren't really necessary in basic sheets, I'd rather they got it usable first.
"You should rewrite in" / "Why does't it do" / "Make it do".
It's nice that people are using it. I generally (try to) assume this is a language/cultural thing, and people don't realise that they're coming across as a bit rude in English.
But, it would be nicer if people approached commenting on OSS by first thinking "Author is doing this for fun, unpaid, and I'm getting something nice out of his/her time", THEN writing their comment.
I'd get the same issues raised, and that's fine. But the language might read a bit nicer.
(again, reachability analysis of unrelated code changes semantics.)
The problem is that this IS defined behaviour - the scope of the instanceof-assigned variable is dependent on whether or not the taken if-statement is provably exiting.
This is intended to allow
{
if (!(obj instanceof String s)) return;
// s exists now.
}
But it's not been thought through.https://docs.oracle.com/javase/specs/jls/se8/html/jls-14.htm...
"14.21. Unreachable Statements It is a compile-time error if a statement cannot be executed because it is unreachable.
This section is devoted to a precise explanation of the word "reachable." The idea is that there must be some possible execution path from the beginning of the constructor, method, instance initializer, or static initializer that contains the statement to the statement itself. The analysis takes into account the structure of statements. Except for the special treatment of while, do, and for statements whose condition expression has the constant value true, the values of expressions are not taken into account in the flow analysis."
I posted a bit about it here http://www.benf.org/other/cfr/java14instanceof_pattern.html
it was first noted https://twitter.com/tagir_valeev/status/1210431331332689920 here
but the main thing is that if the 'taken' conditional is guaranteed to exit, then scope hiding happens, if not, not.
But in java
if (true) { throw new Exception(); }
is not guaranteed to exit.
So: https://github.com/leibnitz27/cfr_tests/blob/master/src_14/o...
In case you don't want to run, as of java (build 14-ea+34-1452) this prints:
Fred
WIBBLE
public class InstanceOfPatternTest10 {
static String s = "WIBBLE";
public static void test(Object obj) {
if (!(obj instanceof String s)) {
throw new IllegalStateException();
}
System.out.println(s);
}
public static void test2(Object obj) {
if (!(obj instanceof String s)) {
if(true) {
throw new IllegalStateException();
}
}
System.out.println(s);
}
public static void main(String ... args) {
test("Fred");
test2("Fred");
}
} static IEnumerable<int> infinite()
{
int x = 2;
while (true)
{
yield return x++;
}
}
static IEnumerable<int> primes(IEnumerable<int> l)
{
int head = l.First();
yield return head;
foreach (var x in primes(l.Skip(1).Where(x => x % head != 0)))
yield return x;
}
static void Main(string[] args)
{
System.Console.WriteLine(string.Join(",", primes(infinite()).Take(20).Select(x => x.ToString())));
}While, granted, I was perhaps a little silly to go org (it seemed like a good idea back then!), it's mildly terrifying that my personal footprint on the web of 20+ years can now be held to ransom by a random VC firm, and to keep my own email address I might have to pay an additional $$$ annually.
Sigh.
"An interview with Barbara Liskov. Accept no substitutes."
If you're trying to show that a language is good, don't slag off other languages just for the sake of it.
At best it makes unjustified suppositions. At worst it makes you look like a bitter zealot.
Hand dryers. Leaf blowers. Hair dryers. Hoovers.
But bowling alleys and swimming pools are fine. I really want to figure out the spectrum of noise that hurts.
With a game like this now (Say, the excellent Thimbleweed Park - you played it, right?), if you get truly, epically stuck, there's a walk-through no more than a few clicks away. And you'll probably admit defeat and go there after a few hours.
When I picked DoTT up (a few seconds after release ;) ), no such thing. You were in it alone. Maybe there was a magazine write in for hints, and if you were lucky you knew a guy on a BBS, but other than that, you were on your own. That made the puzzles so much sweeter when you got them.
Simple guidelines to live your life by ;)
Since it's not mentioned in the article - the signature of a method is the description containing generic information. The descriptor is the erased signature, which, because A strips to Ljava/lang/Object; will likely be a fair bit longer.
An aside - you can (mostly) still get away with corrupting signatures, if you want to obfuscate code.
(eg https://github.com/ItzSomebody/StopDecompilingMyJava/blob/ma... )
(yes, I used to blow up on one of these in https://www.benf.org/other/cfr - (my java decompiler), but it's all good now).
An example - some code I was working with gave subtly different results on two processors. It turned out this was because one of them implemented FMA - Fused Multiply Add.
https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_op...
It wasn't particularly painful to find this, but if you were attempting to debug this kind of problem without considering lower level issues, you'd spend a whole lot of time banging your head against a wall.