PROGRAMMING TUTORIAL

My Favorite Pieces of Syntax in 8 Different Programming Languages

Because Criticizing Is Too Easy…

Yakko Majuri
Jul 16, 2020 · 5 min read
Image for post
Image for post

“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”

Image for post
Image for post

List Comprehension

def squares(limit):
return [num*num for num in range(0, limit)]
Image for post
Image for post

Spread Operator

let nums1 = [1,2,3]
let nums2 = [4,5,6]
let nums = [...nums1, ...nums2]
let nums = [...nums1, ...nums2]
let nums = [...nums1]
nums = [...nums, 6, 7, 8, 9, 10]
Image for post
Image for post

Goroutines

go doSomething()
fmt.Print("Hello")
go func() {
doSomethingSlow()
fmt.Print("world!")
}()
fmt.Print(" there ")
Hello there world!
Image for post
Image for post

Case & Underscore Indifference

proc my_func(s: string) =
echo s
myFunc("hello")
Image for post
Image for post

In-line Assembly

function getTokenAddress() external view returns(address) { 
address token;
assembly {
token := sload(0xffffffffffffffffffffffffffffffffffffffff)
}
return token
}
Image for post
Image for post

For-Each Loop

for (int num : nums) {
doSomething(num);
}
Image for post
Image for post

Macros

#define MAX_VALUE 10
Image for post
Image for post

‘using namespace’

using namespace std;

Author’s Note ✍️

The Startup

Get smarter at building your thing. Join The Startup’s +776K followers.

Yakko Majuri

Written by

Writing code and writing about writing code. Exploring the underrated topics in Software Development. I speak for myself only.

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +776K followers.

Yakko Majuri

Written by

Writing code and writing about writing code. Exploring the underrated topics in Software Development. I speak for myself only.

The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +776K followers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store