Announcement

Collapse
No announcement yet.

A Project

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    A Project

    I've finally found a cool programming idea.

    There are two graphics systems on Linux that interest me: the direct-rendering manager and libpixman.

    Linux graphics (especially window management) have interested me for some years, so I'm going to try wrapping both of them in Crystal (a language I've been introduced to).

    While I don't know C (which is what drm and pixman are written in), I discovered a project that wrapped them in Lua. I don't know Lua either, but it's understandable enough to "map out" what I should probably do.

    This also means I have to figure out Git (work in progress) and a build system (not there yet). I think I'll be getting close in the near future.

    P.S. This is also why I've been less active here, I'm doing a ton of learning! Hopefully I'll have more time to talk eventually.
  • #2

    Hey, best of luck man! Sounds like you're hitting the books pretty hard. I hope that you'll make some good progress. What's the end goal for learning these? A window manager?
    Daryn's Signature



    “Just when you think humanity has found the limits of stupid, they go and ratchet up the standard by another notch.” - Bob

    Comment

    • #3

      Originally posted by Daryn View Post
      Hey, best of luck man! Sounds like you're hitting the books pretty hard. I hope that you'll make some good progress. What's the end goal for learning these? A window manager?
      Thank you!

      My goal? Right now it's just making the wrappers, I might try to create a toy window manager using them and X11 but for now I'm just doing things one step at a time.

      Comment

      • #4

        That's the best way to go about it, I think. Keep at it and don't give up!
        Daryn's Signature



        “Just when you think humanity has found the limits of stupid, they go and ratchet up the standard by another notch.” - Bob

        Comment

        • #5

          So I tried a basic link to libdrm (the link command is easy in Crystal, even though I'm a novice) and I think it worked but I'm not sure. This is also my first go at a non-tutorial git repo.

          So I'll have to figure out how to test a successful linking, meanwhile I'll still be learning the basics of Crystal.

          Interesting stuff so far!

          Comment

          • #6

            Major news! Tried out a basic Pixman and after trying to find the library's name to link, I've finally done it!

            ldd log shows it was imported to the binary:

            tN06mfD.png

            And I got no errors on compilation either! It works!

            Granted the function is super-basic and I have to figure out how to output its data, but it's a start!

            Comment

            • #7

              Every step forward, even if it seems small, is still a step forward.

              It won't be too long until you're outputting stuff and doing all kinds of cool things.
              Daryn's Signature



              “Just when you think humanity has found the limits of stupid, they go and ratchet up the standard by another notch.” - Bob

              Comment

              • #8

                Originally posted by Daryn View Post
                Every step forward, even if it seems small, is still a step forward.

                It won't be too long until you're outputting stuff and doing all kinds of cool things.
                Yeah. Though I'm still learning Crystal right now. I was wracking my brain for the past few hours to write a working anagram checking program.

                Version 1.0:

                Code:
                 def anagram_check(str1, str2)
                if str1.size == str2.size
                str1_array = str1.split("").sort { |a, b| a <=> b }
                str2_array = str2.split("").sort { |a, b| a <=> b }
                if str1_array == str2_array
                puts "These words are anagrams."
                else
                puts "These words are not anagrams."
                end
                else
                puts "These words are not anagrams."
                end
                end # Input tests after this line. anagram_check("cat", "act")
                It's a pretty messy program, but it seems to work so far. Refactoring will definitely be in order though.

                Comment

                • #9

                  So, let's see if I can understand what you're doing here.

                  First you define the function with two string variables. Then you're checking to see if the two strings are the same length. If they're not you exit. If the two strings are the same length, you then split each string into its own array and alpha sort them. Now you're checking to see if the two arrays contents match. If they do you've got an anagram, if not, you don't.

                  Not sure if Crystal has the 'exactly' operator (===) but this might be a case where you'd use that.
                  Daryn's Signature



                  “Just when you think humanity has found the limits of stupid, they go and ratchet up the standard by another notch.” - Bob

                  Comment

                  • #10

                    Originally posted by Daryn View Post
                    So, let's see if I can understand what you're doing here.

                    First you define the function with two string variables. Then you're checking to see if the two strings are the same length. If they're not you exit. If the two strings are the same length, you then split each string into its own array and alpha sort them. Now you're checking to see if the two arrays contents match. If they do you've got an anagram, if not, you don't.

                    Not sure if Crystal has the 'exactly' operator (===) but this might be a case where you'd use that.
                    Correct on figuring out the code! However, Crystal does not have the strict equality operator you mention.

                    I have a refactored version that splits up the functionality, but it's somewhat long so I'll attach it as a text file.

                    anagram_check_v2.txt

                    Comment

                    Working...
                    X