issue150:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue150:c_c [2019/10/29 08:03] – créée d52fr | issue150:c_c [2019/10/31 16:18] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Je commence | + | **Every year I make a point to learn a new programming language or re-visit one I haven’t used for years. A couple of years ago, the new language I wanted to play around with was Rust. I followed a few tutorials, got comfortable with the syntax, did a test project, and then...stopped. Between my job and my comfort in Python, I just didn’t have a lot of situations where I felt like I wanted to take the time to apply a new language, and defaulted to Python instead. As my day job currently consists of Python (and a few other languages), I have found myself revisiting Rust simply as a way for my personal projects to not feel quite so much like work. As such, I’d like to give my readers my take on Rust.** |
+ | |||
+ | Chaque année, je mets un point d' | ||
+ | |||
+ | **What is Rust? | ||
+ | |||
+ | Rust is a systems language that aims to be safer and more stable than C++. It does this by checking for possible errors at compile time, and giving errors/ | ||
+ | |||
+ | Qu' | ||
+ | |||
+ | Rust est un langage système qui se veut plus sûr et plus stable que le C++. Il le fait en vérifiant les erreurs possibles au moment de la compilation et en signalant immédiatement les erreurs/ | ||
+ | |||
+ | **Why use Rust? | ||
+ | |||
+ | If you’re coming from an interpreted language like Java or Python, here are a few things that are different for Rust (or any systems language, really): | ||
+ | • Speed - as Rust is a lower-level language, you can typically assume it will perform faster (once compiled) than an interpreted language, and with less memory overhead. | ||
+ | • If you build a Rust binary (without external dependencies like OpenSSL) it will depend only on system libraries. Meaning running a binary will not require Rust to be installed on the target system. While interpreted language can emulate this effect, they are actually being compiled with a portable version of the interpreter.** | ||
+ | |||
+ | Pourquoi utiliser Rust ? | ||
+ | |||
+ | Si vous arrivez d'un langage interprété comme Java ou Python, il y a vraiment dans Rust (ou, en fait, dans tous les langages système) quelques points différents : | ||
+ | ••La vitesse - Comme Rust est un langage de bas niveau, vous pouvez en général vous attendre à ce qu'il fonctionne plus rapidement (une fois compilé) qu'un langage interprété, | ||
+ | ••Si vous construisez un binaire Rust par compilation (sans dépendance externe comme OpenSSL), il ne dépendra que des bibliothèques du système. Ce qui signifie que, pour faire tourner un binaire, vous n'avez pas besoin que Rust soit installé sur le système cible. Bien qu'un langage interprété puisse émuler cet effet, il est en fait compilé avec une version portable de l' | ||
+ | |||
+ | **• Errors on compilation - in both Java and Python, the interpreter will catch some critical errors. However, you can still run into runtime issues where the application crashes. Rust aims to catch these at compilation time and force the developer to fix them. | ||
+ | • Lastly, just like C in Python, you could theoretically use Rust with Python (admittedly, | ||
+ | |||
+ | ••Les erreurs pendant la compilation - Dans Java, comme dans Python, l' | ||
+ | ••Enfin, | ||
+ | |||
+ | If you’re coming from another systems language like C++, here is my best understanding of what’s different (based on my admittedly limited C++ knowledge): | ||
+ | • Rust is memory/type safe (by default - you can integrate unsafe practices if required). | ||
+ | Rust will catch most errors at bu• ild time. | ||
+ | • Rust offers a build tool and package manager called cargo. | ||
+ | • A massive library of easily-accessible 3rd party libraries via cargo. | ||
+ | • Performance-wise, | ||
+ | |||
+ | Si vous venez d'un autre langage système comme C++, voici ma meilleure compréhension de ce qui diffère : (à partir de ma connaissance limitée de C++) : | ||
+ | ••Rust est sûr pour la mémoire/le type (par défaut - vous pouvez intégrer des pratiques non sûres, au besoin). | ||
+ | ••Rust détectera un maximum d' | ||
+ | ••Rust propose un outil de compilation et un gestionnaire de paquets appelé cargo. | ||
+ | ••Une énorme bibliothèque de bibliothèques tierces facilement accessibles via cargo. | ||
+ | ••Côté performance, | ||
+ | |||
+ | **Resources | ||
+ | |||
+ | Books: | ||
+ | “The Rust Programming Language” - the official rust book - https:// | ||
+ | “A Gentle Introduction to Rust” - https:// | ||
+ | |||
+ | Videos: | ||
+ | The official Rust YouTube channel: https:// | ||
+ | |||
+ | Practice: | ||
+ | Exercism has a track for Rust: https:// | ||
+ | |||
+ | Ressources | ||
+ | |||
+ | Livres : | ||
+ | “The Rust Programming Language” - L' | ||
+ | “A Gentle Introduction to Rust” - https:// | ||
+ | |||
+ | Vidéos : | ||
+ | Le canal officiel de Rust sur YouTube : https:// | ||
+ | |||
+ | Entraînement : | ||
+ | Exercism a un parcours sur Rust: https:// | ||
+ | |||
+ | **My Opinion of Rust | ||
+ | |||
+ | My main language of choice has been Python for quite a long time (outside of the web), and I’ve always meant to sink some time into a systems language, but never really enjoyed C++. So Rust seems like an ideal choice – modern language, similar C++ power. Cargo, especially, makes Rust feel a lot more modern. | ||
+ | |||
+ | That being said – what if you don’t know any other programming languages? Or what if you’re not sure you want to learn a systems language? Here are a few points as to why I think Rust could be a good language to learn on: | ||
+ | • Type and memory safe - learning something like C++ can be frustrating because a mistake can mean a segmentation fault, and debugging them can drive you crazy. Rust will do its best to prevent these from ever happening.** | ||
+ | |||
+ | Mon opinion sur Rust | ||
+ | |||
+ | Mon langage préféré est Python depuis très longtemps (en dehors du Web) et j'ai toujours voulu me plonger dans les langages système, mais je n'ai jamais aimé C++. Aussi Rust semble être le choix idéal - un langage moderne, à la puissance similaire au C++. Cargo, particulièrement, | ||
+ | |||
+ | Cela dit, que se passe-t-il si ne vous connaissez pas d' | ||
+ | ••Sûr pour la mémoire et le type : l' | ||
+ | |||
+ | **• Cargo - when you compile Rust, you get formatted output telling you what line (not just the line number, but the actual code too), with markup and annotations telling you what issue the compiler sees. It’s essentially guiding you through learning the code. It may feel disheartening at first to need multiple passes to fix your code, but eventually you’ll actually understand the issues. | ||
+ | • Computer science - if you’re interested in the topic at a deeper level, Rust is a much better choice than Python for a simple reason – data types. Python will just select the right type based on the value given. Rust can do the same to some degree, but you’ll certainly want to learn the difference between signed and unsigned ints, and select the correct type for a situation (i.e. an 8-bit unsigned int instead of a 32-bit int). This knowledge can make you a much better programmer long-term, because you’ll understand memory usage at a deeper level.** | ||
+ | |||
+ | ••Cargo - Quand vous compilez Rust, vous disposez d'une sortie formatée qui vous dit quelle ligne (pas simplement le numéro de ligne, mais aussi le vrai code), avec un signet et des annotations qui vous indiquent quelle est le problème détecté par le compilateur. En gros, il vous guide dans votre apprentissage du code. Au début, ça peut paraître démoralisant de devoir faire plusieurs passes pour stabiliser votre code, mais, à la longue, vous comprendrez vraiment les problèmes. | ||
+ | ••Informatique - Si vous êtes intéressé par le sujet à un niveau plus élevé, Rust est de loin un meilleur choix que Python pour une raison simple : les types de données. Python ne fait que sélectionner le type correct sur la base de la valeur fournie. Rust peut faire de même jusqu' | ||
+ | |||
+ | **• Community - the entire Rust community is founded on the idea of guiding people through the code, and as such it is one of the most open and welcoming communities I know of. If you’re someone who prefers to be able to ask a person questions when learning, you’ll typically always find someone to answer your question in this community (i.e. on the Rust subreddit).** | ||
+ | |||
+ | ••Communauté - Toute la communauté de Rust est basée sur l' | ||
+ | |||
+ | |||
+ | **Ready for Prime Time? | ||
+ | |||
+ | If you’re a professional programmer and you want to start using Rust at work, you may be asking yourself if it’s ready for that. Here are a few of my thoughts on the matter: | ||
+ | • From an architecture perspective it’s more ready than C++ ever was | ||
+ | • If you have a specific tool or library you need to use with your software, make sure you can integrate it with Rust (i.e. check crates.io for libraries). | ||
+ | • While the very first version of Rust was released in 2012, it hit version 1.0 only in 2015. As such, it’s hard to say whether it’s here to stay. I’m of the opinion that the approach Rust has is the way we need to go for the future, and, being an open-source project, should continue to be developed as long as people are using it. Depending on how long-term your profession needs to think, you’ll need to make a decision yourself on how mature the language is.** | ||
+ | |||
+ | Prêt pour le grand jeu ? | ||
+ | |||
+ | Si vous êtes un programmeur professionnel et que vous voulez commencer à utiliser Rust au travail, vous devriez peut-être vous demander si tout est prêt pour ça. Voici quelques-unes des mes réflexions sur le sujet : | ||
+ | ••D' | ||
+ | ••Si vous avez besoin d' | ||
+ | ••Alors que la toute première version de Rust a été publiée en 2012, il n'a atteint la version 1.0 qu'en 2015. De sorte qu'il est difficile de dire s'il sera pérenne. Mon opinion est que l' | ||
+ | |||
+ | **• If performance is a big factor, make sure you want to invest the time into learning how to optimize Rust. | ||
+ | • If you’re in a position where you have a codebase where you can mix and match (i.e. Python with C libraries), you could implement one small library in Rust the next time you need a new one and try it out that way. | ||
+ | |||
+ | The tl;dr is: It depends on your specific scenario. In that position, you’ll need to know enough to decide for yourself.** | ||
+ | |||
+ | ••Si la performance est un facteur important, assurez-vous que vous voulez investir le temps nécessaire pour apprendre comment optimiser Rust. | ||
+ | ••Si vous êtes dans un emploi où vous avez une base de code dans laquelle vous pouvez faire des mélanges et des correspondances (par exemple, du Python avec bibliothèques en C), vous pouvez implémenter une petite bibliothèque en Rust la prochaine fois que vous aurez besoin d'une nouvelle et testez-le de cette façon. | ||
+ | |||
+ | Bref, ça dépend de votre scénario spécifique. À ce poste, vous aurez besoin d'en savoir assez pour décider seul. | ||
+ | |||
+ | **Conclusion | ||
+ | |||
+ | I sincerely hope that Rust continues to grow in popularity, as its methodology is a big step forward (in my opinion). For any of my readers who know Rust, or learn it - let me know how it goes! Similarly, if anyone has any requests for an article, questions, or just wants to share their opinion, you can reach me at lswest34+fcm@gmail.com.** | ||
+ | |||
+ | Conclusion | ||
+ | |||
+ | J' |
issue150/c_c.1572332635.txt.gz · Dernière modification : 2019/10/29 08:03 de d52fr