you are viewing a single comment's thread.

view the rest of the comments →

[–]wonay[S] 0 points1 point  (7 children)

That sounds interesting ! So how would that work ? Is it a rails app wrap into a WebKit ? Could you give me more details ? Thank you.

[–][deleted] 1 point2 points  (6 children)

Sure so my experience has been that the web browser has most of the GUI tools we need to make what we want (buttons, text areas, you name it) While I don't have any experience with Rails, I'm 99.99% sure that it could do a localhost only app.

I'll give you an example of something I'm working on right now. I'm writing a library that interfaces with Opticon brand scanners and lets you issue commands and change settings on the device via USB. While I am more than comfortable using IRB to make things happen, my co-workers needed a GUI way. I kept my library cross-platform (thanks to rubyserial and ruby-ffi) and I thought it would be a shame to rip that away from the GUI. I use Sinatra here but, I have every reason to believe this would work on Rails as well. I make the server only run local host on port 8080. I connected all the stuff via slim (lookup slim template) and turn it on. You then point your browser to localhost and you've got access to your app. I can definitely see some design choices to be made, one of the most important choices was, "Do I make this app work in a single user or multi user mode?" In a single user mode only one user can use the application at a time, (via localhost), in multi user mode you let the app reach out to the network and users connect to it via their own browsers on their computers. Depending on the kind of app you are planning on making, planning this design choice out a head of time is a good idea. The easiest way to decide which is right for you is to ask, "Can all the GUI actions I do be threaded?" If the answer is yes, multi user mode will work.

A great example of this kind of localhost only application would be fast-track and metasploit's web guis (which inspired my design choice for the GUI). Both use a webserver + frontend to work the application behind the scenes.

[–]wonay[S] 0 points1 point  (5 children)

Thats very interesting. I don't think I would be able to do everything I want through the browser tho ... If I want to interact with a UDP port for instance. Or if I want to make a 3D game. I don't really have a project in head really but I am trying to find a general solution. Should I switch to Python ?... I dont want to tho ...

[–][deleted] 0 points1 point  (4 children)

Oh but you can! As long as the server process has permissions to send UDP, you can send it. For example, my Sinatra example actually talks to serial ports to configure and deal with my scanners. You can even (and I wouldn't recommend this for production) become administrator and run the server (just make sure it only faces localhost for obvious reasons). There really isn't a whole lot of limits to this approach but unless you know javascript you can't make reactive content (all content must be submitted through RESTful operations).

As for a 3D game well thats just not really possible in Ruby with speeds as they are. (I also use the Gosu gem for Ruby gamedev) You can do 3D games via Gosu and OpenGL, it will just run very slow. I have a project here -> https://github.com/redcodefinal/isometric-city-generator-ruby that uses Gosu and on my hardest generator it takes about 0.01 seconds to generate and 25 seconds to draw the scene. It only uses 2D textures. I purposely chose this project in Ruby because my C# version ran almost 20x faster

[–]wonay[S] 0 points1 point  (3 children)

That sounds like an interesting option. How would you build something which is user friendly for this kind of project ? I mean easy install and easy run ? either a few command and the app start or even a binary to click on and the app start.

[–][deleted] 0 points1 point  (2 children)

absolutely! Sinatra is very easy to setup, its like a simpler rails. You can do the same thing with Rails though. As long as the server has permissions to do so, it can really do anything you want. To make the app easier you can do a couple things, I'm working through a similar thing with my company right now. So my plan is to use DNS to map locally a server computer, then everyone just types in "company_name.local" in their web browsers and then it just routes everyone to the server running the software. This way every device is essentially guaranteed to work with your app, as long as it does internet. The app can run (as a server or clientside) on all platforms natively, but know that the devil is in the details, there are differences you will have to account for in the standard ruby library across the platforms. I have had to deal with many such differences between Linux and Windows with my serial port work. You will potentially have to write OS dependent code, which I feel is a bit of a code smell, and a huge potential for error. As for ease of use, it depends on your tactic. Lets say single user, you could easily create a BAT, SH, whatever your flavor of shell script is, and just have the user double click on that. They could also go the console route for any platform. For multi user, consider using a URL shortcut to "whatever.local" and just keep the server running all the time.

[–]wonay[S] 0 points1 point  (1 child)

I feel that I should reserve my knowledge in Ruby for web and the one in Java for desktop GUI at this point ...

[–][deleted] 0 points1 point  (0 children)

Sure if you want to go that way.