sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Ruby's global nightmare!

    Scheduled Pinned Locked Moved Developers' Forum
    26 Posts 13 Posters 1.1k Views 13 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jessejames
      last edited by

      @jim said:

      can you post an example Ruby script that demonstrates that all the variables and functions and classes become global to the interpreter?

      Sure Jim, but it's so easy to write i'll just let you do it.

      
      def global_mess
          puts "hello from global mess"
      end 
      
      

      Now just throw that into a script and run sketchup. Open the console and type

      global_mess
      

      You should not be able to do that without qualifing the function first with a module name, oh yeah i forgot, Ruby makes you use a special syntax for that with more end statements piled into the trash heap!

      @unknownuser said:

      But really JJ, that script is nothing more than a simple function call. Nobody writes such simplistic scripts!

      Oh yes they do! In fact, most the scripts by your major contributors(name omitted for fear of lawsuit) are nothing more than a single function call from a menu item! Of course, for tools and extended functionalities a class is paramount, but i would say 75% of the scripts out there don't even use a class. Heck some people even pay good money for such simplistic scripts (and tee shirts and hats ta boot! 🀒 )

      Jim,
      on what experience do you base your lack of interest in Python? Have you ever actually written any Python code? If you have not, i can not see how you can just say "i have no interest" and just leave it at that. You are a SketchUp scripter are you not? Don't you want a tool that is paramount to efficient workflows and easy to learn and use at the same time.

      I guess we could all use ACAD, but there must be some driving force behind our collective choice to use SketchUp. Is it because SketchUp is so easy to learn and use? Maybe because SU has an intelligent design and workflow? Heck maybe because SU is 30MB download instead of gigs!

      PS: Jim, I will be happy to personally tutor you in the Python language for free if you like. It just might change your outlook on languages and language design the same way SketchUp changed your outlook on modeling and modeling software design!

      Always sleep with a loaded gun under your pillow!

      1 Reply Last reply Reply Quote 0
      • fredo6F Offline
        fredo6
        last edited by

        Jesse,

        Your point on Python is mostly for occasional programmers.
        For guys who engage in programming beyond a few hundreds lines or more and share them to a community of users, they have to understand the language they use and make sure that their script can live with others'.

        In Ruby, the encapsulation is done via Modules. In C or Python (which is actually a derivation of C / C++), the file defines a module implictely. It's a matter of language convention. There is nothing complex there if you invest in understanding the programming language. I personally prefer Modules because you can freely split the code in many files.

        Now, I will fully agree with Jim and TBD. Arguing on the right language for SU is little bit of wasted time. SU comes with a Ruby API, so let's use Ruby.

        Fredo

        PS: based on my programming experience, and for plugin development, Ruby is a superior language, much more elegant, efficient and pleasant to write than Javascript and Python. I think the original SU Team made a very good choice.

        1 Reply Last reply Reply Quote 0
        • J Offline
          jessejames
          last edited by

          @unknownuser said:

          I can see your point but there are other languages for which we could make a similar case.

          First thanks for the level headed response, i like people who can discuss even controversial subjects without getting all emotional, Jim also replied intelligently.

          @unknownuser said:

          It is more a question of whether the api was created for coders or users. My feeling is it was created for SU users, facilitated by coders and this end, justifies the means, whether it be Ruby or Shnuby, a coder often has to adopt a syntax he would like to avoid....you are a little spoiled I think.

          No not a little, i am completely spoiled rotten! And i want you guys to be my fellow brats without bonds!

          @unknownuser said:

          All in all Ruby does a real fine job as reported by the users.

          Well i am sure microsoft thinks they are doing a real fine job too. Without a litmus test or pepsi challenge how will you ever know if Ruby is the right choice. Heck maybe Ruby AND Python are the right choice!

          @unknownuser said:

          If you can create effective pluggins using Python then the user community will decide if Python is a viable alternative...not you...not the coder.

          Python and Ruby can both create effective plugins equally. Python shines in usability, learnability, a clear and clean syntax, and more tutorials than you can shake a stick at!!

          @unknownuser said:

          If you want to use a coders language then go find ObjectStar

          I don't want a coders language, i want an API language that is well known, well aged, and well suited for pro's and nub's. Python is that language.

          Always sleep with a loaded gun under your pillow!

          1 Reply Last reply Reply Quote 0
          • M Offline
            MartinRinehart
            last edited by

            @jessejames said:

            
            > def global_mess
            >     puts "hello from global mess"
            > end 
            > 
            

            It is correct to say that your function names are not protected in Ruby. You do have to use a "module" to protect them. The mechanics of this are not hard (the second time). I posted the recipe here:

            http://forums.sketchucation.com/viewtopic.php?f=180&t=22281

            However, you grossly oversimplify the long running Python/Ruby debate. I agree that the file should be its own namespace (it is, but only for variables). I also prefer Python - I think "there should be one obvious way to do it" and I don't like Tim Toady.

            But Ruby it is because @Last Software chose Ruby. We use Ruby for the same reason Apple Iphone developers use Objective C; for the same reason Henry Ford's Model T customers chose black.

            Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

            1 Reply Last reply Reply Quote 0
            • J Offline
              jessejames
              last edited by

              Ah my fellow Python "brother in arms" Martin, who agrees with me, but only half way... I'm royally screwed! 😒

              @martinrinehart said:

              But Ruby it is because @Last Software chose Ruby. We use Ruby for the same reason Apple Iphone developers use Objective C; for the same reason Henry Ford's Model T customers chose black.

              And this is the flaw in API's world wide. Why is not a C level API exposed to all so that we can wrap with language of choice? As any well versed programmer knows one language can not solve all problems effectively. So what i am saying is give the people the tool that is a thousand tools all in one... C. The mailable metal of programming languages. Then we will hone and forge the element metal into the weapons of war specific to our battle at hand -- Ruby, Python, JavaScript, Perl, and of course TimToady

              😎

              Always sleep with a loaded gun under your pillow!

              1 Reply Last reply Reply Quote 0
              • J Offline
                jessejames
                last edited by

                Hello Fredo,

                Thanks for your level headed response also, but i am going to argue some points you made because they are flawed.

                @unknownuser said:

                Your point on Python is mostly for occasional programmers.

                Wait a minute, are you suggesting that Python is some sort of lego language to only be used by debutantes and adolescents? No Python is much much more, ask You Tube devs, ask NASA, ask Industrial Light and Magic(remember a little trilogy called Star Wars?), oh and don't forget Google, who uses Python extensively!!! Heck don't take my word check this out..
                http://www.python.org/about/quotes/

                @unknownuser said:

                For guys who engage in programming beyond a few hundreds lines or more and share them to a community of users, they have to understand the language they use and make sure that their script can live with others'.

                Yes and that script living with others is why Python is the better choice! Name clashing is a big deal in this community just ask around

                @unknownuser said:

                In Ruby, the encapsulation is done via Modules.

                In Python the encapsulation is done via modules, except the redundant syntax is removed!

                @unknownuser said:

                In C or Python (which is actually a derivation of C / C++), the file defines a module implictely. It's a matter of language convention. There is nothing complex there if you invest in understanding the programming language. I personally prefer Modules because you can freely split the code in many files.

                You can freely split the python code in many modules it's called a package!

                @unknownuser said:

                Now, I will fully agree with Jim and TBD. Arguing on the right language for SU is little bit of wasted time. SU comes with a Ruby API, so let's use Ruby.

                Sure lets use Ruby but if a better alternative exists lets explore the possibilities or lets crusade for changes in the Ruby language.

                Always sleep with a loaded gun under your pillow!

                1 Reply Last reply Reply Quote 0
                • N Offline
                  NewOne
                  last edited by

                  My dear jessejames, I don't really understand your attitude about RUBY... I'm not a programmer and all my last attempts to learn a programming language failed ... Until I became interested in making my work easier. I started learning SketchUp and then RUBY to make SketchUp a more usefull tool for me. And surprise: I've been able to write my own "Hello world" and short time after I wrote some simple plugs for my work (I'm a furniture designer).
                  What I want to say with this? Well... just that RUBY is not so bad as you say if a non-talent in programming as me was able to fully understand it and enjoy ruby-ing. It fits for me and it fits for others...

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jhauswirth
                    last edited by

                    @jessejames said:

                    Ah my fellow Python "brother in arms" Martin, who agrees with me, but only half way... I'm royally screwed! 😒
                    😎

                    But there may be someone at Google that might agree with you.
                    http://www.python.org/~guido/

                    1 Reply Last reply Reply Quote 0
                    • Chris FullmerC Offline
                      Chris Fullmer
                      last edited by

                      Jesse, its not ok to be a brat.

                      Chris

                      Lately you've been tan, suspicious for the winter.
                      All my Plugins I've written

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        jessejames
                        last edited by

                        @chris fullmer said:

                        Jesse, its not ok to be a brat.

                        Ah my old friend and sometimes nemesis Chris Fullmer, the only fellow SketchUpper i love to hate πŸ˜† πŸ˜† πŸ˜†

                        Always sleep with a loaded gun under your pillow!

                        1 Reply Last reply Reply Quote 0
                        • tbdT Offline
                          tbd
                          last edited by

                          @jessejames said:

                          Are you hinting that you would like to use another language besides Ruby but have no other choices at this time?

                          I will use any language that does a job better and quicker (including learning it).

                          @jessejames said:

                          Or maybe you just took my comments as personal attacks?

                          nah.

                          @jessejames said:

                          I would like for you TBD (or anyone) to argue my points and defend the Ruby language if anything i said is untrue.

                          I have better things to do that arguing on Ruby vs Python. yes, you said true things. now get over it and do something productive, like :

                          • tutorial on how to install SuPy with
                          • examples of Python scripts for Sketchup (more than creating a box),
                          • expand Ruby with Python features,
                          • or anything else that the community will benefit. not empty talks.

                          @jessejames said:

                          Discussion is a good thing, even the occasional argument.After all this is a discussion group is it not?

                          flame war is also a discussion, but is not a good thing

                          SketchUp Ruby Consultant | Podium 1.x developer
                          http://plugins.ro

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            david.
                            last edited by

                            jj, you're the one that's brainwashed...

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              david.
                              last edited by

                              you're also truly an obsessive personality...

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                david.
                                last edited by

                                and, getting to be a real troll.

                                1 Reply Last reply Reply Quote 0
                                • D Offline
                                  david.
                                  last edited by

                                  Get Over It...

                                  1 Reply Last reply Reply Quote 0
                                  • StinkieS Offline
                                    Stinkie
                                    last edited by

                                    Nah. These boys are doing fine on their own. Besides, argueing over Ruby!?

                                    Nerds! πŸ˜†

                                    1 Reply Last reply Reply Quote 0
                                    • M Offline
                                      MSP_Greg
                                      last edited by

                                      To all,

                                      I don't know why I looked at this thread, but the basic premise that began it is the idea that an OS object (a file) should have an effect on namespaces in a coding environment. That, at a minimum, is a matter of personal preference.

                                      I could argue that the idea is very foolish, as I want my code to define the namespace, not it's placement in a file, or the file's name.

                                      If we're going to argue about X language vs Y language, might as well address serious topics, not fluff, and somewhere other than a forum about using Ruby in SketchUp.

                                      Greg

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        david.
                                        last edited by

                                        @msp_greg said:

                                        To all,

                                        I don't know why I looked at this thread, but the basic premise that began it is the idea that an OS object (a file) should have an effect on namespaces in a coding environment. That, at a minimum, is a matter of personal preference.

                                        I could argue that the idea is very foolish, as I want my code to define the namespace, not it's placement in a file, or the file's name.

                                        If we're going to argue about X language vs Y language, might as well address serious topics, not fluff, and somewhere other than a forum about using Ruby in SketchUp.

                                        Greg

                                        Agree 100%! Not sure why JJ keeps pushing this other than OCD.

                                        1 Reply Last reply Reply Quote 0
                                        • J Offline
                                          jessejames
                                          last edited by

                                          @msp_greg said:

                                          I could argue that the idea is very foolish, as I want my code to define the namespace, not it's placement in a file, or the file's name.

                                          What is a file? What is a script? They are both simply containers for data, right? (Am i moving to quickly for ya? i'll try to use layman's terms). So when you write a script in Ruby or Python you put some text into a file. This is the same for Ruby and Python and Perl and C and whatever language floats your boat.

                                          HOWEVER, the beauty of Python's module and import mechanisms are the fact that you don't need to contain the code that is already contained in the script with more syntax! Ruby forces you to put one container into another container --this is the very definition of redundancy and defines the lunacy of the Ruby language.

                                          Same goes for the end statement which is completely useless. With indention there is no need to mark the end of a block anymore. It's what we Python coders refer to as elegance. You will fund much elegance in the Python language, but only a very little in Ruby.

                                          So in Ruby you will first need to create a file (or OS object as MSP_Greg has informed us) THEN you must encapsulate the code therein within a module between the tags "Module<name>" and "end" Python removes this completely unnecessary step(and many other redundancies i might add).

                                          Always sleep with a loaded gun under your pillow!

                                          1 Reply Last reply Reply Quote 0
                                          • R Offline
                                            remus
                                            last edited by

                                            You could argue that python forces you to create an excessive number of files to contain your creations, though.

                                            And who says i want to indent my code? i like to be able to lay out my code as i like.

                                            More broadly, you can argue a lot about whats best, but as has been said we've got ruby and it isn't a bad language for SU scripting.

                                            http://remusrendering.wordpress.com/

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement