Technology

CppCon 2019: C++-20 at 40

Bjarne Stroustrup

  • Introduced b a high school student

  • Stability and evolution
  • “A tour of C++”, 2nd edition
  • Distinguish betwee what’s lega and what’s effective
    • Better tool support, eg C_+ core Guidlines
  • C++: principled and eclectic
  • C++ a general purose programming language for the defn, impl and use of lightweight abstractions
  • “We don’t really like C++ but is it the only thing that works”
  • C++ high level aims
    • Evolutionary (stable, gradual adoption)
    • Make simple things simple
    • Zero-overhead principle
    • Aim high: change the way we design and implement software and we think
  • Key C++ “Rules of thumb”
    • Static type sisteym build-in and user-defined
    • Value and referenc semantics
    • Direct use of machine and operating system resources
      • Layers of abstraction
        • The Onion principle:The more layers you peel off, the more you cry
    • Systematic and generl resource management (RAII)
      • Construct/destructor paris
      • Every resource must have an owner; don’t use built-in pointers (T*) to manage
    • Support composition of software from separatelhy developed parts
      • Modules
    • Support for generic programming
      • write code that works for types tat meet abstract requirements
      • requiremensts are defined as concepts
    • Support fo compile-time programming
      • const_expr
      • Move computaton from run-time to compile-time
    • Support for object-oriented programming
      • Still useful and popular
      • Need reference semantics
      • Don’t need run-time; use static resolution (variant)
      • See
        overloaded

        which do not ake it into c++20

    • Concurrency through libraries supported by intrinsics
      • mutex, RAII
      • atomics
    • C++ is tunable and evolves
      • Always measure
    • Things work in combination
    • Library design is language desing; language design is library design
    • cppreference.com/w/cpp/libs
    • Chrono
    • You have to raise the level abstraction for tools to enforce type and resource-safe C++
    • These rules are about 40 years old
    • C++2o the best approximation of C++’s ideals (so far)
  • The future
    • C++23:
      • Completes C++20
      • Plus: standard modules, library support for coroutines, executors and netowrking
      • Maybe: static reflection, pattern match
  • Questions
    • Something about co_await and threads
    • How to deal with legacy code
      • In new code use modern features
      • Either try and encapsulate
      • Need more tooling
    • What feature most affected c++11:
      • const_expr
      • basic support for concurrent programming
    • What feature most affected c++20:
      • concepts will make generic much simpler, elegant, adn useful
      • modules should improve our compile speeds (5-10 times?). Major advantage is from cleaning up your code.
    • Not pay for things you use. However someone has to pay $ for implementing these features
      • It’s better to put the burden on implementers then users. 50,000 users for 5-10 implementors
    • Are there plans to add features to enforce ownership checks at compile time?
      • Use static enforced coding guideless to enforce “good” coding standards instead of “legal” codes.
    • Cyril from Bloomberg. Would you discourage use of runtime polymorphism?
      • Does someting really need hierarchis and runtime/dynamic types
Technology

How Journalists Covered the Rise of Mussolini and Hitler

Bundesarchiv bild 146 1969 065 24 munchener abkommen ankunft mussolini wr jpg 800x600 q85 crop

When Hitler’s party won influence in Parliament, and even after he was made chancellor of Germany in 1933 – about a year and a half before seizing dictatorial power – many American press outlets judged that he would either be outplayed by more traditional politicians or that he would have to become more moderate. Sure, he had a following, but his followers were “impressionable voters” duped by “radical doctrines and quack remedies,” claimed The Washington Post. Now that Hitler actually had to operate within a government the “sober” politicians would “submerge” this movement, according to The New York Times and Christian Science Monitor. A “keen sense of dramatic instinct” was not enough. When it came to time to govern, his lack of “gravity” and “profundity of thought” would be exposed.

Source: How Journalists Covered the Rise of Mussolini and Hitler

Technology

Quote shell characters

Sometimes it’s nice to be able to display a command being run and do it in a form that can be repeated from a terminal window. Unfortunately, I’ll build a command in python like this:

args = ['somecmd', 'WHERE=$(DESTDIR)', '--message', "Lot's of text" ]

The trivial answer of ‘ ‘.join (args) produces something that can’t be passed to the shell:

>>> ' '.join (args)
"somecmd WHERE=$(DESTDIR) --message Lot's of text"

Here is a code fragment and some attached tests that provide better quoting. It’s used like this:

>>> import shquote
>>> args = ['somecmd', 'WHERE=$(DESTDIR)', '--message', "Lot's of text" ]
>>> print ' '.join ([shquote.shquote (a) for a in args])
somecmd 'WHERE=$(DESTDIR)' --message "Lot's of text"
#!/usr/bin/env python
def shquote (arg):
    """
    Quote a single argument in the most readable way so it is safe from
    shell expansion.
    """
    # Return an empty string as double quoted
    if not arg:
        return '""'
    special = """ t[]{}()'*?|;"""   # These need double quotes
    superspecial = """$"!"""        # These need single quotes
    quotechar = None
    # See if we need single quotes
    for c in superspecial:
        if c in arg:
            quotechar = "'"
            break
    # See if we need double quotes
    if not quotechar:
        for c in special:
            if c in arg:
                quotechar = '"'
                break
    # No quoting necessary
    if not quotechar:
        return arg
    # If quotechar is present then escape it by dropping out of quotes
    if quotechar in arg:
        arg = arg.replace (quotechar, "%s\%s%s" % (quotechar, quotechar, quotechar))
    return quotechar + arg + quotechar
if __name__ == '__main__':
    tests = [('',       '""'),
             ('*.cpp',  '"*.cpp"'),
             ('test.[ch]', '"test.[ch]"'),
             ('(',      '"("'),
             (')',      '")"'),
             ('a',      'a'),
             ('$',      """'$'"""),
             ('$a',     """'$a'"""),
             ('abc|def', '"abc|def"'),
             ('abc;def', '"abc;def"'),
             ('a b',    '"a b"'),
             ('"abc"',  """'"abc"'"""),
             ("""It's mine""", '"It's mine"'),
             ('abc | def ABC=$(XYC)', """'abc | def ABC=$(XYC)'"""),
             (""""That's impossible!" he said.""", """'"That'\''s impossible!" he said.'"""),
          ]
    for (input, expected) in tests:
        output = shquote (input)
        if output != expected:
            print 'input    = ', input
            print 'expected = ', expected
            print 'got      = ', output
        else:
            print "%-30s => %s" % (input, output)

And the result of running this:

bash-3.2$ ./shquote.py
                               => ""
*.cpp                          => "*.cpp"
test.[ch]                      => "test.[ch]"
(                              => "("
)                              => ")"
a                              => a
$                              => '$'
$a                             => '$a'
abc|def                        => "abc|def"
abc;def                        => "abc;def"
a b                            => "a b"
"abc"                          => '"abc"'
It's mine                      => "It's mine"
abc | def ABC=$(XYC)           => 'abc | def ABC=$(XYC)'
"That's impossible!" he said.  => '"That'''s impossible!" he said.'
Technology

Game of Thrones meets Rdio

Some humorous social media advertising on Rdio

Pete s Network Rdio

Arya Stark

Arya Stark reviewed a playlist.
X
Playlist by Joffrey Baratheon
Great to hear you are dead – one less on my list.


Jon Snow

Jon Snow reviewed an album.
Shades Of Cool
Lana Del Rey
You know nothing about the lower temperatures my dear… But if you need a fur – I have a couple lying around.
Happy to help.


Tyrion Lannister

Tyrion Lannister reviewed a playlist.
Champion
Playlist by Tyrion Lannister
If they let me drink in this damn cage I would be tossing wine all over for these jams.