[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Java is a good language >prove me wrong
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 133
Thread images: 12
File: descarga.png (3 KB, 200x200) Image search: [Google]
descarga.png
3 KB, 200x200
Java is a good language
>prove me wrong
>>
bumperino
>>
You need to create a class in order to write a hello world to screen.
>>
>>55514251
You need to execute your software in a VM
>>
>>55514251
you need technology to test
>>
>>55514251
Simply adding properties would make it a lot better.
>>
I dont prefer it but what do you like about it OP?
>>
>>55514251
>import java.awt.net.ebean.factory.async.collections.AsyncFactory
>>
File: normies.jpg (28 KB, 1280x720) Image search: [Google]
normies.jpg
28 KB, 1280x720
>>55514251
Most normies use it.
>>
>>55514834
Lel normie may may Reeeeeee xDD lel reddit frogposter
>>>/Facebook/
>>>/redditt/
>>
>>55514862
>tripfag
>>>/reddit/
>>
it's pretty good actually depending on the use-case

now get ready for this thread to be flooded by a billion /pol/ shitters spamming "POO IN LOO XD" and other ebin /pol/ maymays

in b4 "hello pajeet"
>>
>>55514332

In what language can you write hello world to the screen without creating a file for the code to go in?
>>
>>55515480
>>tripfag
>not namefag
>>>/reddit/
>>
>>55514251
java is abandonware.
>>
>>55514451

> Bean beanBeanBeanFactory = new (Bean) beanBeanfactory((beanFactory) beanbean Factory)
>>
>>55515838
This, spring is garbage bloatware that acts as a shitty safety mechanism for bad programmers who don't know how to keep their classes organized and consistent.
>>
File: javadabadoo.jpg (265 KB, 472x560) Image search: [Google]
javadabadoo.jpg
265 KB, 472x560
>>55514251
>>
>>55515697
only java EE is abandonware
>>
print("Hello World")
>>
File: oracle_evil_empire1-300x300.png (129 KB, 300x300) Image search: [Google]
oracle_evil_empire1-300x300.png
129 KB, 300x300
Oracle

Though, DESU, I think they're doing good with MySQL
>>
>>55514251
I prefer C#
>>
File: 1463338301974.png (371 KB, 800x600) Image search: [Google]
1463338301974.png
371 KB, 800x600
>>
>>55514378
Even C++ has properties.
https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
>>
>>55515572
>class
>>
>>55516187
>VC++
>>
Is anyone hear familiar with Excel? I have a question and am about to pull my freaking hair out with this shit.
>>
>>55516178
Why is (a1000 == b1000) false? They both have the same value.
>>
>>55514332
class Program
{
public static void main(String[] args)
{
System.out.println("Hello World\n");
}
}


int main(int argc, char *argv[])
{
printf("Hello World\n");
}


I don't see what't so painful about that, it's not that much more setup.
>>
>>55516234
"int" is primitive, and "Integer" isn't. When doing == you check if two objects point to the same instance. "Integer" has it's own integer cache for lower values (-128 to 127), so values higher aren't part of the cache and therefore point to a separate reference. If you did a1000.equals(b1000); you would get true.

http://stackoverflow.com/questions/1700081/why-does-128-128-return-false-but-127-127-return-true-when-converting-to-integ
if you want to read more or if I lost you.
>>
>>55516278
>uses println
>adds new line character
>Hello World
>
>//input starts here
jej
>>
>>55514251
>>55515510

You have to be 18+ to use this site.
>>
>>55514251
Good : to be desired or approved of.
I hate Java and I do not approve of this post. Fuck you OP.
>>
>>55516289
Could you enlighten me on why having such a cache that breaks uniformity of behavior is not retarded?
>>
Java is obsolete and dying out.
Switch out while you can.
>>
File: java-100432255-primary.idge.jpg (56 KB, 620x413) Image search: [Google]
java-100432255-primary.idge.jpg
56 KB, 620x413
Java used to be really slow, but now with better VM and better hardware this is less of a problem.
Another problem with Java is that even for simple things you usually will write a lot of boilerplate code.
When a company evaluates the work of their programmers, if they use LOC metric, more code "seems" better to unaware managers, so the employee is praised.
Of course this doesn't mean it's good code.
What I really like about Java is that it has integrated classes for windows and graphics.
These days applications usually need to have some sort of UI, in other languages you have to use external libraries that may not be portable, in Java it is integrated into the language itself.
It is OOP and you don't have to think about memory managemeng, because garbage collector does it for you.
This is a +/- case, because the GC can run when you don't want it to making it seem like your application slows down and lags.
/g/ also doesn't like Java because it's known for being simple and easy to learn.
We only like hard things here, because it's challanging (usually).
>>
File: 1436200979041s.jpg (2 KB, 125x125) Image search: [Google]
1436200979041s.jpg
2 KB, 125x125
>>55514251
>subjective claim
>prove
/g/ is full of shitposting autists as usual
>>
>>55516289
>"Integer" has it's own integer cache for lower values (-128 to 127), so values higher aren't part of the cache and therefore point to a separate reference
holy shit that's retarded
>>
People still use Java because it is portable, fast, well-known, and good at most things. In reality, Java's bad rap comes from applet malware and desktop applications. Confluence and Jira are both examples of great Java programs.
>>
File: 1467843131450.png (283 KB, 714x574) Image search: [Google]
1467843131450.png
283 KB, 714x574
>>55514251
I always feel that way too, after using some other language for a long time.
>oh there was nothing wrong with java all langues have problems XD

Then after doing something with Java again, I end up ripping my anus because of how fucking insane it is.
>>
>>55518772
I think it has to do with memory stacks, that range represents one byte and is probably stored in a quicker access memory point, and then larger values are stored in a different location. (More data storage = slower access speed). It actually is pretty smart for getting programs to run faster.
>>
>>55514332
True. Go on ... ?
>>
Java is still ~50% slower than equivalent C code
>>
>>55516234
Integer is an object, int is a type. Comparing int to int would result true. But just like comparing Strings, comparing Integers (capitalized letter), will (not always) be false. If he did a1000.equals(b1000) it'd be true.
>>
>>55518861
Thats because C is closer to hardware level. But that doesnt make C better. Go develop any usable application in C, and then realize you could have used a better language like java, or something else..
>>
>>55514332
Well good think I'm not coding Hello Worlds over and over again.
>>
>>55516278
Once your program gets much more complicated, the bulky java syntax will become very painful to read through and maintain, even though it's easier to implement most of the things when you're writing in java. Also memory overhead.
>>
>>55514251
It's strict OOP and this sucks. You need to create classes for everything.
>>
>>55518772
All of the popular Javascript VMs, Dart, the CLR, LuaJIT, CPython and PyPy do the same.
>>
 throws Exception 
>>
you can't opt out of the OOP

inb4 jsut use static,

its feels wrong anon I want to have proper modules.
>>
>>55518223
See >>55518816

There's a reason why it's -128 to 127. Either way, it wouldn't break if you followed convention and compared objects with .equals() instead of "==". Also, the link that I put there also has the reason why == is different than .equals()
>>
>>55518736
python also has a integrated UI manager module, albeit a kinda shitty one.
>>
Java is a bad language but it has the best tooling and VM.

/thread
>>
On a broader note, could someone explain the problem with OOP? I've been working on a smallish project recently (a 2D flight sim to test collision avoidance), and modeling it as objects handled by a central coordinator (plus a graphical display) seemed the easiest way to go about it. Is the problem bloat associated with the paradigm, or have I just not learned the way of handling everything functionally?
>>
Everything Java does, Scala can do better, and more.
>>
>>55524172
You can safely ignore 99% of the complaints about OOP on /g/. Most of the people here just discovered functional programming and have never written anything non-trivial in their entire neet lives.
>>
>>55524237
I wrote a compiler in Haskell
>>
>>55524172

The main argument against OOP is that is sometimes requires a lot of bloat and code to accomplish certain things that are much easier expressed with some functional ideas like Higher Order Functions.

If you read the book "Game Programming Patterns" in the first part of the book it revisits some patterns in the GoF book which is the iconic book on design patterns of OOP programs.

In some cases he shows how to do something in a functional way, and it's clear that it's much more concise compared the OO way which requires a ton of boilerplate.

So some problems are much more cleanly expressed in a functional way, and many people believe that by making your datastructures immutable you avoid a large class of problems in larger application development.

So being strictly OO in it's current form is restricting in a lot of cases, just like being stricly FP is restricting.
>>
>>55518736
>When a company evaluates the work of their programmers, if they use LOC metric, more code "seems" better to unaware managers, so the employee is praised.
I quit reading here.
>>
>>55524213
Scala is crap. Martin is smart but can't code for shit. Everything he touches inevitably needs to be completely rewritten (scala compiler and 95% of the standard library for example).
>>
>>55524322
Hi Paul!
>>
>>55524277
Fair enough, my program is in Python because I'm a babby so I avoided a lot of the restrictive patterns you see in Java. Mostly I just think the basic idea of encapsulating data and methods is a natural fit for some, well, objects, and either there's something really offensive about that or OOP implies something else.
>>
>>55524374
Paul and Jason are objectively far smarter than everyone else in the Scala community.
>>
>>55520610
that doesn't make it not retarded. The fact that there's a completely different behavior/convention for comparing Integers based on an arbitrary cutoff is horrible language design.

Even if it's to increase speed, it's still a solution to a problem that shouldn't exist, and not a very good solution at that.
>>
>>55524425
Hey, I think Miles is pretty sharp too.
>>
>>55524462
The people designing those VMs are far smarter than you will ever be. It's also expected behavior since Java differentiates between primitives and objects.
>>
>>55524565
>It's also expected behavior

That's the whole problem though, it's not.
https://www.google.com/search?q=java+integer+127&oq=java+integer+127

Unless you happen to know that these values are cached you received unexpected results. That's why this is such horrible design. There's no way to know that == compares by value in a certain range and by reference in another without having either specifically looked it up or faced the issue before.
>>
>>55524633
Business idea: get rid of universal ==, !=, equals, toString, and hashCode
>>
>>55524633
>Unless you happen to know that these values are cached you received unexpected results

Wrong. You just have to know how to compare objects properly in Java and understand what == actually does. This is explained in detail in basically every beginner Java book.
>>
>>55524652
Those should all be removed from the top type (Object in Java). Equality and hashing doesn't even make sense for a lot of objects.
>>
>>55524728
I propose typeclasses
>>
>>55524633
I always laugh my ass off at retards who confuse == and equals()

it's such a simple rule to remember
== for primitives and enums
equals() for everything else

if you can't get even this through your skull, look for a new job
>>
>>55524740
I prefer typeclasses but this could be solved with Java interfaces too. Types that want equality should just have to implement an Equals<A> interface.
>>
>>55524728
I disagree. Those methods are the only way to be able to differentiate instances from each other.
>>
>>55524856
No they aren't and the vast majority of classes don't even implement them because they don't make sense for most objects.
>>
>>55524703
>You just have to know how to compare objects properly in Java and understand what == actually does
== in Java compares values on primitive types and references on objects. I do understand what it actually does and the different between it and equalsto. The problem is that in addition to doing that, it also happens to compare values on Integer in a certain number range, which is a quirk contrary to the actual design and purpose of ==.

At this point I assume you're either autistic or trolling because if you can't get the concept through your head that having a quirk like this which is completely contrary to the behavior of == and .equalsto in every other aspect of the language, is generally a bad design choice, then there's no point in continuing our discussion.

>>55524749
>>== for primitives and enums
>>equals() for everything else
you forget
>also == for Integer between an arbitrary number range because language quirks are fun!
>>
>>55524926
>>also == for Integer between an arbitrary number range because language quirks are fun!
just don't touch Objects
even enums should be off-limits, technically
>>
>>55524926
>also == for Integer between an arbitrary number range because language quirks are fun!

Are you legitimately this dumb? This is an impressive level of stupidity.
>>
>>55524926
It's not a language quirk.
>>
>>55516178
werks in c#
int a = 100;
int b = 100;
int c = 1000;
int d = 1000;

Console.WriteLine(a == b); //true
Console.WriteLine(c == d); //true
Console.WriteLine(ReferenceEquals(a, b)); //false
Console.WriteLine(ReferenceEquals(c, d)); //false
>>
Hello world takes up just 178M of RAM
>>
>>55524991
how much RAM the JVM takes up is entirely up to you, retardo
>>
>>55519324
KEK
>>
>>55524926
>also == for Integer between an arbitrary number range because language quirks are fun!

Integer.equals will always give the correct result. == can also give the wrong result if the two Integer objects were loaded by different class loaders.
>>
>>55524965
>>55524982
how is == behaving completely differently in one specific number range on one specific type not a quirk?
>>
>>55525051
It's how the library works, it reuses the same instances for small numbers.
>>
>>55514251
> OOP
Some languages that are actually good: common lisp, ada, haskell, C, python, OCaml
>>
>>55525051
There is no specific number range in Java 7+ and Integer and int are not the same. You should not be comparing Integer objects with ==, you should be using the .equals method since you want to compare the value itself and not the object reference.
>>
>>55525084
Before people start getting triggered, I take it you mean C++, right?
>>
>>55525106
No, plain old C. C++ is the PHP of statically typed languages.
>>
>>55525084
>python

>dynamically typed
>slow
>unicode problems

fuck right off, mate
>>
This thread is already so big, and yet no one has mentioned Java's most annoying fucking problem

>RUNTIME TYPE ERASURE

Writing any even slightly generic parametrized class is nigh-impossible without retarded hacks and/or workarounds

What on earth made Sun do this?
>>
>>55525234
Backwards compatibility.

Erasure is a good thing, anyway.
>>
>>55525234
> What on earth made Sun do this?

Backwards compatibility. Java and C++ are actually used in places that matter so they have to make progress without breaking everything. That often means features can't be implemented in the optimal way. The limitation on Java generics isn't a problem 99% of the time.
>>
File: 1467925043578.jpg (41 KB, 530x520) Image search: [Google]
1467925043578.jpg
41 KB, 530x520
>>55525181
> slow
hurr durr my 'hello world' niveau programs need to run on C like speed hurr
>>
>>55525367
Python is way too slow to be acceptable. There are tons of languages that are just as expressive that aren't nearly as slow.
>>
>>55525106
>>55525120
this
>>
>>55525318
>Java and C++ are actually used in places that matter so they have to make progress without breaking everything.
and yet most Java legacy software is just kept on its ancient Java version until it completely dies off

also funny you "know" all this and yet seemingly haven't written anything complex enough to require parametrized generics
>>
>>55525423
You're an idiot.
>>
>>55525120
I think I know what you are talking about. I have seen C in OOP style, however is it used often?
>>
>>55525474
good one
>>
>>55516178
public static void main(String[] args) throws java.lang.Exception { ... }


will this even work?
>>
>>55524376

There's nothing offensive about it but there are different view points.

I believe the problem with OOP is fundamentally the way you approach building the software. A OOP developer will think of his programs in terms of a hierarchy of objects interacting with eachother. So a Player inherits from an NPC and interacts with a Weapon and etc. The issue is that you're trying to model this abstract code into something more familiar in the physical world and there is a mismatch.

A Chair and a Foldable Chair and and Breakable Chair are all chairs fundamentally but the way you'd implement them in code is different so there's a mismatch between what you're attempting to do and what it actually is. Programming at it's heart is all about DATA not objects or classes or virtualized methods. It's about taking some data and transforming it into other data, it is a better match for what programmers actually do.

So I try to follow data oriented design rather than object oriented design or FP. It just happens that FP has many useful constructs for transforming data in ways that are easy to maintain and parallelize, so FP is thought of to be a better paradigm. In some cases, putting state inside a container with associated methods is useful, but much of the extra shit that comes with OOP is unnecessary and leads to hard to maintain code.

That is my opinion anyways.
>>
>>55525752
sure why not, all expeptions inherit from java.lang.exeption dont they ?
>>
>>55525786
>It just happens that FP has many useful constructs for transforming data in ways that are easy to maintain and parallelize, so FP is thought of to be a better paradigm.
That's a myth. After 40 years and millions of dollars, FP is no easier to parallelize than it was when Backus wrote his paper, i.e. a lot harder than imperative loops, which were already being parallelized by Fortran compilers in the 1970s.
>>
>>55525752
Yes, main can throw an exception if you want.
>>
>>55525861

I am of the opinion that shared nothing memory processes ala Erlang is a very simple and scalable way to build concurrent and fault tolerant systems.

With Go you have coroutines that can share memory I believe, which works but opens up a world of trouble in many cases when it comes to debugging.

I do not know the deeper implementation details of the BEAM or Go, but I know that it is easier for me to reason about Erlang code than Go code in the context of running multiple processes concurrently.
>>
It's not contrarian enough for /g/.
>>
>>55525956
Erlang is solving problems that 99% of programmers don't have.
>>
>>55525861

Also it's pretty amazing to me how far we've come since the 70s. That is to say, not far at all. The field of CS is now more based on fashion than actually solving new problems in innovative ways.
>>
>>55525976

You don't have it because you replicate the solution by adding more architecture.

For instance, having an in memory store for session storing in backends that talk to mobile/web clients. For most people they'll start off with a php/ruby/python backend, come to this problem and add redis to their stack to handle this, whereas in erlang it's just something you handle via the language and runtime.

Much of what is needed in other languages is irrelevant in erlang, I'd suggest you don't dismiss it entirely, because you might lose out on a new way to think of things.
>>
>>55518861
I'm not convinced this is true at all. Certainly not in some very important cases.
>>
>>55525990
That's because most of the research now is about type systems.
https://unqualifiedreservations.wordpress.com/2007/08/02/whats-wrong-with-cs-research/
>>
>>55526027
You can do in memory caching in any language that isn't slow as shit and replicating a cache across machines is trivial. Redis has skyrocketed in popularity simply because most web developers are using language implementations that are embarrassingly slow and essentially single threaded.

The majority of websites/network services don't need to scale across multiple machines either as long as you aren't using a language that is ridiculously slow (Python, Ruby, PHP, Perl etc.). I have an unoptimized Java service serving 40,000 requests per second on a single box at work and it does multiple database queries on every single request with no caching. Most services will never even come close to this level of traffic and we could easily get 200,000+ with caching.

> I'd suggest you don't dismiss it entirely

I know Erlang and Elixir very well. I'd still suggest using C#, Java, F#, Scala or Go in most cases.
>>
File: performance_ratio.png (250 KB, 600x450) Image search: [Google]
performance_ratio.png
250 KB, 600x450
>>55524161
>best VM
.NET runtime is better desu
>>
>>55526332
>python cross-memery
>relevant
???
>>
No pointers
>>
>>55526248
>https://unqualifiedreservations.wordpress.com/2007/08/02/whats-wrong-with-cs-research/

Great article, thanks.
>>
Anybody else think Project Lombok is the best thing to happen to this language?

>no getter/setter boilerplate
>no constructor boilerplate
>no equals/hashcode boilerplate
>no builder pattern boilerplate
>no synchronization boilerplate
>no logging boilerplate
>no checked exceptions

Patiently waiting for Oracle to get off their asses and integrate it into the language
>>
>>55514251
no shit senpai.
>>
>>55525752
Yes, the reason that was in the image was because it was trying to make fun of how error prone java can be.
>>
>>55526508
>how error prone java can be
what?

where you stick your checked/unchecked exceptions is absolutely your own choice
>>
>>55514251
Its much better than c
>>
>>55525084
I was with you until Python
>>
>>55525388
Like Ruby!
http://benchmarksgame.alioth.debian.org/u64q/ruby.html
>>
>>55525388
JavaScript.
>Over 10 times the speed of Python
>Uses far less memory
>Doesn't force you to write horribly procedural code

http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=node&lang2=python3
>>
File: checkem.jpg (39 KB, 640x360) Image search: [Google]
checkem.jpg
39 KB, 640x360
>>55527666
Welp I like it, but apart from that nice trips m8.
>>
>>55514251
>no operator overloading, user-defined numerical types have to use functions like multiply(a,add(b+c))
>need to define a class to make a Hello World or Fizzbuzz
>impossible to create a reference or pointer to primitive types, makes swap functions nearly impossible to implement
>can't read input from the console without instantiating objects
>>
>>55527685
Ruby is currently slow as shit like Python but at least Matz is trying. They've made some fairly nice performance improvements in the last few releases and Matz's goal for Ruby 3 is to make it 3 times faster. He's also seem to be leaning towards optional typing.

Guido doesn't give a fuck and Python 3 is actually slower than Python 2 in most cases.
>>
>>55515480
>tripfag
>doesn't have a tripcode
>>>/b/eingthisnew

>>55516218
What's the question? Just saying it has to do with Excel doesn't really say much about the problem.

>>55524266
For what, brainfuck?

>>55526332
Doesn't that chart imply .NET is SLOWER than the JVM?
>>
>>55528013
>Doesn't that chart imply .NET is SLOWER than the JVM?

To be fair, nobody really uses Jython or IronPython anyways and neither implementation is likely to be very well optimized.
>>
File: 1441982713395.png (24 KB, 440x358) Image search: [Google]
1441982713395.png
24 KB, 440x358
>>55518736
>What I really like about Java is that it has integrated classes for windows and graphics.
But Java applications are ugly
Thread replies: 133
Thread images: 12

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.