Giter VIP home page Giter VIP logo

jina-shortest-program's Introduction

The shortest (usable) Jina program

  • Uses Jina 2.0
  • Uses minimal lines of code to actually achieve something USEFUL (i.e. index data then let user query it)

WARNING

stupid.py is potentially unsafe. This is because in order to cram everything into one line we have to use some dodgy hackery, namely the rather dangerous exec() function. This could mean a user gives it malicious input like:

import os; os.system('rm -rf ~')

sensible.py is a much more sensibly-written (albeit longer) version that is both safe and easy to understand

What is code?

  • I'm classing "code" as anything the developer writes or imports from other files in the directory. So if app.py is 5 lines and I'm importing everything from executors.py (100 lines), that means 105 lines of code
  • That goes for YAML too. Sure it's not strictly "code", but it's doing the job of code
  • Screw it, I'm including comments. Good code is self-documenting code ;)

What isn't code?

  • Documentation
  • Input data
  • Dependencies (because if you boil it right down you're ALWAYS using dependencies unless you're coding in assembly ffs)

Sacrifices

Condensing code to the smallest working example means sacrifices:

  • No defining variables - everything is hard-coded
  • No comments
  • No unnecessary line breaks

Going further

  • Can replace many (but not all) line breaks with semi-colons

Yes, but...

  • "You're relying on other people's code!" - Duh. Jina Hub Executors are other people's code. Jina is other people's code. So is Python. Short of starting from scratch with my own damn logic gates I have to use other people's code, as does everyone.

jina-shortest-program's People

Contributors

alexcg1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.