Open-source News

FreeType 2.13 Released With New Qt-Based Font Program

Phoronix - Thu, 02/09/2023 - 19:00
FreeType 2.13 is out today as the newest version of this widely-used font rendering library. New to FreeType 2.13 is a new Qt-based demo program...

More Aquacomputer Devices To Be Supported With Linux 6.3

Phoronix - Thu, 02/09/2023 - 18:50
Over the past two years since an Aquacomputer HWMON driver was first introduced to the mainline Linux kernel, it's continued to be extended to support more products from this German PC cooling/peripheral retailer. With Linux 6.3 additional Aquacomputer components are now supported by this kernel driver...

Start developing for WebAssembly with our new guide

opensource.com - Thu, 02/09/2023 - 16:00
Start developing for WebAssembly with our new guide sethkenlon Thu, 02/09/2023 - 03:00

Over the past few decades, the web browser has endured as the most popular cross-platform application. Looking at the browser from a different angle, it is one of the most popular platforms for application delivery. Think of all the websites you use that take the place of activities you used to do with software running on your desktop. You're still using software, but you're accessing it through a browser, and it's running on somebody else's Linux server. In the eternal effort to optimize the software we all use, the world of software development introduced WebAssembly back in 2019 as a way to run compiled code through a web browser. Application performance is better than ever, and the options for coding go far beyond the usual list of PHP, Python, and JavaScript.

Programming and development Red Hat Developers Blog Programming cheat sheets Try for free: Red Hat Learning Subscription eBook: An introduction to programming with Bash Bash shell scripting cheat sheet eBook: Modernizing Enterprise Java An open source developer's guide to building applications A target and a language

One of the powerful but also most confusing things about WebAssembly is that the term "webassembly" refers to both a language and a target. WebAssembly is an assembly language, but not many people choose to write code directly in assembly. Even the assembly language is ultimately converted to a binary format, which is what a computer requires to run code. This binary format is also called WebAssembly. This is good, though, because it means that you can use your choice of languages to write something that's ultimately delivered in WebAssembly, including C, C++, Rust, Javascript, and many others.

The gateway into WebAssembly is Emscripten, an LLVM compiler toolchain that produces WebAssembly from your code.

Install Emscripten

To install Emscripten on your Linux or macOS computer, use Git:

$ git clone \ https://github.com/emscripten-core/emsdk.git

Change directory into the emsdk directory and run the install command:

$ ./emsdk install latest $ ./emsdk activate latest

Everything in the Emscripten toolchain is installed within the emsdk directory and has no effect on the rest of your system. For this reason, before you use emsdk, you must source its environment:

$ source ./emsdk_env.sh

If you plan on using emsdk often, you can also source its environment setup script in .bashrc.

To install Emscripten on Windows, you can run Linux in the WSL environment.

Visit the Emscripten website for more information on installation.

Hello world

Here's a simple "hello world" application in written in C++.

#include <iostream> using namespace std; int main() { cout << "Hello world"; return 0; }

Test it as a standard binary for your system first:

$ g++ hello.cpp -o world $ ./world Hello world

Seeing that it works as expected, use emcc to build it as WebAssembly:

$ emcc hello.cpp -o world.html

Finally, run it with emrun:

$ emrun ./world.html

The emrun utility is a convenience command for local testing. When you host your application on a server, emrun isn't necessary.

Learning more about WebAssembly

Developing for WebAssembly can go in many different directions, depending on what you already know and what you're trying to build. If you know C or C++, then you can write your project using those. If you're learning Rust, then you can use Rust. Even Python code can use the Pyodide module to run as WebAssembly. You have lots of options, and there's no wrong way to start (there's even a COBOL-to-WebAssembly compiler). If you're keen to get started with WebAssembly, download our complimentary eBook.

Developing for WebAssembly can go in many different directions, depending on what you already know and what you're trying to build. Download our new guide to WebAssembly.

Image by:

opensource.com

Programming What to read next A guide to WebAssembly This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Learn Tcl by writing a simple game

opensource.com - Thu, 02/09/2023 - 16:00
Learn Tcl by writing a simple game JamesF Thu, 02/09/2023 - 03:00

My path to Tcl started with a recent need to automate a difficult Java-based command-line configuration utility. I do a bit of automation programming using Ansible, and I occasionally use the expect module. Frankly, I find this module has limited utility for a number of reasons including: difficulty with sequencing identical prompts, capturing values for use in additional steps, limited flexibility with control logic, and so on. Sometimes you can get away with using the shell module instead. But sometimes you hit that ill-behaving and overly complicated command-line interface that seems impossible to automate.

In my case, I was automating the installation of one of my company's programs. The last configuration step could only be done through the command-line, through several ill-formed, repeating prompts and data output that needed capturing. The good old traditional Expect was the only answer. A deep understanding of Tcl is not necessary to use the basics of Expect, but the more you know, the more power you can get from it. This is a topic for a follow-up article. For now, I explore the basic language constructs of Tcl, which include user input, output, variables, conditional evaluation, looping, and simple functions.

Install Tcl

On a Linux system, I use this:

# dnf install tcl # which tclsh /bin/tclsh

On macOS, you can use Homebrew to install the latest Tcl:

$ brew install tcl-tk $ which tclsh /usr/local/bin/tclshGuess the number in Tcl

Start by creating the basic executable script numgame.tcl:

$ touch numgame.tcl $ chmod 755 numgame.tcl

And then start coding in your file headed up by the usual shebang script header:

#!/usr/bin/tclsh

Here are a few quick words about artifacts of Tcl to track along with this article.

The first point is that all of Tcl is considered a series of strings. Variables are generally treated as strings but can switch types and internal representations automatically (something you generally have no visibility into). Functions may interpret their string arguments as numbers ( expr) and are only passed in by value. Strings are usually delineated using double quotes or curly braces. Double quotes allow for variable expansion and escape sequences, and curly braces impose no expansion at all.

The next point is that Tcl statements can be separated by semicolons but usually are not. Statement lines can be split using the backslash character. However, it's typical to enclose multiline statements within curly braces to avoid needing this. Curly braces are just simpler, and the code formatting below reflects this. Curly braces allow for deferred evaluation of strings. A value is passed to a function before Tcl does variable substitution.

Finally, Tcl uses square brackets for command substitution. Anything between the square brackets is sent to a new recursive invocation of the Tcl interpreter for evaluation. This is handy for calling functions in the middle of expressions or for generating parameters for functions.

Procedures

Although not necessary for this game, I start with an example of defining a function in Tcl that you can use later:

proc used_time {start} { return [expr [clock seconds] - $start] }

Using proc sets this up to be a function (or procedure) definition. Next comes the name of the function. This is then followed by a list containing the parameters; in this case 1 parameter {start} and then followed by the function body. Note that the body curly brace starts on this line, it cannot be on the following line. The function returns a value. The returned value is a compound evaluation (square braces) that starts by reading the system clock [clock seconds] and does the math to subtract out the $start parameter.

Setup, logic, and finish

You can add more details to the rest of this game with some initial setup, iterating over the player's guesses, and then printing results when completed:

set num [expr round(rand()*100)] set starttime [clock seconds] set guess -1 set count 0 puts "Guess a number between 1 and 100" while { $guess != $num } { incr count puts -nonewline "==> " flush stdout gets stdin guess if { $guess < $num } { puts "Too small, try again" } elseif { $guess > $num } { puts "Too large, try again" } else { puts "That's right!" } } set used [used_time $starttime] puts "You guessed value $num after $count tries and $used elapsed seconds"

Programming and development Red Hat Developers Blog Programming cheat sheets Try for free: Red Hat Learning Subscription eBook: An introduction to programming with Bash Bash shell scripting cheat sheet eBook: Modernizing Enterprise Java An open source developer's guide to building applications

The first set statements establish variables. The first two evaluate expressions to discern a random number between 1 and 100, and the next one saves the system clock start time.

The puts and gets command are used for output to and input from the player. The puts I've used imply standard out for output. The gets needs the input channel to be defined, so this code specifies stdin as the source for terminal input from the user.

The flush stdout command is needed when puts omits the end-of-line termination because Tcl buffers output and it might not get displayed before the next I/O is needed.

From there the while statement illustrates the looping control structure and conditional logic needed to give the player feedback and eventually end the loop.

The final set command calls our function to calculate elapsed seconds for gameplay, followed by the collected stats to end the game.

Play it! $ ./numgame.tcl Guess a number between 1 and 100 ==> 100 Too large, try again ==> 50 Too large, try again ==> 25 Too large, try again ==> 12 Too large, try again ==> 6 Too large, try again ==> 3 That's right! You guessed value 3 after 6 tries and 20 elapsed seconds Continue learning

When I started this exercise, I doubted just how useful going back to a late 1990s fad language would be to me. Along the way, I found a few things about Tcl that I really enjoyed — my favorite being the square bracket command evaluation. It just seems so much easier to read and use than many other languages that overuse complicated closure structures. What I thought was a dead language was actually still thriving and supported on several platforms. I learned a few new skills and grew an appreciation for this venerable language.

Check out the official site over at https://www.tcl-lang.org. You can find references to the latest source, binary distributions, forums, docs, and information on conferences that are still ongoing.

Explore the basic language constructs of Tcl, which include user input, output, variables, conditional evaluation, looping, and simple functions.

Image by:

Opensource.com

Programming What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

3 types of leadership for open organizations

opensource.com - Thu, 02/09/2023 - 16:00
3 types of leadership for open organizations bbehrens Thu, 02/09/2023 - 03:00

In the classic movie Born Yesterday, a crime boss repeatedly demonstrates his leadership style by bellowing, "Do what I'm tellin' ya!" in a loud, threatening voice. It's entertaining in a comedy, but it would be a recipe for failure and getting ignored in an open organization.

In this article, I review forms of leadership that can be effective in an open organization. Remember that these leadership forms do not exist in a vacuum or silos. To be an effective manager, you want to mix and match techniques from each leadership style based on the requirements of a situation.

These three approaches to leadership are helpful for open organizations.

Servant leadership

There is a saying that politicians want to get elected either to be something or to do something. This adage applies to any type of leader. Some leaders simply want to be in command. While all leaders are ambitious, for this type of leader, satisfying their ambition is the primary goal. The acquisition of power is an end unto itself; once they have it, they may be uninterested in using it to solve problems or build something. Anything that the organization achieves looks like a personal triumph to them.

By contrast, when you're a servant leader, you see your leadership role as a means to serve people. In the political world, you would view public service as not a cliche but as an opportunity to help the public. As a servant leader, you work to improve things for the people you lead and are primarily concerned about the welfare of those around you.

Servant leadership is also contagious. By focusing on the welfare and development of the people you lead, you're growing the next generation of servant leaders. As a servant leader, you're not interested in taking all the credit. For example, when legendary baseball manager Casey Stengel was congratulated for winning a league championship, he famously remarked, "I couldn't have done it without my players." One of his greatest skills as a manager was maximizing each player's contributions to benefit the whole team.

Quiet leadership

For the past several years, we've been living in the age of the celebrity CEO. They are easy to recognize: They are brash and loud, they promote themselves constantly, and they act as if they know the answer to every problem. They attempt to dominate every interaction, want to be the center of attention, and often lead by telling others what to do. Alice Roosevelt Longworth described her father, US President Theodore Roosevelt, as someone who "wanted to be the corpse at every funeral, the bride at every wedding, and the baby at every christening." Roosevelt was an effective leader who did extraordinary things, such as starting the US National Park Service and building the Panama Canal, but he was anything but quiet.

In contrast, when you're a quiet leader, you lead by example. You don't fixate on problems; instead, you maintain a positive attitude and let your actions speak for themselves. You focus on what can be done. You lead by solving problems and by providing an example to your team. When faced with unexpected issues, the quiet leader doesn't spend time complaining but looks for solutions and implements them.

Open leadership

As a servant leader, you work to assist the members of your organization in growing into leaders. Quiet leaders lead by example. Servant leaders and quiet leaders do not act in an autocratic manner. Open leaders combine many of these characteristics.

An open leader is also not a top-down autocratic leader. As an open leader, you succeed by creating organizations in which teams can thrive. In other words, as an open leader, you create a framework or environment in which your organization can achieve the following goals according to The Open Organization Definition:

  • Greater agility: In an open organization, all team members have a clear understanding of the organization's goals and can, therefore, better work together to achieve those goals.
     
  • Faster innovation: In an open organization, ideas are heard (and reviewed and argued over) regardless of their origin. Ideas are not imposed on the organization by its leaders.
     
  • Increased engagement: Because members of the organization can contribute to decisions about the organization's direction, they have a sense of ownership for the team's goals.

The Open Organization defines the following five characteristics as basic tenants of open organizations:

  • Transparency: The organization's decision-making process is open, as are all supporting project resources. The team is never surprised by decisions made in isolation.
     
  • Inclusivity: All team members are included in discussions and reviews. Rules and protocols are established to ensure that all viewpoints are reviewed and respected.
     
  • Adaptability: Feedback is requested and accepted on an ongoing basis. The team continually adjusts its future actions based on results and inputs.
     
  • Collaboration: Team members work together from the start of a project or task. Work is not performed in isolation or in silos and then presented to the rest of the team for input.
     
  • Community: Team members have shared values regarding how the organization functions. Team leaders model these values. All team members are encouraged to make contributions to the team.
Putting leadership styles to work

How can you, as an open leader, incorporate the characteristics of servant and quiet leadership?

In an open organization, to support an inclusive community, you function as a mentor. Just as a servant leader acts to teach and cultivate future servant leaders, you must walk the walk, leading by example, ensuring transparency and collaboration, and operating according to shared values.

Open Organization resources Download resources Join the community What is an open organization? How open is your organization?

How can a quiet leader contribute to an open organization? Open organizations tend to be, for lack of a better word, noisy. Communication and collaboration in an open organization are constant and can sometimes be overwhelming to people not accustomed to it. The ownership felt by members of open organizations can result in contentious and passionate discussions and disagreements.

Quiet leaders with a positive outlook tend to see paths forward through seemingly contradictory viewpoints. Amid these discussions, a quiet leader cuts through the noise. As a calming influence on an open organization, a quiet leader can help people get past differences while driving solutions.

Further resources

Servant leaders, quiet leaders, and open leaders have traits useful to open organizations.

Image by:

Opensource.com

The Open Organization What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. 30 points

Len has been happily employed at Red Hat since 2006 and is a Senior QE Manager concentrating on quality and automation for open source middleware and cloud products including managed services. Len is also an avid writer and blogger, photographer, food pantry volunteer, and golf addict. 

Open Enthusiast Author Register or Login to post a comment.

Etnaviv Driver With Linux 6.3 Enables VeriSilicon NPU Cores

Phoronix - Thu, 02/09/2023 - 13:00
The Etnaviv DRM driver started out in the Linux kernel providing reverse-engineered kernel graphics driver support for Vivante graphics IP developed by VeriSilicon and found within various SoCs. With the upcoming Linux 6.3 cycle the Etnaviv DRM driver is adding support for VeriSilicon's Neural Network Processor (NPU) IP...

Linux Disabling High Resolution Scrolling For Logitech Devices Connected Via USB

Phoronix - Thu, 02/09/2023 - 06:02
While there's been a multi-year effort for Wayland high resolution scrolling, support by the desktop environments for this functionality, and all the other infrastructure work, high resolution scrolling is proving to still be a challenge for Linux in 2023. The latest is now the Linux kernel dropping Logitech high resolution scrolling for mice connected via USB until further improvements can be made...

Pages