{"id":218,"date":"2023-09-01T08:53:49","date_gmt":"2023-09-01T08:53:49","guid":{"rendered":"https:\/\/kurtgrung.com\/blog\/?p=218"},"modified":"2023-11-19T21:30:13","modified_gmt":"2023-11-19T21:30:13","slug":"rust","status":"publish","type":"post","link":"https:\/\/kurtgrung.com\/blog\/rust\/","title":{"rendered":"in rust we trust"},"content":{"rendered":"\n<p>Rust is a programming language that focuses on performance, safety, and concurrency. It was first released in 2010 by Mozilla and has since gained popularity for its ability to provide low-level control over system resources while preventing common programming errors like null pointer dereferences, data races. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Rust has gained popularity in blockchain and web3 development due to its emphasis on memory safety, performance, and low-level control. Its ownership system ensures secure memory management, making it suitable for smart contracts. Rust&#8217;s concurrency support is advantageous for handling multiple transactions, and its cross-platform compatibility aligns with the diverse nature of blockchain ecosystems. The active community, robust tooling, and formal verification capabilities contribute to Rust&#8217;s appeal in building secure and efficient blockchain applications.<\/p>\n\n\n\n<p><br>Rust<strong> Hello World<\/strong><\/p>\n\n\n\n<p>Create the file <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># <em>hello.rs<\/em>\nfn main() {\n    println!(\"Hello World!\");\n}<\/code><\/pre>\n\n\n\n<p><br>Compile the binary<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ rustc hello.rs<\/code><\/pre>\n\n\n\n<p><br>Run it in terminal <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ .\/hello<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Outputs: <em><strong>Hello World!<\/strong><\/em><\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p><br><br>Run Rust in the browser? (basic Web Server kinda like Node.js).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cargo new hello-world\ncd hello-world<\/code><\/pre>\n\n\n\n<p><br>Add the dependencies to the <code><em>Cargo.toml<\/em><\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;dependencies]\nactix = \"0.13.1\"\nactix-web = \"4.4.0\"<\/code><\/pre>\n\n\n\n<p><br>Update the, <code><em>main.rs<\/em><\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>use actix_web::{web, App, HttpServer, Responder};\n\nasync fn hello() -&gt; impl Responder {\n    \"Hello, world!\"\n}\n\n#&#91;actix_web::main]\nasync fn main() -&gt; std::io::Result&lt;()&gt; {\n    HttpServer::new(|| {\n        App::new().service(web::resource(\"\/\").to(hello))\n    })\n    .bind(\"127.0.0.1:8080\")?\n    .run()\n    .await\n}<\/code><\/pre>\n\n\n\n<p><br>Run it<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cargo run<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Visit <code><em>http:\/\/127.0.0.1:8080<\/em><\/code> in your web browser, and you should see the <em><code>\"Hello, world!\"<\/code><\/em> message.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Rust is a programming language that focuses on performance, safety, and concurrency. It was first released in 2010 by Mozilla and has since gained popularity for its ability to provide low-level control over system resources while preventing common programming errors like null pointer dereferences, data races. Rust has gained popularity in blockchain and web3 development [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,51],"tags":[78,75,74,79,76],"class_list":["post-218","post","type-post","status-publish","format-standard","hentry","category-code","category-research","tag-blockchain","tag-programming-language","tag-rust","tag-smart-contracts","tag-systems-programming"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/posts\/218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":10,"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/posts\/218\/revisions\/231"}],"wp:attachment":[{"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kurtgrung.com\/blog\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}