As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

#define THREAD_TITLE "PA Programming Thread"

1535456585962

Posts

  • Options
    HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    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
  • Options
    KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    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.

    Kakodaimonos on
  • Options
    FodderFodder Registered User regular
    edited September 2010
    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.

    Fodder on
    steam_sig.png
  • Options
    Smug DucklingSmug Duckling Registered User regular
    edited September 2010
    Halibut wrote: »
    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? :lol: ), 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.)

    Smug Duckling on
    smugduckling,pc,days.png
  • Options
    Xenocide GeekXenocide Geek Registered User regular
    edited September 2010
    why is C++ overwhelmingly used to write game engines, as opposed to something like java?

    left over from the popularity of C? some inherent advantage i'm not aware of?

    Xenocide Geek on
    i wanted love, i needed love
    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
  • Options
    EndEnd Registered User regular
    edited September 2010
    The memory characteristics of the JVM are a good reason not to do game programming in Java.

    Tradition is definitely a reason too: the libraries exist in C (or C++).

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    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
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    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
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited September 2010
    With setSoTimeout() you can block for 1 ms, but I don't think there's any non-blocking or true asynchronous ways to do it

    Phyphor on
  • Options
    GogoKodoGogoKodo Registered User regular
    edited September 2010
    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?

    GogoKodo on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    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
  • Options
    KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    You're stuck. Unless you want to pull in some other packages, Java does not do async I/O at all.

    Kakodaimonos on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    setSoTimeout() might be what I use then. Connection handling from the server should happen within a few ms anyways.

    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
  • Options
    EndEnd Registered User regular
    edited September 2010
    Goddammit, breaking an accept() call portably when threads are involved is somewhat annoying when you're trying to do a graceful shutdown.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    EndEnd Registered User regular
    edited September 2010
    oh hey, I wonder if calling shutdown() on a listen socket is at all portable.

    Edit: Oh, I hope it doesn't kill existing connections...

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited September 2010
    Won't close() on the socket handle always do it?

    Phyphor on
  • Options
    EndEnd Registered User regular
    edited September 2010
    Nope.

    close() will recover the file descriptor, but accept() will continue accepting connections.

    shutdown() does what I want from initial testing at least.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited September 2010
    Really? Um, well I'm more familiar with Windows than unix (where it will break it)

    You could always give it a connection from inside your app

    Phyphor on
  • Options
    EndEnd Registered User regular
    edited September 2010
    Hm, I didn't even think of that.

    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. :lol:

    (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*

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    InfidelInfidel Heretic Registered User regular
    edited September 2010
    What exactly are you working with End and what are you trying to do?

    Infidel on
    OrokosPA.png
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited September 2010
    templewulf wrote: »
    Jasconius wrote: »
    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
    B) 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

    Jasconius on
  • Options
    EndEnd Registered User regular
    edited September 2010
    Infidel wrote: »
    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
    zaleiria-by-lexxy-sig.jpg
  • Options
    EndEnd Registered User regular
    edited September 2010
    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
    zaleiria-by-lexxy-sig.jpg
  • Options
    clsCorwinclsCorwin Registered User regular
    edited September 2010
    So. Technical interview next week. Position: Software Engineer in an industrial environment.

    What should I expect?

    clsCorwin on
  • Options
    Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    edited September 2010
    clsCorwin wrote: »
    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.

    Alistair Hutton on
    I have a thoughtful and infrequently updated blog about games http://whatithinkaboutwhenithinkaboutgames.wordpress.com/

    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.
  • Options
    KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    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.

    Kakodaimonos on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    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
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited September 2010
    isClosed() returns true I think. I forget if there's a nicer way to check

    Phyphor on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    Phyphor wrote: »
    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
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    Well, I guess it would help if I flushed my buffer wouldn't it. Now it detects a reset properly. Sorry. :?

    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
  • Options
    StarfuckStarfuck Registered User, ClubPA regular
    edited September 2010
    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
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    End wrote: »
    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
  • Options
    zeenyzeeny Registered User regular
    edited September 2010
    Guys, please tell me there is a python3 compatible soap module.
    Please.........

    zeeny on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    zeeny wrote: »
    Guys, please tell me there is a python3 compatible soap module.
    Please.........

    I assume you've tried http://pypi.python.org/pypi/soaplib/0.8.1 ?

    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
  • Options
    zeenyzeeny Registered User regular
    edited September 2010
    bowen wrote: »
    zeeny wrote: »
    Guys, please tell me there is a python3 compatible soap module.
    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.

    zeeny on
  • Options
    EndEnd Registered User regular
    edited September 2010
    bowen wrote: »
    End wrote: »
    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
    zaleiria-by-lexxy-sig.jpg
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    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
  • Options
    KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited September 2010
    Or signal the threads to stop picking up new data from the socket? Thread signaling isn't too difficult in Windows.

    Kakodaimonos on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    I thought native sockets could poll for connections in windows, I know C# can. Java can't obviously.

    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
  • Options
    bowenbowen How you doin'? Registered User regular
    edited September 2010
    Mark the socket as non-blocking, do an accept, check for:

    http://www.sockets.com/err_lst1.htm#WSAEWOULDBLOCK

    That's what my book says to do in the case of win/berkley sockets.

    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
This discussion has been closed.