Language:
switch to room list switch to menu My folders
Go to page: First ... 43 44 45 46 [47] 48 49 50 51 ... Last
[#] Fri Jan 01 2010 19:29:18 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


so does Java really need closures?

After we started doing test-driven development I found myself writing a lot more inner classy, callback functiony, type stuff, because it's a lot more painful to test the same thing 3 times with a cut-and-pasted-3-times algorithm, than it is to take the time to factor our said algorithm into a skeleton wrapped around a callback interface.

at first I was saying "dammit I want real closures" all the time, but Spring uses the callback interface style all over the place, & this is all becoming second nature... certainly java's current style is more verbose.

[#] Fri Jan 01 2010 19:30:27 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

The C++ stuff for eclipe has some of that, but it's nowhere near as

flushed out.

same comment applies to the PHP eclipse stuff. not as much refactoring support, not as much autocompletion, and less metadata available about your code due to the lack of strong typing.

[#] Sat Jan 02 2010 19:57:31 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Speaking of.
eclipse's javascript editor tries real hard to do syntax checking and function and method validation and stuff like that, but js isn't typed at all so it always fails.
For example, if you getelementbyID and you know it's a checkbox so you check it 'checked'value, it highlights it as an error because var obj doesn't have a 'checked' member. Well, sure, it doesn't know it's a checkbox, but I do. But (as far as I know, and I'm no js maven) there's no way to tell javascript what it is, nor does it care, so it's impossible to write a clean javascript function in eclipse.
So what am I missing/>

[#] Mon Jan 04 2010 13:42:30 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Just disable the javascript validation :)

[#] Mon Jan 04 2010 15:54:16 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

That's what I ended up doing.
but I just can't imagine what they were thinking when they wrote it. It can't possibly be useful.

In other news, I did a really cool thing today.


I've forever suffered pain from trying to get httpclient to connect from my desktop at work to the real world via our insanely annoying proxy.
Of course I have a few ways around it if I HAD to get something done, but dammit, I just want it to work, why do I always have to suffer at the hands of security people.

Anyway, one of the problems I always have is that you have to supply credentials to httpclient so that it can pass them to the proxy and blah blah blah it never works. It always tells me it picked some NTLM auth protocol to which I am not allowed to supply credentials.
So one day I said fuck it, and I took my incredibly useful packetbouncer program, and shoved in a little thing that when it detects the first set of \r\n\r\n from the client socket, it shoves in Proxy-Authentication: Basic yadayadayada
And I just never told httpclient that it had to authenticate to the proxy, and voila everything works.

Worked, anyway. Until today. today I came across a test server that responded to httpclient's GEt request with 302 moved.

Being http 1.1, it uses the same connection and sends another request to the new url, but this time, my packetbouncer hack isn't looking for \r\n\r\n anymore so the second request fails proxy authentication. ARRRRRRRRRGGGGGGGGGHHHHHHHHH.

So I got this bright idea. This instance of packetbounce is assuming an HTTP connection anyway, so it can know that if it gets a response from the server end, to reset the flag saying "check for \r\n\r\n" so that if the client goes to send another request, it will find the endof the next set of headers.
And voila it worked. I was amazed.

This isn't a perfect setup, if it decides to use chunking, I'm kinda screwed, it will mess up the connection completely, but while the requests going out aren't that big, it functions.

It's just so dumb that I have to do shit like this just to do my job.

[#] Tue Jan 05 2010 14:29:10 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

THIS IS AWESOME. I accidently fixed my pandora constant-reauthentication problem. I never realized, but it was the same thing.
Pandora kept pestering me constantly about authenticating, and I realize now it was reusing the same http connection, and I would only send credentials on the first request, now that it sends credentials on every request it doesn't pester me anymore. THIS IS AWESOME.

[#] Wed Jan 06 2010 00:36:47 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

What are you doing all of that low-level HTTP stuff for? Don't you have an HTTP library that you can just make calls into?

[#] Wed Jan 06 2010 08:50:00 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


sounds like he's using commons-httpclient, but I don't understand the issue either ...

[#] Thu Jan 07 2010 14:16:07 EST from Spell Binder @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Re: Does Java really need closures?

I'm still not sure I completely grok closures. I can understand the idea of passing around a block of code to be executed later, and even a stack frame attached to it so it can reference free variables, but I'm having trouble seeing where it could be useful. I also have to wonder if there are use-cases that can only be implemented using a closure. All the examples I've seen so far, which, admittedly, is not many, leads me to think that most closures can be replaced by passing references to functions or methods.

I googled for Java closures and the first page that came up, http://javac.info/ seems like an interesting implementation on the surface. I get the feeling that, because Java is a loosely-typed language, any kind of implementation of closures is going to end up being syntactically messy, a la generics.

I never realized until recently that Smalltalk implemented closures, and they're used pretty much everywhere.
Pretty much every control structure is just a method that takes closures as parameters. Smalltalk calls them "nlocks," though. Syntactically, it works very well since Smalltalk is untyped. Putting on my Ford hat for a moment, though, that's an extra layer of overhead to deal with everytime you do something simple as "if: then: else:".
Closure Binder

[#] Thu Jan 07 2010 14:24:31 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

in C you could use the CPP to write begin...end instead so it would look as if it was pascal ;-)



[#] Thu Jan 07 2010 15:18:37 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Smalltalk, while great as languages go, does incure a heavy amount of overhead just from its dynamic typing, let alone having to deal with if: then: else:.

[#] Thu Jan 07 2010 16:05:29 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

What are you doing all of that low-level HTTP stuff for? Don't you
have an HTTP library that you can just make calls into?

Not one that works.
apache commons httpclient is the standard everybody loves, and I can't for the life of me get it to go through our proxy.

[#] Thu Jan 07 2010 16:08:09 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

There can't possibly be a use case that can't be implemented without closures simply because all the languages that implement closures compile down to assembly, and as afar as I know there ain't no processor that nativly supports closures in its instruction set.

Big picture, all you really need is a turing machine, everything else is unneccesary sugar.

[#] Thu Jan 07 2010 16:12:19 EST from Ford II @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

sounds like he's using commons-httpclient, but I don't understand the

issue either ...

The issue is basically, that httpclient does everything but proxy authentication correclty (for me anyway)
I have no question that it's something goofy about our proxy, but there's no way to get http client to authenticate to our proxy.
It will use a proxy if you don't have to authenticate, which is what I have working by having my proxy shim shove in the credentials without it knowing.


I imagine there's some discovery protocol headers that say "Hi! I'm the proxy and I support this this this and that preferably in that order."
And then httpclient says "Okay, let's use this."
And our proxy says "GREAT! Let's get started. What's your name and password."
Obidiently httpclient says: "My name is x and my password is y. Can we do this?"
And the proxy says "Oh, no no no, see, I validate credentials against a windows somethingorother server and we can't use user password, I have to verify your domain, and when doing that, I can't accept name and password. Sorry, you FAIL."

I imagine that's not the exact thing that's going on, but something like it.

[#] Thu Jan 07 2010 16:12:27 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Is assembly-language Turing complete?

(laughing to myself)

[#] Thu Jan 07 2010 21:48:25 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

All the examples I've seen so far, which, admittedly, is not many,
leads me to think that most closures can be replaced by passing
references to functions or methods.

In LISP and Scheme they're called lambda functions. And in LISP or Scheme, basically the entire universe is block structured (my understanding - could be wrong - is that globals are essentially just locals defined within the outermost block.) So you don't exactly have this concept that there's only one namespace that can contain classes, for instance.

the issue with closures in Java is that from within an inner class (which are java's current poor mans substitute for closures) you can't write to variables that are defined on the stack. In LISP or Scheme or even Perl, this would be easy, because a closure is lexically scoped within its containing block, and can write to anything within that scope, even variables that are allocated on the stack.

So the Java syndrome becomes allocate everything as a class field so that they can be written from inner classes and so that functions can return more than one value. which creates a lot of small temporary objects that the garbage collector has to deal with.


The Groovy language (a JVM hosted language and basically a syntactic superset of Java) has closures native - for interoperability with Java code, they all are emitted as classes that implement Runnable - but in order to create the illusion that the closures have write accees to their containing scope, the groovyc probably has to emit a lot of boilerplate crap...

[#] Thu Jan 07 2010 23:39:08 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

There can't possibly be a use case that can't be implemented without

closures simply because all the languages that implement closures
compile down to assembly, and as afar as I know there ain't no
processor that nativly supports closures in its instruction set.

Wasn't there some sort of Java-native processor that Sun was playing with when Java first came out?

[#] Fri Jan 08 2010 04:41:23 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

 

Do Jan 07 2010 23:39:08 EST von IGnatius T Foobar @ Uncensored
There can't possibly be a use case that can't be implemented without
closures simply because all the languages that implement closures
compile down to assembly, and as afar as I know there ain't no
processor that nativly supports closures in its instruction set.

Wasn't there some sort of Java-native processor that Sun was playing with when Java first came out?

I think that was a marketing buzz.

You can actualy purchase a "java extension" for a Z, but that actualy an x86 board.



[#] Fri Jan 08 2010 09:37:08 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

http://hyperrealm.com/main.php?s=cbase

interesting libs, maybe one could have a look at these...



[#] Sat Jan 09 2010 17:13:56 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Wasn't there some sort of Java-native processor that Sun was playing

with when Java first came out?

Yeah, now that you mention it I remember the "Java chip." Probably a bad idea since they keep making extensions to the virtual machine, besides the fact that a special purpose processor could never compete with Intel...

Go to page: First ... 43 44 45 46 [47] 48 49 50 51 ... Last