Need A New Programming Language? Try Zig

Need A New Programming Language? Try Zig

Maybe you’ve heard of it, maybe you haven’t. Zig is a new programming language that seems to be growing in popularity. Let’s do a quick dive into what it is, why it’s unique, and what sort of things you would use it for. (Ed Note: Other than “for great justice“, naturally.)

What Is It?

You’ve likely heard of Rust as it has made significant inroads in critical low-level infrastructures such as operating systems and embedded microcontrollers. As a gross oversimplification, it offers memory safety and many traditional runtime checks pushed to compile time. It has been the darling of many posts here at Hackaday as it offers some unique advantages. With Rust on the rise, it makes sense that there might be some space for some new players. Languages like Julia, Go, Swift, and even Racket are all relative newcomers vying for the highly coveted mindshare of software engineers everywhere.

So let’s talk Zig. In a broad sense, Zig is really trying to provide some of the safety of Rust with the simplicity and ease of C. It touts a few core features such as:

  • No hidden control flow
  • No hidden memory allocations
  • No preprocessor, no macros
  • First-class support for optional standard library
  • Interoperable by design
  • Adjustable Runtime Safety
  • Compile-time code-execution

The last one, in particular, is perhaps the most interesting, but we’ll come back to that. Let’s look at some code, but skipping past hello world and headed straight to opening a file. Here’s the C++ code:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
int main (int argc, char const *argv[]) {
  ifstream file("nonexistingfile.txt");

  char buffer[1024];
  file.read(buffer, sizeof(buffer));

  cout << buffer << endl;

  file.close();
  return 0;
}

Now let’s look at some comparable Zig code:

const std = @import("std");

using namespace std.fs;

pub fn main() !void {
    const stdout = std.io.getStdOut().writer();

    const file = try cwd().openFile(
        "nonexistingfile.txt",
        .{ .read = true },
    );
    defer file.close();

    var buffer: [1024]u8 = undefined;
    const size = try file.readAll(buffer[0..]);

    try stdout.writeAll(buffer[0..size]);
}

(Thanks to Erik Engheim for the C++ and Zig sample code.)

As you might have guessed from the file name, the file doesn’t exist. The C++ code doesn’t explicitly check for any errors and in this scenario, it is perfectly valid code that displays no indication that anything failed. Zig, on the other hand, we have to do a try since that file could fail. When it does fail, you get a nice stack trace:

error: FileNotFound
/usr/local/Cellar/zig/0.7.0/lib/zig/std/os.zig:1196:23: 0x10b3ba52e in std.os.openatZ (fileopen)
            ENOENT => return error.FileNotFound,
                      ^
/usr/local/Cellar/zig/0.7.0/lib/zig/std/fs.zig:754:13: 0x10b3b857e in std.fs.Dir.openFileZ (fileopen)
            try os.openatZ(self.fd, sub_path, os_flags, 0);
            ^
/usr/local/Cellar/zig/0.7.0/lib/zig/std/fs.zig:687:9: 0x10b3b6c4b in std.fs.Dir.openFile (fileopen)
        return self.openFileZ(&path_c, flags);
        ^
~/Development/Zig/fileopen.zig:8:18: 0x10b3b6810 in main (fileopen)
    const file = try cwd().openFile(

Removing the try results in a compilation error. The backtrace here is especially impressive because this is a relatively simple language without a garbage collector, runtime, or virtual machine.

Let’s talk about some of Zig’s other

… Read More

A.I. Can Now Write Its Own Computer Code. That’s Good News for Humans.

A.I. Can Now Write Its Own Computer Code. That’s Good News for Humans.

As soon as Tom Smith got his hands on Codex — a new artificial intelligence technology that writes its own computer programs — he gave it a job interview.

He asked if it could tackle the “coding challenges” that programmers often face when interviewing for big-money jobs at Silicon Valley companies like Google and Facebook. Could it write a program that replaces all the spaces in a sentence with dashes? Even better, could it write one that identifies invalid ZIP codes?

It did both instantly, before completing several other tasks. “These are problems that would be tough for a lot of humans to solve, myself included, and it would type out the response in two seconds,” said Mr. Smith, a seasoned programmer who oversees an A.I. start-up called Gado Images. “It was spooky to watch.”

Codex seemed like a technology that would soon replace human workers. As Mr. Smith continued testing the system, he realized that its skills extended well beyond a knack for answering canned interview questions. It could even translate from one programming language to another.

Yet after several weeks working with this new technology, Mr. Smith believes it poses no threat to professional coders. In fact, like many other experts, he sees it as a tool that will end up boosting human productivity. It may even help a whole new generation of people learn the art of computers, by showing them how to write simple pieces of code, almost like a personal tutor.

“This is a tool that can make a coder’s life a lot easier,” Mr. Smith said.

About four years ago, researchers at labs like OpenAI started designing neural networks that analyzed enormous amounts of prose, including thousands of digital books, Wikipedia articles and all sorts of other text posted to the internet.

By pinpointing patterns in all that text, the networks learned to predict the next word in a sequence. When someone typed a few words into these “universal language models,” they could complete the thought with entire paragraphs. In this way, one system — an OpenAI creation called GPT-3 — could write its own Twitter posts, speeches, poetry and news articles.

Much to the surprise of even the researchers who built the system, it could even write its own computer programs, though they were short and simple. Apparently, it had learned from an untold number of programs posted to the internet. So OpenAI went a step further, training a new system — Codex — on an enormous array of both prose and code.

The result is a system that understands both prose and code — to a point. You can ask, in plain English, for snow falling on a black background, and it will give you code that creates a virtual snowstorm. If you ask for a blue bouncing ball, it will give you that, too.

“You can tell it to do something, and it will do it,” said Ania Kubow, another programmer who has used the technology.

Codex can generate programs in

… Read More

The easiest programming languages to learn

The easiest programming languages to learn

Coding can be challenging, particularly for beginners. New programmers often benefit from starting with an easier programming language.

Programming languages tell computers how to do specific tasks. Complex programming languages with dense syntax and complicated functions can challenge even experienced coders. Programming pros who want to learn a new language may prefer an easier option.

Our list introduces the easiest programming languages to learn, including each programming language’s uses and roles that use them. 

CSS

Roles that use it: Front-end developers, CSS developers, full-stack developers, mobile app developers, bloggers, website editors

Why it’s easy to learn: 

  • CSS styles websites, so it’s simpler than many programming languages.

  • Learners can pick up the fundamentals in a matter of weeks.

  • By mastering style types and properties, learners can use CSS to build websites.

CSS, or cascading style sheets, determines the look of a website. While HTML provides website content, CSS determines how it displays, including colors, fonts, and layouts. Every website uses CSS. 

As a rule-based language, CSS makes it easy to learn foundational skills like changing colors or font size. Many learners teach themselves CSS through online tutorials, books, or other self-teaching resources. Web development bootcamps and online college classes also teach CSS.

Go

Roles that use it: Systems engineers, Go developers, Google cloud developers, software engineers, data scientists

Why it’s easy to learn:

  • Go has less syntax than many other programming languages.

  • Users can typically master the syntax and avoid looking up rules while coding.

  • Programmers who know other languages, especially C languages, can pick up Go quickly. 

A programming language developed by Google, Go can be used for infrastructure, cloud applications, and other server-side uses. A simpler language than C++, Go provides simple, readable code for all kinds of uses, including in data science, robotics, and artificial intelligence. 

Go, sometimes called Golang, prioritizes speed. The language makes automation and system programming simpler. It’s also an open-source language. Learners can pick up Go through self-taught tutorials or through a bootcamp. 

HTML

Roles that use it: Front-end developers, full-stack developers, web developers, email developers, bloggers, website editors, mobile app developers 

Why it’s easy to learn: 

  • Thanks to simple rules, learners can pick up HTML basics in hours.

  • HTML does not require a strong theoretical foundation in programming.

  • The programming language has not changed much since the 1990s.

HTML, or hypertext markup language, tells websites how to display text and what text to show. Using HTML, programmers can create bullet points, headers, or text blocks. They can also insert images or hyperlinks into text. 

Every website since the mid-1990s has used HTML, and the language has changed little in that time. Most learners pick up HTML quickly. Many people teach themselves HTML through free courses, online tutorials, or other resources. Web development bootcamps also teach HTML. 

JavaScript

Roles that use it: Web developers, front-end developers, full-stack developers, front-end engineers, back-end developers, JavaScript developers

Why it’s easy to learn: 

  • After learning the fundamentals, users can start building applications.

  • Learners can test out pieces of

… Read More

Python overtakes Java, JavaScript as most popular programming language for first time in 20 years

Python overtakes Java, JavaScript as most popular programming language for first time in 20 years

What just happened? For the first time in more than 20 years, the Python programming language has overtaken Java, JavaScript, and C as the most popular language. The updated rankings for October revealed the achievement via Tiobe, an index that calculates the findings based on web searches.

Tiobe, a firm that specialize in assessing and tracking the quality of software, has tracked the popularity of programming languages for the past two decades. It uses queries on popular search engines and websites including Google, Bing, Yahoo!, Wikipedia and YouTube to assemble its index. A total of 25 search engines and sites are examined in the process.

The index itself is not about the best programming language per se or the language in which the most lines of code have been written, but strictly the amount of searches for languages on search engines. So while some may not take the feat achieved by Python seriously based on the methodology used, it’s still an important milestone given it’s the first time in 20 years Python has topped the rankings.

“Python, which started as a simple scripting language, as an alternative to Perl, has become mature. Its ease of learning, its huge amount of libraries, and its widespread use in all kinds of domains, has made it the most popular programming language of today,” said Tiobe CEO Paul Jansen.

As shown in Tiobe’s ‘Programming Language of the Year’ list, awarded for having the highest rise in ratings in a year, Python has kept itself in the conversation among the other popular languages since 2007 by winning four times.

Python topping the index, however, wasn’t necessarily because of an increase in searches. Instead, other languages falling in searches saw that an 11.27 percent share for Python was enough for it to take the lead. C fell 5.79 percent compared to October 2020 for an 11.16 percent share on the index, while Java fell 2.11 percent to 10.46 percent.

Other languages that rounded out the top 10 in the October index were C++, C#, Visual Basic, JavaScript, SQL, PHP, and Assembly Language.

A survey from 2020 based on 17,000 responses from developers showed how JavaScript continued to be the most used programming language. The report also revealed that Python added 2.2 million developers, predominantly due to the increase in both machine learning and data science.

https://www.techspot.com/news/91669-python-overtakes-java-javascript-most-popular-programming-language.html…

Read More

Which Programming Language Will Grow Most Over the Next Two Years?

Which Programming Language Will Grow Most Over the Next Two Years?

Which programming languages will grow the most over the next two years? While it’s impossible to predict the future, we can certainly make an educated guess based on data—and the answer might not align with your expectations.

Emsi Burning Glass collects and analyzes millions of job postings from across the country. As part of that analysis, it predicts how certain skills (and programming languages) will grow or decline in usage within companies. Here’s what the platform said about the potential growth rates for some of the country’s most popular programming languages:

Perhaps it’s no surprise that Python (which recently seized the top position on the TIOBE Index’s long-running list of the world’s most buzzed-about programming languages) is predicted to gain substantially over the next two years. Long popular as a generalist language, Python has been making substantial inroads lately into highly specialized arenas such as data science and machine learning. But the real standout here is TypeScript, which Emsi Burning Glass thinks will grow an eye-watering 140 percent over the next two years. 

What’s potentially behind that stunning rise? TypeScript is a superset of the ultra-popular JavaScript (which has led rise to significant debates over whether TypeScript is actually a “full” programming language). It’s also widely beloved by technologists: In the 2020 edition of the Stack Overflow Developer Survey, some 86.1 percent of surveyed developers said that Rust was a language they loved, followed by TypeScript (67.1 percent), Python (66.7 percent), Kotlin (62.9 percent), and Go (62.3 percent). 

“TypeScript’s surge in popularity highlights Microsoft’s change of direction and embrace of the open source movement,” Stack Overflow added at the time. “As front-end web and Node.JS codebases grow in size and complexity, adopting TypeScript’s static typing gives developers increased confidence in their code’s correctness.”

TypeScript recently hit version 4.0, with new features including labeled tuple elements, speed improvements, and custom JSX factories. While none of the features in the latest version are “huge,” they do contribute to the language’s stability, potentially making it even more enticing for developers to utilize it. 

How will TypeScript’s rise impact JavaScript usage? Given JavaScript’s massive legacy codebase and popularity, it seems unlikely that anything will significantly impact it anytime soon. But if you’re interested in anything JavaScript-related, you should add TypeScript to your learning schedule. 

https://insights.dice.com/2021/10/25/which-programming-language-will-grow-most-over-the-next-two-years/…

Read More

What is computer programming, exactly? A techie’s guide

What is computer programming, exactly? A techie’s guide

The 21st-century world runs on computers. And computers run on programs. Understanding computer programming unlocks the power of computing systems — and programming opens career doors.

Computer programs communicate information to computing devices. Computers then carry out tasks based on the program instructions. Simple programs tell computers to run calculations, while complex programs can run video games, analyze big data, or drive a car.

Our guide defines computer programs, explores uses of programming, and looks at the knowledge and skills required for careers in programming. 

What is computer programming?

What is computer programming? Programming, also known as coding, refers to the process of writing instructions for computing devices and systems. A computer program translates those instructions into a language that computers can understand.  

Computer programmers use many different languages to command computers. Popular programming languages include Python, JavaScript, Java, and the C-languages. 

The tech industry relies on computer programming to create innovative new uses for computers. Groundbreaking fields like machine learning and artificial intelligence depend on computer programming.

Computer users interact with programs frequently. Web browsers, for example, are specialized computer programs. These user-facing programs fall into the category of front-end development. In contrast, back-end development creates programs for tasks the user does not see, including server communication. 

How is computer programming used?

Computer programmers created every application that computers run — from photo editing software to word processors and web browsers. Programming languages unlock the power of computing systems. And without computer programming, our computing devices would not function. 

In addition to the uses of programming visible to users, programming languages also manage the hidden side of computing. Programs pull information from databases, implement security procedures to protect private data, and operate memory backup systems.

What computer programmers do

Computer programmers write code in languages like JavaScript, Python, and C++. Depending on their focus area — web development, mobile application development, software engineering, and so on — they use different languages. 

Computer programmers need more than fluency in one or more programming languages. They also need to know how to debug and modify code. Programmers often work in teams. 

The process of creating a program is complex and involves steps such as:

  • Conceptualizing the goal of the application

  • Building a layout of the different parts of the program

  • Writing code

  • Debugging the code and resolving any errors

  • Testing the application 

  • Releasing the program to beta users

Computer programming jobs

Many tech jobs require programming skills. For example, computer programmers, web developers, software developers, and software engineers all use coding skills regularly. 

According to the Bureau of Labor Statistics, the median annual wage for computer and information technology occupations was $91,250 in May 2020, more than twice the $41,950 median annual wage for all occupations. The best computer science jobs also show growth above the national average.

Other computer programming jobs include:

Becoming a computer programmer

Computer programmers gain coding skills through college programs, coding bootcamps, and self-study. A degree in computer science or programming builds strong

… Read More