« first day (1525 days earlier)      last day (3416 days later) » 

fge
12:14 AM
@Gemtastic hey
 
'sup?
 
fge
Playing for the next generation of throwing-lambdas (0.1.0 released) --> gist.github.com/fge/d3cac2361b047b56683f
(look at the main() at the end of the file)
 
12:32 AM
Playing for?
I'm a little too tired to know what I'm looking at XD
 
fge
Well, imagine you use a stream and you want to filter it
Now, your filter function may throw an exception
In this case you want to return false
With this code you could do myStream.filter(tryAnd(myPredicate).orReturn(false))
 
Ah yeah, now it makes sense to me
 
user868935
Hello. Anyone managed to hook up Raspberry Pi B+ to NetBeans 8?
 
fge
Uh, not me, no
I don't even have a Raspberry Pi
And I don't use NetBeans
But what do you call "hooking up" anyway?
 
user868935
Registering Java SE Embedded between Netbeans and Raspberry Pi.
 
user868935
12:41 AM
That way you can develop Java on Netbeans and send it to the RPi and test it
 
fge
Why Java SE? Why not a regular JRE?
I mean, there is a standard JDK for arm, doesn't that work on a Pi?
 
user868935
 
user868935
Thats the tutorial, but it doesn't explain how after installing JDK-8 how it gets registered, because apparently the old method doesn't work with the newer pi
 
user868935
The JRE is installed, I can access my pi via puTTy with no problem, but when it comes to registering, I get a build error stating I should check my settings.
 
fge
1:01 AM
I don't really get that "registered" stuff; why is it needed? All you need is to be able to 1. launch your JVM on the Pi with an agent configured, 2. connect to that agent from your IDE
 
user868935
Needed so that projects made in netbeans can be uploaded directly to RPi and test.
 
fge
1:16 AM
Yeah, and then how are you going to distribute them?
Relying on your IDE for distribution is a bad habit
 
user868935
Netbeans is just used for easier development and uploads it to a NB project folder on the RPi created by the JRE.
 
fge
Easier development, OK
Uploads? That means generating and copying
THose two things should NOT be left to the IDE
Otherwise it means you cannot build and distribute in a noninteractive fashion
 
user868935
Instead of saving the project to your own computer, it saves it to the RPi
 
fge
That's not the question
 
user868935
Well you may want to take your concerns up to Oracle, because they are the ones that made it possible to develop for the Pi in Java
 
user868935
1:28 AM
Other than that, you can create java projects using nano on the RPi, but that's not really any different from creating a java program in notepad
 
user4202350
5:28 AM
morn
 
morning
@Unihedro heya
I need to buy a shared VPN which has java support. Any pointers?
 
user4202350
all enjoying
 
user4202350
holidays?
 
nope
 
user4202350
y shinchan
 
5:33 AM
boring Christmas :(
 
user4202350
hey shimchan can u pls tell 2004: Java

System.out.printf("%10.2f", x);

2014: JAVA

LAMBDA EXPRESSION how sop is replaced by lamda expression
 
SOP is not replaced by lambda
Lambda is the next big turn of events happening in java
 
user4202350
can u give overwview
 
Do you know what lambda is used for?
 
user4202350
r u taloing about alga beta?
 
5:39 AM
what?
 
user4202350
Lambda (uppercase Λ, lowercase λ; Greek: Λάμ(β)δα lam(b)da) is the 11th letter of the Greek alphabet. In the system of Greek numerals lambda has a value of 30. Lambda is related to the Phoenician letter Lamed . Letters in other alphabets that stemmed from lambda include the Latin L and the Cyrillic letter El (Л, л). The ancient grammarians and dramatists give evidence to the pronunciation as [laːbdaː] (λάβδα) in Classical Greek times. In Modern Greek the name of the letter, Λάμδα, is pronounced [lamða]; the spoken letter itself has the sound of [l] as with Latinate "L". In early Greek alphabets...
 
lolz
Are you in school?
 
user4202350
No im a professional java developer
 
professional..
 
user4202350
hey shinchan....
 
user4202350
5:43 AM
r u telling me lamda expressoion?
 
yeah
lets get back
so you gotta know what a functional interface is before we get into lambdas..
 
user4202350
m not aware of jaava 8 classes
 
so gotta know them
if you are interested
 
@ItachiUchiha Heya
@ItachiUchiha Just go for VPNs that lets you install stuff, because the ones that give Java support are usually outdated and are still at Java 7, may as well install them yourself
 
@Unihedro VPNs will throw me out of my budget :P
 
5:55 AM
@ItachiUchiha There are VPS's that cost a dollar per month, if you're willing to invest that.
Whoops, didn't mean VPN, sorry.
Cheap and reliable VPS ^
 
RAM - 256 MB :-O
 
Will you ever need more than that? :P
 
I need to run tomcat on it :P
 
6:16 AM
@ShaU A nice introduction to lambdas docs.oracle.com/javase/tutorial/java/javaOO/…
 
how do i initialise this array?
class Grid{
	Boolean[][] twoDArray = new Boolean[3][3];

	Grid(){

	}

	void printElements(){
		for(Boolean[] oneDArray : twoDArray){
			for(Boolean element : oneDArray)
				System.out.println(element.booleanValue());
		}
	}
}
 
the twoDArray?
 
6:34 AM
Good morning, Java!
@Unihedro Why?
 
user4202350
hey shinchan ... im trying to understand...but can u give one simle code to usndertsand lamda?
 
(a, b) -> a + b;
It means that we are passing two parameters to a function and it returns the sum
 
7:04 AM
It's also two-arity.
 
7:56 AM
@fge I <3 the FAQ page for lambdas :)
 
8:42 AM
Hi, I am building a query that may contain variable number of parameters so it will not be neat to use preparedstatement
but i don't know how should i escape characters like quote, backslash
 
@Tarun You can't. Use preparedstatements.
 
yeah but parameters are dynamic
 
@Tarun Then make a query that allows dynamic numbering and ordering of variables, you still have to use a prepared statement unless you want to allow injection.
 
9:06 AM
Hello
 
Hello
 
Hello
 
fge
9:43 AM
Moo
 
fge
I need insights on a design idea
 
Shoot
 
fge
gist.github.com/fge/3ee6f6fc955403e75f85 <-- I've managed to do this but I'm not sure 1. about the named and 2. about the classes
gist.github.com/fge/ee4cd3204cfa1e9fda18 <-- that's the ThrowablesFactory
 
So you have a ChainedFunction class with 3 methods
 
fge
9:49 AM
Err, 2
And one constructor
 
tryAnd, orThrow, orReturn
 
fge
No, tryAnd is a static method
 
2?
ohh yeah
so what is the confusion with the names?
 
fge
Well, I don't know, I believe it could be better somewhat
Also, I wonder about defining a type parameter for the exception class in ThrowingFunction
And I don't quite like the name ChainedFunction either
 
A noob question
why the ChainedFunction class?
 
fge
10:02 AM
Needed for the "fluent" design
 
What changes are you making to the design?
 
fge
Well, that's the question
People may want to throw their own exception or define a default return value if the invocation fails, so...
 
So, instead of just ThrownByLambdaException, they can throw other exception as well?
I guess I am missing some point in here
 
fge
Well, it was a suggestion by @Bohemian that it would be nice if your own exceptions could be rethrown
OTOH maybe some of this code could be in the interface itself
Ahwell
 
10:17 AM
So well, instead of always using ThrownByLambdaException, user can throw their own exception?
 
fge
Yes
I proposed rethrow(whatever).as(MyException.class) too
But that's a name conflict
Also, @Vogel612 complains that it is not generalized :p
Meh, I can't do everything
 
lolz
But as ThrownByLambdaException is inheriting RuntimeException, we can easily allow the user to thrown anything that is a child of this class
isn't it?
 
fge
This is not really what happens
 
enlighten me
If you have some free time :P
 
fge
Throwing* interfaces are declared to throw Throwable; the actual method of the "original" functional interface is wrapped with a default implementation which catches that Throwable and throws a ThrownByLambdaException
For Function<T, R> for instance, the method is R apply(T t); ThrowingFunction<T, R> defines R doApply(T t) throws Throwable and apply simply tries to doApply and throws ThrownByLambdaException if these is an exception (which isn't an error or an unchecked exception; those are thrown as is)
Also, for any interface Foo, ThrowingFoo extends Foo which is why they can be used in lambdas
I can therefore do final ThrowingFunction<Path, Path> f = Path::toRealPath; and use f in a lambda if desired; that is an alternative to Functions.rethrow(Path::toRealPath)
(and a bonus of the idea that @Unihedro suggested)
 
10:34 AM
So we have defined a new FunctionalInterface ThrowingFunction for the already present FunctionalInterface Function, its method apply() calls to doApply() (which throws Throwable). And inside the apply(), we catch this Throwable and just throw ThrownByLambdaException
 
fge
Yes, with the thrown Throwable as the cause, and if that Throwable is not a subclass of either an Error or a RuntimeException
 
Ahh, ok
 
fge
Updated the README with the example I just mentioned
 
use f in a lambda if desired ?
 
fge
Yes
 
10:42 AM
I still don't get, how Path::toRealPath is returning ThrowingFunction<Path, Path> without using the rethrow
 
fge
Because its signature matches that of doApply() in ThrowingFunction
And ThrowingFunction is a @FunctionalInterface too
The signature of Path's .toRealPath() is that it takes a Path as an argument (in fact, itself), returns a Path, and throws an IOException
 
`R doApply(T t) throws Throwable;`
           v/s
`Path toRealPath(LinkOption... options) throws IOException`
 
fge
If we match that do doApply(), T is Path, so is R, and IOException is the Throwable
The link options is a vararg, and here we pass none
 
Now, it matches :P
@fge But, doesn't the doApply() expects atleast one arg?
 
@ItachiUchiha It expects T, which is Path
duh
 
fge
10:48 AM
@ItachiUchiha in the event of a non static method reference, the caller itself is the argument
 
:20649948 It does say about T
 
fge
The first argument, I mean
 
and doApply expects T, T ------- >>> Path toRealPath(LinkOption... options) throws ...
 
fge
Another example of a method which matches ThrowingFunction is this one:
=javadoc Statement.executeQuery(String)
 
@fge Sorry, I never heard of that class. :(
 
fge
10:50 AM
Argh
=javadoc Statement#executeQuery(*)
 
Which one do you mean? (type the number)
1. java.beans.Statement
2. java.sql.Statement
 
fge
2
 
@fge java.sql.Statement: The object used for executing a static SQL statement and returning the results it produces. (1/2)
 
fge
=javadoc Statement.executeQuery(*)
 
@fge Sorry, I never heard of that class. :(
 
fge
10:51 AM
Grr
Well, anyway, this method is a ThrowingFunction<String, ResultSet>
 
Haha! Data for a bunch of tests became a pumpkin! :D
 
=javadoc java.sql.Statement#executeQuery(*)
 
@Unihedro ResultSet executeQuery(String sql): Executes the given SQL statement, which returns a single ResultSet object. (1/2)
 
2
=javadoc java.sql.Statement#executeQuery(*) 2
 
@Unihedro **Note:**This method cannot be called on a PreparedStatement or CallableStatement. (2/2)
 
10:52 AM
@Michael Broken formatting alert!
 
fge
@Unihedro your idea of a design has an unexpected bonus, you don't even need to wrap with rethrow() if you do this: ThrowingFunction<Foo, Bar> f = what::ever; -- you can use f directly in the lambda
 
@fge So you mean in case of Path::toRealPath, Path itself is passed as an argument?
 
fge
@ItachiUchiha yes
 
@fge Plus ThrowingFunction is also automatically future-compatible because whenever java.util.function.Function changes, your ThrowingFunction sticks with the new changes
So imagine if Function now comes with doAlso(Function a, Function b), your ThrowingFunction will have that automagically.
\o/
 
fge
@Unihedro also, I managed that but I'm not really satisified: gist.github.com/fge/3ee6f6fc955403e75f85
 
10:56 AM
On first sight the only thing I worry is if anything leaks.
ThrowingFunctions can be mutable, right?
 
fge
Not sure what you mean
 
final ThrowablesFactory factory = ThrowablesFactory.byDefault();
Sure this is a good idea?
 
fge
Eh?
Well anyway, my concern is that it may not be necessary
 
Same.
 
fge
I wonder whether it wouldn't be possible to stick that directly in the interface
As to the factory part it is necessary
 
11:00 AM
Why not only get the factory when needed?
        return t -> {
            try { ... } catch (Throwable tooBad) {
                throw ThrowablesFactory.byDefault().get(c, tooBad);
            }
        };
 
fge
gist.github.com/fge/cf00f67b1d15034a8ea6 <-- that's the implementation
Meh, I may as well make it a singleton and be done with it
 
throw new IllegalStateException(oops);
lols
Does it work? Looks good to me.
 
fge
Yeah, it works
I was wondering however whether it was possible to do without this intermediate class and define these directly at the interface level
 
Ah.
Is it necessary though? From the view here, after ChainedFunction<T, R> calls orReturn and the user gets their incredible lambda t -> {}, this intermediate class is garbage and will be GC'd anyway.
 
fge
Yeah but why create an intermediate class if not needed... Well, I'll try
 
11:10 AM
@fge Well it makes your life easier.
 
fge
Also, this .get() method is a prime example of an "erasure signature"
In fact the cast is not to E exactly (Java can't do that) but since E extends RuntimeException the cast is to RuntimeException
 
Yeah, generics in Java are kind of... Bad.
 
fge
Which is why the return type of the MethodType is altered to RuntimeException, and which is why I can invokeExact
 
key -> {
        try {
            return LOOKUP.findConstructor(c, TYPE)
                .asType(TYPE.changeReturnType(RuntimeException.class));
        } catch (IllegalAccessException | NoSuchMethodException e) {
            throw new IllegalStateException(e);
        }
    }
That feels like a great candidate to turn into a method and use lambda form to rethrow(). :P
 
fge
Hmm, it works
 
11:20 AM
What does?
 
GistOverflow
Huh...
For ThrowingFoo bar, if you make baz = bar.orReturn(defaultValue), will bar be garbage-collected? And if so, will you lose doApply()?
 
fge
Well, given the state of the current code yes, since it will be "downgraded" into a Function
And bar will not be garbage collected but then the JIT will kick in and the code will certainly be inlined anyway
 
Actually, my concern is that if the original interface that created orReturn can be garbage-collected, the return for doApply may be lost. I checked to see that this is not the case though - the new Function (baz) will keep reference to the original interface (bar) because of doApply.
 
fge
And .orThrow() also works
Hmm
Meh, I love computeIfAbsent
So, those can directly be defined in the interface, then
wonders where to go from there
 
11:38 AM
deploy!
 
fge
Well, 0.1.0 is released
I just wonder what to do for the next release, that's all :p
 
Update!
Oh. :P
 
hi all
 
fge
I wonder whether I should ask the question on SO
 
i have a doubt regarding java
 
11:39 AM
@fge Oh?
 
fge
@kondapaka Java, don't doubt -- MySQL, replace
 
Remember that you can always ask on CP if the SO people closes your question.
 
fge
CP?
 
@kondapaka ... just no, fix that set up
Where you can ask all the crap questions you ever wanted!
 
fge
Huh
Really, I don't know which way to go
I mean, it's quite nice to have that already
 
11:41 AM
You can even ask how to hack someone's computer, and no one will close your question. It's like Yahoo! Answers, except for experts!
 
@Unihedro How?!
 
@OlegKuznetsov I have no idea, they live on traffic, you see. :P
 
Let's see...
 
Morning
 
/me opens milw0rm DB... :P
 
11:42 AM
Morning!
 
@Gemtastic Afternoon! ;)
 
@OlegKuznetsov They helped me install MongoDb, I'm grateful for CP.
 
fge
<-- should also review the new process API in Java 9
 
i have a table with 400 rows in a table, i want to show only 8 events at a time in my front end, when press LoadMore i want to show next 8 events, for sorting purpose i am unable to use Pagination, so what's the best way to show 8 events at a time?
 
Is it common to store images in databases or do you normally just store the reference?
 
11:43 AM
@kondapaka temp tables and iterations
 
shall i restrict events in server side or front end side
 
fge
@kondapaka 1. ditch MySQL, replace with PostgreSQL; 2. use JooQ
 
@kondapaka You can use something that's supported by most databases (but not MySQL because it sucks):
 
@kondapaka If its just 8 events, you can do it on the front end
but normally it is done on the server side :P
 
in mysql i am unable to sort my events as i expected
 
11:44 AM
:0
 
that's why i retrievre all events at a time and sort them in java class
 
@fge Why not just switch to MariaDB? :-/
 
you are doing something wrong with the SQL query
@OlegKuznetsov or Cassandra :P
 
fge
@OlegKuznetsov because MariaDB builds on a castle of sand; PostgreSQL on the other hand has über strong foundations
 
There are many choices, you just pick anyone of them and start coding :P
 
11:46 AM
@ItachiUchiha nope: moving to another DB can be tricky
@fge huh?
 
fge
@OlegKuznetsov MariaDB is still MySQL at the core
 
@OlegKuznetsov Nobody is talking about moving from one db to another :P
 
SELECT * INTO #Iterator
  FROM (table) WHERE (condition)
DECLARE TABLE (temp table)

// this is your fetch statement
INSERT INTO (temp table) (params....)
SELECT TOP 8
  FROM #Iterator
  ORDER BY (this is important... add condition here to sort and fetch the firsts)
DELETE FROM #Iterator WHERE EXISTS(IN (temp table))
 
@fge And?.. It means that migration will be less painful than switching to completely different RDBMS
 
@fge I didn't really get what to did to your Test.java at the end :P
 
fge
11:47 AM
MySQL is a case of TWA (Try With Another)
 
When you get nothing, the iterator is empty
@ItachiUchiha stuff
 
@Unihedro Hit me
 
@ItachiUchiha yep
 
I got completely ignored :(
 
fge
@OlegKuznetsov meh, one table with 400 rows, how hard can it be?
 
11:48 AM
@Gemtastic Heya, when did you come?
 
5 mins ago, by Gemtastic
Is it common to store images in databases or do you normally just store the reference?
@Gem there's something called OLE (object linkage & embedding), read it up
Object Linking and Embedding (OLE, sometimes pronounced /oˈlɛj/) is a proprietary technology developed by Microsoft that allows embedding and linking to documents and other objects. For developers, it brought OLE Control Extension (OCX), a way to develop and use custom user interface elements. On a technical level, an OLE object is any object that implements the IOleObject interface, possibly along with a wide range of other interfaces, depending on the object's needs. == Overview == OLE allows an editing application to export part of a document to another editing application and then import it...
 
/me hugs @Gemtastic
 
@ItachiUchiha Back when I said Morning :P
 
IIRC, some databases supports transferring DataObject by hooking into serialization of your programming language.
 
@Unihedro Now that't the kind of answer I was looking for :D
 
11:51 AM
I'm not sure though, it was ages when I read that up (like when I was 12) :P
 
It's somewhere to start
 
@Unihedro Well, you can :) and let @fge answer my questions :P
 
I may not have googled very intensely but while it is possible to add a picture to a database it doesn't seem very Java
 
@ItachiUchiha Well, fge's not answering, that's exactly why I am...
 
@Gemtastic Adding a picture to database has nothing to do with java, you just keep a blob entry in sql and send the file via java
 
11:54 AM
@Gemtastic It's dependant on the database - some supports OLE natively, some wraps them in containers, which makes it a PITA to have the imagine portable, it's usually not necessary though.
 
fge
Eh? Badmouthing me? :p
 
@fge Nope :P
 
fge
And what was the question anyway?
 
8 mins ago, by ItachiUchiha
@fge I didn't really get what to did to your Test.java at the end :P
 
fge
@ItachiUchiha which one?
 
11:55 AM
From this to this
 
^^
 
fge
Oh
@ItachiUchiha an experiment, namely this
I was just thinking about another idea... Make .wrap() methods in Functions and the like which would return Throwing versions (since they extend the original) and then use the methods on the interface to alter the behaviour
Hmmm
 
@ItachiUchiha Well, I'm trying to figure how most people who do backend programming solves having databases and images related to those entries. Let's say I'm making a database for an online-store. Each entry is a product and on the website each entry will be displayed with an image. Now, do you put a blop in the database of do you store the images on the server and tie the database entry to a reference?
Or is there another way I'm ignorant of?
 

« first day (1525 days earlier)      last day (3416 days later) »