9 ms·
My Delorean runs Perl
- farnsworthy 9y agohttps://en.wikipedia.org/wiki/History_of_programming_languages https://en.wikipedia.org/wiki/History_of_programming_languag... Objective-C? Or maybe Ada is more contemporaneous…
- asaph 9y ago> "Because I don't have a lot of time to plan out the full requirements of my objects, it has been a great boost to productivity to just toss in an additional few attributes on unsuspecting objects, or quickly sort through a list of objects based on criteria that would require awkward reflection code in Java or C++." In Java, sorting objects based on arbitrary criteria doesn't require reflection. Just pass in a Comparator to one of the JDK-supplied sort methods. It's not awkward. I'm not a C++ programmer but I suspect it's similar.
- pjmlp 9y agoWith C++ you can even do it over template parameters.
- throwaway080383 9y agoYep, in C++ you can pass in a lambda to create the comparator inline: std::sort( myvec.begin(), myvec.end(), [](obj& A, obj& b) { return A.attr < B.attr; } );
- brianwawok 9y agoThat is disgusting as a non-C++ programmer
- mhh__ 9y agoeh, it's not Haskell (or even D for that matter) but C++ has come a long way in the last few years.
- electricslpnsld 9y agoIf you use std::begin and std::end instead of the member functions this will even work with old-school C-style arrays.
- emmelaich 9y agoYes, and you can even use the range syntax instead of begin/end. Here's a file with a few different ways https://gist.github.com/anonymous/78b4f257e60d55537b36e2e4f3c6de9d https://gist.github.com/anonymous/78b4f257e60d55537b36e2e4f3...
- emmelaich 9y ago.. and Herb Sutter recommends those free functions over the member functions for this reason -- genericity.
- nrdvana 9y agoWhat I'm talking about is arbitrary attributes that might not exist on the base class, resulting in something like: std::sort( myvec.begin(), myvec.end(), [](obj& A, obj& b) { int A_attr1= dynamic_cast<Thing1*>(&A)? dynamic_cast<Thing1*>(&A)->attr1 : dynamic_cast<Thing2*>(&A)? dynamic_cast<Thing2*>(&A)->attr1 : -1; int B_attr1= dynamic_cast<Thing1*>(&B)? dynamic_cast<Thing1*>(&B)->attr1 : dynamic_cast<Thing2*>(&B)? dynamic_cast<Thing2*>(&B)->attr1 : -1; return A_attr1 < B_attr1; } ); and then compare that to @list= sort { ($a->{attr1} // -1) <=> ($b->{attr1} // -1) } @list;
- nrdvana 9y agoYou need reflection if the type of object you're comparing doesn't have that attribute, and only half the subclasses do. You then have to inspect the actual class to see if the attribute exists before you can access it, and the code to do that is so ugly it would take less time to go edit the base class and constructors to give them all the attribute. This is the hassle that perl is avoiding, in the same way that JavaScript would avoid it. Every object is just a collection of attributes and you can access them by name. It's not as efficient as structs or interfaces, but it's very convenient for prototyping.
- tyingq 9y agoSeems directly related to Larry Wall's (Perl founder) "Laziness, Impatience, Hubris " idea: http://wiki.c2.com/?LazinessImpatienceHubris http://wiki.c2.com/?LazinessImpatienceHubris
- noonespecial 9y agoThat's a lot of lines for "it's my $##& project and I wanted to use perl." More power to 'im! I use lua for such things myself. Because I like it. That's the beauty (and even a big part of the reason) for solo projects. You get to do it your way.
- Grazester 9y agoInteresting project. The real issue with the Dolorean however is the engine and drivetrain not the dash.
- Animats 9y agoThat can be fixed. Here's Stanford's all-electric, self-driving, self-drifting DeLorean.[1] With a computer display as the dashboard. [1] https://www.youtube.com/watch?v=WNIDcT0Zdj4 https://www.youtube.com/watch?v=WNIDcT0Zdj4
- avg_dev 9y agoThat video is awesome, but self-driving is only true if you want to drive in tight little circles.
- _jal 9y agoI still fall back to perl for experimental/recreational programming. Possibly because it is the first scripting language I really felt fluent in, but I think just because it is so quick and flexible to write. These days, anything I inflict on others in this category tends to be redone in Python, but for hacking? Perl just hits a sweet spot like no other language for me.
- v_lisivka 9y agoPerl is joy to write (especially with Modern::Perl qw(2016) and feature qw(signatures)) but is hard to read. I can write lot of code in single line with map/reduce/split/join/regexps, but without chaining of operators it is mess, because order of operators is opposite to order of execution. It because of traditional function or operator invocation syntax: "x(a1, y(a2, z(a3, a4), a5), a6)", instead of modern chain of calls: "z(a3,a4).y(a2, a5).x(a1, a6)" . The more operators I pack into single line of code with traditional syntax, the harder it to read. Perl6 has "feed operator", but it is not ported to perl5 to date. Perl6 syntax is clean: my @array = <7 8 9 0 1 2 4 3 5 6 7 8 9>; @array ==> unique() ==> sort() ==> reverse() ==> my @final-array; say @final-array; but perl6 is slow, so it is not gaining any popularity.
- singingfish 9y agoperl can be hard to read. but then again it can be easy e.g. https://gist.github.com/anonymous/a229b77c8ab25026633f1ab819c29a78 https://gist.github.com/anonymous/a229b77c8ab25026633f1ab819...
- v_lisivka 9y agoI can write readable page of code. I want to write readable line of code.
- lizmat 9y agoNot sure when you last tried to run your Perl 6 program, but things have improved over the years. Today Rakudo Perl 6 celebrated having one of the most tested canary programs break the 100x faster barrier: https://twitter.com/zoffix/status/957322578460315649 https://twitter.com/zoffix/status/957322578460315649
- int0x80 9y ago> embedding C++ code into Perl What could posibly go wrong. No seriously, the project looks amazing.
- userbinator 9y agoI'm a fan of car modding myself, but I don't think replacing the entire instrument cluster with a single centralised system --- where one fault can leave you with no instruments instead of just one inop --- is such a good idea. Adding a secondary display for less critical indicators would be useful, however.
- laythea 9y agoWhy is a failure of the cluster readout display, during driving, a big deal? If it fails, it would be fixed soon. The driver still has the window. I'm struggling to see how an immediate failure of speed readout etc would immediately endanger the car? Assuming it performs no control function.
- throwawayjava 9y ago> Why is a failure of the cluster readout display, during driving, a big deal? It's true that you probably won't die immediately. But for most people, driving a long distance without a cluster display would be extremely dangerous. Especially at night on an empty road. For me, I start relying on the readouts for speed and rpm around the four hour mark. Tired brains don't work well. Which means you probably have to get it fixed ASAP. If that happened more than a couple of times with a car, I'd sell the car / not buy it in the fist place.
- lsc 9y agoYou aren't wrong, but if you really are concerned about those sorts of things, you should probably drive a late-model Toyota, not a Delorian. They stopped making this car in 1983; it is far beyond it's design lifetime already, and was never a particularly reliable car to begin with, from my understanding. Like most classic cars, you probably shouldn't drive it unless you enjoy maintaining it, and are okay with (and carry substantial liability insurance for) a car that is dramatically less reliable and less safe than a modern car. Like most classic cars, you probably shouldn't drive it places where you are likely to die or otherwise suffer dramatically bad consequences if it breaks down. This isn't a criticism of the Delorian specifically as much as it is a truth about early '80s automotive engineering and running vehicles beyond their service life. Of course, as a society, we've decided that this (tradeof off cool car vs danger) is a reasonable choice to make; we don't force people to buy newer cars because they are safer. Within this context, the addition of a special instrument panel seems to me like it's not adding substantial additional danger to the system.
- xt00 9y agoWho else was hoping to see some Perl scripts running in a shell on the dash of the Delorean..
- trco 9y agoI wonder how long it takes to boot up the system before you can drive with this approach.
- dfox 9y agoIt is easy to tune Debian Wheezy such that it boots into your X application from rotating HDD in less than 15 seconds from powerup on typical Atom ITX board. For newer distributions with systemd you don't even need any special tuning for the boot time to be dominated by BIOS POST.
- AlexCoventry 9y agoPerl 5 or 6?
- xeeeeeeeeeeenu 9y agoIt's clear that he's using Perl 5. XS and CPAN are concepts exclusive to Perl 5.
- shakna 9y agoI don't think that is entirely true. > Uploading a module to CPAN is the preferred way of distributing Perl 6 modules. [0] Though XS was replaced with NativeCall in Perl6, so he is still using Perl, not it's new brother. [0] https://docs.perl6.org/language/modules#Upload_your_Module_to_CPAN https://docs.perl6.org/language/modules#Upload_your_Module_t...
- raiph 9y agoI haven't read the parent to this comment. But: > XS [is] exclusive to Perl 5. Perl 5 modules, including XS ones, are `use`able with P6 (`use Module::Using::XS:from<Perl5>; # P6 code...`). > CPAN [is] exclusive to Perl 5. CPAN has been an optional store for Perl 6 modules since 2016 iirc. In the last couple months it's become more or less the preferred store.
- billytetrud 9y agoWhere's the flux capacitor?
- throwawazqq 9y agoIt is a great idea to program a dashboard to one’s taste. Most dashboards these days are terrible and illustrative of somebody else’s UI dreams. Imagine something more useful than what Audi or Tesla provides and not the crap Apple/Google gives us on our phones
- greglindahl 9y agoTesla owners have been writing javascript websites to run in the web browser on the 17" touchscreen ever since the Model S was released. You can't do much of a car dashboard, alas, but you can do weather forecasts, TODO lists, geofenced content like work server status while I'm driving to work, and so on.
- pcunite 9y agoPeople who like Perl are weird. :-)
- gbacon 9y agoBut productive.
- Cyberdog 9y agoLet me get this straight. You have a DeLorean DMC-12, a touchstone of '80s aesthetics and American pop culture icon, and you tear out the instrument panel and replace it with contemporary over-engineered Linux-powered glitz? You ruined it!
- pmlnr 9y agoPerl was first released in '87, so it kinda fits.
- nrdvana 9y agoThe DeLorean was famous exactly because it wasn't 80's aesthetics; it STILL looks like the car of the future. But the instrument cluster? it's made of cheesy analog gauges that bounce with the fluctuations of the system voltage. It desperately needed an upgrade. (but I have all the original pieces and no parts were cut in the process of the mod ;-)
- Cyberdog 9y agoBut that's part of the experience, is it not? Analogue gauges! Also, assuming you're the one that did this modification; How long does it take for your instrument panel to boot? Fast enough to see the tach needle (or replacement thereof) jump up as the engine starts and then bounce back down to normal? Being in a car where I wouldn't be able to see that happen would be… surreal.
- nrdvana 9y agoMy kernel takes 2 seconds, and the userspace takes about 4, mostly waiting for Xorg to initialize the display (which I could probably improve using a hardcoded xorg config, rather than autodetect). The real killer is BIOS though- my FitPC 3 takes about 7 seconds to POST. However, I power it on when the door opens, rather than when the key turns, and one of these days I'll get it connected to my remote unlock button. The microcontroller is always on and consumes almost no power. I would buy a new PC if I knew for sure that the post time was less, but nobody ever advertises that statistic, and anything based on BIOS/UEFI tends to be abysmally slow. Meanwhile the display rendering should be within ~50ms of the measurements from the microcontroller, so the tach and other measurements feel really "tight". (the tach is that curved column of horizontal bars on the left)
- elfchief 9y agoNow what I would like to know is ... is this perl code on github?