News for hackers. Stuff that matters.
Re:I think Zig is hard but worth it by chrsig on Thursday June 01, 2023 @11:16AM (#36152323)
> I've lately thought that a package manager is as essential to a new language as a standard library. I would also add a LSP and standard code formatter to that list.

Agreed. Especially on a formatter. The number of code review comments it cuts out is incredibly time and energy saving.

> It is a bit unfortunate because all of the above is a pretty tall order. We're getting to the point that new languages are expected to boil the ocean by the time they reach 1.0

In order to get into production? yes. there are minimum requirements that must be met. those are higher now than in the past, because of lessons learned the hard way. those problems have been solved (for some value of solved) in existing ecosystems -- a new language wont change the need for them to be solved.

it shatters the dream of hacking up something on a weekend and having it turn into a hit success, but it also removes the case of hacking up something in 10 days and suffering the consequences for the next 30 years.

Until they have what you mentioned, the languages aren't ready for large scale use -- they need to grow into it. They can be useful prior to that -- enthusiasts and early adopters can reap what benefits are provided. That adoption is what fuels the development of things like a standard code formatter.

edit: fixed omission of a unit of time after '30'

Re:I think Zig is hard but worth it by clessg on Thursday June 01, 2023 @01:01PM (#36154051)
> but it also removes the case of hacking up something in 10 days and suffering the consequences for the next 30 years

Ha, I thought this sounded distressingly familiar!

"In September 1995, a Netscape programmer named Brandan Eich developed a new scripting language in just 10 days. It was originally named Mocha, but quickly became known as LiveScript and, later, JavaScript."

Re:I think Zig is hard but worth it by erhaetherth on Friday June 02, 2023 @03:17AM (#36162085)
I think JS was somehow salvaged after all that time. The event loop paradigm is lovely.
Re:I think Zig is hard but worth it by 6keZbCECT2uB on Thursday June 01, 2023 @03:34PM (#36156226)
Not sure about lsp, but I think if you defined your language in tree sitter, you might be able to define a basic autoformatter generically on tree sitter to accelerate bootstrapping your language.

You could also use an existing language agnostic package manager like nix, guix, or conda to bootstrap your language package manager.

Lsp is something I don't know of a way to make that easy without overly constraining the design space.

Re:I think Zig is hard but worth it by xormapmap on Thursday June 01, 2023 @07:07PM (#36158675)
> Agreed. Especially on a formatter. The number of code review comments it cuts out is incredibly time and energy saving.

Are people realistically reviewing code formatting? As long as people aren't making egregious violations I generally don't care if someone leaves a brace on the same line or writes a one-line if statement. I tend to review the overall design and look for bugs and edge cases that might've been missed. If somebody told me they didn't like the way I formatted the code then they've got their own editor and are welcome to change it if they want to be petty.

Re:I think Zig is hard but worth it by throwawaymaths on Thursday June 01, 2023 @07:21PM (#36158795)
Nobody is reviewing it. They are rejecting malformatted code in CI step.
Re:I think Zig is hard but worth it by nickcox on Thursday June 01, 2023 @11:12PM (#36160435)
That's not the workflow your GP is describing.
Re:I think Zig is hard but worth it by hyperhopper on Thursday June 01, 2023 @07:23PM (#36158810)
You're looking at it the wrong way

People review code. As soon as that happens, formatting is part of the conversation. Either consciously or subconsciously

Re:I think Zig is hard but worth it by xxpor on Thursday June 01, 2023 @07:15PM (#36158750)
Absolutely. Inconsistency is sloppy, increases cognitive burden while reading code, and can hide bugs.

Everyone should take the time to setup their editor to format their code consistent with the project style, it doesn't take long at all.

Re:I think Zig is hard but worth it by patmorgan23 on Thursday June 01, 2023 @08:51PM (#36159451)
The point of the auto formatter is to get those slight differences out of the way so your Brian can focus on parsing and understanding the important parts
Re:I think Zig is hard but worth it by brundolf on Thursday June 01, 2023 @09:43PM (#36159851)
In addition to reviews, I've started to really enjoy format-on-save as a way to save keystrokes. Instead of manually formatting my code (even for myself), I can take the shortest editor path to the AST that I want and then have everything else snap into place
Re:I think Zig is hard but worth it by erhaetherth on Friday June 02, 2023 @03:19AM (#36162098)
Makes me so sad that I can't just code up a parser and have a useable language. I have a lot of ideas, but heck, just syntax highlighting is... I don't know where to begin. And auto-completions. I need a tool that does 90% of that like PegJS or other parser-generators do for the parsing part. Don't see why a parser-generator can't also spit out an LSP. And if it knows what tokens are valid next, it should be able to generate completion suggestions. And if you have an AST, you can probably format the code half decently. And then I imagine it's possible to have a semi-universal package manager, I don't know why we need one per language, really. Aren't they all "put some code in some predefined location, and resolve these dependencies with semver please"? Maybe some extra junk for precompiled deps but still.
Re:I think Zig is hard but worth it by aldanor on Saturday June 03, 2023 @06:42AM (#36175430)
Because LSP is not just "give me some semi-decent completions based on parsing tokens in this file". Proper LSP will treat code semantically, in case of e.g. Rust it may complete a method name from a trait method because you have the trait somewhere in scope, which comes from a third-party package which the LSP also parses, where it needs to expand some procedural macros to get to source code, etc etc.

We've been spoiled by good LSPs, perhaps. But again, it's not just "parse this file please".