|
more like dICK posted:in java you just extend the compiler using undocumented internal interfaces to make it a different programming language
|
![]() |
|
![]()
|
# ? Jun 25, 2024 04:30 |
|
Max Facetime posted:or just check for nulls in a less stupid way: Eclipse will still flag a bunch of this stuff as "potential" null pointer accesses, because who can say that the second or third call to getSoundcard() won't suddenly return null!? Also, Eclipse has no idea how to do null analysis on that Optional class. Basically, null analysis should be built into the drat language already.
|
![]() |
|
that example article is loving terrible in all sorts of ways also who gives a poo poo about getters/setters, you know you can just have your data member poo poo public and you're not going to get hanged by the Inquisition right sometimes a struct is just a struct. other times validating data might be a good idea idk it seems to me like an object should always enforce its own validity so a setter would be a good place to perform validation. c# properties are not that offensive but not a particularly good idea either imo. you inevitably get dipshits who do something not-thread-safe or mutating or not-idempotent in a c# getter. just like how they blindly c&p'ed java to make c# 1.0 and then bolted their own redundant poo poo on top like having both Equals() and an operator== overload and expressing one in terms of the other is a loving pain in the dick. does x == y test logical equality? identity??? who the gently caress knows??????? Alt-poo poo-S, R to bring up the autogenerate dialog, Alt-A to select everything, Enter, there, now you have a bunch of accessors. now stop being a loving baby. sometimes being clear about what's going on is worth a few extra (automated) keystrokes. really all that this demonstrates is that, once again, stupid bad programmers try to use Java and then blame Java for their own lovely ineptitude, and that Java is the best programming language for most jobs performed by adults who perform useful labour. the existence of plangs to draw off insecure children who have something to prove is something i am thankful for every day.
|
![]() |
|
ya it owns
|
![]() |
|
java meets the needs of the enterprise
|
![]() |
|
Mr Dog posted:that example article is loving terrible in all sorts of ways do you have a better way to use Optional
|
![]() |
|
FamDav posted:re: rails is slow as poo poo still faster than symfony!
|
![]() |
|
Bloody posted:right, that makes sense. I guess I don't get the "mark everything private and give it a getter and setter" thing that seems to be popular. it's marking where you pass mutable data structures around ![]()
|
![]() |
|
yospos what are your opinions about circular references in classes
|
![]() |
|
for those who don't read the python thread, shadowhawk is most likely referring to something like this:Python code:
|
![]() |
|
vapid cutlery posted:do you have a better way to use Optional let me tell you about do-notation,
|
![]() |
|
ShadowHawk posted:yospos what are your opinions about circular references in classes do u like weak references?
|
![]() |
|
Malcolm XML posted:do u like weak references? As much as I like __del__.
|
![]() |
|
ShadowHawk posted:yospos what are your opinions about circular references in classes you'll want them pretty quickly when you have a tree or other graph thing, and then they gently caress up your ~raii~ not worth avoiding imo, just never rely on the destructor and have a sensible way to unravel it if you don't have gc
|
![]() |
|
Symbolic Butt posted:for those who don't read the python thread i gave up with that thread ![]()
|
![]() |
|
surprise: it's game dev code ![]()
|
![]() |
|
tef posted:surprise: it's game dev code you mean people will actually run it?
|
![]() |
|
vapid cutlery posted:you mean people will actually run it? gamers aren't people
|
![]() |
|
Mr Dog posted:sometimes a struct is just a struct. other times validating data might be a good idea idk it seems to me like an object should always enforce its own validity so a setter would be a good place to perform validation. mutable objects are the root problem
|
![]() |
|
hepatizon posted:mutable objects are the root problem this is truth if you find yourself creating an object with a bunch of setters, and it's not a builder, you may possibly have hosed up
|
![]() |
|
hepatizon posted:mutable objects are the root problem this is a good pragmatic rule but if you get religious about it then you end up with haskell were i to redesign java from scratch though i'd remove the final keyword and replace it by "mutable" instead. and i'd add unsigned types too, of course. however, java isn't a plang and it's used for more important things than worthless startup fart app poo poo. so the stewards of java don't burn it all to the ground every three years because they want the bikeshed to be pink instead of blue this time.
|
![]() |
|
it is overall not that hard to just not mutate poo poo in java, it is even pretty trivial to write tools that statically verify that you don't where you say you don't (well, if you can assume that no code is dead or it is fine to disallow mutation even in dead code). so really the realization that mutating poo poo is bad is 95% of the battle
Cybernetic Vermin fucked around with this message at 21:56 on Dec 29, 2014 |
![]() |
|
Cybernetic Vermin posted:it is overall not that hard to just not mutate poo poo in java, it is even pretty trivial to write tools that statically verify that you don't where you say you don't (well, if you can assume that no code is dead or it is fine to disallow mutation even in dead code). so really the realization that mutating poo poo is bad is 95% of the battle the reason why i like have this just be part of the language is i'd rather let a compiler police this poo poo than elder devs (and in some cases the elders are part of the problem ![]()
|
![]() |
|
seriously. help the compiler help you.
|
![]() |
|
plus the sap maintaining your code will be left wondering why there are methods that must not be called
|
![]() |
|
Cybernetic Vermin posted:so really the realization that mutating poo poo is bad is 95% of the battle This is massive in front end dev as well. With tools like React that now encourage you to really define your state versus immutable properties, the whole ball of wax becomes so much more maintainable.
|
![]() |
|
Mr Dog posted:but if you get religious about it then you end up with haskell im not seeing the problem here
|
![]() |
|
fart simpson posted:im not seeing the problem here that's because there isn't any, the immutability part of haskell is just fine. the problem is lazy evaluation although sometimes it's nice to say "for this algorithm i'll need a contiguous array of memory whose cells i can mutate in constant time" and have your language respond with something other than "go gently caress yourself"
|
![]() |
|
JewKiller 3000 posted:that's because there isn't any, the immutability part of haskell is just fine. the problem is lazy evaluation data.vector.mutable
|
![]() |
|
Malcolm XML posted:data.vector.mutable Portability non-portable Stability experimental Maintainer Roman Leshchinskiy <rl@cse.unsw.edu.au>
|
![]() |
|
Mr Dog posted:however, java isn't a plang and it's used for more important things than worthless startup fart app poo poo. so the stewards of java don't burn it all to the ground every three years because they want the bikeshed to be pink instead of blue this time. lol real programmers write business logic in an xml framework, none of this curly bracket poo poo
|
![]() |
|
Mr Dog posted:this is a good pragmatic rule public mutable void method () { }
|
![]() |
|
tef posted:public mutable void method () { tbh would be nice to specify the things you are okay with being overridden because not designing for inheritance leads to awful inheritance
|
![]() |
|
JewKiller 3000 posted:Portability non-portable its shipped with ghc, it's good enough
|
![]() |
|
Brain Candy posted:designing for inheritance leads to awful inheritance fixed!
|
![]() |
|
just because inheritance is awful doesn't mean I'm not going to do it
|
![]() |
|
tef posted:lol real programmers write business logic in an xml framework, none of this curly bracket poo poo nah that's another java strawman tef posted:public mutable void method () { concrete inheritance is poo poo in most cases but there are few boilerplate-y things it's good at dealing with, provided you don't expose your data members like some sort of loving animal. in this imaginary cleaned-up java classes should be final unless explicitly declared otherwise (and then the same should be true of methods on top of that), and most of the time classes should be abstract, final, or an exception. but yeah, most of the time. every now and again you come across a situation where a dirty solution like concrete inheritance is the least bad solution. early oop emphasised concrete inheritance heavily which we know now to be a mistake.
|
![]() |
|
traits or die trying
|
![]() |
|
Bloody posted:right, that makes sense. I guess I don't get the "mark everything private and give it a getter and setter" thing that seems to be popular. this is really big in java because there is simultaneously a need to create consistent, long-lived interfaces and APIs and also a total lack of modern PL features for abstraction (surprise, it's because java has to be a consistent, long-lived interface). setters and getters are encapsulation at a really small scale. for example, pretend you have this class in the first version of your application: code:
in conclusion, it's another practice that is a good idea in java because java's not that good of a language. Pie Colony fucked around with this message at 19:04 on Dec 30, 2014 |
![]() |
|
![]()
|
# ? Jun 25, 2024 04:30 |
|
waaaaait, can you really not do an implicit widening conversion from int -> float
|
![]() |