Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Sep 23, 2024
1 parent 7931d12 commit 8229ac0
Showing 1 changed file with 142 additions and 50 deletions.
192 changes: 142 additions & 50 deletions _releases/2024-10-09-1.14.0-released.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ improving the language! ❤️
As part of the [project to improve multi-threading support](/2024/02/09/84codes-manas-mt) with the help of [84codes],
this release includes several improvements and refactors related to concurrency and the event loop. So far, these have been mostly internal changes with minor relevance from a user's point of view. We expect more significant changes in the next release.

A preview of the upcoming execution context ([RFC](https://github.com/crystal-lang/rfcs/pull/2)) is available as a standalone shard: [`ysbaddaden/execution_context`](https://github.com/ysbaddaden/execution_context). It's available for testing by eager developers. This library is expected to be part of the compiler once we are certain it's ready.
A preview of the upcoming execution context ([RFC 2](https://github.com/crystal-lang/rfcs/pull/2)) is available as a standalone shard: [`ysbaddaden/execution_context`](https://github.com/ysbaddaden/execution_context). It's available for testing by eager developers. This library is expected to be part of the compiler once we are certain it's ready.

## Changes

Expand All @@ -31,62 +31,103 @@ For more details, visit the [full changelog](https://github.com/crystal-lang/cry

### Breaking

`Slice#[start, count]` accepts a negative index for `start`, like similar methods already do.
This would break existing code that depends on the current behaviou that a negative start index raises `IndexError` ([#14778], thanks @ysbaddaden).
⚠️ `Slice#[start, count]` now accepts a negative index for `start`, like similar methods already do.
This would break existing code that depends on the current behaviour that a negative start index raises `IndexError` ([#14778]).

[#14778]: https://github.com/crystal-lang/crystal/pull/14778

Finalizers for `Socket` and `IO::FileDescriptor` do no longer flush.
⚠️ Finalizers for `Socket` and `IO::FileDescriptor` do no longer flush.
Flushing is too heavy for a finalizer, as it might involve the event loop and even memory allocations which must be strictly avoided in a finalizer.
Be sure to always flush before letting a stream go out of scope, ideally with an explicit `#close` ([#14882], thanks @straight-shoota).
Be sure to always flush before letting a stream go out of scope, ideally with an explicit `#close` ([#14882]).

[#14882]: https://github.com/crystal-lang/crystal/pull/14882

`XML::Error.errors` had been deprecated since [1.7.0](/releases/2023-01-09-1.7.0-released.md), but continued to work.
⚠️ `XML::Error.errors` had been deprecated since [1.7.0](/releases/2023-01-09-1.7.0-released.md), but continued to work.
This unconditioned availability causes a serious memory leak, which cannot be fixed without disabling `XML::Error.errors`.
In order to make this obvious, calling the method causes a compile time error now. ([#14936], thanks @straight-shoota)
In order to make this obvious, calling the method causes a compile time error now. ([#14936]).

[#14936]: https://github.com/crystal-lang/crystal/pull/14936

`Hash::Entry` has been removed from public API docs. It was never intended to be a public type. ([#14881], thanks @Blacksmoke16)
⚠️ `Hash::Entry` has been removed from public API docs. It was never intended to be a public type. ([#14881]).

*Thanks [@ysbaddaden], [@straight-shoota] and [@Blacksmoke16]*

[#14881]: https://github.com/crystal-lang/crystal/pull/14881

### Language features

Allow `^` in constant numeric expressions ([#14951], thanks @HertzDevil).
Allow `^` in constant numeric expressions ([#14951]). This operator was oddly missing even though `|` and `&` were already supported.

*Thanks [@HertzDevil]*

[#14951]: https://github.com/crystal-lang/crystal/pull/14951

`HashLiteral` and `NamedTupleLiteral` respond to `#has_key?`, just like their regular counterparts `Hash` and `NamedTuple` ([#14890], thanks @kamil-gwozdz)
`HashLiteral` and `NamedTupleLiteral` respond to `#has_key?`, just like their regular counterparts `Hash` and `NamedTuple` ([#14890]).

*Thanks [@kamil-gwozdz]*

### Standard library

- Support ARM64 Windows ([#14911], thanks @HertzDevil)
The `WaitGroup` concurrency primitive gains some convenience methods,
`WaitGroup.wait` and `WaitGroup#spawn` ([#14837]).

```crystal
require "wait_group"
WaitGroup.wait do |wg|
10.times do
wg.spawn do
sleep 5.seconds
end
end
end
```

[#14911]: https://github.com/crystal-lang/crystal/pull/14911
*Thanks [@jgaskins]*

[#14837]: https://github.com/crystal-lang/crystal/pull/14837

There are two new methods for working with slices: `Slice#same?`checks
if two slices point to the same memory ([#14728]).
And `Pointer::Appender#to_slice` ([#14874]) makes it easy to create a slice
containing the items from an appender.

- *(collection)* Add `Slice#same?` ([#14728], thanks @straight-shoota)
[#14728]: https://github.com/crystal-lang/crystal/pull/14728
- *(runtime)* Add `Pointer::Appender#to_slice` ([#14874], thanks @straight-shoota)
[#14874]: https://github.com/crystal-lang/crystal/pull/14874

- *(concurrency)* Add `WaitGroup.wait` and `WaitGroup#spawn` ([#14837], thanks @jgaskins)
[#14837]: https://github.com/crystal-lang/crystal/pull/14837
*Thanks [@straight-shoota]*

A minor fix turning an eager class getter into a lazy one avoids linking `libpcre`
for programs that do not use `Regex` ([#14891]).

*Thanks [@kojix2]*

- *(codegen)* Fix avoid linking `libpcre` when unused ([#14891], thanks @kojix2)
[#14891]: https://github.com/crystal-lang/crystal/pull/14891

### Windows

- *(concurrency)* Open non-blocking regular files as overlapped on Windows ([#14921], thanks @HertzDevil)
- *(concurrency)* Support non-blocking `File#read` and `#write` on Windows ([#14940], thanks @HertzDevil)
- *(concurrency)* Support non-blocking `File#read_at` on Windows ([#14958], thanks @HertzDevil)
- *(concurrency)* Support non-blocking `Process.run` standard streams on Windows ([#14941], thanks @HertzDevil)
- *(concurrency)* Support `IO::FileDescriptor#flock_*` on non-blocking files on Windows ([#14943], thanks @HertzDevil)
- *(concurrency)* Emulate non-blocking `STDIN` console on Windows ([#14947], thanks @HertzDevil)
- *(concurrency)* Async DNS resolution on Windows ([#14979], thanks @HertzDevil)
- *(system)* Implement `System::User` on Windows ([#14933], thanks @HertzDevil)
- *(system)* Implement `System::Group` on Windows ([#14945], thanks @HertzDevil)
Windows support is making good progress.

The interpreter runs on Windows ([#14964]). There is still a limitation:
networking does not work due to [#12495].

And Crystal runs on ARM64 Windows, i.e. the `aarch64-windows-msvc` target.
Both standard library and the compiler should work. It's not 100% polished, but
looking pretty well. Read [#14911] for details on how to test it out.

Starting with this release, DNS requests resolve asynchronously on Windows ([#14979]).
It's actually the first platform to support that.

There are also a number of improvements regarding non-blocking IO:

- Support non-blocking `File#read` and `#write` ([#14940]), `File#read_at` ([#14958]), `Process.run` standard streams ([#14941]), `IO::FileDescriptor#flock_*` ([#14943]).
- Emulate non-blocking `STDIN` console ([#14947]).
- Open non-blocking regular files as overlapped ([#14921]).

And we add implementations of `System::User` ([#14933]) and `System::Group` on Windows ([#14945]).

*Thanks [@HertzDevil]*

[#14911]: https://github.com/crystal-lang/crystal/pull/14911
[#14921]: https://github.com/crystal-lang/crystal/pull/14921
[#14940]: https://github.com/crystal-lang/crystal/pull/14940
[#14958]: https://github.com/crystal-lang/crystal/pull/14958
Expand All @@ -96,60 +137,109 @@ Allow `^` in constant numeric expressions ([#14951], thanks @HertzDevil).
[#14979]: https://github.com/crystal-lang/crystal/pull/14979
[#14933]: https://github.com/crystal-lang/crystal/pull/14933
[#14945]: https://github.com/crystal-lang/crystal/pull/14945

- *(interpreter)* Enable the interpreter on Windows ([#14964], thanks @HertzDevil)
[#14964]: https://github.com/crystal-lang/crystal/pull/14964
[#12495]: https://github.com/crystal-lang/crystal/issues/12495

### `URI::Params`

- *(serialization)* Add `URI.from_json_object_key?` and `URI#to_json_object_key` ([#14834], thanks @nobodywasishere)
- *(serialization)* Add `URI::Params::Serializable` ([#14684], thanks @Blacksmoke16)
`URI::Params::Serializable` is a new serialization API which works similar to
the JSON and YAML variants, but for the URI query parameters format ([#14684]).

```crystal
require "uri/params/serializable"
record Applicant,
first_name : String
last_name : String
qualities : Array(String) do
include URI::Params::Serializable
end
applicant = Applicant.from_www_form "first_name=John&last_name=Doe&qualities=kind&qualities=smart"
applicant # => Applicant(@first_name="John", @last_name="Doe", @qualities=["kind", "smart"])
applicant.to_www_form # => "first_name=John&last_name=Doe&qualities=kind&qualities=smart"
```

*Thanks [@Blacksmoke16]*

In a related matter, `URI` is now applicable as a key in JSON objects via `URI.from_json_object_key?` and `URI#to_json_object_key` ([#14834]).

*Thanks [@nobodywasishere]*

[#14834]: https://github.com/crystal-lang/crystal/pull/14834
[#14684]: https://github.com/crystal-lang/crystal/pull/14684

### Compiler tools

- *(cli)* Adds initial support for external commands ([#14953], thanks @bcardiff)
The compiler binary can now execute external programs as subcommands.
This allows us to split the compiler binary into separate executables which helps
improve iteration speed ([#14953]).

*Thanks [@bcardiff]*

[#14953]: https://github.com/crystal-lang/crystal/pull/14953

- *(docs-generator)* Add nodoc filter to doc type methods ([#14910], thanks @spuun)
We fixed a bug where the doc generator referenced and linked undocumented types ([#14910]).

*Thanks [@spuun]*

[#14910]: https://github.com/crystal-lang/crystal/pull/14910

### Performance

- *(codegen)* Reduce calls to `Crystal::Type#remove_indirection` in module dispatch ([#14992]).

- *(codegen)* Reduce calls to `Crystal::Type#remove_indirection` in module dispatch ([#14992], thanks @HertzDevil)
*Thanks [@HertzDevil]*

[#14992]: https://github.com/crystal-lang/crystal/pull/14992

- Avoid unwinding the stack on hot path in method call lookups ([#15002], thanks @ggiraldez)
- *(codegen)* Compiler: enable parallel codegen with MT ([#14748], thanks @ysbaddaden)
- Avoid unwinding the stack on hot path in method call lookups ([#15002]).

*Thanks [@ggiraldez]*

- *(codegen)* Compiler: enable parallel codegen with MT ([#14748]).

*Thanks [@ysbaddaden]*

[#15002]: https://github.com/crystal-lang/crystal/pull/15002
[#14748]: https://github.com/crystal-lang/crystal/pull/14748

### Dependencies

- *(crypto)* Update `LibCrypto` bindings for LibreSSL 3.5+ ([#14872], thanks @straight-shoota)
- *(crypto)* Update `LibCrypto` bindings for LibreSSL 3.5+ ([#14872]).

*Thanks [@straight-shoota]*

[#14872]: https://github.com/crystal-lang/crystal/pull/14872
- *(text)* Support Unicode 16.0.0 ([#14997], thanks @HertzDevil)

- *(text)* Support Unicode 16.0.0 ([#14997]).

*Thanks [@HertzDevil]*

[#14997]: https://github.com/crystal-lang/crystal/pull/14997
- *(interpreter:repl)* Update REPLy version ([#14950], thanks @HertzDevil)

- *(interpreter:repl)* Update REPLy version ([#14950]).

*Thanks [@HertzDevil]*

[#14950]: https://github.com/crystal-lang/crystal/pull/14950

## Deprecations

-
- *(runtime)* **[deprecation]** Deprecate `Pointer.new(Int)` ([#14875], thanks @straight-shoota)
- `Pointer.new(Int)` ([#14875]) was deprecated in favour of `Process.new(UInt64)`.
Deprecation warnings for argument type that autocast to `UInt64` can be ignored
or disabled by explicitly casting to `UInt64`.

*Thanks [@straight-shoota]*

[#14875]: https://github.com/crystal-lang/crystal/pull/14875
- **[deprecation]** Use `Time::Span` in `Benchmark.ips` ([#14805], thanks @HertzDevil)
[#14805]: https://github.com/crystal-lang/crystal/pull/14805

- **[deprecation]** Deprecate `::sleep(Number)` ([#14962], thanks @HertzDevil)
- We updated a couple of APIs that used `Number` to represent a time span. `Benchmark.ips` ([#14805])
and `::sleep(Number)` ([#14962]) explicitly require `Time::Span`. You can convert bare numbers with `Number#seconds` to use the valid overload.

*Thanks [@HertzDevil]*

[#14805]: https://github.com/crystal-lang/crystal/pull/14805
[#14962]: https://github.com/crystal-lang/crystal/pull/14962

---
Expand All @@ -164,13 +254,15 @@ Allow `^` in constant numeric expressions ([#14951], thanks @HertzDevil).
> if you’d like to become a direct sponsor or find other ways to support Crystal.
> We thank you in advance!
[@ysbaddaden]: https://github.com/ysbaddaden
[@jgaskins]: https://github.com/jgaskins
[@bcardiff]: https://github.com/bcardiff
[@Blacksmoke16]: https://github.com/Blacksmoke16
[@ggiraldez]: https://github.com/ggiraldez
[@HertzDevil]: https://github.com/HertzDevil
[@jgaskins]: https://github.com/jgaskins
[@kamil-gwozdz]: https://github.com/kamil-gwozdz
[@kojix2]: https://github.com/kojix2
[@nobodywasishere]: https://github.com/nobodywasishere
[@spuun]: https://github.com/spuun
[@straight-shoota]: https://github.com/straight-shoota
[@Blacksmoke16]: https://github.com/Blacksmoke16
[@hovsater]: https://github.com/hovsater
[@summer-alice]: https://github.com/summer-alice
[@meatball133]: https://github.com/meatball133
[@Hadeweka]: https://github.com/@Hadeweka
[@ysbaddaden]: https://github.com/ysbaddaden
[84codes]: https://www.84codes.com/

0 comments on commit 8229ac0

Please sign in to comment.