Live data from Hacker News

The Design of Software is a Thing Apart

pathsensitive.com

121–124 of 124 posts

Re: The Design of Software is a Thing Apart

#121
post #91

Earlier quoted context omitted.

I've had similar thoughts, notably as a way to side-stepping the composability limits of current parsing theory. But these limitation are increasingly worked around... And looking at rust, I can start to imagine a future where macros are powerful enough to support a lot of declarative coding. When coding javascript today I write code like: // can be imported, and api.router() mounted in express let api = new API(...)…

Nice. But also a workaround, right? Because it's not actually declarative, it's APIs that are made to look declarative-ish. So there's several layers of mismatch, for example most of the active ingredients being strings, meaning you're coding mostly in the string-language embedded into JS. We do that a lot. Probably time to start looking at our workarounds (and Macros are another workaround) and figure out what we ar…

> But also a workaround, right? Because it's not actually declarative, it's APIs that are made to look declarative-ish.

I'm not entirely sure what you mean...

In an ideal world "API" would be a keyword, similar to how "class" is a keyword for declaring/defining classes. Example:

    API MyApi {
      constructor(defaultName) {
        this.defaultName = defaultName;
      }
    
      /** some description */
      method: get
      route:  /hello-world
      scopes: some-permission-string || other-permission-string
      {
        let name = request.query.name;
        if (!name) {
          name = this.defaultName;
        }
        response.send('hello ' + name);
      }
    
    }
    module.exports = MyApi;  // similar to how you would export a class in JS

I think something _like_ this will be doable using rust macros in the future (if not already on nightly).

Whilst my JS code, where I create an API object and call API.declare(...) for each route isn't as neat as having an "API" keyword and code-generation for said keyword, it's pretty close.

I just write the API.declare(...) as something that collects arguments, and then those can be instantiated multiple times... Similar to how a class can be instantiated multiple times.

I do similar things for loading components that depend on each other: declare dependencies, define function for loading using said dependencies -- then have some library code construct a function that loads any desired component with maximum concurrency (by analysing the DAG).

Re: The Design of Software is a Thing Apart

#122
post #111
post #91

Earlier quoted context omitted.

I've had similar thoughts, notably as a way to side-stepping the composability limits of current parsing theory. But these limitation are increasingly worked around... And looking at rust, I can start to imagine a future where macros are powerful enough to support a lot of declarative coding. When coding javascript today I write code like: // can be imported, and api.router() mounted in express let api = new API(...)…

We can't and don't have to give up text. Text is essential for humans and could be a significant part of the interface (both reading and typing). The problem is more about the underlying unit being text. The problematic part of text is when we just write it freely and then have to parse it back and make sense of it which has very severe consequences. This is because in the programming environment world we are forever…

> The problem is more about the underlying unit being text.

I think richer editing, in effect editing the AST, rather than the concrete syntax is interesting.

But I'm not convinced that it's a blocker for making more declarative code. I think macros will get us very very far. The procedural stuff in rust, has me really excited about the future.

The downside of not using text as the underlying unit of truth is that you have to reinvent an IDE, version control, conflict resolution, review tools, etc. That takes a LOT of buy-in.

If you can 90% of syntactic sugar required from macros (and the like), you can work on the actual abstractions / declarations instead of the compiler toolchain.

Just my two cents.

Re: The Design of Software is a Thing Apart

#123
post #118

Earlier quoted context omitted.

Completely disagree here. If you test this way you'll be sure to have a correct implementation for this dummy program. Further, if the test fails you now have to try and figure out what component caused the failure. A unit test should test a specific unit; commonly a class. You should have unit tests for the interface of that unit (never private or even protected methods). This absolutely does not prevent internal re…

> If you test this way you'll be sure to have a correct implementation for this dummy program. That's the point. If the dummy program fails then your implementation is bad. > Further, if the test fails you now have to try and figure out what component caused the failure. Have you heard of logging? > A unit test should test a specific unit; commonly a class. You should have unit tests for the interface of that unit (n…

>Have you heard of logging?

So your solution is to dig through log files to find the problem instead of read the unit test name(s) that demonstrate the failure?

>This is almost exactly what I suggested.

Well, it wasn't clear from your wording. It sounded like you were advocating integration testing instead of unit testing (which is a thing that people commonly do, so that's why I reacted to it).

Re: The Design of Software is a Thing Apart

#124
post #119

Earlier quoted context omitted.

A. You took it too literally ( maybe it's not a hw bug on some exotic processor, maybe it's a mitigation for a security vulnerability that affects a broad set of OS distros). B. Your solution is not obviously better, it's a different trade-off. And it's not immediately apparent to me how exactly you would write the test for the affected hardware, in the first place. What if the hardware bug is extremely hard to repro…

Fair points. A. When I encounter areas that need specialized workarounds (such as a mitigation for a security vuln) then I advocate using two methods: one of the normal condition and one for the specialized workaround. Same reasons as above, i.e. separation of concerns, easier/clearer normal path, easier to end of life the workaround. B. In my experience tests are better than documentation for any kind of mitigation…

> Imagine this way: if a team uses just documentation, not tests, then what's your ideal for the team to track when the external bug is fixed, and also phasing out the mitigation code?

- not all external bugs are fixed, some are permanent (e.g. the hardware issues).

- tests can tell you when something is wrong, but not when something is working. I'm not really sure how a test could tell you that "external bug is now fixed" - and even in cases where that _might_ work, I'm not sure it's a good idea to use a test for that.

Post reply on HN