HalibutPassion FishSwimming in obscurity.Registered Userregular
edited September 2010
Java (the language) does not treat functions as objects which is why you can't pass around a function as an argument to another function. Java (the bytecode specification) does not have any OO concepts build into it, and it allows the JVM to execute code differently from how you'd think about your objects "doing work."
That's why other JVM languages like Scala or the afore-mentioned Clojure let you pass functions as arguments, but Java (the language) does not.
Halibut on
0
Options
KakodaimonosCode fondlerHelping the 1% get richerRegistered Userregular
edited September 2010
Yes and that's the difference between the .Net runtime and C#/F#/VB.Net. As long are you're able to generate IL, you can run it in the .Net runtime. There's even a port of Clojure on to the .Net runtime
But the lack of lambdas and closures in Java is annoying. There's a chance that they'll show up in Java 7, but I haven't heard any movement on that lately. I've not been very impressed at how slowly things have been added into the Java language specification. But, they are faster than the C++ standard group.
Most of the cool stuff like first class functions and lambdas and making collections first class objects and all have actually been taken out of the Java 7 spec now I think. I'm sort of becoming massively disillusioned with the whole thing now.
Java (the language) does not treat functions as objects which is why you can't pass around a function as an argument to another function. Java (the bytecode specification) does not have any OO concepts build into it, and it allows the JVM to execute code differently from how you'd think about your objects "doing work."
That's why other JVM languages like Scala or the afore-mentioned Clojure let you pass functions as arguments, but Java (the language) does not.
Behind the scenes in Java, functions are objects (check out the Method class. You can call them on an instance of the class they belong to using Method.invoke()), and you can get at them using the reflection libraries. It's not clean or non-verbose (but what in Java isn't verbose? ), but it's certainly possible to do functionalish things in Java. (Although typically it would be done with anonymous classes and stuff, rather than the reflection libraries.)
If you don't need blazing speed, C# or python wins the fucking day in games now-a-days.
But Java is still used here and there. Like... for Minecraft. Java's advantage over C++ is rapid devel. C(++)'s advantages over Java are it's speed and low level accessibility. Low level is pretty antiquated this day and age.
And it took me a day and a half to rewrite my library in Java, holy shit, there are some weird nuances I've forgotten since I left school.
Also thanks all for helping me.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Hopefully this is the last question I need to ask: How do you check if there's connections to be accepted by the ServerSocket? I don't want my server blocking while it waits for a connection but I also don't want more than 1 thread. Reading is working fine, it's the .accept method that's locking down my thread.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
So I'm starting a new job on Monday and I asked them if there was anything they would like me to look at before I start and they said webGL. I have some experience with OpenGLES for iPhone.
They aren't expecting me to know anything about webGL out of the gate, I know that they are starting research into the area for a future product so I'd like to start learning.
From wikipedia it looks like a platform that's still kind of in infancy with not a whole lot to the article, and several different developer libraries. Anyone have recommendations for books and/or websites I could look into for the basics in terms of research and overview not necessarily technical programming?
Oy. That sucks. I was able to do it fine in C#, their socket has a .Available for incoming connections. The plus for Java is their InputStream gives me the ability to see how much data is waiting to be read, so that's automatically not blocking there.
Urgh. Urgghhhhhh. I do not want to do a 2nd thread.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
Options
KakodaimonosCode fondlerHelping the 1% get richerRegistered Userregular
edited September 2010
You're stuck. Unless you want to pull in some other packages, Java does not do async I/O at all.
What are you using this for? Might I suggest DataMapper as lightweight beginner friendly alternative? Easier DB config.
A) I'm not trying to do anything in particular. I'm still new to ruby, and I just want to try rails out to see how I like it. I figured following the tutorials would be the easiest way, but the db setup is making me :x That DataMapper looks to be what rake is trying to do in these steps; I'll see if I can integrate it into a rails setup.
C) I want to figure out what I'm doing wrong before I just drop it altogether. It's not producing error messages anymore, so I feel like I'm pretty close to the answer.
I honestly don't know, I'm not really a ruby guy. I just know that I am marrying Sinatra+DataMapper+Heroku
What exactly are you working with End and what are you trying to do?
It's a server obviously. It's multithreaded. Each thread handles a request.
I looked how apache handles it with the worker mpm, and they basically poll the listener and use signals to interrupt only the thread currently listening. That doesn't work so well for me, because I allow multiple processes as well, and unless I do a global lock across processes, both could wake up, and one would end up blocking. Hm, I guess I could also make it a non blocking accept, that could do it.
Right now I'm working on a branch that uses APR, and I'm trying to fix the way certain things work while I'm rewriting parts. Part of the problem with APR is the operations you can do on apr threads is somewhat restricted, but then the sort of things that might solve my problem are apparently sort of implementation dependent.
Edit: Actually, I'm a bit confused about one point. I'll have to check how exactly they're masking the signals, since I didn't think apr exposed pthread_sigmask
End on
I wish that someway, somehow, that I could save every one of us
Okay, so tried shutdown() on windows. No effect on accept()'s behavior.
Tried close() instead. Generated an assertion. Looked, oh oops, it's supposed to be closesocket(). So yeah, closesocket() works.
I might just resort to shutdown/close trickery on platforms I know that works on, and then elsewhere just kill the process a little less gracefully. I dunno.
End on
I wish that someway, somehow, that I could save every one of us
So. Technical interview next week. Position: Software Engineer in an industrial environment.
What should I expect?
A cornucopia of possibilities. Companies vary from grilling your ability to explain basic core concepts (What is Inheritance, basic issues with Concurrency etc) to giving you a series of small or even a single large programming problems to take a crack at.
KakodaimonosCode fondlerHelping the 1% get richerRegistered Userregular
edited September 2010
How much experience do you have? When I've interviewed people, what I'd ask an experienced software engineer with 5+ years of experience was totally different than what I'd ask someone who was applying for our new grad or intern positions.
Oh hi guys. So, me again. How do I detect if a connection dropped? Reading/writing is returning successfully with an Input and Output stream. Or, rather, it's not throwing an exception when a client forcible drops (reset) or if they willfully close their socket. Any ideas?
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
isClosed() returns true I think. I forget if there's a nicer way to check
Negative. Has the same issues isConnected() has and follows the same principles as sockets in general. Shows state from last IO. I tried keepalives and a timeout and that had no effect and for some reason writing a single byte isn't doing squat.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Spent a week with Javascript and have a new project for work up and running.
Finding decent intellisense support for JS is such a pain in the ass. VS2008 won't even recognize named functions. I've gone back to Eclipse for editing. I have Dreamweaver 8 at work too, so I might give that a shot today.
Still reading a couple of books, but are there any articles or guidelines on how one should organize js files. I don't really like having a large JS file as I may want to parse out some of these functions for use in other projects.
Starfuck on
jackfaces
"If you're going to play tiddly winks, play it with man hole covers."
- John McCallum
Okay, so tried shutdown() on windows. No effect on accept()'s behavior.
Tried close() instead. Generated an assertion. Looked, oh oops, it's supposed to be closesocket(). So yeah, closesocket() works.
I might just resort to shutdown/close trickery on platforms I know that works on, and then elsewhere just kill the process a little less gracefully. I dunno.
What're you trying to do again end? I've been doing a lot of socket programming lately maybe what I've picked up will help you.
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Okay, so tried shutdown() on windows. No effect on accept()'s behavior.
Tried close() instead. Generated an assertion. Looked, oh oops, it's supposed to be closesocket(). So yeah, closesocket() works.
I might just resort to shutdown/close trickery on platforms I know that works on, and then elsewhere just kill the process a little less gracefully. I dunno.
What're you trying to do again end? I've been doing a lot of socket programming lately maybe what I've picked up will help you.
Right now? Just gracefully shutdown while accept() is blocking. Threads really throw a wrench in things since it means I might still want to finish up a request in another thread.
I'm scrapping the shutdown/close idea, since it depends on undefined behavior (although I still use close() early, which will be helpful for windows). I went back and looked again how apache does it, and oh yeah I guess it does use signals.
So I think my best options are to either use signal masking like apache, or monkey around with a non-blocking accept(), although that might just move the problem.
End on
I wish that someway, somehow, that I could save every one of us
Yeah your best bet is to move away from the blocking accept. Worst case in that situation is a client thinks it's connecting and gets interrupted anyways. Any reason you can't just kill the thread?
bowen on
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
0
Options
KakodaimonosCode fondlerHelping the 1% get richerRegistered Userregular
edited September 2010
Or signal the threads to stop picking up new data from the socket? Thread signaling isn't too difficult in Windows.
Posts
That's why other JVM languages like Scala or the afore-mentioned Clojure let you pass functions as arguments, but Java (the language) does not.
But the lack of lambdas and closures in Java is annoying. There's a chance that they'll show up in Java 7, but I haven't heard any movement on that lately. I've not been very impressed at how slowly things have been added into the Java language specification. But, they are faster than the C++ standard group.
Behind the scenes in Java, functions are objects (check out the Method class. You can call them on an instance of the class they belong to using Method.invoke()), and you can get at them using the reflection libraries. It's not clean or non-verbose (but what in Java isn't verbose? ), but it's certainly possible to do functionalish things in Java. (Although typically it would be done with anonymous classes and stuff, rather than the reflection libraries.)
left over from the popularity of C? some inherent advantage i'm not aware of?
most of all, most of all
someone said true love was dead
but i'm bound to fall
bound to fall for you
oh what can i do
Tradition is definitely a reason too: the libraries exist in C (or C++).
But Java is still used here and there. Like... for Minecraft. Java's advantage over C++ is rapid devel. C(++)'s advantages over Java are it's speed and low level accessibility. Low level is pretty antiquated this day and age.
And it took me a day and a half to rewrite my library in Java, holy shit, there are some weird nuances I've forgotten since I left school.
Also thanks all for helping me.
They aren't expecting me to know anything about webGL out of the gate, I know that they are starting research into the area for a future product so I'd like to start learning.
From wikipedia it looks like a platform that's still kind of in infancy with not a whole lot to the article, and several different developer libraries. Anyone have recommendations for books and/or websites I could look into for the basics in terms of research and overview not necessarily technical programming?
Urgh. Urgghhhhhh. I do not want to do a 2nd thread.
Edit: Oh, I hope it doesn't kill existing connections...
close() will recover the file descriptor, but accept() will continue accepting connections.
shutdown() does what I want from initial testing at least.
You could always give it a connection from inside your app
Although, the way I use it, I don't think that'd work, since I set it up as a chown'd unix domain socket.
(It supports TCP too, but I like the reduced overhead a unix domain socket gives, and not having an open port, even if it'd be firewalled, is nice.)
I doubt shutdown() will be portable in that way though *grumble*
I honestly don't know, I'm not really a ruby guy. I just know that I am marrying Sinatra+DataMapper+Heroku
It's a server obviously. It's multithreaded. Each thread handles a request.
I looked how apache handles it with the worker mpm, and they basically poll the listener and use signals to interrupt only the thread currently listening. That doesn't work so well for me, because I allow multiple processes as well, and unless I do a global lock across processes, both could wake up, and one would end up blocking. Hm, I guess I could also make it a non blocking accept, that could do it.
Right now I'm working on a branch that uses APR, and I'm trying to fix the way certain things work while I'm rewriting parts. Part of the problem with APR is the operations you can do on apr threads is somewhat restricted, but then the sort of things that might solve my problem are apparently sort of implementation dependent.
Edit: Actually, I'm a bit confused about one point. I'll have to check how exactly they're masking the signals, since I didn't think apr exposed pthread_sigmask
Tried close() instead. Generated an assertion. Looked, oh oops, it's supposed to be closesocket(). So yeah, closesocket() works.
I might just resort to shutdown/close trickery on platforms I know that works on, and then elsewhere just kill the process a little less gracefully. I dunno.
What should I expect?
See how many books I've read so far in 2010
A cornucopia of possibilities. Companies vary from grilling your ability to explain basic core concepts (What is Inheritance, basic issues with Concurrency etc) to giving you a series of small or even a single large programming problems to take a crack at.
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
Negative. Has the same issues isConnected() has and follows the same principles as sockets in general. Shows state from last IO. I tried keepalives and a timeout and that had no effect and for some reason writing a single byte isn't doing squat.
Finding decent intellisense support for JS is such a pain in the ass. VS2008 won't even recognize named functions. I've gone back to Eclipse for editing. I have Dreamweaver 8 at work too, so I might give that a shot today.
Still reading a couple of books, but are there any articles or guidelines on how one should organize js files. I don't really like having a large JS file as I may want to parse out some of these functions for use in other projects.
"If you're going to play tiddly winks, play it with man hole covers."
- John McCallum
What're you trying to do again end? I've been doing a lot of socket programming lately maybe what I've picked up will help you.
Please.........
I assume you've tried http://pypi.python.org/pypi/soaplib/0.8.1 ?
The library itself seems to be installing, but it relies on pytz which doesn't have a port for 3......grrrrrrrrrr
Edit: Oh well, suds & 2.6 it is.
Right now? Just gracefully shutdown while accept() is blocking. Threads really throw a wrench in things since it means I might still want to finish up a request in another thread.
I'm scrapping the shutdown/close idea, since it depends on undefined behavior (although I still use close() early, which will be helpful for windows). I went back and looked again how apache does it, and oh yeah I guess it does use signals.
So I think my best options are to either use signal masking like apache, or monkey around with a non-blocking accept(), although that might just move the problem.
http://www.sockets.com/err_lst1.htm#WSAEWOULDBLOCK
That's what my book says to do in the case of win/berkley sockets.