Rust-03: Improving the simple program
In the last post we created a simple program that would accept an input like 5+5 and calculates the result. In this post we will improve this program. To prepare for adding more operators we need to improve the input-parsing. Currently, we just split the input-string at the plus-sign. If we want to know the operator, we have to choose another approach. In this case I chose regex: #[derive(Debug)]struct Operation{left: i32,operator: char,right: i32,}implOperation{fn from_string(input: &String)-> Option<Operation>{letregex=Regex::new(r"^\s*(\d+)\s*([+])\s*(\d+)\s*$"). Continue readingRust-02: The beginning
At first, I didn’t like Rust. Managing memory myself is something I don’t want to do. After a first look at Rust and setting it aside for a few weeks, it appeared back on my radar. I thought: “This time I’m looking deeper into it”. So I started by reading the Rust Book; and I’m still reading it and find new concepts that are really clever. One of the first things I discovered is that I do not need to manage memory myself. Continue readingRust-01: Why am I learning Rust?
This is a good question, a very good question. Why am I learning Rust? To begin with, I programmed in a lot of languages so far: C++, Python, Swift, Java, Kotlin and TypeScript to name a few. All languages have some features I missed when programming in other languages. Currently, my favorite languages are Kotlin and TypeScript; with Kotlin having the lead. These languages are expressive, and really nice to write. Continue readingQt Signals & Slots: How they work
The one thing that confuses the most people in the beginning is the
Signal & Slot mechanism of Qt. But it’s actually not that difficult to
understand. In general Signals & Slots are used to loosely connect
classes. Illustrated by the keyword emit
, Signals are used to
broadcast a message to all connected Slots. If no Slots are connected,
the message “is lost in the wild”. So a connection between Signals &
Slots is like a TCP/IP connection with a few exceptions, but this
metaphor will help you to get the principle. A Signal is an outgoing
port and a Slot is an input only port and a Signal can be connected to
multiple Slots.
Should I use Qt containers or the std ones?
If you come from plain vanilla C++, you only know the C++ Standard
Library with its containers like std::vector
. If you know how to use
them, you can accomplish your tasks pretty fast. But if you’re coming
from another language, the naming might be a bit odd. The Qt containers
offer both, C++ style and Java style naming of methods. So coming from
another language the Qt one’s might be easier to use.