|
Thermopyle posted:Java isn't really notably slow (depends on what/how you're comparing, of course), This is relatively old but you reminded me of the quote: quote:The plain truth is: Java is slow. Java isn’t just slow, it’s really slow, surprisingly slow. It is “you get to watch the buttons being drawn on your toolbar” slow. I read it in another paper that talked about JIT compilers. Pre-gnu-lightning Smalltalk wasn't spared either. dougdrums fucked around with this message at 19:01 on Aug 16, 2016 |
# ? Aug 16, 2016 18:58 |
|
|
# ? Jun 5, 2024 05:50 |
|
feedmegin posted:Doesn't help with the complaint about reading the code though. Plus, to my mind a language that requires an IDE to generate massive chunks of code for you to be usable is not a very good language. You'd hate C++ then. Or, not to mention, C. Scala ... eh, is an interesting language, but when reading some gibberish code and then trying to google for it to see WTF is that thing doing and the search returns no results, what does that say about that language then? And about the IDE hate: what year are you living in? Without syntax coloring or some modicum of autocompletion or at least helpers and hints every now and then ... it sucks, doesn't matter the language. I wrote code in Turbo C++ on a monochrome monitor back in early 90s, I don't wanna do that again.
|
# ? Aug 16, 2016 20:59 |
|
I'm not getting into specifics, but any time I try to do something new using the Windows API, I feel like it's been written by a hardware vendor. It's 2016, you're the ones promoting C++ at the least, or C#/managed code more often than not; why the hell does your API read and write through pointers, giving me obtuse handles connecting to system objects I then have to keep around as parameters for future system calls? I frequently find myself scouring github for dumb wrapper/multiplatform classes with MIT license or the boost library to avoid dealing with what should be straightforward for someone writing Microsoft Windows code in Microsoft Visual Studio.
|
# ? Aug 16, 2016 23:23 |
|
TooMuchAbstraction posted:Java's big problem is with verbosity.
|
# ? Aug 17, 2016 00:12 |
|
Absurd Alhazred posted:I'm not getting into specifics, but any time I try to do something new using the Windows API, I feel like it's been written by a hardware vendor. Because it's old as gently caress. (I'm assuming you're not talking about WinRT.)
|
# ? Aug 17, 2016 00:28 |
|
raminasi posted:Because it's old as gently caress. (I'm assuming you're not talking about WinRT.) Windows 7+ is about 7 years old. That's not old as gently caress. Java, which as a language is old as gently caress, already had object-based APIs throughout pretty much since its inception.
|
# ? Aug 17, 2016 00:34 |
|
A lot of Windows' API has been unchanged for a distressing number of years. I mean, take a look at the Hello World example from the Windows SDK circa 1985 and tell me how many functions you recognize... http://www.charlespetzold.com/blog/2014/12/The-Infamous-Windows-Hello-World-Program.html
|
# ? Aug 17, 2016 00:40 |
|
Kazinsal posted:A lot of Windows' API has been unchanged for a distressing number of years. I mean, take a look at the Hello World example from the Windows SDK circa 1985 and tell me how many functions you recognize... You know, there's a 50/50 chance that you can compile and run that exact code.
|
# ? Aug 17, 2016 01:07 |
|
Volguus posted:There are, yes, numerous verbosity complaints about Java, but the IDEs have largely fixed all/most of them. C# is a good example of a Java w/ much less boilerplate, although C# still has a lot of flaws IMO around verbosity.
|
# ? Aug 17, 2016 05:03 |
|
Absurd Alhazred posted:Windows 7+ is about 7 years old. That's not old as gently caress. Java, which as a language is old as gently caress, already had object-based APIs throughout pretty much since its inception. The API I presume you are complaining about is basically Windows 95-era. They don't re-do it with every Windows release. There are newer APIs (.NET, or WinRT) but you're not using them for some reason.
|
# ? Aug 17, 2016 05:42 |
|
That feel when a language requires implementing gethashcode whenever you want to implement equals
|
# ? Aug 17, 2016 06:00 |
|
I still want to know why Java's URL.equals does DNS lookup on the domains.
|
# ? Aug 17, 2016 06:40 |
|
fleshweasel posted:That feel when a language requires implementing gethashcode whenever you want to implement equals Yeah, thats dumb as gently caress, but lets be honest - the entire idea of gethashcode method is wrong and dumb. vOv posted:I still want to know why Java's URL.equals does DNS lookup on the domains. "It seemed like a good idea at the time." I guess. Someone probably wanted to get absolutely canonical answer and didn't think too hard about the tradeoffs.
|
# ? Aug 17, 2016 06:59 |
|
fleshweasel posted:That feel when a language requires implementing gethashcode whenever you want to implement equals Xarn posted:Yeah, thats dumb as gently caress, but lets be honest - the entire idea of gethashcode method is wrong and dumb. Having never used C# in anger, what's wrong with this?
|
# ? Aug 17, 2016 07:50 |
|
You have to implement an entirely irrelevant method just because of the off-chance that someone might put an instance of your class in a hashtable. On the other hand, knowing that you can put any arbitrary object into a hashtable is actually pretty darn useful.
|
# ? Aug 17, 2016 08:13 |
|
Jabor posted:You have to implement an entirely irrelevant method just because of the off-chance that someone might put an instance of your class in a hashtable. Honestly it was a mistake for Equals and GetHashCode to be defined on System.Object. Lots of classes have no notion of equality and should never even be compared to each other, let alone be used as keys in hashtables, but because every object has Equals and GetHashCode the compiler will never tell you that you're probably making a mistake if you try to do it. IMO there should've been something like an IHashable interface, and Dictionary<TKey, TValue> should've been constrained to only work with keys that implement IHashable. Similarly it should only be possible to compare objects for equality if they implement IEquatable<T> or with some custom method. Of course you can always use object.ReferenceEquals(a, b) if what you want is reference equality, but in my experience it almost never is. Haskell gets this right. If you want to compare objects using the == operator you have to derive the Eq typeclass, and for types with members that themselves don't implement Eq (e.g. functions) it's usually impossible to define Eq in a consistent way, so you'll never get this wrong unless you really go out of your way. For types that do have a proper notion of equality you can just write deriving (Eq) after the type definition and it will give you what you want 9/10 times, which is structural equality. While we're on the subject, even ToString shouldn't have been defined on System.Object. Not all types can be converted to strings in a satisfactory way, and the default ToString implementation that just returns "[ClassName]" is virtually useless anyway. I guess all of these things are mistakes .NET inherited from Java.
|
# ? Aug 17, 2016 09:04 |
|
vOv posted:Having never used C# in anger, what's wrong with this? It places the responsibility for hashing at the wrong place, especially if you have a non-trivial object. If you are implementing a String (or generally a container of primitives), you can easily look up a good hash function and implement it for the type, but its still something that shouldn't have to be done more than once. If you are implementing a non-trivial class, even something that only contains a pair of strings, then you have to somehow magically merge the hashes without sacrificing quality of the hash. This is basically crossing your fingers, while praying to your favourite computer deity. It also makes it really loving hard to test how performant different hashes are for your application, or deciding to use a different hash for this purpose. (IE you found out that in this specific place the application is hashing a fuckload of strings, but you know that they have some specific property -- ie they all have 16 characters, or are distinct on a prefix/suffix etc) The proper way to do all this would be to take a look at the usual hashes and recognize that almost without an exception* operate in 3 phases 1) Initialize the hash state. ie for SHA 256 this means init the initial hash and prepare constants for hashing rounds 2) Eat raw data in chunks. ie SHA 256 takes the input data in 512 bits chunks 3) Transform internal state to the actual output hash If you create a hash object, phase 1 is the object constructor. Phase 2 could be a bit problematic in languages which don't let you access raw bytes, but probably could be solved by fuckload of overloads like code:
Phase 3 is a trivial method to implement. getHashCode() is then transformed into addDataToHash(Hasher) and hashing non-trivial objects becomes easy -> you just pass given Hasher to members. * I know of one, but I don't claim to know every obscure hash ever invented.
|
# ? Aug 17, 2016 09:08 |
|
There are lots of unequatable objects that you often want to put into a hashtable though, based on object identity rather than some sort of equality test. Which is where the motivation for having these methods defined on object comes from. Object identity of subcomponents is also often used when it comes to comparing equality for other complex objects. Of course with the benefit of hindsight, it might have been better to have something like a HashComparator, with a platform-provided implementation based on object identity.
|
# ? Aug 17, 2016 09:32 |
|
If you don't want to support putting your object in Dictionaries why not write a GetHashCode that throws? I got curious so I did a search, and Microsoft's documentation explicitly says: "The GetHashCode method should not throw exceptions." ... But why not?
|
# ? Aug 17, 2016 09:34 |
|
Jabor posted:There are lots of unequatable objects that you often want to put into a hashtable though, based on object identity rather than some sort of equality test. Which is where the motivation for having these methods defined on object comes from. Object identity of subcomponents is also often used when it comes to comparing equality for other complex objects. I'm personally not very comfortable comparing or hashing based on object identity because I find it takes so little for someone to accidentally create a new instance with the same values somewhere and subtly break everything, but YMMV. If you really need to do this I'd want you to have to do something like this: C# code:
|
# ? Aug 17, 2016 09:45 |
|
FrantzX posted:You know, there's a 50/50 chance that you can compile and run that exact code.
|
# ? Aug 17, 2016 09:56 |
|
LOOK I AM A TURTLE posted:I'm personally not very comfortable comparing or hashing based on object identity because I find it takes so little for someone to accidentally create a new instance with the same values somewhere and subtly break everything, but YMMV. Consider things like wiring up components with an event registration model - when everything (by default) can just go into an identity-based hashtable, you can implement listener registration pretty trivially, and can easily look them up again to deregister them. Otherwise, you need to do wacky stuff like iterating over every single listener to find the one being removed, or creating synthetic keys that the listener needs to hang on to in order to deregister later. Fat classes like UI widgets don't generally override equality, but benefit a lot from an identity-based hashcode.
|
# ? Aug 17, 2016 10:03 |
|
Jabor posted:Consider things like wiring up components with an event registration model - when everything (by default) can just go into an identity-based hashtable, you can implement listener registration pretty trivially, and can easily look them up again to deregister them. Otherwise, you need to do wacky stuff like iterating over every single listener to find the one being removed, or creating synthetic keys that the listener needs to hang on to in order to deregister later. Fair enough. For such cases you could have a subclass of Dictionary that implicitly uses the default implementation. C# code:
code:
Edit: DictionaryBase can't be internal in my example obviously LOOK I AM A TURTLE fucked around with this message at 10:23 on Aug 17, 2016 |
# ? Aug 17, 2016 10:21 |
|
Volguus posted:You'd hate C++ then. Or, not to mention, C. . My day job is writing C++ and it doesn't involve an IDE generating anything, nor is the codebase I work in excessively verbose. Why would you think it did?
|
# ? Aug 17, 2016 12:24 |
|
I don't know who the horror is here, but... We've got a client who wants SSO between their ecommerce site and ours, but they don't have the experience or time to build an identity provider - so we've built a temporary solution that's kinda hacky, but basically works - we redirect to them to log in, they redirect back to us with a short lived 'login' token. So we had a bug where a user would be logged in on their side, but not on ours. You'd be on our site, on a logged out page, all is good. But sometimes, without clicking any links, you'd refresh the page and suddenly be logged in. So I opened the network pane in Chrome - no traffic to the other side...but sometimes still logged in after refreshing the page. Caching? Nope...nothing. Cookies? Nope...nothing. So I opened fiddler - and every now and then there's a request to their site's login-redirect-thing - bingo! But where's it coming from, and why doesn't it show up in the network pane in Chrome? Can't find anything in our Angular code. So when exactly does the request happen? Hovering over links...nope, nothing. Clicking links...nope, nothing. So then I type in the url of a logged-in page in the address bar...bingo! There's the request to their side. WTF... Long, tedious story short it turns out that Chrome pre-fetches pages when you type their url in the address bar, before you even press enter, and not only that, it executes javascript linked from that resource! So just typing in the url of a logged-in page would, behind the scenes, cause Chrome to go off, fetch the page, execute javascript, and set cookies...before you even pressed enter. gently caress me. As an aside, it appears Chrome doesn't even send pre-fetch headers anymore, so it's harder to protect your site against it.
|
# ? Aug 17, 2016 12:29 |
|
feedmegin posted:My day job is writing C++ and it doesn't involve an IDE generating anything, nor is the codebase I work in excessively verbose. Why would you think it did? If you think that Java is more verbose than C++, well, I don't know what to say. Though, is it true, code generation in C++ from an IDE is even now in infancy, compared to Java/C#, so you can't do that even if you wanted to.
|
# ? Aug 17, 2016 12:43 |
|
toiletbrush posted:Long, tedious story short it turns out that Chrome pre-fetches pages when you type their url in the address bar, before you even press enter, and not only that, it executes javascript linked from that resource! So just typing in the url of a logged-in page would, behind the scenes, cause Chrome to go off, fetch the page, execute javascript, and set cookies...before you even pressed enter. That's bonkers, but how did this issue get noticed in the first place? Do your testers go around typing stuff into the address bar without actually going to the page, just in case it has an effect? That's some comprehensive testing. I don't understand how it got picked up in the first place, unless there are other circumstances in which Chrome does this prefetching. What does Chrome do in failure cases? For example what does it do if the prefetched JavaScript goes into a loop?
|
# ? Aug 17, 2016 13:11 |
|
Volguus posted:If you think that Java is more verbose than C++, well, I don't know what to say. Though, is it true, code generation in C++ from an IDE is even now in infancy, compared to Java/C#, so you can't do that even if you wanted to. Lolwhatareyouonabout. Java doesn't even have variadic templates. e: void iSeeYourPoint() { } void iSeeYourPoint(int this) { } void iSeeYourPoint(int this, int is) { } void iSeeYourPoint(int this, int is, int clearly) { } void iSeeYourPoint(int this, int is, int clearly, int less) { } void iSeeYourPoint(int this, int is, int clearly, int less, int verbose) { } leper khan fucked around with this message at 13:24 on Aug 17, 2016 |
# ? Aug 17, 2016 13:18 |
|
raminasi posted:The API I presume you are complaining about is basically Windows 95-era. They don't re-do it with every Windows release. There are newer APIs (.NET, or WinRT) but you're not using them for some reason. And isn't the Win95-era API is a 32-bit cleaned up variant of Windows 3.x-era API?
|
# ? Aug 17, 2016 13:24 |
|
Hammerite posted:That's bonkers, but how did this issue get noticed in the first place? Do your testers go around typing stuff into the address bar without actually going to the page, just in case it has an effect? That's some comprehensive testing. I don't understand how it got picked up in the first place, unless there are other circumstances in which Chrome does this prefetching. toiletbrush fucked around with this message at 13:47 on Aug 17, 2016 |
# ? Aug 17, 2016 13:43 |
OddObserver posted:And isn't the Win95-era API is a 32-bit cleaned up variant of Windows 3.x-era API? Kind of. It removes a lot of the near/far call weirdnesses, affects string handling somewhat (I assume), but on the other hand introduces most of the Win32 stuff from NT with synchronization objects and kernel handles.
|
|
# ? Aug 17, 2016 14:12 |
|
leper khan posted:Lolwhatareyouonabout. It doesn't have variadic templates, but it does have variable arguments: void iSeeYourPoint(int... noneedfor100methods) { }
|
# ? Aug 17, 2016 14:41 |
|
Speaking of Java boilerplate, am I the only one who sees this as a coding horror?
|
# ? Aug 17, 2016 15:17 |
|
leper khan posted:Lolwhatareyouonabout. It depends; if there's a method, or especially a constructor, that takes a whole bunch of arguments and can take different sets of arguments, I'm pretty okay with having the actual signatures available, so the IDE can remind me what the gently caress I'm supposed to put in there and in which order, and also so that the argument types are statically checked. It's a little verbose, yes, but I don't think it ends up being worse code as a result.
|
# ? Aug 17, 2016 15:19 |
|
NihilCredo posted:Speaking of Java boilerplate, am I the only one who sees this as a coding horror? No.
|
# ? Aug 17, 2016 15:28 |
|
NihilCredo posted:Speaking of Java boilerplate, am I the only one who sees this as a coding horror? Am I the only one who views @autowired as a horror?
|
# ? Aug 17, 2016 15:33 |
Does Java have auto yet? That made C++11 much less verbose IMO.
|
|
# ? Aug 17, 2016 15:34 |
|
NihilCredo posted:Speaking of Java boilerplate, am I the only one who sees this as a coding horror? I hope not. That's simply stupid.If it contains "extreme" in the name ... its probably safe to not follow.
|
# ? Aug 17, 2016 15:37 |
|
NihilCredo posted:Speaking of Java boilerplate, am I the only one who sees this as a coding horror? Haha, it's like people are coming full circle on OOP. They're almost back to it being plain functions. This here looks to be basically functions with closures implemented with classes.
|
# ? Aug 17, 2016 15:58 |
|
|
# ? Jun 5, 2024 05:50 |
|
NihilCredo posted:Speaking of Java boilerplate, am I the only one who sees this as a coding horror? Has he never heard of Scala or something? He mentions functional programming in the post so he obviously knows the phrase, but doesn't recognize what hes trying to do?
|
# ? Aug 17, 2016 16:14 |