I used ChatGPT to write the same routine in 12 top programming languages. Here’s how it did

lang-1

David Gewirtz/ZDNET (with a little help from ChatGPT)

Over the past few months, we’ve all come to know that ChatGPT can write code. I gave it a number of tests in PHP and WordPress that showed both the strengths and weaknesses of ChatGPT’s coding capabilities.

Also: Okay, so ChatGPT just debugged my code. For real.

But how far does ChatGPT’s coding knowledge extend? In this article, I’m going to throw the classic “Hello, world” programming assignment against the twelve popular languages in O’Reilly Media’s popularity rankings for 2023.

Because “Hello, world” can often be coded in one line, I’m adding a slight wrinkle, having ChatGPT present “Hello, world” ten times, each time incrementing a counter value. I’m also asking it to check the time and begin each sequence with “Good morning,” “Good afternoon,” or “Good evening.”

Also: How to use ChatGPT: What you need to know now

That should give us a look at program flow and some intrinsic functions as well, but still keep the code small enough that I can include a dozen screenshots in this article.

Here’s the prompt:

Write a program in ____ that outputs “Good morning,” “Good afternoon,” or “Good evening” based on what time it is here in Oregon, and then outputs ten lines containing the loop index (beginning with 1), a space, and then the words “Hello, world!”.

For each programming language, I also asked ChatGPT to describe its primary use. Here’s the prompt I used for this query:

For each of the following languages, write a one-sentence description of its primary use and differentiating factor: Java, Python, Rust, Go, C++, JavaScript, C#, C, TypeScript, R, Kotlin, Scala.

Now, let’s look at each language.

Java

ChatGPT describes Java as, “A general-purpose language used primarily for building desktop, web, and mobile applications, and known for its ‘write once, run anywhere’ philosophy.”

Also: The best AI art generators to try

Java was originally developed by Sun Microsystems, but when Oracle bought Sun, it also bought Java. While the Java spec is open, the language is owned by Oracle. This has led to some spectacular legal fireworks over the years.

Here’s ChatGPT’s code:

java

Screenshot by David Gewirtz/ZDNET

Python

ChatGPT describes Python as, “A general-purpose language used for data analysis, artificial intelligence, web development, and automation, and known for its readability and ease of use.”

Also: How to write better ChatGPT prompts

My advice: if you plan to learn to code for AI applications, learn Python. Almost all AI code has tight Python integration.

Here’s ChatGPT’s code:

python

Screenshot by David Gewirtz/ZDNET

Rust

ChatGPT describes Rust as, “A systems programming language used for building high-performance and reliable software, and known for its memory safety and thread safety guarantees.”

Here’s ChatGPT’s code:

rust

Screenshot by David Gewirtz/ZDNET

Go

ChatGPT describes Go as, “A systems programming language used for building scalable and efficient network and server applications, and known for its simplicity and built-in concurrency features.”

Also: How to make ChatGPT provide sources and citations

Go is open source, but it’s

Read More

Memory safe and sound programming languages are on the increase. Here’s how developers ought to answer

two developers coding at computers

Picture: Maskot / Getty

Builders throughout federal government and business really should dedicate to employing memory risk-free languages for new goods and tools, and establish the most essential libraries and offers to shift to memory harmless languages, in accordance to a research from Buyer Reports.

The US nonprofit, which is recognized for testing shopper solutions, questioned what actions can be taken to support usher in “memory harmless” languages, like Rust, about choices this kind of as C and C++. Purchaser Stories mentioned it needed to tackle “marketplace-wide threats that are not able to be solved via user habits or even client alternative” and it identified “memory unsafety” as one particular this kind of issue. 

The report, Potential of Memory Basic safety, seems to be at selection of troubles, such as issues in setting up memory harmless language adoption inside of universities, stages of distrust for memory risk-free languages, introducing memory harmless languages to code bases penned in other languages, and also incentives and general public accountability.       

Also: Programming languages: Why this old favourite is on the increase once more

In the course of the past two a long time, far more and a lot more tasks have started off steadily adopting Rust for codebases created in C and C++ to make code a lot more memory safe. Between them are initiatives from Meta, Google’s Android Open Source Task, the C++-dominated Chromium project (sort of), and the Linux kernel. 

In 2019, Microsoft unveiled that 70% of safety bugs it had mounted throughout the earlier 12 yrs were memory security troubles. The determine was significant since Windows was composed largely in C and C++. Because then, the Nationwide Stability Agency (NSA) has proposed builders make a strategic shift absent from C++ in favor C#, Java, Ruby, Rust, and Swift.  

The shift in direction of memory safe and sound languages — most notably, but not only, to Rust — has even prompted the creator of C++, Bjarne Stroustrup and his peers, to devise a plan for the “Security of C++”. Developers like C++ for its efficiency and it continue to dominates embedded methods. C++ is however way far more extensively made use of than Rust, but the two are common languages for methods programming.  

The Buyer Stories analyze involves input from quite a few outstanding figures in information and facts safety, as nicely as reps from the Cybersecurity and Infrastructure Security Company (CISA), Online Safety Exploration Group, Google, the Workplace of the Nationwide Cyber Director, and a lot more. 

The report highlights that laptop science professors have a “golden option below to reveal the hazards” and could, for case in point, raise the fat of memory protection blunders in examining grades. But it provides that instructing parts of some courses in Rust could incorporate “inessential complexity” and that there is certainly a perception Rust is more challenging to learn, when C appears to be a risk-free wager for employability in future for a lot of pupils. 

The report suggests the marketplace

Read More

Opinion: Technological innovation is transforming the character of cash. Here’s how it will influence our life

Prasad: The usefulness of digital payments to each customers and organizations tends to make it highly unlikely that hard cash will survive significantly for a longer period.

In China there are two non-public payment companies, Alipay and WeChat Pay back, that have blanketed the full Chinese financial state with extremely lower-price electronic payments. You can use these for some thing as simple as buying, say, a piece of fruit or a couple of dumplings from a street seller. In innovative economies like Sweden, the personal sector is executing an similarly superior task of furnishing very lower-charge electronic payments.

IMF: Is it probable that cryptocurrencies like Bitcoin will be applied to purchase a cup of coffee or pay the lease?

Prasad: Bitcoin has not labored quite well as a medium of exchange that can be applied for day-to-day transactions. 1 principal reason is that Bitcoin has extremely unstable worth. It is really as although you took a bitcoin in with you to a coffee store, and one particular working day you could get a whole meal with it and on another day just get a tiny cup of espresso. In addition, Bitcoin is relatively sluggish and cumbersome to use.

IMF: Some nations are thinking about the adoption of a so-referred to as central lender digital forex (CBDC). What is the rationale?

Prasad: For some establishing nations around the world, the objective is that of broadening monetary inclusion. There are several folks in those people nations around the world who do not have obtain to digital payments. They never have obtain to essential banking goods and expert services. In nations around the world like Sweden, wherever most people today do have access to bank accounts, the essential is a very little unique. The Swedish central lender, the Riksbank, envisions the e-krona, or the electronic krona, as essentially a backstop to the private payment infrastructure.

The US dollar could go digital. Here's what you need to know

IMF: How about China?

Prasad: The Chinese authorities is very anxious about two payment companies that have arrive to dominate the payment technique and are blocking successfully the entry of new rivals who could supply innovations. The Chinese central bank views a electronic yuan as fundamentally a enhance to the existing payment systems, but one that could in basic principle raise the sum of opposition.

IMF: How does a electronic forex have an effect on the potential of a central lender to control inflation and be certain total employment?

Prasad: Let’s say all American citizens experienced, in result, an account with the Federal Reserve, then it would be a ton a lot easier for the Fed to undertake certain operations these types of as stimulus payments.

When the pandemic hit, the original coronavirus stimulus invoice involved a big volume of revenue becoming transferred to American households. Numerous households that had direct deposit information on file with the Interior Profits Service had been in a position to get direct deposits to their financial institution accounts, but homes that did not have that information on file with the IRS finished

Read More

AWS: Here’s why we are investing in the Rust programming language

Cloud-computing big Amazon World-wide-web Expert services (AWS) has outlined the factors its engineers are embracing Rust, which includes that it is a additional electrical power-successful programming language.

Just 7 a long time in the past, the Rust programming language attained model 1., building it a person of the youngest languages and a person that also holds large assure for massive code bases written in C and C++. Currently, Amazon, Google, and Microsoft back the language that at first began as a individual project of Graydon Hoare in advance of starting to be a investigate challenge at Mozilla in 2010.

Rust isn’t as well-liked as Java, JavaScript or Python, but it is really grow to be a significant language for constructing techniques like the Linux kernel, Home windows, Chrome, and Android. AWS was an early supporter of Rust and is a founding member of the Rust Foundation, and has an ongoing Rust recruitment generate. 

SEE: Net developer or CTO, which tech work opportunities have the speediest growing salaries?

Rust will help developers prevent a host of memory-relevant flaws popular to C/C++, which eventually charge organizations in stability updates. The language obtained its most significant-profile aid when Microsoft exposed it was experimenting with it for Windows, chiefly to dodge memory bugs. 

But a write-up by AWS’s Rust advocate and software engineer Shane Miller and Carl Lerche, a principal engineer at AWS, highlights that Rust isn’t only about memory protection and lessening stability flaws it is really a much greener language than Python and Java. In that way, it backs up Amazon’s broader drive to make its facts facilities a lot less destructive to the atmosphere, with the enterprise aiming to have its datacenters go absolutely renewable by 2025. 

AWS companies designed on Rust incorporate Firecracker, the know-how behind its Lamba serverless system for containerized applications, Amazon Straightforward Storage Service (S3), Elastic Compute Cloud (EC2), its CloudFront written content delivery network, and Bottlerocket, a Linux-based container OS.     

Datacenters make up 1% of the world’s energy consumption, amounting to about 200 terawatt several hours of power a working day, and the programming languages made use of can also affect electrical power use. 

“It is not a shock that C and Rust are much more economical than other languages. What is stunning is the magnitude of the distinction. Broad adoption of C and Rust could reduce energy consumption of compute by 50% – even with a conservative estimate,” claims Miller, pointing to a study showing the relative electricity efficiency of languages, from C to Google’s Go, Lua, Python, Ruby and previous Fortran.   

“Rust delivers the strength effectiveness of C without the need of the risk of undefined conduct. We can slash energy use in half devoid of shedding the added benefits of memory basic safety,” states Miller. 

She points to the general performance of an app by cybersecurity organization Tenable that was earlier created in JavaScript but is now prepared in Rust. The Rust app trounces JavaScript in CPU effectiveness, chopping latency by 50

Read More

Programming languages: Here’s how Raspberry Pi is generating a new technology of Python builders

coding-young-programmer-kids-tech-skills.jpg

Raspberry Pi’s Python training course teaches younger coders how to use variables, loops, and capabilities to develop interactive tasks.


Impression: SolStock/GETTY

The Raspberry Pi Basis has released a new introductory path for Python programming aimed at youthful folks.

The new Introduction to Python undertaking route has been intended to teach children the principles of Python programming and help them get assimilated with core programming concepts through hands-on assignments designed by the Raspberry Pi Basis.

Aimed at beginners and far more skilled youthful programmers, the training course usually takes learners through a variety of guided responsibilities and far more impartial initiatives, right before being presented the opportunity to generate some thing special making use of the know-how they’ve obtained.

SEE: Best Raspberry Pi alternative 2022: Best SBCs

Raspberry Pi by now delivers learning paths in Scratch programming, in which young coders are guided by means of essential programming and layout expertise to make apps, game titles, and computer system-produced artwork, making use of the block-primarily based language.

The Introduction to Python path is one thing of a step up in terms of complexity: being a textual content-based language, the project path is created to get younger coders acquainted with the underlying rules of ‘true’ programming languages utilised in the serious environment, this kind of as syntax, utilizing variables, and defining capabilities.

Python is an great language for younger and novice coders due to the fact its syntax is comparable to the English language, according to Raspberry Pi studying supervisor, Rebecca Franks.

Python is also a programming language that is extensively utilised by expert builders in burgeoning fields like data science, generating it a precious ability for young coders fascinated in a occupation in tech.

“The ‘Introduction to Python’ challenge route is designed according to our Electronic Building Framework, encouraging learners to turn out to be impartial coders and electronic makers by gently eradicating scaffolding as they development along the jobs in a route,” Franks claimed in a weblog submit.

“The composition of our Electronic Creating Framework means that learners working experience the structured growth system of a coding undertaking and find out how to transform their tips into truth. The Framework also supports with obtaining glitches in their code (debugging), exhibiting them that problems are a component of computer system programming and just momentary setbacks that you can conquer.”

SEE: Programming languages: How Python is making a developer group of millions

Raspberry Pi’s Python task path is break up into 6 elements, commencing with 3 ‘Explore’ assignments in which learners are released to new coding skills via guided jobs. Compared with some other introductory programs that aim on creating textual content-primarily based outputs, Raspberry Pi’s project path focuses on creating digital visuals making use of the Python p5 library.

Just after the ‘Explore’ jobs are two ‘Design’ jobs, the place young Python coders are encouraged to practise their coding techniques with more customized creations. Eventually, learners comprehensive a person ‘Invent’ undertaking, where they place every thing that they have figured out

Read More

Here’s why some online games are not “verified” for Steam Deck compatibility

Pictures of the Steam Deck.
Enlarge / The Steam Deck, from Valve.

Again in October, Valve laid out the unique critique recommendations that a Steam game would have to follow to gain an optional “Deck Confirmed” badge on its Steam Shop website page. Now, the results of the 1st of individuals verification testimonials are starting off to leak out, and they are showing some minimal input and interface challenges throughout a handful of game titles jogging on Steam Deck.

Even though the Deck Verified badges have yet to clearly show up on the Steam Retail store alone, the metadata surrounding the system is previously getting extra to the Steam backend for some titles ahead of the Steam Deck’s planned launch up coming month, as picked up by expert services like SteamDB. Of the 86 game titles with verification evaluation success so much, 41 have at minimum a single situation avoiding them from getting a comprehensive “Confirmed” badge.

Initially, the fantastic information: Nearly all of those un-verified games are nevertheless rated as “Playable” beneath Steam’s recommendations. Only 5 reviewed game titles so considerably have received the dreaded Steam Deck “Unsupported” badge from Valve. 4 are digital fact video games, which are unsuccessful for the straightforward mentioned explanation that “Steam Deck Does Not Aid VR Game titles.” The fifth, Persona 4 Golden, appears to be to fall short since in-activity videos use a problematic Home windows Media Player codec that could be hard to put into action through Steam Deck’s Linux Proton compatibility layer. “Valve is still doing work on incorporating guidance for this game on Steam Deck,” the game’s metadata states.

Every solitary “Playable” or “Confirmed” activity, on the other hand, has a “default graphics configuration [that] performs properly on Steam Deck.” That traces up with Valve’s July guarantee that the Steam Deck will be able to run “seriously the complete Steam library” at 30 fps with the device’s native 800p resolution.

Not ideal, but still “playable”

The widespread issues that differentiate a “Confirmed” activity from a just “Playable” one particular on the Steam Deck frequently quantity to input annoyances. In 15 of the 36 “Playable” titles identified so considerably, for instance, a launcher or setup device “may perhaps require the touchscreen or digital keyboard or have challenging-to-go through textual content,” in accordance to Steam.

There are also 14 games identified so considerably in which “entering some text requires manually invoking the on-monitor keyboard” and 11 that “involve use of the touchscreen or virtual keyboard or a local community configuration.” A whole of 13 game titles do not help “external controllers for the most important player,” which could be a issue if you want to plug in your possess machine by way of USB.

For some Steam games, this kind of external input won't work for primary player control on the Steam Deck.
Enlarge / For some Steam game titles, this variety of exterior enter is not going to do the job for principal participant regulate on the Steam Deck.

Visual interface difficulties are also comparatively widespread in the to start with batch of Deck Verified opinions. Unreadably small text has been

Read More