« first day (1667 days earlier)      last day (3273 days later) » 
00:00 - 14:0014:00 - 23:00

fge
12:00 AM
<-- looking for a new avatar
 
 
4 hours later…
4:28 AM
morning
 
Good morning!
 
hi @Unihedron =)
 
hiya :p
 
4:49 AM
Hello Room!
Got a question that I think I'm over-thinking. In Processing (simplified java code), running empty code draws a 100x100px white window.
The question "why does it draw it this size?" is a practice question from previous exam. They're not looking for a complicated answer. Is it because a) 100 is a nice number to work with for positioning elements?
b) 100x100 will fit on any screen being used for coding?
c) something I haven't thought of
Thanks
 
@mikeeustace c - they suck and provide terrible default sizes
 
@Unihedron - prob not the answer the examiner was looking for :)
but also, esp. with zero indexing, isn't 100 pretty good. Approximations to bin fractions are easy. 1/3, 1/6 etc are too
 
 
1 hour later…
6:11 AM
weekend horror
 
yes
<- coding joyfully
 
6:50 AM
hi.. Good Afternoon
String ddd = request.getParameter("est_dlvy_dt");
		System.out.println("Estimated Delivery Date = "+ddd);
		try {
			SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
			Date date = (Date) formatter.parse(ddd);
			System.out.println(" date >>> "+date);//print Wed Sep 10 00:00:00 IST 2014
			java.sql.Date sqlDate = new java.sql.Date(date.getTime());
			System.out.println("sql date ::: "+sqlDate);
			rec.add(sqlDate);// 1
		} catch (Exception e) {
			e.printStackTrace();
		}
my input date was 41/05/2015 (which i expected to throw an exception when formatter.parse())
i don't get any exceptions :(
anyone can help me?
 
7:33 AM
What's the problem?
 
7:46 AM
Did you try to var dump the date itself?
 
8:35 AM
hey!! are scala questions welcome?
pastie.org/private/pnukzkfwzuvq0dhcl9dmw I was hoping some one could help with that. I have a type error in the while statement
 
@argentum47 No.
 
oops
ok
umm why ?
 
fge
Because Scala is not Java and this room is dedicated to the Java programming language :)
 
but Scala uses jvm :P and there is no scala room :(
 
I presume a jvm question would be on topic, but scala the language is not
 
8:44 AM
ow.. ok
 
just another language we are not familiar with
 
hello
 
duh, I will dump Scala, waste of time... although I picked that one because I thought I could get a taste of java but would have to write less code.. but it seems the amount of time required is becoming the same ..
o wait, wth, when I saved the file the error is gone, what kind of troll is this . facepalm
 
@argentum47 Yes, Scala is an absolute waste of time.
 
fge
8:57 AM
@argentum47 it is a fallacious argument at best that writing less code is better
If you want to write less code, program in brainfuck; and good luck in re-reading yourself even after a week
Code is WORM -- Write Once, Read Many
 
that is true ..
 
Java can be overtly verbose sometimes (though that was partly fixed with 8), but it's the reading time that matters, not the writing time
Optimizing the writing time has to be the mother of all premature optimizations
 
i just want to learn DS and Algo ..
 
fge
@kiheru it is even a cardinal sin :p
DS?
Data structures?
 
yup, not in C or C ++
 
fge
9:02 AM
Well, have a go at Haskell
It's a really interesting language
 
that is an entirely new language with lots of -> .. I will stick to java
 
hello all , has anybody worked on jax-ws web service implementation with asynchronus client generation ?
 
fge
Wait, you didn't try out Scala because it claimed to be functional? :p
 
I did, but it had some commonality with java, i thought
 
never used Haskell, so I may be completely wrong, but would not some data structure work be a bit more complicated due to the pure functional nature?
 
fge
9:11 AM
@kiheru Haskell's type system is precisely one of its strengths
 
I have heard the type system is really nice. Mainly I was thinking about mutability.
 
9:43 AM
Mutability? Look at Clojure, everything is immutable :P
 
hi
 
can anybody help me with compiling openfire using netbeans ?
i am able to compile it using the command line, but with netbeans, it should a ton of errors
 
@harvey_slash Sure. I accept paypal, mastercard, visa, BTC, dogecoins and nyancoins
 
@Coldplay heya
 
okay, moving on.
can anybody else help me
 
9:47 AM
@harvey_slash lolz :P
 
I need dogecoins :)
 
@harvey_slash No, because I forbid it. :P
 
please, help me out
 
1 message moved to Trash
 
9:48 AM
@Unihedron hey
 
@Coldplay Cut it out.
 
@coldplay , please dont post all that. I know , with 20 rep, you must be very happy about being able to chat here
so, anybody ?
 
@harvey_slash so that's what you do guessing other people thoughts
 
yeap, thats what I do , thats why i need help from others when it comes to programming
 
fge
@harvey_slash you don't show any code at all, how do you think anyone can help?
 
9:50 AM
its nothing that I have writte @fge , its something I want to compile. Openfire . Its an xmpp client
 
I said cut it out.
 
lol :P
Did you just kicked him?
 
@ItachiUchiha Chatting is a privilege that can be taken away.
 
lol, poor guy
 
He was just having a good time :)
 
9:52 AM
this is exactly what I have done btw
 
@ItachiUchiha You can take it that I'm jealous, then.
 
@Unihedron coz he was posting better pictures than you did :P
@Coldplay wb :)
 
@Unihedron why are you inviting to to trash?
 
>:(
You have a problem with my art skillz?
 
@Coldplay , please dont be so artistic here
 
9:54 AM
:v lol
 
@harvey_slash Are you the moderator here?
I need to talk to the boss
of this group
 
btw, which country are you from @Coldplay ?
 
@harvey_slash Brazil
 
russia
ow
 
fge
9:57 AM
@Coldplay what for? There is no "boss", just volunteers
 
if thats the case, then i volunteer to be the boss :)
 
@harvey_slash Declined.
 
I am going out you guys enjoy
 
you arent the boos, you are just a volunteer
so you have no say
 
Will meet you 6 hours later
 
9:58 AM
This volunteer is capable of declining your requests. For some weird reason.
 
@argentum47 @Coldplay @harvey_slash @Unihedron @fge @mikeeustace @Michael @kiheru @MadaraUchiha @Gemtastic @Kylar @rlemon @LeeJeong Welcome people from around the world to the Java Room :)
 
Hi! Welcome everyone!
 
Welcome
 
morningz all
 
btw @Unihedron, what do you work as ?
 
9:59 AM
o/
 
@harvey_slash My profession?
I am a student.
 
@Unihedron student of ...?
 
I occasionally freelance, but not anymore since April.
 
oh , what are you studying right now ?
post graduation ? undergrad?
 
10:00 AM
High school, with electives of Chemistry and ICT.
 
wow, smart guy
which country are you from ?
 
I'm not smart.
@harvey_slash Huh?
 
7 k reputation means smart :P
 
7k rep is low.
 
its high enough
 
10:02 AM
I consider 10k - 20k to be the median range, where past 19k+ rep you're in the top 12%.
 
which country are your from ?
 
@harvey_slash For?
@harvey_slash I don't come from a country.
 
huh ?
 
ah Chemistry ... crystal structures unihedron
 
Click on the arrow icon thingy to the left of a message.
@argentum47 Actually, "Unihedron" has nothing to do with chemistry specifically, but I mixed greek and latin roots for a username and used it.
 
10:04 AM
ow, i thought tetrtahedral , unihedral unihedron :P
 
That wouldn't be a real thing because in substances, "1" is prefixed for me-, not uni- :P
 
Space formed by only one plane isn't existential in regular geometry anyway.
 
true that
 
@fge: I've decided not to re-implement an IntStream to make collect(IntStream) work since that's figuratively impossible (I hate to use reflection for an implementation like this), so I'll just fall back to the old method.
 
10:47 AM
@ItachiUchiha uh, thanks :P
 
if (intCollector.finisher() == Function.identity())
    return (V) result;
Is this a good idea or just a waste of computation time doing the cast?
Pfft
Would ((Function<T, T>) a -> a) == ((Function<T, T>) b -> b) be true?
Nope. Fascinating.
 
@Unihedron Different instances, that's true in pretty much every language...
!!> (a=>a) == (a=>a)
 
@MadaraUchiha "SyntaxError: invalid arrow-function arguments (parentheses around the arrow-function may help)"
@MadaraUchiha false
 
System.out.println(Function.identity() == Function.identity());
// true
System.out.println(Function.identity().equals(Function.identity()));
// true
System.out.println(
    ((Function<T, T>) a -> a) == ((Function<T, T>) a -> a));
// false
System.out.println(
    ((Function<T, T>) a -> a).equals((Function<T, T>) a -> a));
// false
... how am I going to check if two instances of an FI does the same thingy then?
 
@Unihedron That also makes sense
!!> var fn = a=>a; fn === fn
 
11:00 AM
@MadaraUchiha true
 
Function.identity() is the same "function instance" as Function.identity()
If you were to clone Function.identity() and try to compare, they wouldn't compare.
 
Yes, it is.
 
For the same reason "bar" != "bar" in Java.
Different objects, same values.
 
that's why we have .equals()
 
@Gemtastic it doesn't help in my use case
Function<T, R> function1 = a -> a,
    function2 = a -> a,
    functionX = a -> null;
 
11:02 AM
@Gemtastic No, Java sucks, that's why you have .equals :P Most if not all other normal languages have no problem comparing strings normally
Like a sane person
 
How would I know that function1 ~ function2 and functionX !~ function1, !~ function2?
 
@Unihedron no it doesn't since you're comparing instances, if I understood it correct
 
(equals performs an equality check here because meta-factory implementations doesn't implement it)
 
@Unihedron Don't think you can.
 
... :(
 
11:03 AM
@MadaraUchiha Well, programmings languages aren't people so it's perfectly sensible that Java isn't irrational like people are ;P
 
ok this collector implementation thingy is practically impossible
 
For an approximation, review the types of the inputs and the returns, test a few inputs and assert output is equal
But that is just an approximation.
@Gemtastic Programming languages were written and read by and for people.
They are tools for us, and not vice versa.
 
there's a problem with that approach, because that asserts the ability to mock objects of T
 
@MadaraUchiha yes, and so are books, but that doesn't make the book a person ;P
 
Firstly, you can't even be sure you can access constructors of it; nor to cast to T from Object; nor that the type is public to scope
 
11:05 AM
@Gemtastic "Like a sane person" I meant the person writing the equality check
Not the equality check itself nor the engine that runs it.
Don't go full fge on me please :P
 
sorry :)
 
@MadaraUchiha the programmer's sanity has nothing to do with the program's function, but it may be affected by it ;P
 
I can either implement only a small portion (the part that requires minimal work) and ditch the part about primitive streams; or alternatively, ditch this idea altogether
 
@Gemtastic Are you forgetting I program in JavaScript? "sanity" isn't one of my top priorities :P
 
@MadaraUchiha That's what you get when you hate on Java in the java room
 
11:07 AM
26
Q: Is there a way to compare lambdas?

Peter LawreySay I have a List of object which were defined using lambda expressions (closures). Is there a way to inspect them so they can be compared? The code I am most interested in is List<Strategy> strategies = getStrategies(); Strategy a = (Strategy) this::a; if (strategies.contains(a)) ...

@Unihedron looks promising ^
 
It's like putting coins in the soda vending machine and get upset that you're not receiving ice-cream :P
 
@MadaraUchiha Thanks!
The answer just says "reference-equal (==) lambdas -> same implementation (/ instance), no other guarantees), but it already gave me enough information - "no"
wait I have an idea
Ok, I hope this works
 
11:25 AM
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:

** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException MESSAGE: Communications link failure

Last packet sent to the server was 4975 ms ago.

STACKTRACE:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 4975 ms ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.Nati
please help me friends
 
What kind of help are you expecting?
 
why this error comes
 
Because something is broken.
 
it working for some time
but after some time i got this error repeat
 
Well, you're using MySQL, which is known to be poor in design, and let me guess... It runs on Windows?
 
11:30 AM
no it's on ubuntu 14.04
 
Alright guys, needz halps
I need to write my first multithreading application, would appreciate a general practical explanation (or a link to a good resource)
 
in Java?
 
multithreading is hard...
 
Generally what I'm interested in:
- How do I set the number of threads?
- How do I build a queue and keep things synchronized?
- How can I tell when stuff is over?
- Is it possible to keep progress?
@Unihedron I already know most of the principle. I'm looking for implementation details on this one.
 
11:36 AM
Oh, neat!
Some concurrent collections and atomic elements already exist, where most of the your-implementation-details work is handled by Executors.
Thread pools and executors are how most applications perform asynchronous tasks.
@fge: You might be proud of the way I implemented .collect(IntCollector) without re-implementing a Spliterator :P no guarantees but I think I got an awesome design at last
 
11:56 AM
@Unihedron How do I synchronize between threads?
Give them tasks?
I have one action I need to perform on 20k different entities
Most of the work is IO (database)
 
@MadaraUchiha by denoting the method they call synchronized.
 
How can I track progress and make sure I don't have collisions?
 
You understand how synchronized contexts works by holding locks for a thread and then forcing another thread to wait until that lock is released?
... Yeah, that. It's implemented like that: Lock lock = new ReentrantLock(); method() { lock.lock(); do stuff here; lock.unlock();} or even synchronized(WRITE_LOCK) { do stuff here }
 
@Unihedron I'm not sure that's what I want
I want multiple threads to call the same method at the same time, just with different parameters as input
 
Without concurrency?
 
12:02 PM
Define: concurrency
 
multiple threads doing the same thing at once
 
@Unihedron They will trigger the same method with different parameters
Which in turn will trigger the same code path, just with different data in it.
 
at once, right?
 
Ok, each local variable in a method is stored (represented, at least) in a local thread stack, but referenced objects like new creation aren't.
So pure functions are threadsafe automagically.
 
12:04 PM
Sec
 
But if they're not (invokes an underlying method of an instance that multiple threads may cause a race condition within), the call has to be surrounded by synchronization to ensure that entry is only allowed after the previous thread finishes. To keep track of progress per task, look into executor services, which comes with that information.
 
@Unihedron But if only one thread can access the target method at a time, that kind of beats the purpose of concurrency, does it not?
 
@MadaraUchiha As long as the function call is threadsafe, which means it has to be guarded by concurrent collections, there's no problem just calling it as-is from asynchronous context.
 
The function to call is as follows:
    public String bakeLoader(final Publisher publisher, final ClientPropertiesVersion version) throws SQLException, TaboolaException {
        final Collection<Map<String, Object>> globalConf = getGlobalConfiguration(publisher);
        final Collection<Map<String, Object>> clientConf = getClientConfiguration(publisher, version);
        final Collection<Map<String, Object>> styleConf  = getStyleConfiguration(publisher, version);
        final String locale = getLocale(getVersionProperty(publisher.getName(), version.getVersionName(), "language"));
bakerRunner is an interface
 
You're good to go as long as none of those method calls in the function aren't threadsafe.
Also, if bake() is called asynchronously which uses the "params" object asynchronously, you might consider using a ConcurrentHashMap over HashMap
 
12:24 PM
Possibly the world's greatest pie chart. http://t.co/B8obAYvbtj
 
12:49 PM
hi @Unihedron
 
@CrazyNinja Hi
 
@Unihedron How does one use parameters "asynchronously"?
 
6 hours ago, by Crazy Ninja
String ddd = request.getParameter("est_dlvy_dt");
		System.out.println("Estimated Delivery Date = "+ddd);
		try {
			SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
			Date date = (Date) formatter.parse(ddd);
			System.out.println(" date >>> "+date);//print Wed Sep 10 00:00:00 IST 2014
			java.sql.Date sqlDate = new java.sql.Date(date.getTime());
			System.out.println("sql date ::: "+sqlDate);
			rec.add(sqlDate);// 1
		} catch (Exception e) {
			e.printStackTrace();
		}
 
@Unihedron Definitely older than him.
 
@Unihedron sorry for not replying. Had a sleep. :) my problem is, I am not getting the ParseException from above code
 
12:51 PM
@MadaraUchiha well, you passed params to bake(), and since you're going to call bakeLoader among multiple threads, bake() is called asynchronously
which means the underlying method calls in bakeLoader is also called asynchronously
HashMap is not concurrent.
 
sigh T_T have I mentioned how Java sucks?
"You thought you knew something? You thought it was safe to use this thing? Nah man, here's some concurrency for you!"
FFS
@Unihedron aside from converting my parameters to ConcurrentInsertCollectionHere, anything else I need to know?
 
1:15 PM
@MadaraUchiha oh, be careful of assignments and read-writes to stateful variables
while local variables in methods are thread-local, class-level fields aren't, static stuff aren't either - in order for the read-write to these fields to be threadsafe while well maintained, you can make the read-write atomic with the volatile keyword for the field
A volatile field really just means that the value of this variable will never be cached thread-locally, and therefore access to the variable acts as though it is enclosed in a synchronized block, except atomically.
public class StoppableThread extends Thread {
  private volatile boolean stop = false;

  public void run() {
    while (!stop) {
      // do work
    }
  }

  public void stopWork() {
    stop = true;
  }
}
 
1:35 PM
@MadaraUchiha The first thing I said after knowing you need to write a multithreading application is that multithreading is hard :p
 
@Unihedron No it's not
JavaScript does multithreading simply and beautifully. You get a simple simple interface with two methods to communicate with your Worker
Why the hell does Java expect people to know all this stuff? And it's not something they can do by reference
 
@MadaraUchiha That doesn't back your point at all. Just because the engine went through all the hard work so you don't have to doesn't change how much work goes into parallel programming. Even if you're implementing this in C#, it's equally if not more difficult.
 
No, they have to be aware of all of those constraints while developing
It's like knowing security, it's not something you can sprinkle on later. If you wrote an application and you wanted to scale up with threads you're screwed if you didn't plan ahead.
 
That's like writing code without planning to write unit tests. You're screwed equally when you decide to write unit tests.
 
hellow all
 
1:42 PM
hiya!
 
hiya too =)
 
Morning, Java!
 
morning
 
@Unihedron Haha, clever.
@MadaraUchiha Javascript is not multithreaded.
 
@Michael Web Workers are.
It's a (relatively) recent JavaScript feature.
 
1:50 PM
@Michael It provides multithreaded implementations like webworkers, but it's true that JS developers do none of multithreading on their end.
 
@MadaraUchiha True. But that's all that is multithreaded.
 
@Michael That's right. That's all that needs to be multithreaded.
 
I thought that you might be referring to things like making HTTP requests.
How you can do something else while waiting for the response.
 
fge
@MadaraUchiha and you think this is enough to do all things multithreading? :p
(it's not)
 
@fge It's enough for everything I need.
 
1:54 PM
Javascript has an event queue to which processes like handling HTTP responses are added.
 
@Michael That's an event loop.
And that's not what I'm referring to.
There are rare occasions where you need to perform CPU intensive actions that the event loop is not well suited to handle.
Web workers solve that case for you.
 
@MadaraUchiha Then it appears that we are in agreement in terms of the multi-threaded capabilities of the Javascript programming language.
 
The rest (basically, waiting for I/O, which is 90% of the work done with threads in Java) is handled very well by the event loop.
You spawn a worker, you worker.postMessage(obj) to it, and on the other side, you have a this.onMessage(handlerFn) listener you subscribe to.
 
fge
Ah, again asynchronous I/O, eh?
Java can do that too
 
@fge Not. Sanely.
 
fge
1:58 PM
And it's the source of the biggest fallacy in CS these last few years. No, async I/O is not faster
 
@fge lol, are you kidding me?
 
fge
In fact it is slower on modern hardware than well devised multithreading
 
Disregarding async I/O for a moment, Java is one of the worst language to write for performance.
 
fge
THat's a fact -- do some googling around
 
It's one of the easiest languages to get performance wrong
 
fge
1:59 PM
Yes, and so is C
But when you do, it's darn fast
 
@MadaraUchiha You can get equivalently poor performance by doing Javascript wrong.
 
@fge C isn't a high level language.
@Unihedron But it's a lot harder to get JavaScript that wrong.
It's possible, mind you.
But you really have to go on the exact opposite direction from common sense.
 
00:00 - 14:0014:00 - 23:00

« first day (1667 days earlier)      last day (3273 days later) »