Unity+ Posted October 17, 2014 Posted October 17, 2014 So, I have been conflicted on what language to use: Ruby or Python? There are many sites that probably have comparisons, but I want to ask if anyone, in experiencing any of the two languages, if they could give their take on their pros and cons. Is there some benefit using one or the other? Is it merely style? Is one more powerful than the other? Or is one just easier to work with? Here is some categories when posting comparisons: Dealing with data sets(lists) Recursion issues Dynamics Syntax Other
davidivad Posted October 17, 2014 Posted October 17, 2014 (edited) what do you want to use it for? i prefer python just because of the origination of its name... good old slapstick humor is where it is at... and you will need that humor for some things. Edited October 17, 2014 by davidivad
Sensei Posted October 17, 2014 Posted October 17, 2014 i prefer python just because of the origination of its name... I prefer C/C++ just because of its powerfulness...
davidivad Posted October 17, 2014 Posted October 17, 2014 (edited) c++ is the way to go sometimes. i usually try things out first and then reimpliment it in the best chioce if i like it. Edited October 17, 2014 by davidivad
Unity+ Posted October 17, 2014 Author Posted October 17, 2014 what do you want to use it for? i prefer python just because of the origination of its name... good old slapstick humor is where it is at... and you will need that humor for some things. Well, I am implementing a protocol that I developed that requires sending data when it is requested from a server. It involves sending two pieces of data at the sametime as the user requests one of these pieces of data.
Sensei Posted October 18, 2014 Posted October 18, 2014 (edited) Well, I am implementing a protocol that I developed that requires sending data when it is requested from a server. It involves sending two pieces of data at the sametime as the user requests one of these pieces of data. Using interpreted language for such task is one of the most stupid things I heard about (sorry).. (can you imagine making apache http server using python??) It might be done for non-commercial private test use, but when somebody pays you for doing so, you definitely should use C/C++ code to handle packets, to have as fast as possible rate of handling data.. Or even create separate threads for each connected client to have as high as possible transfer.. If you won't do so (create thread), you're running into problem that single-thread code is doing its stuff (handling packet) while other client tries to connect to server (that's busy and doesn't respond).. You would have to test hundred or thousands clients per second trying to connect to your service to see it though. Check time your code is spending on handling single packet.. Edited October 18, 2014 by Sensei
Sato Posted October 18, 2014 Posted October 18, 2014 Hey Gregg, remember when you commented on Popcorn's smugness? I think some of it rubbed off on you . If you're writing a networking protocol that's going to hang around on not-particularly-powerful single-board computers like the Raspberry Pi, I'd recommend using C (or C++ if you need). The reason being that C compilers are being optimized to this day, since the language's beginnings for writing Unix, and so programs written in it are some of the fastest you can make. Further, because C is a low level language and many operating systems (including Raspbian) are designed by and written in it, you can implement your own low-level assembly optimizations and access networking hardware as needed, without having to go through layers and layers of API's and bog. I suppose if you just want to test whatever idea you have you can use Python—why did Ruby even come up? Some Googling will show you they both have similar expressiveness and benchmarks, Ruby often winning on the former and Python on the latter, but not to any significant extent that I can tell, not having worked with Ruby—, but if you want to actually implement your protocol for production, then I'd recommend writing it in C. 1
davidivad Posted October 18, 2014 Posted October 18, 2014 (edited) i think he realizes certain differences in the two and is doing a brake check... lol i personally like python due to my familiarity with it and the fact that you can apply it elsewhere without having to pick up yet another language. Edited October 18, 2014 by davidivad 1
Unity+ Posted October 18, 2014 Author Posted October 18, 2014 (edited) Hey Gregg, remember when you commented on Popcorn's smugness? I think some of it rubbed off on you . If you're writing a networking protocol that's going to hang around on not-particularly-powerful single-board computers like the Raspberry Pi, I'd recommend using C (or C++ if you need). The reason being that C compilers are being optimized to this day, since the language's beginnings for writing Unix, and so programs written in it are some of the fastest you can make. Further, because C is a low level language and many operating systems (including Raspbian) are designed by and written in it, you can implement your own low-level assembly optimizations and access networking hardware as needed, without having to go through layers and layers of API's and bog. I suppose if you just want to test whatever idea you have you can use Python—why did Ruby even come up? Some Googling will show you they both have similar expressiveness and benchmarks, Ruby often winning on the former and Python on the latter, but not to any significant extent that I can tell, not having worked with Ruby—, but if you want to actually implement your protocol for production, then I'd recommend writing it in C. I don't know what you mean. I don't like Python because of its syntax and handling of stuff. Ruby seems better from what I have tried out with it. However, I don't particularly know how well it deals with data structures, which is why I asked. I guess C could be used, but that would be used on a different aspect of it because I am merely dealing with filesystems, such as removing wrongly placed files in the server folder and uploading files to a server. To implement the actual protocol, I would probably use C to allow the files to be transferred to the device requesting the information. Using interpreted language for such task is one of the most stupid things I heard about (sorry).. (can you imagine making apache http server using python??) It might be done for non-commercial private test use, but when somebody pays you for doing so, you definitely should use C/C++ code to handle packets, to have as fast as possible rate of handling data.. Or even create separate threads for each connected client to have as high as possible transfer.. If you won't do so (create thread), you're running into problem that single-thread code is doing its stuff (handling packet) while other client tries to connect to server (that's busy and doesn't respond).. You would have to test hundred or thousands clients per second trying to connect to your service to see it though. Check time your code is spending on handling single packet.. Doesn't Ruby support multithreading? I know Python does, but Ruby is a different story I think. Edited October 18, 2014 by Unity+
davidivad Posted October 18, 2014 Posted October 18, 2014 there is a good question. which one has the best support.
Strange Posted October 20, 2014 Posted October 20, 2014 Using interpreted language for such task is one of the most stupid things I heard about. Many such services are implemented in interpreted languages ... PHP, Perl, Python, Ruby, Javascript ...
Sensei Posted October 20, 2014 Posted October 20, 2014 (edited) Many such services are implemented in interpreted languages ... PHP, Perl, Python, Ruby, Javascript ... PHP script is typically executed by server when somebody (client) visited url, and extremely quickly sends result output to client that requested it (web browser). JavaScript is executed by web browser internally, while user is watching url. Then when he goes other url, it's gone.. Total time of execution calculated in seconds or minutes, as long as browser window/tab is open.. Unity+ wants to create his own *server* that has loop waiting for clients packets at some port. Client connects to f.e. 80 port, send packet, and code made by Unity+ have to process that packet and send response. That code has to work hours and hours waiting for clients... There is example of daemon in PHP docs. http://php.net/manual/en/function.socket-accept.php This usleep(100) and set_time_limit() "nicely" summarize usage of this language for such task.. You *have* to explicitly tell PHP to not automatically shut-down by using set_time_limit(0); at beginning of script. (default shut-down time is.. 30 seconds) "Warning This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini." Edited October 20, 2014 by Sensei
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now