CommunityNews

CommunityNews

Truth Functional Logic for Hackers - Part One

Bob and Alice are two hackers working on an embedded system with a severe computational constraint - there is a bug in their low-cost microcontroller making OR operations significantly slower than any other operation on the chipset.
When they profiled their micropython code, they found that OR operations were up to 5x slower than any other operation.
Alice This is a big problem! We could replace the faulty chips with better ones, if they arrive before the deadline. Bob I don’t think we can afford to wait - the deadline is in 3 days. A better option is to rewrite the code to avoid the OR operation. Alice How could we do that? We’re using the OR operation in a lot of critical places. Look: def authorize_access(request): # A user is denied if they are on a blacklist OR # their account is expired if (user_is_blacklisted(request.user_id) or account_is_expired(request.account) return “Access denied” return “Access granted” Let’s take a moment to understand the problem. The authorize_access function is used to check if a user is authorized to access a resource. The or operation is used to combine the conditions. How could we rewrite this function to avoid the OR operation?

Read in full here:

Popular General Dev topics Top

First poster: mafinar
The following languages will help current and new web developers navigate the programming landscape to code web-based services and apps t...
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New
AstonJ
Which keyboard switches do you use/like? :upside_down_face:
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
herminiotorres
Someone where use Doom Emacs right now? I like to starting this topic to discuss it and learn a little bit more, not just only the emacs ...
New
Exadra37
I am thinking in buying one as the second monitor for my Thinkpad while I am travelling: Anyone has experience in using on...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
New
AstonJ
This was interesting: He’s definitely more of an Emacs fan (which is fine) and the thing I found interesting is how you wo...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New

Other popular topics Top

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New