Better HN
topnewbestaskshowjobs
Log inSign up

grumblingdev

225 karma · joined Aug 2, 2022 (4y ago) · 102 submissions

Submissions

comment 3y ago · link · parent

`Bun.build` is a game-changer. They key is it is a fast and simple bundling _primitive_. You can use it to write your own `webpack-dev-server`, you can spin up 10 of them in parallel or series, with one api call. And it's only going to get better. It 100% made sense that Bun own this. Bun's plugins work for bundling and server runtime. Another example: for SSR, you can parse the AST of a file once, and re-use that for SSR runtime and bundling during dev. They key is that bundling is no longer this _heavy_ task that you spawn in another process, it can be as simple as function call.

Once you get it, you will realize how much of a game-changer it is. This is the reason Bun is going to win.

comment 3y ago · link · parent

100%.

People get so intimidated by these huge frameworks and get FOMO, that they never try to build something from scratch.

React seems simple, but if you tried to understand what is going on under the hood it would take you months.

Simple should be: can you trace through all the code yourself. Like Backbone.js for example.

Plus, there is already so much rendering complexity under the hood in browser engines. The DOM and CSS are already incredible abstractions available for you to use.

I really don't get what is so bad about just having some object to manage a dom element's rendering.

Create a single relational source of truth for your data. Then create some view models that listen to this source of truth. Then make your objects listen to these view models.

This vdom diffing stuff is so overated.

If you have a list of items, and a new item is inserted, I can just insert that directly into the dom. If I render a different entity and it uses mostly the same dom elements, it's really not that hard to tell say: here are some new props, compare them with your old ones, and do what you think is best. React promises this for the entire app but its all magic. I want control of my rendering so I can make things fast. Debugging perf issues in React is insane. Good luck debugging anything.

comment 3y ago · link · parent

The cpp ecosystem is insane. I don't know how it got so out of hand. At the end of the day you are just a running a bunch of clang/gcc cli commands. It's really, really, really simple. But all these commands are generated, and the user becomes so detached from what they are actually doing, and then they are left with an error about one of these commands not working, and then they need to dive into this huge monstrosity to figure out what is making a command do something.

Declarative build systems obfuscate so much without providing the proper debugging and error-handling capabilities.

Build systems should be imperative and type-checked. A simple script that a user can step through and observe what is happening.

Makefiles suck because they are not type-checked.

The only abstraction you need is some kind of dependency graph. But then it should be completely transparent to the user so they can easily understand it.

comment 3y ago · link · parent

SQL not so good for tree structures. Recursive CTEs are pretty gnarly.

Graphdb would be ideal.

comment 3y ago · link · parent

I'm thinking just like Zuck decided to personally hunt and kill every animal he ate, I shall build from source and install every package I use.

66.

Tell HN: The terminal shell is a nightmare

1 points · by grumblingdev · 3y ago · 4 comments

comment 3y ago · link · parent

STM provide the most garbage source code ever. I've never seen more of an abomination in my life than the STM32Cube.

comment 3y ago · link · parent

Just started getting into Lisp.

I realized that when I call a bunch of functions one after the other, I want to be able to reference them. I would have to put them in an array.

Then I thought why do I have to make this choice case by case. If only everything was a list…

I now want to see how I can shoehorn this into TypeScript. Maybe with macros or transpilation or something.

Then I want to see what cool things I can now do.

The only thing that gives me pause is that the language is insane to read and when you look at the implementation of Lisp defun and defmacro the code gets pretty wacky.

Figuring out what is a primative and what is just lists is very difficult.

I wonder if there is a less purist Lisp out there that looks nicer.

comment 3y ago · link · parent

The Atom editor was JavaScript + Electron same as VSCode. You could configure everything a lot more than VSCode IIRC. I was very excited initially.

But I think perf issues did it in from this design choice.

I'm keen to explore Emacs more.

Plugin systems are one of the hardest things in software (but also look the easiest from the outside).

comment 3y ago · link · parent

I guess they could have implemented some of the flags as aliases or rather bash functions to a preset chain of invocations. The merging of flags would be difficult though.

There are many flags that change the behavior of the file system calls that would be made...such as getting additional information.

To support all the formatting commands, the piped output of `ls` would need to be very verbose and structured too...like json or something.

They had to draw boundaries of functionality at some point.

So the unix idea of "one thing" was probably defined a bit more vaguely or more end-user use case related. Convenience seemed to be king.

It would have be nicer if they could have added a shell-like pipe syntax to C (and designed the code in a more modular and stream-like way).

In the `ls` [source code][1] you can see simple blocks of steps like:

    if (!file_ignored(file)) {
      ...
      sort_files ();
      print_current_files ();
      clear_files ();   
    }
For example the `file_ignored` function in `ls` would have made a nice reusable library (with standardized configuration params) and a cli tool (with standardized flags).

Missed opportunity to unify the shell and C, but I guess SmallTalk was kicking around at that time which went a whole lot further.

It's funny that we are still very much lacking this unification...

We don't have a high-level interpreted language that can also perform well as a system's language.

New systems languages are popping up all the time, but they are more and more hardcore (looking at you Rust). They don't embrace any aspect of scriptability.

The best effort I can think of is https://www.modular.com/.

Surely though, a native TypeScript-based language is the way. It by far has the nicest syntax out of the popular scripting languages today.

We have come so close...like with Dart...but still everyone seems to be avoiding the inevitability.

[1]: https://github.com/wertarbyte/coreutils/blob/master/src/ls.c

comment 3y ago · link · parent

I mean people still use `ls` everyday so it in fact did win. We have super rich GUIs, REPLs, the start menu, live programming environments and notebooks, web browser file listing capability, the ability to build your own web app to list files visually anyway you want.

And yet everyone still uses `ls`.

comment 3y ago · link · parent

> My copy of `ls` has at least 40 flags

Good point.

You have to hand it to them though, that shell commands are still the least-typing way to do something compared to every programming language out there.

Like if you gave the user an always-on JavaScript or Python repl, shell commands are still going to win every time.

There are so many JS functions I have that I wish would just get automatic cli interfaces...instead of having to go through the ceremony, or use a repl, or something like that.

comment 3y ago · link · parent

Usually tooling related. I don't know what language you can pick today that is not a complete shit-show for dependency management.

comment 3y ago · link · parent

I would prefer "end-to-end debuggable...". The biggest casualty of the web-scale era.

comment 3y ago · link · parent

> "How to organize software"

I have recently had the thought that this is mostly what software architecture is...at some level.

It's about where we draw the boundaries around code to make it easy for humans to understand.

Imagine taking an existing repo, and extracting every block of code into a function, and then moving them into their own separate file in one big folder. You could extend it to all the libraries of your code, and of those services we communicate with over the network too.

This would look a bit like a debugger symbol table. It's closer to how the computer understands the program.

The app still runs. It's just hard for people to understand what is going on.

Software architecture is simply the grouping of these functions to some extent.

It's not a foolproof analogy, because there are some decisions to be made about implementation details of things, but at some level of abstraction you would find the same operations need to be run.

Just an interesting thought.

> The question of how to architect such software is still an open one.

I find a problem we face with architecture discussions is that its always about tradeoffs that are not immediately apparent.

And it takes a lot of mental effort to remember why something is a bad idea.

The way we discuss it is limited by plain text. It's hard to demonstrate a system evolving over time in a concise manner.

Architecture should be evaluated by throwing a spec at it, and then changing every part of the spec (including adding perf requirements) and seeing how long it takes to make the changes, and how many bugs it has.

comment 3y ago · link · parent

Great repo. I've always wanted to build a transpiler from TS to every other language. We have so many languages but all syntax is so similar in the end.

I often wonder how much of the code we write is actually doing something not possible in another language. Like runtime-specific, or low-level stuff. Most of the business logic...loops and if statements are rather similar.

comment 3y ago · link · parent

JS also kills Python for inline functions thanks to hoisting.

It's much easier to follow the control flow with hoisting. I see `run()` being called, and then I want to know what it is. In other languages you are usually seeing a huge bunch of inline functions and then asking: okay, but when and how is this actually called?

    def foo():
      def run():
        print("hi")
      run()

    function foo() {
      run()
      function run() {
        console.log('hi')
      }
    }

comment 3y ago · link · parent

I listen to so much of this stuff. It's super annoying. I just want 10hr mixes.

I want an app that just does this and nothing else that is not terrible.

comment 3y ago · link · parent

Interesting, didn't know about single-method-interfaces.

There are lots of singletons in OO. I find it useful to add static metadata (not state) to them, without having to escalate them to a class. I guess Java has decorators for the same purpose. I'd really like decorators for functions in TypeScript though.

comment 3y ago · link · parent

TypeScript is an incredible language in general.

The fact that Functions are Objects that can have properties/methods is supremely undervalued.

Are there other languages that do this so nicely? It's the perfect blend of OO and functional.

Programming is mostly about gradually figuring out the right design I find. JS/TS let's me evolve things naturally without big rewrites.

    function foo() {}
    function bar() {}
    function baz() {}
    const commands = [foo, bar, baz]
    // Run commands
    commands.forEach(x => x())

    foo.help = 'This does something'
    // Describe commands
    commands.forEach(x => console.log(x.help))

    // Add some state via closure.
    const config = {}
    function foo() { config.blah }

    // Add some state using partials.
    function _foo(config) { config.blah }
    const foo = foo.bind(null, config)
I can flexibly do what I need, without ever having to define a class like `Command`, which I probably don't even know what it should be yet.

This premature naming of things in OO creates so many dramas.

It avoids things like `VideoCompressor#compress()`, `VideoSplitter#split()`. You don't have to think: what state belongs in which class...you just call the function and pass it what it needs.

comment 3y ago · link · parent

It's funny that its satirical, but I could make an argument why every point is actually a good thing.

comment 3y ago · link · parent

Oh yes, I'm super interested in this space too.

Really waiting for one of these ideas to breakthrough to mainstream.

comment 3y ago · link · parent

It's interesting. I've gone the other direction. Everything as functions.

I've realized that things always need to change in unexpected ways. Objects are sticky, people just cram stuff into them instead of re-thinking the hierarchy properly.

There probably exists a really nice and cleanly separated object-hierarchy for a codebase at a given point in time, but requirements always evolve too rapidly to enjoy this for too long.

comment 3y ago · link · parent

> It’s typical to listen to this stream of events and use chained if-else statements to determine an action based on the type of the events that occur.

You'd think something like directory watching would have a clear set of events that would make nice objects with consistent meanings, but in my experience file watching gets crazy complicated, and can have all sorts of edge cases.

Just take a looked here for all the various edge cases that crop up: https://github.com/paulmillr/chokidar/issues

Then you have linux, windows, macos, and maybe you want to abstract over some underlying implementation like chokidar vs fb/watchman vs webpack/watchpack. Every new OS release could also cause things to change. A big leaky abstraction.

So usually its going to be a bunch of if-else statements hacked together to get around edge cases, and have to be revisited later on.

Any attempt to abstract this into objects, just obfuscates things. And OO forces you to name things, when in fact they might be un-nameable. `FileSystemModifyEventExceptWhenXAndYAndSometimesZ`.

The behavior might rely on a series of events together, so the object hierarchy must be re-worked.

OO has this rosy idea that we just have to come up with the perfect hierarchy, but things change in unexpected ways, and everything must have a descriptive noun.

comment 3y ago · link · parent

> Bundling behavior together means the behavior is out of the control of the object; the object's identity now becomes a critical part of the operation being performed. IMO, putting the focus on behavior is the wrong approach here.

Why? Do you have an example to better explain?

If find people rarely talk about the evaluation criteria for which approach to programming is better. That is, what are you optimizing for?

comment 3y ago · link · parent

Basic functional programming concepts are good, but it can easily go off the rails when people take it too far.

comment 3y ago · link · parent

It took me a long time to realize that I actually prefer not using classes.

It's the small things in programming that can make a huge difference. It always felt like I should be using the C++ way because it was slightly dry-er and looked nicer, and I could have all these OO features.

Like when you see `int get_numer(void *r)` or Python's `def get_numer(self)`, or Go's `func (rational *Rational) GetNumer() (n int)`, you think: "how silly, why does the object pointer need to be in scope, just use `this`". But this tiny thing is liberating. It allows you to see that everything is just functions operating on data. And that a "method", is just a function that is taking _the entire object_ as a parameter...and hence a dependency. Which allows you to think: hmm, does this function really need to depend on the entire object...maybe it can be a separate utility function all by itself without any connection to the class. And maybe it doesn't actually need access to any of the other functions in the class...and maybe the class could be split up...etc.

I just watched a [talk](1) by Alan Kay the inventor of SmallTalk and the phrase "object-oriented" who never stops shitting on C++.

Yet OO is still absolutely everywhere.

[1]: https://www.youtube.com/watch?v=oKg1hTOQXoY

comment 3y ago · link · parent

Transpilation.

Imagine if TypeScript/JSX was available native in the browser requiring no transpilation step, and we dropped support for any package requiring some exotic transpilation.

You could easily step through your entire codebase first and thirty-party without battling source-maps or minified files.

Libraries that required adding a compilation step and a complex dev server would be shunned. Having this compilation step in place means it's easy to just pile on tons of functionality, import hooks, AST transformations, etc. which causes the complexity.

comment 4y ago · link · parent

> There's no meaningful in-between.

Completely disagree. I believe it will come eventually. Check out AssemblyScript for example.

People choose TypeScript because it's simple and easy. They choose Rust because they need the features and ecosystem that are not available in another syntax as of yet.

comment 4y ago · link · parent

> This is why Objective-C looks so bizarre

Interesting point, hadn't thought about this before.

> TS doesn't have syntax for value vs reference types or memory ownership/lifetimes...if you kept the syntax similar to TS, then new features may end up looking bolted on and forced

I would argue that the vast majority of code in a low-level language doesn't care about manual memory access or pass by val/ref. It's all abstracted away into libraries. It just comes down to a different syntax, but they are all doing the same thing. As seen here: https://rosetta.fiatjaf.com/compare/TypeScript/Rust/.

Most of the time we are just passing around references anyway. So why no make this the default implicit case, and then when you need something exotic, add syntax then.

1234