« first day (1252 days earlier)      last day (3690 days later) » 

fge
12:42 AM
github.com/fge/java7-fs-ftp <-- contributors more than welcome
 
 
4 hours later…
5:02 AM
hi guys
 
fge
Hello
 
 
5 hours later…
9:39 AM
hey guyz anybody there to help me
 
 
4 hours later…
1:31 PM
1 message moved from JavaScript
 
2:10 PM
Good morning, Java!
 
What exactly does that message do in this room either?
 
1 message moved to JavaScript
 
user1596138
lol 4 hours later
 
We're not here to actually help people. Come on.
@fge Ah, I see the Builder pattern. Nice.
 
2:28 PM
I've got a small problem in java. I got the error of "the left-hand side of an assignment must be a variable while instantiating the StringBuilder elements of an Vector. Can anyone help? here's a sample code:
 
fge
@Michael FtpConfiguration?
 
Vector<StringBuilder> a = new Vector<StringBuilder>();
a.setSize(10);
for(int counter = 0; counter < a.size(); counter++)
{
a.elementAt(counter) = new StringBuilder();
}
 
fge
@MelikaBarzegaranHosseini why a Vector? This is 2014, not 1994
 
What should I use instead? but if you can help around Vector in this problem as well I'll be thankfull.
 
fge
Use an ArrayList for instance; also, they resize on demand
With an ArrayList you could do for (int i = 0; i < wantedSize; i++) list.add(new StringBuilder());
 
2:32 PM
@fge Yep.
 
fge
@MelikaBarzegaranHosseini you can do the same with a Vector since Vector also implements List -- but use an ArrayList
 
So, how are you people enjoying Java 8?
 
@MelikaBarzegaranHosseini You cannot assign a variable to a method call.
@BenjaminGruenbaum Haven't used it.
And "you people"?
 
"Room people"
 
Ah, ok.
 
2:35 PM
I was just wondering if they really fixed Java
 
fge
@BenjaminGruenbaum fixed?
 
Yeah, as in - it's an acceptable language now.
 
fge
What is there to "fix"? (OK, apart from that backwards compatibility preventing runtime types for generics)
@BenjaminGruenbaum looking to start a war? ;)
 
We have lambdas now. :D
 
fge
@Michael yep, and a lot of room for unreadable code in the process -- it has already started :/
 
2:38 PM
@fge not looking to start a ridiculously easy to win war :D Java 7 is quite horrible. On the upside it looks like 8 is really improving things.
 
The problem with vector that you say it shouldn't be used is something related to Synchronizing and threads?
 
fge
@BenjaminGruenbaum matter of tastes, as always
 
It's not just runtime generics, there is a whole world of things Java can't do.
Generators are huge for example.
 
fge
@BenjaminGruenbaum for instance I hate python, but I don't say it is horrible
 
Functional interfaces and default interface implementation goes a long way I hope.
 
2:39 PM
@MelikaBarzegaranHosseini The Vector class is thread-safe, which cuts into performance and is something you don't need in many situations.
 
@fge because it's not, I'm not a Python fan either but it's a decent language for sure.
It has all the building blocks a programmer needs and a lot of correct abstractions in place. It has its weaknesses - but it's well thought out.
 
fge
I mean, relying on indentation in 2014? The only language which did that previously was COBOL!
 
ArrayList is the better choice. Vector is pretty much deprecated.
 
@fge how is "two languages are doing it and one is old" an argument?
 
uhum, thanks for help guys. :)
 
2:40 PM
@MelikaBarzegaranHosseini You're welcome.
 
fge
Anyway, I don't see anything fundamentally wrong with Java
 
@fge seriously?
 
fge
It does everything I need and more, and it is rock solid
Yes, seriously
 
How do you write your asynchronous IO with Java 7 :)
 
fge
Simple
 
2:40 PM
/me prepares for flame war
 
fge
Look at java.nio, it has everything you need
 
Let's say I want to make a DB call, and then based on it read a file, and then based on it make two web requests, when both are done, print something to the screen based on their result.
Something that's trivial to do with C#, or JavaScript for that matter.
 
fge
Nothing undoable in Java
 
How would it look?
Let me start by how I'd do it in C#?
Let's say the query selects all elements in the Experts table with even IDs?
 
fge
That is a neverending argument, mate
 
2:43 PM
No, it's really simple
 
fge
And you should really google around for libraries doing queries for you, some are ridiculously easy to use
Anyway, I am plenty happy with Java 7 already, and FileSystem rocks
I mean, you can Files.copy() from an FTP server right into a ZIP file with one line of code
ONE
 
var expert = await db.Experts.FirstAsync(x=>x.Id%2 == 0);
var f = await File.ReadAllTextAsync("File"+expert+".txt");
var reqs = await Task.WhenAll(new Request("url1"), new Request("url2");
Console.WriteLine("Hello {0} {1} {2}",req1.Result,req2.Result,expert.Name);
Something like this. This is the above requirements in C#, let's not 'boast' C# here though, let's choose another language, let's look at JavaScript:
var exp;
db.experts.first({$id:"x%2 !== 0").then(function(expert){
     exp = expert;
     return await File.ReadAllTextAsync("File"+expert+".txt");
}).then(function(text){
      return [request("url1"),request("url2")];
}).spread(function(res1,res2){
     console.log("Hello",res1,res2,expert);
});
(Or, with generators, you can get C# syntax, but let's disregard that for now)
Let's talk about filtering a list? With Java 7 that's very crafty, Java 8 does a much nicer job.
@fge you can do that with most other languages too, but the abstractions break when you want to synchronize things :D
Java 7 simply doesn't have strong enough built in abstractions in 2014, I asked if 8 fixes it.
 
fge
Uh right
 
Meh, didn't want to start a debate on why Java sucks. I though that was pretty established :/ Wanted to ask about opinions of Java 8
 
fge
I don't care, and what is more, the code above lacks one crucial thing from my point of view
Error checking
"Java sucks" is your opinion
 
2:50 PM
@fge that's the thing, it's built in :D
 
fge
As far as I'm concerned, it rocks
 
You can try { } catch( the asynchronous C# code above, that capability is built into the language.
Same for the JavaScript code, you can .catch it based on type or predicate at any stage.
 
fge
What you don't seem to realize is that there are libraries doing that for you already
Ever heard of Guava?
 
Of course :) I love Guava
It's just that even with the libraries, Java is ~5 years behind other language - wanted to know if it was fixed that's all.
 
Two words: compiled language
In Javascript, you don't know about syntax errors until your code runs.
 
2:52 PM
Of course you do...
 
</end-debate>
 
There have been linters for years now.
Not to mention C# is also a compiled language.
 
Oh, so you need to go to some ad-riddled website and upload your code to some dude's website.
 
fge
I don't care about petty abstractions which make your code shorter to write, I want code that Just Works(tm)
 
fge
2:53 PM
And Java works
 
So does assembly, don't see me writing my code in that..
 
fge
And Java 8 is all good all fine, but I really wish people started to actually use 7's java.nio.file before that
Even today most code for file manipulation uses the antiquated File
That's beyond me
 
@fge That's what I'm trying to say, the language could be a lot more powerful with abstractions like await which would make nio much nicer to work with.
You're right nio is a much better abstraction than the old io, but imagine having language support for asynchronous code.
Imagine having a much better abstraction for tasks than just Runnable, like a non broken Future that chains. Like the JS example above.
 
fge
Why do you want such abstractions in the language where you already have the building blocks to do these, and can rely on external libraries to do your stuff? I don't get it
If you want an asynchronous server, use Netty, for instance
 
I want good building blocks, not broken ones.
 
fge
2:56 PM
If you want super fast string splitting, use Guava's Splitter
 
Waiting for an asynchronous operation is fundamental.
 
fge
The fact that Java's building blocks are low level doesn't make them broken, mate
They exist
One word: Future
 
@fge No, the fact that everything is an object except some stuff that is not an object is broken.
 
fge
It has been there since jAva 5
 
@fge Future is broken - I said that already in this conversation, it doesn't really chain well. Imagine a .then method on a future that takes a callable and applies it to the future's result when it is available and then runs a function on that.
Better, in C# they built in a powerful version of Future into the core.
You can await a future which is like .Wait except it doesn't block.
 
fge
2:58 PM
Why would I need chaining in the language itself whereas it is sooo easy to program the chaining yourself?
 
Not to mention not having events, generators, first order functions, strong composition facilities, operator overloading, value types, real lambdas etc.
 
fge
Operator overloading is a misfeature to me
 
@fge that's the thing, without first order functions and without closures it's really not.
 
fge
There, you see? Beauty is in the eye of the beholder
</debate>
 
@fge no it's not. BigInteger is a nightmare.
If I may ask, what other languages do you code in?
Not trying to go ad hominem here, but I'm really starting to suspect you just haven't used that many other languages.
 
fge
3:00 PM
perl, C, shell and (only when I really have to) python
 
:(
Ok, </debate> :D
 
fge
I've done some Scheme as well -- nice language but a toy
 
If I may say something that sounds offensive - You should definitely check out C# to get more perspective.
 
fge
And add groovy to that since all my projects use gradle
 
Speaking of toys :P
If I had to pick out two JVM languages they'd be scala and clojure, although I did and still do more Java than either of those.
 
fge
3:02 PM
I positively hate Scala
 
I just think you should reconsider your stance about the abstractions. Having a strong abstraction on 'work' built into the language is amazing.
Also, generators, events, lambdas, meh - I'm missing the train again ain't I?
 
fge
You know what? I do'nt miss any of those -- either because I just don't need them or have libraries which do that for me
 
Not to mention most Java I read is horrible. People do horrible things, but then again that's true for many other languages.
@fge probably the former.
Imagine being able to parallelize a workload with .AsParallel()
 
fge
With Java 8 you can .parallelStream() any Collection
 
Imagine that boom - the JVM rolls out a pool and ExecuterService and manages concurrency optimally for you.
Yeah, I wasn't dissing Java8 here :D I was dissing Java 7. I like streams so far.
Except for the part where the Java object system is broken and ints and friends are not objects and you have the ugly casts - it's really nice.
I just wish they'd let people have better type inference outside of flamdas, and give people the ability to use closures.
 
fge
3:06 PM
As to "optimal concurrency" <-- that doesn't exist, you cannot build that into the language, it entirely depends on what your task does
 
Yeah, the runtime figures it out for you :D
It's not 100% bulletproof, but it works nicely most of the time. It evaluates the workload and distributes it differently and more effectively as it goes.
 
fge
Pure computing tasks will use nrCpus, but tasks which mix I/O and CPU don't have an "optimal concurrency"
No amount of language builtin mechanism will ever do that for you
 
It'll take the I/O and run that on events without using a thread, and take the CPU tasks and run those on threads.
I said, it's not 100% bulletproof, but it works.
A thread and an event based workload both base themselves on the same Task API.
 
fge
Well, the day I'll do Windows, I'll go C#, but right now I do Linux and Java it is ;)
 
Hah, C# is also really expensive to develop with.
I'm not saying it's all sunshine there either, but I really hope streams and java 8 abstractions modernize Java.
 
fge
3:13 PM
What I hope is that lambdas won't produce too much unreadable code
Unfortunately it has already started
 
@fge unreadable?
Example?
 
fge
Example? Well, `.forEach(() -> { /* 40 lines of code here */ })
I mean, that is ridiculous
Might as well create a method and call .forEach(method::referenceHere)
 
C# actually doesn't have forEach on streams for that reason.
Their streams in the language integrated querying (LINQ) explicitly don't have a .ForEach method, lists do but it's unused really.
 
fge
Make that anywhere you can use a @FunctionalInterface, .forEach() is far from being the only thing you can abuse
 
Instead you just use the standard foreach(var el in iterable) loop or the for(TooLongNameBecauseNoExposedInference el : iterable)` Java version
 
fge
3:17 PM
`final Runnable r = () -> { /* some overly complex übercode */};
 
@fge just because you can abuse a feature doesn't mean you should :D
 
fge
Heh, sure, but that doesn't prevent people from doing so, does it?
 
Hmm, jQuery author John Resig once gave us (JS room) a very good answer when the room accused jQuery of people writing bad code.
Lemme find it.
 
fge
jQuery? Bad code?
 
in JavaScript, Feb 19 '13 at 16:12, by John Resig
bad uses of JavaScript existed long before jQuery ever came out - jQuery being popular doesn't stop bad devs from existing, the only thing that stops bad devs is good education, which is why I've written two books and am working at Khan Academy
 
fge
3:19 PM
Uh, I use it, and I think it is a great addition
 
I mean people doing
$(function(){
   // 200 lines of code
});
Or using selectors heavily, after the bootstrap phase of the application. Or very long event listeners.
 
fge
Abuse exists everywhere anyway -- but more particularly when a "new kid" comes in town
Thus I preidict Java 8's lambdas will be abused
(well, they are already)
 
Abuse of features is a part of evolution :)
 
fge
Yes but it can detract people from using a feature entirely if all they see is some toying around with anonymous lambdas only
Look at that: stackoverflow.com/a/22663410/1093528 <-- did you know you could use all of these as lambdas?
 
They are very useful though for their problem domain
 
fge
3:24 PM
This is quite a viper's nest
 
Only for incompetent developers. No one serious believes readability isn't one of the most important aspects of code in 2014.
Although I have to say all those videos of Uncle Bob butchering code and making it worse with refactoring aren't making a good case :P
 
I know its an old question and I have read couple of things on internet. It all seems confusing so I wanted to confirm from you guys. About two threads running in parallel on multi-core processor. In practical, can java two threads execute in parallel? I know we can start two threads in parallel but can they execute whatever functionality they are supposed to run?
 
@webdev yes, in practice two Java threads can execute in parallel.
 
fge
@webdev of course they can, what made you think they couldn't?
(or wouldn't, rather)
 
Unless you're on Java 1.1 or lower :P In which case they don't work well on multiple CPUs, but unless the code is from 2000 that shouldn't be the case anyway.
 
3:28 PM
ok I saw couple of posts including this one stackoverflow.com/questions/3836937/…
 
@webdev that's about it doing it itself without you having to use threads, not about threads doing it.
 
so as fas as I understand its up to OS to divide them into separate cores? We can not force it.
 
fge
@webdev uh no
 
@webdev there are two things at play here, the Java threads and the OS threads.
 
fge
@webdev you ask the OS to create a new process/thread
 
3:31 PM
The OS can always decide to schedule all your work on only one thread and let the rest idle if it pleases. However, modern OSs don't work against you.
The OS can run every process you're running on a single thread if it pleases, but it won't because that's be silly :)
 
fge
@webdev anyway, for Java, buy "Java Concurrency In Practice" -- and read it correctly
 
The JVM can also stop and decide it's running everything on one OS level thread (aka, green threads) but it normally won't.
 
hmm so if I write a program to divide my work on multiple threads and expect them to work in parallel not concurrently. It may not work as I expected on all the platforms
 
Assuming you use a modern JVM (which you most likely are) it'll just work as expected.
 
fge
@webdev if you use the correct APIs the JVM will do its best to answer your needs
 
3:34 PM
However, the complete answer is that it might not. It's not up to you to decide, you ask and the JVM complies by asking the OS which in turn complies.
The OS will also use clever OS level scheduling algorithms to decide which thread gets more "juice", although you normally don't want much more threads than cores.
So all in all, it'll work, although it might be a bit different on different operating systems. A common example is that Windows gives UI foreground programs more cpu time than background ones where linux for example doesn't.
 
yea I got it. May be old posts but have seen so many posts that claims that Java will always run threads concurrently not in parallel. Thanks for you help @BenjaminGruenbaum @fge
 
@webdev sure.
 
fge
@webdev and what difference do you make between "concurrently" and "in parallel" exactly?
 
concurrently means threads start, run, and complete in overlapping time periods and parallel means literally run at same time
 
fge
Uuuh
 
3:40 PM
am I wrong :P
 
fge
Well that is not how I'd define them
But nevermind
 
so may be I didn't ask my question properly I was asking can two java threads run in parallel i mean at same time
thats fine thanks for your help
 
fge
Well, the answer to that is yes if you have multiple execution units
 
Well that is valid for any kind of application running on OS. But I got the point that from Java point of view you can't do anything other than trusting that everything will be fine :)
 
fge
That's true for any language
But don't worry, JVMs do their job just fine
 
3:51 PM
:) thanks for your help @fge
 
 
1 hour later…
5:04 PM
I wanted to do some auditing of the calls, but wanted it to be pretty much automatic. AOP is the way to go, but I find junior developers have all sorts of problems with it (learning curve). So, what do you think is the way to go? Lambda expressions to surround the expressions and create logging, or use something like New Relic?
 
Hi, anyone having idea of internationalization in eventhandling using spring
 
 
1 hour later…
6:25 PM
hello everyone
guys, please help me to start building a webservice using java for mobile apps
hello webdev
 
7:02 PM
Hello every one
real life application of graph in data structure??
 
7:21 PM
The Internet.
 
7:41 PM
hey guys
 
8:28 PM
anyone familiar to quartz?
 
8:54 PM
HI. Can anyone help me on a scala question?
0
Q: Unable to get `POST` parameters in `params`

loveshI am running scalatra 2.2 using sbt version 0.13.0 and using its in build server(jetty). I am running on kubuntu 13.10 64 bit and my OS version a and java version 1.7.0_51. I am using OpenJDK 64-Bit. In my sample app i can get GET parameters through params but i cannot get POST parameters. I chec...

 
9:10 PM
What doubt you have on quartz ?
 
Greetings. I am receiving error that integer cannot be cast as Double. It seems that error is because that type conversion is with (Double) not (double):
double minPathPrecision = ((Double)request.getHint("douglas.minprecision", Double.valueOf(1.0D))).doubleValue();

This is not my code, but inside class file inside jar archive. Any way to fix it?
 
9:29 PM
@Abhilasha I'm working on a legacy application that runs some jobs, thing is I was looking at a sql trace and it sets IMPLICIT_TRANSACTION_ON everytime it runs, but does not autocommit
@DanielsPitkevičs what's the return type of doubleValue?, stack trace?
 
@Gu
@GustavoSuarez sorry, but the owner of that jar file answered on issue in github. So sorry for disturbing. :)
 
@DanielsPitkevičs that's ok, glad you found a solution
 
9:57 PM
@G
@GustavoSuarez : What is Quartz property set to ?
 
10:14 PM
@GustavoSuarez : you need to set org.quartz.jobStore.dontSetAutoCommitFalse=true in your main configuration file.
 
10:34 PM
@Abhilasha what's the default value of that param?
 

« first day (1252 days earlier)      last day (3690 days later) »