Open-source News

LibreOffice 7.5 Released With Improved Dark Mode, Better PDF Exporting

Phoronix - Thu, 02/02/2023 - 19:28
LibreOffice 7.5 released on-schedule this morning as the newest version of this cross-platform, free software office suite to rival Microsoft Office...

Microsoft CBL-Mariner 2.0 Update Adds New PipeWire, Other Changes

Phoronix - Thu, 02/02/2023 - 19:14
Microsoft on Wednesday released CBL-Mariner 2.0.20230126-2.0 as the newest version of this in-house Linux distribution used for a variety of use-cases from within Azure infrastructure over to WSL purposes...

Arm Publishes Initial Confidential Compute Architecture "CCA" Code For Linux VMs

Phoronix - Thu, 02/02/2023 - 16:00
Arm ended out January by publishing an early request for comments (RFC) version of its Confidential Compute Architecture (CCA) support for the Linux kernel so there can be KVM virtualization integration around Arm CCA, a KVM user-space ABI for managing Realms, and Linux guest support for Arm Realms...

Learn Basic by coding a game

opensource.com - Thu, 02/02/2023 - 16:00
Learn Basic by coding a game Moshe Zadka Thu, 02/02/2023 - 03:00

Writing the same application in multiple languages is a great way to learn new ways to program. Most programming languages have certain things in common, such as:

  • Variables
  • Expressions
  • Statements

These concepts are the basis of most programming languages. Once you understand them, you can start figuring the rest out.

Programming languages usually share some similarities. Once you know one programming language, you can learn the basics of another by recognizing its differences.

Practicing with a standard program is a good way of learning a new language. It allows you to focus on the language, not the program's logic. I'm doing that in this article series using a "guess the number" program, in which the computer picks a number between one and 100 and asks you to guess it. The program loops until you guess the number correctly.

This program exercises several concepts in programming languages:

  • Variables
  • Input
  • Output
  • Conditional evaluation
  • Loops

It's a great practical experiment to learn a new programming language. This article focuses on Basic.

Guess the number in (Bywater) Basic

There is no real standard for the Basic programming language. Wikipedia says, "BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use." The BWBasic implementation is available under the GPL.

You can explore Basic by writing a version of the "guess the number" game.

Install Basic on Linux

In Debian or Ubuntu, you can install Basic with the following:

$ apt install -y bwbasic

Download the latest release tarball for Fedora, CentOS, Mageia, and any other Linux distribution. Extract it, make it executable, and then run it from a terminal:

$ tar --extract --file bwbasic*z $ chmod +x bywater $ ./bywater 

On Windows, download the .exe release.

Basic code

Here is my implementation:

10 value$ = cint(rnd * 100) + 1 20 input "enter guess"; guess$ 30 guess$ = val(guess$) 40 if guess$ < value$ then print "Too low" 50 if guess$ > value$ then print "Too high" 60 if guess$ = value$ then 80 70 goto 20 80 print "That's right"

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

Basic programs can be numbered or unnumbered. Usually, it is better to write programs unnumbered, but writing them with numbered lines makes it easier to refer to individual lines.

By convention, coders write lines as multiples of 10. This approach allows interpolating new lines between existing ones for debugging. Here's an explanation of my method above:

  • Line 10: Computes a random value between 1 and 100 using the built-in rnd function, which generates a number between 0 and 1, not including 1.
  • Line 20: Asks for a guess and puts the value in the guess$ scalar variable. Line 30 converts the value to a numeric one.
  • Lines 40 and 50: Give the guesser feedback, depending on the comparison.
  • Line 70: Goes to the beginning of the loop.
  • Line 60: Breaks& the loop by transferring control to line 80. Line 80 is the last line, so the program exits after that.
Sample output

The following is an example of the program after putting it in program.bas:

$ bwbasic program.bas  Bywater BASIC Interpreter/Shell, version 2.20 patch level 2 Copyright (c) 1993, Ted A. Campbell Copyright (c) 1995-1997, Jon B. Volkoff enter guess? 50 Too low enter guess? 75 Too low enter guess? 88 Too high enter guess? 80 Too low enter guess? 84 Too low enter guess? 86 Too high enter guess? 85 That's rightGet started

This "guess the number" game is a great introductory program for learning a new programming language because it exercises several common programming concepts in a pretty straightforward way. By implementing this simple game in different programming languages, you can demonstrate some core concepts of the languages and compare their details.

Do you have a favorite programming language? How would you write the "guess the number" game in it? Follow this article series to see examples of other programming languages that might interest you!

This tutorial lets you explore Basic by writing a version of the "guess the number" game.

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.

How to List and Extract tar.xz File in Linux

Tecmint - Thu, 02/02/2023 - 15:01
The post How to List and Extract tar.xz File in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

A tar.xz file extension shows that the file is a tar archive file compressed using the XZ compression tool. In this guide, we will cover various examples of how to list contests of a

The post How to List and Extract tar.xz File in Linux first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Mesa 23.0-rc4 Released Due To Blocker Bugs

Phoronix - Thu, 02/02/2023 - 13:00
While the Mesa 23.0 graphics drivers were aiming for release this week, due to outstanding blocker bugs it has instead resulted in a fourth weekly release candidate...

Steam Survey Results Start 2023 With Linux Marketshare Flat

Phoronix - Thu, 02/02/2023 - 08:14
Valve has just published their Steam Survey results for the month of January. Apple macOS has eaten a tiny bit of marketshare from Windows while on a percentage basis there is no change for Linux...

Customer success stories: How Red Hat products and services enable innovation in telecommunications and IT organizations

Red Hat News - Thu, 02/02/2023 - 08:00
<p>In this first edition of customer success highlights for 2023, learn how Brightly uses Red Hat products and services to accelerate innovation while improving efficiency and cutting costs. Also, read about HT Eronet’s digital transformation efforts using a number of Red Hat products to transition to a modern SAP-based billing system that can intake data from multiple sources, making it more secure and agile.</p> <h3>Brightly accelerates innovation with new technology and new ways of working</h3> <p><strong&a

Pages