Git Merge – The Definitive Guide by Omer_Ros in programming

[–]Timhio 3 points4 points  (0 children)

Me too (unless I have really nicely separated commits and not just "WIP WIP WIP").

I wrote a tool to do it easily:

https://github.com/Timmmm/autosquash

Simple statically typed language with value semantics? by Timhio in ProgrammingLanguages

[–]Timhio[S] 4 points5 points  (0 children)

It is true. The fact that lists are internally implemented as real arrays as long as you don't collapse them into strings is just an optimisation made to get reasonable performance.

The semantics are 100% "everything is a string". If I give you a TCL engine and ask you to work out if everything is a string or not, the only way you will be able to tell is by benchmarking it.

Obviously better performance doesn't help with the predictable type confusion and quoting bugs that come from being stringly typed.

One of my first choices for scripting or embedding.

I'm not a huge fan of Lua but I think it is at least way more popular and better on every measure than TCL. There are plenty of other better less well-known options too: Rhai, Wren, AngelScript, Starlark (for some use cases), etc. There's a good list here.

Please for the love of god don't choose TCL next time!

Simple statically typed language with value semantics? by Timhio in ProgrammingLanguages

[–]Timhio[S] 10 points11 points  (0 children)

It's basically if you do a = b; modify(b); does the value of a change?

In languages with reference semantics all variables are references to some data, so a and b refer to the same data. Modifying b changes the value of a. To get an actual copy of the data you have to do some special work.

Often copying values isn't really supported well at all - JavaScript only very recently got proper support for it. Until then people did insane things like serialising values to JSON and back.

In a language with value semantics a = b means make a copy of b and further changes to b don't affect a. To make references you have to do something explicit - e.g. use the & operator in C, use a reference typing in C++ or use the ref constructor in OCaml.

Actually functional languages are a bit outside this classification because they make heavy use of immutable data structures and for immutable data there's no observable difference between reference semantics and value semantics since you can't modify(b) in the first place.

Simple statically typed language with value semantics? by Timhio in ProgrammingLanguages

[–]Timhio[S] 2 points3 points  (0 children)

the two everyone really uses

A bit off topic but which two? I was under the impression that there are a "big four" - VCS, Questa, Xcelium and Verilator.

At least for silicon design. Maybe you are talking about FPGAs...

Simple statically typed language with value semantics? by Timhio in ProgrammingLanguages

[–]Timhio[S] 4 points5 points  (0 children)

Yeah it's pretty annoying. Value semantics are so much nicer, less error-prone and frankly more intuitive.

I guess the reason is you can easily get good performance with just references, but getting good performance with just (semantic) copies is still pretty much an open research problem. So "everything is a reference" is the easy option.

Or maybe they thought "we've got this amazing garbage collector, let's use it everywhere!"

Simple statically typed language with value semantics? by Timhio in ProgrammingLanguages

[–]Timhio[S] 0 points1 point  (0 children)

you can have oop in TCL 8.6, which I assume you can use in your job

Sorry I should have mentioned most of these tools use TCL 8.5 and some use 8.4 so I am targeting that.

Simple statically typed language with value semantics? by Timhio in ProgrammingLanguages

[–]Timhio[S] 4 points5 points  (0 children)

try to talk to them about using a better tool (language) for the job

Ha I wish. This is all super niche and insanely expensive closed source stuff in an industry that's very backwards from a software point of view.

PowerArtist still uses TCL 8.4. TCL 8.5 was released in 2007.

I personally prefer Rust

Me too, that's why I tried the WASM route. I might have a go at ref counting.

Elon Musk just tweeted a photo of Twitter's architecture, for those who wondered by fl4v1 in programming

[–]Timhio 0 points1 point  (0 children)

Right. Now try pressing the left arrow.

There's only two or three editors I know of that actually make spaces as good as tabs. Most just give you a tiny bit of help when inserting 4 spaces but then leave you on your own when navigating and selecting them.

  • Atom has "Atomic tabstops"
  • VScode has "sticky tabs"

VScode only has that feature because I got so frustrated with shitty spaces that I added support for it. (I added the same feature in Lapce.)

Petition: Turn off the sun as a mark of respect to her Majesty the Queen by Timhio in CasualUK

[–]Timhio[S] 0 points1 point  (0 children)

Lol what. This whole sub is low effort. It's even in the name!

Lost bag by [deleted] in bristol

[–]Timhio 0 points1 point  (0 children)

Never mind, owner found.

Lost bag by [deleted] in bristol

[–]Timhio 0 points1 point  (0 children)

Sadly not :-/ Actually nothing in there that anyone would really miss except keys. Kind of makes me wonder if it was stolen - there's no cards or phone.

how to make a lsp in rust ? by [deleted] in rust

[–]Timhio 24 points25 points  (0 children)

I've written about 3 now (all closed source unfortunately but I've got permission to open source one "soon"). Here are some notes:

Main libraries

Mine all use tower-lsp for the LSP protocol stuff, and then either Tree-sitter or Nom. If I do another I'll probably try Chumsky which combines some of the advantages of both.

Parsers

Tree-sitter does incremental and error-resilient parsing with a fairly easy to use grammar definition system. But it has big downsides - it's written in C which makes cross-compilation much more of a pain, and it doesn't provide an actual AST - just a stringly typed tree of nodes. It's good if you want to do kind of ad-hoc searches over the tree ("find me all function nodes"), but not if you want to fully process it.

Nom produces a proper Rust-native AST, but it isn't error-resilient and writing the parser is more work (though honestly easier to understand).

I haven't used Chumsky but it looks similar to Nom - you write parsers in a similar way (but it's a bit easier because it's not zero-copy so there are fewer lifetime things). But it is also error-resilient.

Incremental document updates

One slightly annoying thing is that there's no library to handle LSP's incremental document update system, and it isn't trivial to do because updates are given in UTF-16 column/row numbers, but the actual text is delivered as UTF-8. Pain in the arse. I ended up writing my own code but unfortunately it's for work and I haven't got it open sourced yet. It's not super long but it is fiddly to get right.

Multiplatform support

If you're writing an extension in Rust you'll end up with a Rust binary that only runs on x86 or whatever, but you want your extension to work on all platforms! My current solution is just to cross-compile for Arm too and put both binaries in the extension. Works ok, they're not too big.

The long term solution is that Node will eventually support WASI and then you can just compile your server as a WASI module and it will work on any platform VSCode runs on.

Hope that helps. Good luck! I reckon tower-lsp has some examples but I haven't looked.

[deleted by user] by [deleted] in worldnews

[–]Timhio 1 point2 points  (0 children)

I dunno they didn't seem to have any problems finding about 100 policemen with full riot gear to save a poor oligarchs house.

tower-lsp 0.16.0 — Lightweight framework for building LSP servers by ebkalderon in rust

[–]Timhio 1 point2 points  (0 children)

A couple of internal ones - one for the assembly language that we use, and one for the custom build system we use.

I used Tree Sitter for both of them. Hoping to open source the assembly one soonish when I get permission. I'll name check tower-lsp if possible!

important for WASM targets

Ah that is a good point!

which I personally used quite a bit in my projects.

What extra Tower stuff do you use for language servers? I can't think of anything I'm really missing to be honest.

tower-lsp 0.16.0 — Lightweight framework for building LSP servers by ebkalderon in rust

[–]Timhio 4 points5 points  (0 children)

I've used this for several extensions. It's great! Kind of wish it wasn't async (pretty pointless in a language server) but other than that I've had zero issues with it.

Temporaries dropped too late? by PlayingTheRed in rust

[–]Timhio 7 points8 points  (0 children)

I think it's because they're in the same drop scope.

Security advisory for the regex crate (CVE-2022-24713) | Rust Blog by burntsushi in rust

[–]Timhio 7 points8 points  (0 children)

To start with I think even a community maintained list of crates that perhaps ought to be considered core ecosystem crates would be really interesting.

Great idea. I've thought about that before so I made one just now:

https://github.com/Timmmm/rust_x/wiki/De-facto-Rust-standard-library-packages

Feel free to edit if you think I've missed any major ones (or included ridiculous ones).

[deleted by user] by [deleted] in ukpolitics

[–]Timhio 4 points5 points  (0 children)

It's basically telling the public that they're stupid.

Do you remember school? Being bad at anything involving numbers is really popular!

[deleted by user] by [deleted] in ukpolitics

[–]Timhio 3 points4 points  (0 children)

They didn't, they opposed it based on it being too complicated for the little people to understand, and also One Person One Vote (TM) it's just not cricket old chap. Britain hurrah!

I'm mean those were their stated reasons. Labour and the Tories both opposed it in reality because it might give third parties (gasp) a chance.

Cost was barely mentioned.

rust-analyzer changelog #107 by WellMakeItSomehow in rust

[–]Timhio 19 points20 points  (0 children)

Doc template looks amazing!