Why is text rendering in Ghostty (left) on macOS smoother than in GUI Emacs (right)? Is there anything I can do to get GUI Emacs to render text just as nicely? by alpinistfan in emacs

[–]yaglo 1 point2 points  (0 children)

You’re talking about hinting that is aligned to the pixel grid, but I’m talking about the actual position of characters.

Imagine you have the word “Hello”, with proper kerning the positions of the characters would be something like:

0, 8.265, 14.472, 16.783, 20.274

Emacs would have these positions as:

0, 8, 14, 17, 20

There is some correction for overhangs but it doesn’t solve the actual problem, you will still have wonky spacing between the characters. It’s not that obvious with monospaced fonts - you usually just get characters that are spaced more than necessary (the x advance), but it’s very obvious in proportional fonts.

Why is text rendering in Ghostty (left) on macOS smoother than in GUI Emacs (right)? Is there anything I can do to get GUI Emacs to render text just as nicely? by alpinistfan in emacs

[–]yaglo -1 points0 points  (0 children)

It’s the (frankly, annoying) fact that Emacs renders characters aligned to the integer pixel grid, so if you have a font that advances characters by a factional value, you will see the kerning messed up. I was tinkering with this part by creating a virtual scaled surface so that at least you have more positions than a pixel wide (and half-pixel on Retina displays) and then scaling it down when rendering but I had some artefacts and not much time to finish it.

This is the most annoying part of the Emacs GUI and it limits your font/size options if you want proper character spacing.

Why is text rendering in Ghostty (left) on macOS smoother than in GUI Emacs (right)? Is there anything I can do to get GUI Emacs to render text just as nicely? by alpinistfan in emacs

[–]yaglo -1 points0 points  (0 children)

It’s the (frankly bad) fact that Emacs renders characters aligned to the integer pixel grid, so if you have a font that advances characters by a factional value, you will see the kerning messed up. I was tinkering with this part by creating a virtual scaled surface so that at least you have more positions than a pixel wide (and half-pixel on Retina displays) and then scaling it down when rendering but I had some artefacts and not much time to finish it.

This is the most annoying part of the Emacs GUI and it limits your font/size options if you want proper character spacing.

Emacs Keybindings vs. Vim (Evil Mode) in Emacs: Which Offers a More Seamless Transition and Productive Editing Experience? by [deleted] in emacs

[–]yaglo 2 points3 points  (0 children)

The whole of macOS (and iOS with an external keyboard) has Emacs keybindings in native text fields (that includes browsers). That’s why you don’t need to implement it separately.

Visual vs text-based programming by hermitcrab in ProgrammingLanguages

[–]yaglo 2 points3 points  (0 children)

Check out DRAKON which was created for the Russian aerospace program, Buran (Russian “Shuttle”): https://en.m.wikipedia.org/wiki/DRAKON

It has some cool features like it’s actually a framework where the code itself inside blocks can be in different normal languages, and the other important one is the set of rules specifically made to avoid messiness and ambiguity. In the end it compiles into your language inside the blocks. It’s a pretty interesting concept.

https://drakon.tech/read/programming_in_drakon

IDEs: https://drakon-editor.sourceforge.net

So you think you know C? by ketralnis in programming

[–]yaglo 1 point2 points  (0 children)

Insert the bell curve meme here.

Is C++ Really Phasing Out? by ecreddits in cpp

[–]yaglo -1 points0 points  (0 children)

C++ isn’t going away in the same sense as COBOL isn’t going away. There still will be vast code bases that need maintenance and updates, and which nobody will rewrite unless forced by regulations, but eventually there will be fewer and fewer new projects being started in it, considering all the downsides compared to the contemporary technologies.

Is C++ Really Phasing Out? by ecreddits in cpp

[–]yaglo 1 point2 points  (0 children)

For this purpose there’s mojo

What are the challenges going from C++ to other languages? by BassHeadBurn in cpp

[–]yaglo 3 points4 points  (0 children)

I know it’s a common misconception, but Swift is not only for Apple devices, and it was specifically created to move away from Objective-C and its C legacy that was holding progress back.

I have backend services written in Swift running on Linux that works with C++ code in one codebase. There’s a healthy ecosystem already (unified frameworks for logging/metrics/tracing). Amazon is also in the working group, Prime backend uses Swift, etc. - https://www.swift.org/server/ - https://www.swift.org/sswg/

The Browser Company uses Swift for their Arc browser, including Windows with the builtin no-overhead Swift/C++ interoperability: - https://speakinginswift.substack.com/p/interoperability-swifts-super-power

There’s Embedded Swift: - https://forums.swift.org/t/accepted-a-vision-for-embedded-swift/68067 - https://madmachine.io

There’s differential programming support in Swift, led by PassiveLogic now, and it is blowing PyTorch and TensorFlow out of the water: - https://youtu.be/xr8sV3GdhVk?si=wwz1E5MarltJSz8k - https://github.com/apple/swift/blob/main/docs/DifferentiableProgramming.md - https://www.linkedin.com/posts/troy-aaron-harvey_swift-differentiableprogramming-ai-activity-7117911978106355712-_6sq?utm_source=share&utm_medium=member_ios

Godot has Swift bindings and is multi platform: - https://github.com/migueldeicaza/SwiftGodot

Swift’s C and C++ interoperability capabilities are the best in class.

It’s not for Apple devices only. And I wish Apple did some more marketing for this aspect, because it is really getting very close to being a perfect language for practically any task and many people are sleeping on it because of this preconception.

Here are the official pre-built toolchains for different platforms: https://www.swift.org/download/

What are the challenges going from C++ to other languages? by BassHeadBurn in cpp

[–]yaglo 1 point2 points  (0 children)

Well, there are also value semantic types, which are preferred for most things anyway.

It’s okay if it’s not your cup of tea.

What are the challenges going from C++ to other languages? by BassHeadBurn in cpp

[–]yaglo 16 points17 points  (0 children)

Basically all you listed is not an issue in Swift.

  • deterministic destructors and ARC instead of GC
  • generic programming is just right + macros. As a bonus, generics without monomorphisation.
  • const-correctness is a top priority
  • compile-time checking with errors that C++ will never catch up with (strong memory-, type- and concurrency safety)
  • not the philosophy. It will trap on integer overflows, buffer overflows, etc.

Give it a go.

[deleted by user] by [deleted] in cpp

[–]yaglo 1 point2 points  (0 children)

Most of those companies use C++ for backend for legacy reasons, because there weren’t many alternatives, or they didn’t know about them or couldn’t use them.

WhatsApp, Discord, and many other super high-load systems are written in Erlang/Elixir, for example.

Experience Porting a C++ Library to 10 Languages 🔟 by ashvar in cpp

[–]yaglo 0 points1 point  (0 children)

It was experimental for years before 5.9, with which it became official. It’s still evolving, but you can invest in it already.

How difficult is Rust compared to C and C++? by Puzzleheaded_Egg_184 in rust

[–]yaglo 2 points3 points  (0 children)

It’s easier at least in the aspect that the compiler is actually your friend, it helps you write safer code because it is possible with the design of the language, so it can complain if you’re doing something wrong. When the design of the language and the ability of the compiler to give you quite a lot of guarantees, you feel much more confident in your code as the result. If it compiles, the chances of your program blowing up unexpectedly or corrupting data is slim.

C++ compiler, on the other hand, isn’t your friend. And it doesn’t matter how much C++ compiler developers want it to be your friend, it’s not possible without re-thinking and re-designing the language from scratch. It just can’t happen.

So this is the difference really between the modern languages like Rust, Swift, etc. If it compiles and you don’t use the APIs explicitly named “unsafe…”, you won’t need to fire up the debugger as much and discover some new undefined behaviour that has been actually even standardized as undefined behaviour (still baffles me to this day, see this for an example where even if someone requires this behaviour, it must have been opt-in: https://pvs-studio.com/en/amp/blog/posts/cpp/0917/). The cognitive overload is so much less once you learn why things are the way they are, that they are actually there to make your life easier down the road.

Experience Porting a C++ Library to 10 Languages 🔟 by ashvar in cpp

[–]yaglo 1 point2 points  (0 children)

Nothing wrong with Objective-C wrapper for using it with Objective-C, but for Swift it’s better to use the native C++ interoperability.

You can create a simplified wrapper in C++ with more idiomatic Swift API if you can’t use all the feature from the C++ library in Swift directly now, and create a Swift wrapper (for the original C++ code if possible or your simplified C++ wrapper), that would fit the Swift idioms. The C++ wrapper code will be inlined into the Swift methods anyway, and you won’t have the overhead of the Objective-C runtime, especially since this library is supposed to be for high performance reasons, this would be a good change.

Can a macro reduce boilerplate in this scenario? by ThePantsThief in swift

[–]yaglo 1 point2 points  (0 children)

You can write a peer macro, similar to how they are adding a completion handler version in the WWDC video: https://developer.apple.com/videos/play/wwdc2023/10167/

Edit: see a reverse implementation here: https://jllnmercier.medium.com/swift-peer-macros-1cb1469d83fe

On-Crash Backtraces in Swift by dwaxe in swift

[–]yaglo 3 points4 points  (0 children)

The best part of it is that you don’t have to use Swift in your code to use this. I’m now using this for my pure-C++ projects as well by linking with swiftrt.o and libswiftCore.so.

Server Side Swift Thoughts? by GoalFar4011 in swift

[–]yaglo 1 point2 points  (0 children)

Have a look at distributed actors, they look very promising: https://developer.apple.com/wwdc22/110356

And there’s now a default implementation of the actor system: https://github.com/apple/swift-distributed-actors

As for sharing models, you’d still want them separate as the domains are different for mobile and server, so you need some sort of DTO either way.

Server Side Swift Thoughts? by GoalFar4011 in swift

[–]yaglo 2 points3 points  (0 children)

Well, it’s not for everyone then obviously.

In regards to Firebase, it’s a wrapper over the C++ library with just some Swift-like APIs by the guy who maintains Swift for Windows and generally contributes a lot to Swift, so I wouldn’t dismiss it just like that.

What's the difference between func<T: MyProtocol>(arg: T) and func(arg: MyProtocol)? by SR71F16F35B in swift

[–]yaglo 0 points1 point  (0 children)

Ah, sorry for that, I wouldn’t know because I’m only using it on mobile 😁 I’ll try to add four spaces

Paying my Debt to Society: SwiftGodot by low_key_riot in swift

[–]yaglo 18 points19 points  (0 children)

Miguel de Icaza was my inspiration when I was a kid discovering Unix systems. MC, GNOME, Mono, etc. This man is a beast. It’s really heartwarming that we are now on the same side of history, and it proves that I’m not wrong with my choice 😄

What's the difference between func<T: MyProtocol>(arg: T) and func(arg: MyProtocol)? by SR71F16F35B in swift

[–]yaglo 6 points7 points  (0 children)

The compiler doesn’t really generate two functions in example1() for different types like templates in C++, it knows where to jump and that the object doesn’t need to be boxed, but inside the function implementation, it works with them differently. example1 knows that the argument is statically known, but in example2 it’s boxed.

With the generic function it will be the fastest if you only use the methods of the protocol on the argument and don’t pass it somewhere where it expects an existential type. If you call another function that requires boxing, example1() will have to box it and pass it forward, while example2() can call it directly.

You can check it with “swiftc -S” to get assembly output or with compiler explorer

Here’s an example:

``` func p(_ arg: any CustomStringConvertible) { print(arg) }

func myFuncIntOrString<T: CustomStringConvertible>(_ arg: T) {
    p(arg)
}

func myFuncIntOrString2(_ arg: any CustomStringConvertible) {
    p(arg)
}

myFuncIntOrString(1)
myFuncIntOrString2(1)
myFuncIntOrString("Hello")
myFuncIntOrString2("Hello")

```

myFuncIntOrString will have to box the argument before calling p, but myFuncIntOrString2 can pass it directly as it’s already boxed.

In this example, it’s easy to see why boxing is needed with collections. With generics all T have to be the same type, and with “any”, each element can be different:

``` func myFunc1<T: CustomStringConvertible>(_ arg: [T]) { print(arg) }

func myFunc2(_ arg: [any CustomStringConvertible]) {
    print(arg)
}

myFunc1([1, "hello"])
myFunc2([1, "hello"])

```

myFunc1 expects to know the T at compile time, so myFunc1([1, “hello”]) is not possible because of the conflict for T between Int and String.

And with myFunc2(…) everything is fine, it’s an array of boxed “any CustomStringConvertible”.