Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AST in Wonderland

AST in Wonderland

Presented at Full Stack Antwerp and PHP development Eindhoven.
---
We read and write code every day to build maintainable software. To help us in our effort, we use and rely on numerous tools. As we write software for increasingly complex problems, our tooling should also evolve to support this. Like ancient craftsmen, we should not only improve our skills but also the tools we use.

In his presentation 'AST in Wonderland', Jeroen will take you on an adventure, that started for him, with Abstract Syntax Trees. In his journey, he found new tools and techniques to help us in our code writing endeavor. He encountered mutants, lakes and even artificial life.

Join him and see how deep the rabbit hole goes...

Speaker: Jeroen Herczeg is a freelance developer with 13 years of experience. He is a fan of cyberpunk and loves to travel with his girlfriend and cats.

Jeroen Herczeg

September 25, 2019
Tweet

More Decks by Jeroen Herczeg

Other Decks in Technology

Transcript

  1. <?php namespace Meetup\PHPLimburg; class Presentation { public function hello() {

    return 'Hello!'; } } T_OPEN_TAG T_WHITESPACE T_NAMESPACE T_WHITESPACE T_CLASS T_PUBLIC T_RETURN T_STRING T_STRING T_STRING T_FUNCTION T_STRING T_CONSTANT_ENCAPSED_STRING
  2. <?php namespace Meetup\function; class Namespace { public function **() {

    return 'return'; } } T_OPEN_TAG T_WHITESPACE T_NAMESPACE T_WHITESPACE T_CLASS T_PUBLIC T_RETURN T_STRING T_FUNCTION T_NAMESPACE T_FUNCTION T_POW T_CONSTANT_ENCAPSED_STRING
  3. <?php namespace Meetup\PHPLimburg; class Presentation { public function hello() {

    return 'Hello!'; } } T_OPEN_TAG T_WHITESPACE T_NAMESPACE T_WHITESPACE T_CLASS T_PUBLIC T_RETURN T_STRING T_STRING T_STRING T_FUNCTION T_STRING T_CONSTANT_ENCAPSED_STRING
  4. <?php namespace Meetup\PHPLimburg; class Presentation { public function hello() {

    return 'Hello!'; } } T_OPEN_TAG T_WHITESPACE T_NAMESPACE T_WHITESPACE T_CLASS T_PUBLIC T_RETURN T_STRING T_STRING T_STRING T_FUNCTION T_STRING T_CONSTANT_ENCAPSED_STRING
  5. <?php namespace Meetup\PHPLimburg; class Presentation { public function hello() {

    return 'Hello!'; } } T_OPEN_TAG T_WHITESPACE T_NAMESPACE T_WHITESPACE T_CLASS T_PUBLIC T_RETURN T_STRING T_STRING T_STRING T_FUNCTION T_STRING T_CONSTANT_ENCAPSED_STRING
  6. • Finding probable bugs • Locating “dead” code • Detecting

    performance issues • Improving code structure and maintainability
  7. Exakat - 9.572. Useless Return A return value inside a

    constructor is inaccessible. Codebase Codebase Codebase AST Functions/UselessReturn src/Presentation.php:7 Functions/UselessReturn src/Presentation.php:7
  8. Rector is a reconstructor tool. It does instant upgrades and

    instant refactoring of your code. Rector
  9. Hello AST Chapter One • AST is a tree representation

    of source code • Why it was introduced in PHP7 in the internals • How we can use AST in userland (PHP-Parser) • Example of cool dev tools using AST
  10. Chef #1 Chef #2 Salade 1 minute 5 minutes Rice

    bowl 5 minutes 10 minutes Sushi 5 minutes 20 minutes
  11. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes How long does an order take?
  12. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes
  13. INPUTS OUTPUTS HIDDEN LAYER 0.4 0.32 0.2 0.5 3 1

    0.66 0.3 0.3 0.6 1 1 0 (1 x 0.4) + (0 x 0.5) + 3 = 3.4 2
  14. INPUTS OUTPUTS HIDDEN LAYER 0.4 0.32 0.2 0.5 3 1

    0.66 0.3 0.3 0.6 1 1 0 3.4 0.9 Activation function 0.9 2
  15. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 1 1 0 0 0
  16. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 1 1 0 0 0
  17. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 1 1 0 0 0 0.05 0.60 0.10 0.05 0.20
  18. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 1 1 0 0 0 0.05 0.60 0.10 0.05 0.20
  19. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 0 0 1 1 0
  20. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 0 0 1 1 0
  21. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 0 0 1 1 0 0.34 0.20 0.16 0.03 0.27
  22. Chef #1 Chef #2 Salade Rice bowl Sushi 1 minute

    5 minutes 10 minutes 15 minutes 20 minutes 0.34 0.20 0.16 0.03 0.27 0 0 1 1 0
  23. Vision Natural language processing (NLP) • Translation • Summarisation •

    Sentiment analysis • Dialogue • Classification • Object detection • Facial recognition • Generation Speech Robotics Planning
  24. Deep Learning Chapter Two • Where we are with A.I.

    • Deep learning isn’t magic, it’s statistics! • What problems we can solve with ML. • Very exciting times!
  25. In this project, you'll generate your own Simpsons TV scripts

    using RNNs. You'll be using part of the Simpsons dataset of scripts from 27 seasons. The neural network you'll build will generate a new TV script.
  26. 1. Request list of package names 2. Loop through list

    and request package information 3. Clone package using repository url
  27. ML on Code Chapter Three • We can use NLP

    also for programming languages • Programming languages have great features • They can help to improve the developer tools