Learn coding in Python, Go and Rust from Serdar Yegulalp, software dev specialist and senior writer at InfoWorld.
Developers who use Microsoft Windows as their main platform often grouse about how Windows's malware protection can interfere with their work. The new Dev Drive feature in Windows 11 lets you create a special volume, either on a physical disk or a virtual drive, where your files are only minimally scanned for malware. Learn how to set up and use Dev Drive in this video, and what scenarios it's best for.
A new API introduced in Python 3.12 provides developers with efficient, low-impact ways to hook events in Python code, monitor behavior, and write powerful profiling and coverage tools. Watch this video to see a quick tour of the new API and how to use it, with an example where we write a hook function that fires on every function call in an application. For further information on the new API, see PEP 669: https://peps.python.org/pep-0669/
Python's linting and code formatting tools are typically written in Python, and can slow down significantly on large code bases. Ruff, a new linter and code formatter for Python, is written in Rust, and runs many times faster than comparable Python tools. But it also adheres closely to existing Python standards for code-checking and formatting. This video shows Ruff in action, and how it stacks up against existing Python tools for speed.
Cython compiles Python to C for high performance, and Cython modules can be redistributed with your code in a Python package -- a source distribution or "wheel" file -- so others can use it, too. You can deliver both the generated C source code, and a precompiled binary for a specific platform, for the widest possible re-use. Learn in this video how to set up your project when Cython code is present, and what tools you'll need to build wheels and source distributions from it. Also be sure to check out some of our other videos about Cython: https://www.infoworld.com/video/116719/cython-3-0-compiling-python-to-c-the-next-generation https://www.infoworld.com/video/112519/cythons-new-pure-python-syntax-faster-python-made-easier
WebAssembly has been described as the future of the web, and so much more besides. But for a long time it's been a little hard to work with because of its toolchain. In this video we'll look at AssemblyScript, a JavaScript-like language, based on Microsoft's TypeScript, that makes writing and deploying WebAssembly modules as easy as writing JavaScript itself.
How do you do more than one thing at a time in Python? In this video we lay out the two main ways we can do more than one thing at a time -- parallelism, and concurrency -- and show how Python has three mechanisms for doing those things. Learn how threading, async, and multiprocessing all make it possible to juggle multiple tasks or run them side by side.
Writing interactive web apps requires JavaScript, and often a lot of it. Too much of the time spent developing a web app gets eaten by creating many of the same behaviors across sites, like fetching content from an endpoint and inserting it into a page. The Htmx JavaScript library makes it easy to add common interactive behaviors on web pages, often with nothing more than a couple of custom HTML tags. This video shows a few basic examples, from type-to-search input boxes to infinite-scroll displays.
NumPy, the Python library for fast array and matrix math, is a staple presence in the data science world. A new major revision of NumPy, version 2.0, is on the horizon. Here's what breaking changes to expect with this new version, what new features might be offered, and how to prepare your projects for them.
Want an all-in-one way to create, manage, and package Python projects -- which even automates fetching and setting up Python itself? Rye, an experimental new project written in Rust, provides a command-line tool for obtaining Python runtimes, setting up new projects, adding requirements, publishing to PyPI, and many other common tasks that normally have to be done manually. In this video, you'll see a quick example of Rye in action, and what kinds of tasks it can automate.
Mojo, a newly developed language aimed at machine learning and data science tasks, promises C++- and Rust-like speeds with the syntax of Python. Previously, the only way to try Mojo was through its online portal. Now the language's developer, Modular, has released a locally installable version of Mojo, although it's currently only available for Linux. In this video we take a simple walkthrough of its basic operations, running in WSL on Windows, and see how it interoperates with Python and compiles to native binaries.
Unlike the various breeds of Linux, Microsoft Windows hasn't really had a package management mechanism, except for ad-hoc third party offerings or the proprietary Microsoft Store. Winget offers a Microsoft-authored open source mechanism for managing, retrieving, and updating whole sets of software in Windows. Learn the basics of how Winget works, along with examples of how third-party apps can be built atop Winget for even easier package management solutions, too.
The Go programming language is normally used with its own libraries and packages, but it can interface with the world of C libraries and programs, too. Learn in this video how to use the cgo package to connect with C libraries, interface with them through your Go programs, and handle a few common issues with crossing the boundaries between the two languages.
Cython makes it easy to create C extensions for Python, using the Python syntax you already know. It also lets you create convenient Python wrappers for C libraries using their header files. Learn in this video how to create Python function bindings to a C library, by writing a Cython module and using its external function binding syntax.
CPython's Global Interperter Lock, or GIL, has long prevented it from being a truly parallel, multicore language. A new proposal, PEP 703, describes a roadmap to a new design for CPython that can use multithreading to properly unlock parallelism. Watch in this video as we use a prototype build of the "no-GIL" edition of Python to demonstrate how much faster code can be if this proposal takes off. Read more here about PEP 703 and what it promises: https://www.infoworld.com/article/3704248/python-moves-to-remove-the-gil-and-boost-concurrency.html
The Cython project compiles Python to C -- not just to make code faster, but also to wrap external C libraries easily, and make it easy to write C extensions for Python generally. Cython 3.0 is a major overhaul of the project. Learn in this video what's new about it, why it's worth upgrading your Cython code to use its features, and some pitfalls to avoid along the way. I talk more about the basics of Cython here: https://www.infoworld.com/article/3250299/what-is-cython-python-at-the-speed-of-c.html More here about the CPython limited API, and other future changes to CPython: https://www.infoworld.com/article/3694512/python-312-faster-leaner-more-future-proof.html
Moden Python projects use pyproject.toml files to describe a project's metadata, dependencies, and other valuable attributes. Learn in this video the basics of how pyproject.toml works -- how it can be used to describe a simple project, install its dependencies, and define other things such as command-line scripts used with the project.
Python's Django framework lets you spin up full-featured websites with database backends, user management systems, and many other features. In this fourth episode of a series, we'll explore how to take the basic message board app we've been using as an example, and add the ability for user information to be associated with a given post. We'll also show how to allow users to log in using Django's own utilities for processing logins. You can access the code used in this example here: https://github.com/syegulalp/django-2023/releases/tag/part-4
The Python embeddable redistribution (for Windows only) gives you a minimal, self-contained Python runtime that runs in a single directory. Learn how to use the embeddable redistribution to package up and distribute simple Python applications for re-use, and how to install third-party packages in the embeddable with pip if you need them. The Python embeddable redistribution can be downloaded from Python.org (it's listed as the "Windows embeddable package" with a given release version).
The Python buffer protocol provides a mechanism for directly accessing regions of memory wrapped by Python objects. Until now you couldn't create a Python class that exposed the buffer protocol directly, but Python 3.12 adds class methods to do just that. Learn in this video how to create classes that expose the buffer protocol, and how to manage the resulting memory views. Part 1: https://youtu.be/AHtChZg2cFA
Python 3.12 is out in beta now and worth trying out, with many new features that aid day-to-day productivity. In this video we'll look at two big new improvements: better, more robust error messages; and improvements to Python's f-string formatting system.
Microsoft Visual C++ (MSVC for short) is the default C/C++ compiler for Windows, but it isn't included by default in that OS -- a common developer's complaint. And installing Microsoft Visual Studio, which includes MSVC, can be overkill if you just need MSVC by itself. In this video we'll walk through the fast way to install just the MSVC build tools, typically all you need to compile C/C++ in Windows from the command line.
Mojo, a new language designed to be a more powerful Python, is now available in a limited preview. In this video, we take a look at Mojo's syntax and design, and explore the ways it aims to unite convenient programming with the speed and power needed for data science and machine learning.
How much thought do you give to the fonts you use in your code editor? Here's a look at some of the most popular and versatile fonts for working with code, from basic all-around typefaces to advanced, highly hackable and customizable fonts with web-based tooling.
Python's Django framework lets you spin up full-featured websites with database backends, user management systems, and many other features. In this second episode of a series, we'll examine how to create a basic route for a Django app, and how to set up the way data for the app is represented in Django's database system. Part 1: https://youtu.be/055sCJfk0f0
Python's Django framework lets you spin up full-featured websites with database backends, user management systems, and many other features. In this first episode of a series, we'll walk through the basics of setting up a Django project -- creating the project, defining apps within it, and preparing the database and user account system.
The Poetry utility for Python provides a high-level way to set up Python projects, manage their dependencies, and redistribute them through PyPI, all through a single handy command-line interface. This video provides a quick tour of Poetry's basic functionality for a sample project, including working with Poetry's managed virtual environments in an instance of Visual Studio Code.
Cython lets you write C extension modules for Python using Python itself. A common use for this is to take Python code and rewrite it in C for speed. Learn in this video what scenarios are the best fit for using Cython to speed up Python, and how Cython's type-decorating syntax helps you achieve this.
Regular expressions give you a powerful system for matching patterns against text. But there are cases where a regex (as it's called) can be misused, where it's not the only tool you should be using, or when it's just not the right tool, period. Learn about 4 cases where regex isn't a great fit, when it needs a fine-grained approach, or when you need something else altogether.
Tired of having your Python projects littered with .pyc cache files and __pycache__ directories? This video teaches you about a little-used but powerful Python feature that lets you keep all your Python cache files in a single directory, away from your project directories and under central control.
The Codon project offers a highly Python-compatible language, built from the ground up, that compiles to native machine code for speed. It's not a drop-in replacement for Python, but it promises some significant speedups for math-and-stats applications. Could Codon's approach be how Python gets faster in general? Or is Codon more of a complement to the existing Python ecosystem rather than a long-term replacement? Watch and learn more.
Want to create cross-platform apps with web UIs, but don't like Electron's sheer size? In this video we'll check out Tauri, a framework for building cross-platform, web-powered apps with Rust. Tauri apps have a fraction of the size of Electron apps, and the Tauri toolset lets you use anything from vanilla HTML to frameworks like Svelte for your app's frontend. Watch us build a simple Tauri app, modify its HTML components without recompiling, and create an .MSI installable package from it.
Go's internal assembly language is generated from Go source code as an intermediate step towards creating a machine-specific binary. You can dump out the generated assembly and inspect it using Go's tooling, and use the generated code to get an idea of what kinds of optimizations are being applied to your code. Learn the basics of how this works in this video.
Rust has a number of web frameworks. Actix Web is the most popular and widely used. Learn in this video how a simple web service can be set up in Actix, and how Actix makes use of Rust's async programming features for maximum performance.
A common frustration for the Python developer is circular imports -- when two modules each try to import something from the other simultaneously. Learn in this video how this problem arises in Python applications, and several methods you can use to fix or avoid it entirely.
Python's set data type lets you store collections of objects with unique elements. Go has no such data type natively, but the golang-set package gives you set-like functionality in Go. Learn the basics of working with golang-set in this video, including multi-set operations.
Hashmaps in Rust let you store values (most any type) and access them by way of keys (like strings or integers). They're similar to their named counterparts in Java, or Python's dictionaries. Learn in this video the basics of working with Rust hashmaps, including their memory management details.
Math in Python can be made faster with Numpy and Numba, but what's even faster than that? CuPy, a GPU-accelerated drop-in replacement for Numpy -- and the GPU-accelerated features available in Numba. Learn how to use CuPy and Numba's CUDA extensions in conjunction for amazingly fast computations in your Python programs. For more on Numba, see our previous videos: Numba: Faster numerical code in Python made simple | InfoWorld, and https://www.infoworld.com/video/114779/how-to-use-numba-to-speed-up-numpy
.env files are used in many languages to provide applications with environment variable settings. Go doesn't have a native way to read .env files, but a third-party package gives you that functionality. Learn how to employ .env files for your Go application deployments in this quick introduction.
Traits give you a way to group together behaviors common to many different custom datatypes. Learn in this video the basics of implementing and using traits on types you create.
Ever wanted to write a script and automatically deploy it so you can invoke it by just typing a simple command at the console? Python's setuptools library lets you do that with any Python package. Learn in this video how to set up a Python program to run from the command line using the entry point functionality in setuptools.
Building command-line applications is a common use case for Go. The Cobra package offers tools for making command-line interfaces without having to manually process input and wrangle strings. This video tours the basics of this utility library, used by such popular Go projects as Kubernetes, to put together a CLI for a simple utility.
Python's built-in profiling tools only provide information at the function-call level. A third-party utility, line_profiler, can shed light on what specific lines in your code take up the most runtime. Learn how to analyze your programs with line_profiler in this quick introduction. line_profiler is hosted on Github at https://github.com/pyutils/line_profiler and on PyPI at https://pypi.org/project/line-profiler/
Anonymous functions in Go let you define a function in-line, in the context of another block of code. Learn how anonymous functions can be used, and what advantages they can provide over regular named functions.
Mypyc, available in the mypy package, lets you compile Python modules into C extensions. With the right type hints, ordinary Python code can be sped up by anywhere from two to twenty times, or even more, depending on the job at hand. Learn in this video how to get started using Mypyc for low-effort performance boosts.
Arrays and vectors in Rust let you group together collections of elements in contiguous blocks of memory, but have different behaviors. Learn how to choose between an array or a vector when creating Rust data structures -- how arrays give you a predictable compile-time structure, while vectors are more flexible at runtime.
The third-party Gorm library gives Go developers a convenient set of abstractions for working with databases, without having to write raw SQL. Learn in this introductory video how to set up and query a simple SQLite database with Gorm, which also supports a wide variety of other common database systems.
Numpy gives you fast operations for analytics and datq science, but there are times when you want to go even faster. Learn how the Numba just-in-time compilation system can be used hand-in-hand with Numpy to speed things up even further.
Rust's match keyword lets you make decisions based on the contents of variables. But it can also be used to make decisions based on a variable's type, too. Learn how using match with the Option type allows you to use types at compile time to improve the performance and safety of your code.
Many languages offer "nullable" variables, which can be set to some value, or nothing at all. Rust's Option type provides a safe and powerful way to encode a given variable as nullable. Learn the basics of using Option and its .unwrap methods here. (A future video will explore the use of Option with the match statement.)
The "del" keyword in Python is the source of much misunderstanding. What does it actually do, and where do you want to really use it?
Sponsored Links