Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "object"


Storing unboxed trait objects in Rust

  • This blog post will outline the creation of dynstack, a stack datastructure that stores trait objects unboxed to minimize the number of heap allocations necessary.
  • This means that unless you're using a trait object, Rust doesn't use vtables.
  • This also means that we can't store trait objects on the stack, because Rust doesn't permit variable stack usage (recursion aside).
  • Aside: The representation for a fat pointer, as of Rust 1.32, is a packed (*mut Struct, *const Vtable) tuple.
  • Generally, if we want to store trait objects, we have to allocate them on the heap.
  • The item descriptor table is laid out similarly to the Vec of boxed trait objects, with one important caveat.
  • Note that we need to move the trait object into our data structure.
  • This benchmark pushes once to a Vec<Box<Fn>> / DynStack<Fn>, then calls the closure, then pops it from the list.

save | comments | report | share on


Storing unboxed trait objects in Rust

  • This blog post will outline the creation of dynstack, a stack datastructure that stores trait objects unboxed to minimize the number of heap allocations necessary.
  • This means that unless you're using a trait object, Rust doesn't use vtables.
  • This also means that we can't store trait objects on the stack, because Rust doesn't permit variable stack usage (recursion aside).
  • Aside: The representation for a fat pointer, as of Rust 1.32, is a packed (*mut Struct, *const Vtable) tuple.
  • Generally, if we want to store trait objects, we have to allocate them on the heap.
  • The item descriptor table is laid out similarly to the Vec of boxed trait objects, with one important caveat.
  • Note that we need to move the trait object into our data structure.
  • This benchmark pushes once to a Vec<Box<Fn>> / DynStack<Fn>, then calls the closure, then pops it from the list.

save | comments | report | share on


Object Oriented Programming

  • So you see, both procedural and object-oriented paradigms were trying to solve the same issues: the issue of mutating the global state and breaking down complex tasks into smaller modular units (subroutines/functions vs.
  • Contrary to procedural and functional paradigms where we would pass data from a function to function, manipulate it and return it, in OOP we want the object that encapsulates that data (has it in its internal state) to do the manipulation for us.
  • In other words, the interface defines the methods a class needs to implement in order for our program to work otherwise it will break.
  • Good example - Since we programmed to an interface and not an implementation, changing the storage method is just a matter of changing the class we provide through the App's constructor, we are changing just one line of code.

save | comments | report | share on


Free Capture app turns some iPhones and iPads into 3D scanners for AR

  • As of late 2018, Apple has brought depth-sensing front cameras to six of its flagship iPad and iPhone devices, but the hardware has largely been limited to two purposes: Face ID unlocking and creating cartoony Animojis.
  • Now there’s a compelling new use for the camera, as developer Standard Cyborg has released Capture, a free app that lets users create detailed 3D scans of people and objects for use in augmented reality or other purposes.
  • Using Capture is straightforward: The screen reflects what the front camera is seeing, offering a preview of the object you want to scan.
  • The sensed object appears in almost comically basic rainbow shades within the preview window, and fine details such as hair may not be captured ideally by the scan.
  • Additionally, you can activate an AR mode where you can preview how the scanned object will look in a real-world environment, including intuitive ARKit-based room measurement and pinch-to-resize motions.

save | comments | report | share on


Some lists are not like the others

  • This operation is independent of the array size, since we don't have to count the size of the collection each time we access that property, so let's assign that a cost of 1.
  • The second one is similar to the first; accessing a string property on a JavaScript object carries a fixed cost similar to length, so let's assign that the same cost, 1.
  • Sometimes, algorithms can be changed to leverage other types of data structures that perform better than arrays on some tasks, making O(n) seem painfully slow in comparison.
  • By carefully reasoning about what the built-in methods do, we've been able to derive Big O performance envelopes that we can use to estimate how fast our programs will run when using arrays as the primary data structure.

save | comments | report | share on


Some lists are not like the others

  • This operation is independent of the array size, since we don't have to count the size of the collection each time we access that property, so let's assign that a cost of 1.
  • The second one is similar to the first; accessing a string property on a JavaScript object carries a fixed cost similar to length, so let's assign that the same cost, 1.
  • Sometimes, algorithms can be changed to leverage other types of data structures that perform better than arrays on some tasks, making O(n) seem painfully slow in comparison.
  • By carefully reasoning about what the built-in methods do, we've been able to derive Big O performance envelopes that we can use to estimate how fast our programs will run when using arrays as the primary data structure.

save | comments | report | share on


Here's How to Watch the Geminids 2018 Meteor Shower

  • If you look towards the sky later tonight, you might catch some shooting stars: the peak of the Geminids meteor shower.
  • While they’re slightly less well-known than the August Perseids partially due to the cold weather, the Geminids are one of the strongest meteor showers to arrive every December, according to Diana Hannikainen, observing editor at Sky & Telescope.
  • In suburban areas, where there’s likely more light pollution, observers should be able to spot roughly 30 to 40 meteors per hour.
  • If you can’t stay up until 2 a.m., Sky & Telescope reports the Earth will pass through the thickest part of 3200 Phaethon’s debris, with the most potential for meteors, around 7:30 a.m. eastern time on Friday.
  • If that’s still too early, you should be able to catch a few meteors any time after dark, particularly after the moon sets.

save | comments | report | share on


Lenses: The What and How

  • If you ever had some maths class in your life, you know, that functions can be composed with each other, i.e. you have then you can define the composition of f with g as and means nothing else than .
  • One thing you may have noticed already, is that function composition works best, when the argument and return value of the composed functions are of the same type.
  • We are now going to create three ComposableGetterSetters -- aka lenses -- to see how they work and what is needed to use them for retrieving values or changing the data (in an immutable way).
  • We will use default values in getters (to avoid exceptions) and object spread to maintain immutability in setters.
  • lensPath creates a lens that focuses on deeply nested object properties and array indexes, by creating and pre-composing lenses lensProp and lensIndex lenses for you.

save | comments | report | share on


Lenses: The What and How

  • If you ever had some maths class in your life, you know, that functions can be composed with each other, i.e. you have then you can define the composition of f with g as and means nothing else than .
  • One thing you may have noticed already, is that function composition works best, when the argument and return value of the composed functions are of the same type.
  • We are now going to create three ComposableGetterSetters -- aka lenses -- to see how they work and what is needed to use them for retrieving values or changing the data (in an immutable way).
  • We will use default values in getters (to avoid exceptions) and object spread to maintain immutability in setters.
  • lensPath creates a lens that focuses on deeply nested object properties and array indexes, by creating and pre-composing lenses lensProp and lensIndex lenses for you.

save | comments | report | share on


Storing C++ Objects in Distributed Memory

  • The implementation details are not particularly important here (we're just reading from and writing to a string), but the import thing is that this provides an interface that we can then use to create a container class for storing strings in distributed memory.
  • Since we're now just storing a regular object of type T in distributed memory, which the user is guaranteeing to us by contract is byte-copyable, we can store the value itself inside the container instead of holding a pointer to the serialized value.
  • So we've created a container abstraction that we can use to store any C++ object in distributed memory, given that it is trivially copyable or we can define a serialization struct for it.

save | comments | report | share on