60
bahua
6y

This is my first IoT project. It's pretty simple, but I've been very happy with the results thus far.

About this time last year, someone got into our garage and rifled through my wife's car.

I have a camera in my garage, and a Phillips Hue motion detector. Using the Hue's excellent API, I have a perl script that checks for motion every couple of seconds, and starts capturing from the camera via RTSP if it does. That video is then staged, ready to be uploaded to a digital ocean droplet if I click on a link in the mailgun-powered email that's then sent to me and my wife, along with a preview GIF of the video, created through the same ffmpeg process that pulled the capture from the camera.

Here you can see me getting home from work.

Comments
  • 8
    Thats so fucking cool actually.

    Like, so fucking cool.
  • 6
    @zlice

    Yep, perl rules.
  • 3
    @bahua solid work.

    But also, what's good about Perl? I see it's dynamically typed, which I've never found advantageous compared to static ones (having done dynamic languages professionally for 3 years)
  • 3
    @Nevoic

    It processes text like a bat out of hell, and uses miniscule system resources to do it. It ain't purty, but I'm not writing art. I'm writing functional code that performs without eating the server for lunch.
  • 0
    @bahua I doubt it's more performant than Rust, Crystal, or C.

    All the above being statically typed and C (the normal performance benchmark) is (by idiomatic code) outdone by the other two languages.
  • 4
    Future improvements:

    UPS
    BACKUP 4G Connection
  • 0
    @bahua Crystal looks nearly identical to Ruby, and Rust's slogan is "Zero cost abstractions".
  • 1
    @Nevoic

    It's not the best in the world at what it does, but it's close, and it's everywhere, with zero install or config required. Also, I know it well.
  • 1
    @bahua that's fine. I'm asking for me, not for you. Looking for a reason to try it out, but sounds like there probably isn't one except for fun.

    I think in your situation it's a perfectly good thing to use, plus just making shit is cool.
  • 2
    That's amazing.
    I love it so much I might build something similar
  • 0
    @zlice it might be. I was comparing it to statically typed, compiled languages.

    There's not really an advantage to interpreted languages, other than the time saved in compilation, which is almost always under 2 seconds. A small price to pay for better runtime, safer code, less bugs, etc.
  • 3
    Fuck yeah someone used Perl! 😂
  • 2
    To me it is not the huge things that matter, those small things that actually help are the best thing ever. Just like your project, you faced a problem and solved it, I know it isn't easy doing that but the results are just amazing.
  • 0
    @Bitwise agreed 100%. I was referencing C as it's generally the "benchmarking" language, and I wanted to make the point that there are newer languages (Rust/Crystal) that aren't nightmarish to work with and are *more* performant.

    Crystal looks exactly like a dynamic language (like I specified before, it often is identical to Ruby).

    No pointer/memory management, no segfaults, no shit that makes coding annoying. It's a high level statically typed language, with the safety that comes with that, and performance that's better than C.

    I don't see what Perl has over that.
  • 0
    @Nevoic

    Lolwut.

    Are you reading what you are saying?

    Compiled languages have less bugs? Wut.fucking.face

    How many professionally released and supported projects have you got under your belt?
  • 0
    @D--M only 3. But don't start using fallacies here (namely attacking my credentials instead of my arguments).

    Have you read the academic paper on the person who migrated Python's *standard library* over to Haskell, and found multiple typing errors?

    The developers of these dynamic languages have bugs that are central to the code. Even if you're a prodigy and are typing perfect code, it's still going to be buggy just by the nature of the language.
  • 0
    @Nevoic
    What I am getting at is, there is 0, none, zero evidence that static typed languages have less bugs then dynamically typed ones.

    So your one bit of rebuttle is;
    Someone migrated a library from one language to another and found bugs?
    "Woop de doo", colour me surprised, what a discovery, very wow.
  • 0
    @D--M and also, don't compare something like C to Python. It's an unfair comparison. C came out decades earlier. Of course normally C code is going to be buggy.

    The closest we can possibly get is Crystal vs Ruby. There are instances where 10s or 100s of lines of idiomatic code can be identical.

    In that situation, one is backed by a compiler checking types, the other isn't. There's no advantage (in the realm of bugs) to not have your types checked automatically.
  • 0
    @D--M I'm arguing that by the very nature of compiled languages, if all else is the same (i.e identical languages), that having something to check your typing, and the ability to know all objects before runtime (and verify all method calls), you'll have fewer opportunities for bugs.

    It's impossible to throw a method missing error at runtime. It's also impossible to have a typing error at runtime. These are innate advantages to compiled, statically typed languages that, all else being the same, gives static, compiled languages the advantage.
  • 0
    @D--M to clarify, there are certain generic constructs that exist in some statically typed languages that allow for runtime typing errors, but that's not a universal truth of statically typed/compiled languages, while it is of dynamically typed/interpreted ones.
Add Comment