sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Ruby's global nightmare!

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    26 貼文 13 Posters 1.5k 瀏覽 13 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • M 離線
      MSP_Greg
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • D 離線
        david.
        最後由 編輯

        @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 條回覆 最後回覆 回覆 引用 0
        • J 離線
          jessejames
          最後由 編輯

          @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 條回覆 最後回覆 回覆 引用 0
          • R 離線
            remus
            最後由 編輯

            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 條回覆 最後回覆 回覆 引用 0
            • N 離線
              NewOne
              最後由 編輯

              If we complain about Ruby, what AutoCAD users say about Lisp? 💚

              1 條回覆 最後回覆 回覆 引用 0
              • M 離線
                MSP_Greg
                最後由 編輯

                jessejames,

                @jessejames said:

                Am i moving to quickly for ya?

                Having written code in Python, Ruby, C#, Java, JavaScript, various dialects of Basic, and C++, probably not. Also, having a CompSci prof in the late '70's always wax on about the elegance of Pascal conditioned me to the large distinction between 'elegant' when finished, vs easy to reach 'finished.'

                The Python features you’re referring to would be considered simple syntax conventions by most programmers, and, hence, trivial. I'll respond anyway.

                1. Namespaces – Lets say I'm working on a real project, and production code will be a minimal set of files. As the code is being created, it's often helpful to have the code being worked on by itself, in a separate IDE container. Once complete, it's moved into another container that has finished code. Often, that IDE container is a file. I don't want the namespace changing if I move code between them.

                2. End vs indent – I've written code where there may be a lot of end statements, one after the other. Also, indenting is commonplace today. Hence, it would seem that Python's removal of statements like 'end' would be helpful, even though almost all other languages use them. Conversely, when writing code, I often leave test/debug statements on the left margin as a marker that I can delete them when the code works. I can't do that in Python.

                I might suggest that you read a few books like 'Design Patterns' by the 'Gang of Four' to get an idea of what the real distinctions are in programming languages. Real distinctions affect whether a framework can be moved/ported to another language, as opposed to simple syntax conventions.

                I might also suggest that there's plenty of others forums for your concerns. This one is for Ruby used in SketchUp.

                BTW, I'm ignoring the flame, otherwise we might get into that layman concept...

                Greg

                1 條回覆 最後回覆 回覆 引用 0
                • 1
                • 2
                • 2 / 2
                • 第一個貼文
                  最後的貼文
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement