News for hackers. Stuff that matters.

neurotrace

I'd love to see some performance metrics and if there are any guard rails against circular dependencies.
Re:Using TODO For Everything on Monday May 02, 2022 @11:08AM (#31236095)
I'm a fan of using the extensions the author mentioned when I'm exploring a problem space. I scaffold out the overall design for the problem in terms of modules and functions so that the code reads correctly, type checks, and works for an extreme subset of inputs. Anywhere that I haven't actually implemented the real solution I put in a "NO-MERGE" comment. Then when I feel that I've solved the problem at that scale, I can go through all of my NO-MERGE comments and implement them correctly. As the name implies, these are never merged in to main/master. They just act as bookmarks which should be obvious when reviewing my changes.

Personally, I try not to commit any TODO comments. They're sort of like warnings. Unless you're religious about clearing them out, they're just going to build up and be ignored.

> Why would you be worried about vendor-lock if you haven't built anything?

When else would you worry about lock-in? The early stages of a project involve setting up the foundation. If you build your foundation on vendor-specific tech, you've just locked yourself in or signed yourself up for a very painful transition in the future

Re:Node.js packages don't deserve trust on Monday April 11, 2022 @11:47AM (#30990418)
> why is NPM so uniquely absolutely horrible?

I'm not sure that it is. I think it's a numbers game. I've read* that npm is the largest repository in the world. More actors means more good and bad actors.

* Taken from this link. Old article and I'm not sure what the original data source is: https://www.linux.com/news/state-union-npm/

Re:Twitter accounts dropping “.eth” from usernames on Friday April 08, 2022 @04:06PM (#30961905)
If JS had no effect on the experience of the page (or the loading of it) then no one would write it. Personally, I don't generally mind running a bunch of JS but I understand why people don't. I use both the modern web and Gemini
I've gotten so used to seeing variants of Wordle that I read "Redditle" and immediately thought it was some sort of Reddit-based Wordle
Re:The plain-text internet is coming on Monday March 28, 2022 @12:04PM (#30831963)
You should check out Gemini[1]. That's basically how it works.

[1]: https://gemini.circumlunar.space/

Re:Brutal OS reached milestone 4 on Monday March 28, 2022 @11:07AM (#30831249)
You're right. Lifting a coffee cup with poor ergonomics isn't going to cause any injuries. Typing for hundreds of hours over many years in a poor position can lead to problems such as RSI.
Re:Monorepos done right on Wednesday March 16, 2022 @11:23AM (#30699934)
Good point. I have always run integration tests with Postgres etc. and have found value in it. I do think that you should have a substantially smaller set of those sorts of tests though.
Re:Delightful React file/directory structure on Tuesday March 15, 2022 @04:43PM (#30691402)
Not OP but I avoid default exports unless I need to do a lazy import. For me, there's a few reasons: consistent naming, easier importing, encourages importing what you need, avoids weird situation where you do both a default and named import.

Consistent naming: since I named the exported thing, that's what the consumers will call it as well unless they go out of their way to do `import { X as Y } from '...'`. This is useful because it helps ensure all consuming code looks similar at least in it's usage of modules. More familiar code is easier to read and reason about. It's also useful for looking up usages of something. I know I can run $IDE's version of "Find Usage" but sometimes it's easier to just Ctrl+Shift+F > X.

Easier importing: If I have something exported as X then I go to a module that isn't using it and I type X, my editor will suggest I import it from the appropriate module. This _can_ work on default exports but only if you use the same name as was used internally at the point of definition. That kind of defeats the benefit of default imports where you can use whatever name you want without hassle and it's your responsibility to make sure you match the names correctly.

Encourages importing what you need: when you default to named exports, you default to pulling in the bare minimum to do the job. Consider the opposite case. Someone imports some monolithic chunk of code as a single object then does `library.thingIWant` with a bunch of different things. Now you've got a larger possible space to look at when trying to load all of the context of a file in to your head. This is also useful for tree shaking. Assuming you've written your code in a well-defined manner and are using a smart build system, it can more easily eliminate dead code because it knows you never import certain pieces of a module. This applies to both your code and code from third-parties.

Both default and named imports: This is common when working with React. You'll see `import React, { useState } from 'react'` or similar. I don't have a rational answer for this but it rubs me the wrong way.

Re:Delightful React file/directory structure on Tuesday March 15, 2022 @12:58PM (#30687749)
> Finally, in terms of organization, I want things to be organized by function, not by feature.

I found this super surprising. I much prefer doing things by feature than by function. Where it goes is a function of which page/view/route it's on. If it's a general purpose component that is used on multiple pages (like `Button`) then, sure, it goes in `src/components`. Otherwise, it goes in `src/routes/app-section/components`. Truth be told, I've taken to doing a setup like this:

    src/
    - routes/
      - app-section/
        - effects/
          - some-action.effect.ts
        - ui/
          - app-section.component.tsx
          - index.ts
          - some-component.component.tsx
        - app-section.route.ts
        - app-section.types.ts
        - index.ts
        
`effects` basically holds your business logic, `ui` contains section specific components and exports the top-level component via `ui/index.ts`, `thing.route` hooks up the route to state management, `index.ts` provides a bundle for hooking up the effects to your effect system and the route component itself. The `name.type.extension` naming scheme clears up the tab name confusion problem. Maybe I should write my own article about this ;)
Re:Monorepos done right on Tuesday March 15, 2022 @12:07PM (#30687056)
I'd argue that you should have thorough unit tests for each service to ensure that they always respect their public API. Additionally, in a monorepo you can share type definitions so regardless of the service, you know for sure that you're using the right API. If all of that is in place then you can test the integration by just mocking out those services rather than testing their API n times.

If you're in an environment where you have limited/absence of type checking then you're right. In my experience, most problems that come from the integration of networked services come from not properly accounting for all possible responses. You're expecting to get a 200 response and a field of `x` but you got a 204 so the response is empty. That sort of thing.

Absolutely. I recently dropped in to a job where I was led to believe I'd be spending most of my time architecting applications but I've spent most of my time on ops stuff. Every engineer is expected to have more than a working knowledge of AWS, Terraform, and Kubernetes. I don't know how anyone gets anything done
Re:First look: adding type annotations to JavaScript on Thursday March 10, 2022 @12:05PM (#30629267)
> And in the next few sections it includes someone who wants to build on the proposal including using type hints to optimize code.

This changes literally nothing about the JS language. JS engines already attempt to determine the types of things to optimize the code they generate. Type annotations would just allow them to make more aggressive optimizations.

Re:First look: adding type annotations to JavaScript on Thursday March 10, 2022 @12:02PM (#30629230)
One of the benefits of TypeScript is that it literally is just JavaScript plus some. You can literally run `tsc` and it will spit out JavaScript written the same way as you wrote it but without any of the types. The only things that might look out of place is things like enums or decorators but you can choose not to use them.
Re:A Proposal for Type Syntax in JavaScript on Wednesday March 09, 2022 @05:59PM (#30621117)
> Considered a mistake by whom?

The developers of TypeScript. TypeScript aims to avoid adding anything to the runtime as a result of the type system[1].

> It would change nothing to the already complex build pipelines JS developers are already mandated to use for production.

You're right, it wouldn't change anything when you're building for production if you're doing things right. It would mean that you don't have to repeatedly compile your code while you're developing it though.

> What Typescript should do as an alternative is better support for JSDoc type analysis.

If you read the proposal you'll see they explain why expanding JSDoc is not ideal. Personally, I wrote a lot of JSDoc back before TypeScript and now I don't want to touch the stuff. TS is much more ergonomic and expressive.

[1]: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Desi...

Re:A Proposal for Type Syntax in JavaScript on Wednesday March 09, 2022 @05:54PM (#30621064)
I hear what you're saying but I'd rather not waste even those two hours ;)

I agree with what @erikpukinskis said but I'll also add that I just like the way they read. It immediately tells me that there is a limited number of potential values that can be put in a place. If I see some arbitrary string then I have to wonder, if only briefly, if any arbitrary string can be plugged in there.

    // What does addTask take? Days of the week?
    // Time-sensitive identifiers like you'd see in moment.js?
    // I guess I'll check the definition or mock out a call to see
    addTask('Sunday', newTask)

    // vs.
    // Ah, it takes a day
    addTask(Day.Sunday, newTask)
It's subtle and not super important but it makes me happy.
Re:A Proposal for Type Syntax in JavaScript on Wednesday March 09, 2022 @04:24PM (#30620172)
For better or for worse, features of TypeScript that generate code (like enums) are generally considered a mistake. I assume part of the idea here is that people would aim to target this particular subset so they can avoid compiling while in development and as such people would move away from those features. I like enums but you can get most of the same benefits with

    type RGB = 'red' | 'green' | 'blue'
Re:Advanced Programming Languages (2009) on Sunday March 06, 2022 @02:26PM (#30580335)
The comment was supposed to explain monads by common usage rather than as a mathematical notion. Prolog is not a commonly used language by us blue collar programmers. I feel I have a grasp on monads and yet that explanation meant little to me given my limited experience with Prolog.
Looks interesting but here's what I don't understand. So many programming languages do not show example code on the homepage. That's like if Mazda didn't show cars on their homepage. Sure, you won't really know what it's like to drive it without getting your hands dirty but at least let me see the trim.
Re:State of JavaScript 2021 on Wednesday February 16, 2022 @08:46AM (#30359827)
Unpopular opinion here: the more I use Vue, the more I realize that it started off doing things differently because it thought it was smarter than more established frameworks. Over time, you're seeing it copy a lot ideas from other systems because they're actually hard earned lessons. Vue is the manifestation of the frontend hype cycle. There's no reason to use it over something like React which is much better supported
Re:Diving into BoardGameGeek on Monday January 24, 2022 @12:27PM (#30060833)
Children can learn Monopoly fairly quickly. To me, that sounds pretty simple. Buy property, get money when people land on it, get more money if you have more house/hotels. That's just about it
Re:Open-Sourcing our Firmware on Friday January 21, 2022 @04:23PM (#30030183)
I've had my laptop for a while now and haven't noticed any build quality issues. It definitely feels nice and light but it seems sturdy enough. I'm not in the habit of dropping my laptop on the ground but I do chuck it on to the bed from time and to time and it doesn't seem any worse for wear.
Re:Dear sir, you have built a compiler on Thursday January 13, 2022 @10:57AM (#29922113)
I think "easy to use" might be an overstatement. I spent a fair bit of time trying to get in to the flex/bison workflow and it never seemed to click. I've found it much easier to use PEG parsers, parser combinators, or a hand-written recursive descent parser. Based on their ubiquity and the high reviews, I'm sure they're great tools once the initial hump is passed but that initial hump is quite large.
Re:Crispy Doom on Monday January 10, 2022 @06:16PM (#29884451)
I recently played through Doom and Doom II via GZDoom and had a great experience playing at 1080p and with disabled texture filtering. I didn't play these games when they first came out so mouselook feels natural to me and I'd recommend it for people in similar positions. These games really do hold up
Re:I Miss RSS on Wednesday January 05, 2022 @04:54PM (#29815566)
I have a private Discord server that acts as an RSS reader via MonitoRSS[1]. It works great because Discord has really good notification configuration. Some feeds I want to know about immediately, others I only want to see when I check the news, and because I can mute channels I can let my friends use it as well. They set up their own feeds and I don't have to be alerted to it but I can go look if I'm interested in what they're reading lately.

All that is to say that RSS still works. What's missing is the original content creators of the early RSS world. Nowadays, most people create small, easy-to-write, easy-to-consume content in one of the walled gardens since the notifications, interactions, and network are all included for them.

[1]: https://monitorss.xyz/

Re:Web3 is centralized on Sunday January 02, 2022 @08:22AM (#29768491)
> being proud of one's economic transaction history would be awesome.

I sincerely doubt we'll ever see that. First off, Venmo has already tried to apply the social media formula to transactions. I don't know of a single person who reads their Venmo feed just for fun. Next, most transactions are boring and not worth sharing. "John bought toilet paper and Q-tips. [Like] [Retweet]".

You state that the move to hyper-publicity that we've already seen hasn't reached it's peak for usefulness and yet there are already widespread conversations about the dangers and pain that this hyper-publicity has caused.

If we reach a future where people are "proud" of their transactions and are sharing them everywhere then we've made a horrible mistake.

As someone who used to have to buy everything secondhand, this makes me sad. I can't tell you how exciting it was to find something that you wanted but knew you couldn't afford going for a reasonable price at the thrift store. I feel like by buying up all of those quality items, you're depriving people in less fortunate situations from experiencing the same sort of happiness.
Seems like the link ought to point here: https://impervious.com/beacon
Re:Tailwind CSS v3.0 on Thursday December 09, 2021 @06:14PM (#29504413)
I've been a web dev for about 10 years. My day to day now involves building out React-based applications dealing with both the backend and frontend. I put in the work and built a real side project using Tailwind and it was so annoying.

When you write anything substantial you end up with class name soup. The answer to this is to use `@apply` which is literally just a normal CSS class with extra steps.

The new vernacular just means that users have to learn Tailwind language rather than proper CSS.

CSS modules solve the main problems that Tailwind attempts to solve. The other things are solved with use of CSS variables.

The only thing that I find useful in Tailwind is the responsive design classes. Being able to do `md:<some other style here>` is pretty cool.

To me, Tailwind seems valuable to newer engineers because they feel like they don't have to learn CSS. They learn "Tailwind." It's like all those people who would say "I don't know JavaScript, I know jQuery." Like jQuery, there are benefits in having a unified language especially when you're newer. I believe that a better solution to styling is inevitable (my latest favorite heavily uses CSS variables). I do not believe Tailwind is the best way forward.

Older »