Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

rip grep works outside of a git repo


PWA are indeed limited, but they are particularly so because Safari drags them down.


No, it is because the idea that everything must be build using web tech is dragging them down.


Houses are something that have been built for 1000 of years, we mater the thing. And we have the tool to build them automatically: software, giant printers, etc.

Yet we still don't.

I do think it's possible that softwares will be built more and more by automatic tools (shopify, wix and wordpress are good examples), but 80% is a tad optimistic.


Then use streams.


Oh but redis is much more than that.

It's so simple any little script can interact with it in seconds, instead of having to craft complex SQL or import your wrapper. You can call redis from the weirdest places, like from the inside of an nginx config file. You needn't even a compiled driver if that matters.

It's easier to get it to perform. It's possible to get great perfs with PostgreSQL, but you just got them for free with redis. Very hard to screw up. Read, write ? N+1 ? Batching ? Who cares, it will be fast no matter the concurrency or the load.

Sure you can expire with Postgres, but having done so in practice, it's way harder than it looks to get right. With redis, you don't have to care. Set a cache, set a lock with a timeout, store data your are not sure you need. It will all disapear.

Redis is not just key/value. You have sets, so ensuring unicity is a piece of cake, no constraints to define, then insertion to check against. And of course, you have sorted sets, which you are kept ordered at insertion by any number you pair the value with, such as a timestamp/score/index, and truncate by range for extra magic.

And then you have bonuses like hyperloglog which you need an extension for in Posgres. Super handy for stats.

Finally, you have streams, which for most apps will fill the gap for a timeserie database or a way to store your app logs. All that with a 2ms latency at 10k/s requests. None of my projects ever needed more than 1K/s though, even one with 1M users/month.

You have all of that with a dead simple install and basically no maintenance.

In fact, redis by itself consume almost no resource, it's not even worth it to not have it in your toolset. I just install it by default on all my projects: I never regretted it, there is always something it can do for you. It not now, just wait a bit, it's costing you nothing, and something will come up.

So no, let use Postgres for what it's great at, which is being a robust all purpose database. Redis is a fantastic complement to it, not a competitor, just use both.

Unless you are google size, there are little chances you will reach a stage where you need to migrate from any of them.

It's part of those tech that are just too good to be true, like SQLite or Python.

My only regret is that it doesn't exist on windows.

P.S: if you need caching and can't afford redis on a small python script, use Disk Cache, it's awesome: http://www.grantjenks.com/docs/diskcache/index.html


Not to mention I've never personally experienced redis go down by itself - it's always some stupid user error that could have happened to any part of the infrastructure.

Redis is, far and away, _the_ most robust piece of software I've ever had the pleasure of deploying to production.


That + the best documentation in the industry. It is a joy to work with.


I suppose if arrays language get popular enough, we will get a module to use them as a DSL for libs like numpy, just like we have regex for strings, instead of a whole language dedicated for them.

It would be a win / win, you gain the strength of J, K and APL for array processing, without the weakness of them for anything else.

And just like with regex, you'll get fat disclaimers in doc telling you to not get carried away too much as it can quickly become unreadable.


APL is not unreadable any more than mathematical or musical notation are. Sure, to someone who doesn’t know the notation it looks like an incomprehensible mess. So does math, music, greek, chinese, arabic, hebrew, etc.

I used APL professionally every day for ten years. I can read it. I can touch-type it. And I don’t need a specially-labelled keyboard (even thirty years later).

This should not be surprising at all. A pianist does not need labeled keys and people familiar enough with the above-listed spoken languages can touch-type them without much effort.

While, sadly, APL has no practical application in modern software engineering (it stagnated and became irrelevant and impractical) it is wrong to look at the brilliant use of notation as a tool for the concise communication and expression of ideas and list it as a negative. Not being able to speak, read or write Chinese does not make it a bad language.


> Not being able to speak, read or write Chinese does not make it a bad language.

Well that's the problem. Not being able to read or write APL makes it more fun to learn.



Thanks for posting this intriguing link. A glance at the Jupyter notebook on this site will bring a smile to a Julia user who grew up on (or has somehow encountered) APL.


What an incredibly concise, elegant implementation.


The regex DSL only works for strings. I lament that I cannot use something regex-like to match general sequences, e.g. a sequence of tokens, instead of only strings (sequence of characters).

The operations could be the same. There are classes, and operators for matching 0, 1, or more repetitions, etc.

Array languages are powerful especially when you have arrays with arbitrary elements, including arrays themselves. Good luck using a regex DSL to match a sequence of strings, where you might want to define a string class (analogous to a character class) as a regex itself.


> I lament that I cannot use something regex-like to match general sequences, e.g. a sequence of tokens

You can. It's not typically built into a programming language's standard library. But there are plenty of general-purpose automata-building libraries out there, and some of them do provide DSLs. At least to the extent that the regular expressions you're using are actually regular (many aren't), all a regex is is a domain-specific specialization of nondeterministic finite automata.

I sometimes lament that I don't see them, or hand-coded automata, more often. This was CS101-level stuff when I was in college, and it's pretty easy to code your own even if you don't have a good library available in your language. And, for problems where they're appropriate, using them typically yields a result that's simpler and easier to maintain than whatever ad-hoc alternative you might see instead.


> using a regex DSL to match a sequence of strings, where you might want to define a string class (analogous to a character class) as a regex itself.

http://p3rl.org/retut#Defining-named-patterns

https://docs.raku.org/language/grammar_tutorial#The_technica...

If you want a demo, reply with a concrete example I can implement.


The now defunct Viewpoints Research org chased an idea similar to this. It was a meta language that was based around PEGs, intended to allow the easy creation of DSLs. I imagine the papers are still up somewhere. It was called OMeta.


There are a few libraries expanding on the concept, here's one: https://clojure.org/guides/spec#_sequences


I'm not sure of the need to do that. Not for parsing anyway.

A well designed regex system is enough without tokenization.

The parser for the Raku language, for example, is a collection of regexes composed into grammars. (A grammar is a type of class where the methods are regexes.)

We could probably do the token thing with multi functions, if we had to.

    multi parse ( 'if',  $ where /\s+/, …, '{', *@_ ) {…}
    multi parse ( 'for', $ where /\s+/, …, '{', *@_ ) {…}
    …
Or something like that anyway.

(Note that `if` and `for` etc are keywords only when they are followed immediately by whitespace.)

I'm not sure how well that would work in practice; as hypothetically Raku doesn't start with any keywords or operators. They are supposed to seem like they are added the same way keywords and operators are added by module authors. (In order to bootstrap it we of course need to actually have keywords and operators there to build upon.)

Since modules can add new things, we would need to update the list of known tokens as we are parsing. Which means that even if Raku did the tokenization thing, it would have to happen at the same time as the other steps.

Tokenization seems like an antiquated way to create compilers. It was needed as there wasn't enough memory to have all of the stages loaded at the same time.

---

Here is an example parser for JSON files using regexes in a grammar to show the simplicity and power of parsing things this way.

    grammar JSON::Parser::Example {

        token TOP       { \s* <value> \s* }

        rule object     { '{' ~ '}' <pairlist>  }
        rule pairlist   { <pair> * % ','        }
        rule pair       { <string> ':' <value>  }

        rule array      { '[' ~ ']' <arraylist> }
        rule arraylist  {  <value> * % ','      }

        proto token value {*}

        token value:sym<number> {
            '-'?                          # optional negation
            [ 0 | <[1..9]> <[0..9]>* ]    # no leading 0 allowed
            [ '.' <[0..9]>+ ]?            # optional decimal point
            [ <[eE]> <[+-]>? <[0..9]>+ ]? # optional exponent
        }

        token value:sym<true>    { <sym>    }
        token value:sym<false>   { <sym>    }
        token value:sym<null>    { <sym>    }

        token value:sym<object>  { <object> }
        token value:sym<array>   { <array>  }
        token value:sym<string>  { <string> }

        token string {
            「"」 ~ 「"」 [ <str> | 「\」 <str=.str_escape> ]*
        }

        token str { <-["\\\t\x[0A]]>+ }
        token str_escape { <["\\/bfnrt]> }
    }
A `token` is a `regex` with `:ratchet` mode enabled (no backtracking). A `rule` is a `token` with `:sigspace` also enabled (whitespace becomes the same as a call to `<.ws>`).

The only one of those that really looks anything like traditional regexes is the `value:sym<number>` token. (Raku replaced non capturing grouping `(?:…)` with `[…]`, and character classes `[eE]` with `<[eE]>`)

This code was copied from https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Gra... but some parts were simplified to be slightly easier to understand. Mainly I removed the Unicode handling capabilities.

It will generate a tree based structure when you use it.

    my $json = Q:to/END/;
    {
      "foo": ["bar", "baz"],
      "ultimate-answer": 42
    }
    END
    my $result = JSON::Parser::Example.parse($json);
    say $result;
The above will display the resultant tree structure like this:

    「{
      "foo": ["bar", "baz"],
      "ultimate-answer": 42
    }
    」
     value => 「{
      "foo": ["bar", "baz"],
      "ultimate-answer": 42
    }
    」
      object => 「{
      "foo": ["bar", "baz"],
      "ultimate-answer": 42
    }
    」
       pairlist => 「"foo": ["bar", "baz"],
      "ultimate-answer": 42
    」
        pair => 「"foo": ["bar", "baz"]」
         string => 「"foo"」
          str => 「foo」
         value => 「["bar", "baz"]」
          array => 「["bar", "baz"]」
           arraylist => 「"bar", "baz"」
            value => 「"bar"」
             string => 「"bar"」
              str => 「bar」
            value => 「"baz"」
             string => 「"baz"」
              str => 「baz」
        pair => 「"ultimate-answer": 42
    」
         string => 「"ultimate-answer"」
          str => 「ultimate-answer」
         value => 「42」
You can access parts of the data using array and hash accesses.

    my @pairs = $result<value><object><pairlist><pair>;

    my @keys = @pairs.map( *.<string>.substr(1,*-1) );
    my @values = @pairs.map( *.<value> );

    say @pairs.first( *.<string><str> eq 'ultimate-answer' )<value>;
    # 「42」
You can also pass in an actions class to do your processing at the same time. It is also a lot less fragile.

See https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Act... for an example of an actions class.

---

Note that things which you would historically talk about as a token such as `true`, `false`, and `null` are written using `token`. This is a useful association as it will naturally cause you to write shorter, more composable regexes.

Since they are composable, we could do things like extend the grammar to add the ability to have non string keys. Or perhaps add `Inf`, `-Inf`, and `NaN` as values.

    grammar Extended::JSON::Example is JSON::Parser::Example {
        rule pair { <key=.value> ':' <value>  } # replaces existing rule

        # adds to the existing set of value tokens.
        token value:sym<Inf>    { <sym> }
        token value:sym<-Inf>   { <sym> }
        token value:sym<NaN>    { <sym> }
    }
This is basically how Raku handles adding new keywords and operators under the hood.


I've written an open source version of q: http://www.timestored.com/jq/ It's implemented in java. You idea is interesting. Allowing q and java intermixed... combining it inside java like linq and C# would be interesting.


Not OP, but every time I do a purchase online with a new shop, my bank does this. Also every time I spend more than x euros in one transaction.

Before that they sent an SMS code, I much prefer the app notification.


Offline first is a majors selection criteria for me.

First, it's just faster. Offline apps are an order of magnitude faster and the speed is stable.

Secondly, data is way easier to backup. I don't trust any provider with important data. Your account can be banned, or you could be locked out. There are outage, data corruption, human errors from people you share data with...

Then there is the no internet part. Internet at home can go off for many reasons, you may be abroad, in a plane, in a tunnel, in the country side. Or internet could be slow, unreliable, behind an agressive proxy, etc.

That's why i use thunderbird and not a web mail, dynalist and not the competition, mp3 and not spotify... That's why i keep osmand next to waze and torrents next to netflix.

Last week internet went down in accounting. They took the day off, because they used office 365. Great for them, not so much for the work to be done.


Alternatively, just don't write an SPA. Write a regular site, with just the few interactive elements you need.

If you use react or vue, you can plug components precisely anywhere on the page, you don't need to take over the page entirely.

In fact, with vue, you can even put the template in the HTML directly, and just hook the logic on to it, angularjs v1 style.


> In fact, with vue, you can even put the template in the HTML directly, and just hook the logic on to it, angularjs v1 style.

That's what I do, I love the simplicity of it and how it lets you render html pages server side, with the added JS for interactivity.

Maybe not the cleanest architecture but extremely straightforward.


+1. I would even pay to watch you code this.


Didn’t know there was a market for coding session watchers. Let me know if someone’s interested in watch me slow-code my current long running side project: Focusly.


> Didn’t know there was a market for coding session watchers.

I think this is an actual niche on Twitch.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: