Giter Site home page Giter Site logo

margual56 / grep-clone Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 34 KB

A grep clone written in Rust following the rustlings guide. Nice practice for learning Rust :)

License: GNU Affero General Public License v3.0

Rust 100.00%
grep rust rust-lang rustlings

grep-clone's Introduction

GREP clone

A clone of grep, simpler, slower and without unit testing (for the moment).

Check out the wiki if you want to dive deeper into... stuff :)

Why is this "different"?

As mentioned in multiple places in this repo, this app was created following the guide.

However, this version includes piping support (reading from stdin), meaning that the input file flag is optional. It also implements a Buffered Reader instead of loading the entire file (or stdin) into memory at once.

Note: Using a Buffered Reader has a drawback, which is that you are creating a copy of the input, and processing it later.

Note II: it also uses a Buffered output, which can cause performance issues as discussed in the performance analysis.

Future features

  • Colored output, with an optional flag.
  • Multiple patterns
  • Doing the much needed optimizations
  • Multi-threading
  • Add a debug or verbose flag(?) but I don't know what it should output

Usage

Straight from grepclone -h:

grepclone 0.2.0
Just a simple grep clone programmed in Rust.
grepclone takes either an input file (`-i` option) or reads the stdin if no file is passed as an argument.

USAGE:
    grepclone [FLAGS] [OPTIONS] [patterns]...

FLAGS:
    -c, --color      Wether to print with colored output or not
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -i, --input <input>    Input file (Optional)

ARGS:
    <patterns>...    Pattern(s) to search for. Required parameter

Cross-compiling

I used the amazing and wonderful "cross" cargo program to cross-compile the program to windows. Can't compile for Mac because I don't own one :) blame Apple.

Why is it slower?

Check the detailed explanation and analysis in the wiki.

TL;DR: They do byte manipulations and program at a lower level, as well as being smarter xD.

Multithreading?

It would be really cool, and a good learning experience, BUT!

Multithreading comes with certain overhead, meaning that it is only worth using for really large tasks. So the program would need to check the size of the input(?) and then use multithreading (single-threading otherwise).

grep-clone's People

Contributors

margual56 avatar

Watchers

 avatar  avatar

grep-clone's Issues

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.