SlideShare a Scribd company logo
Syntax
C Java Go
Extension .c .java .go
VM Needed Not needed JVM is there to
convert java files
to class files
Not needed
Compiler TurboC javac gc
Program
Execution
Starts from
main() function
Starts from
public static void
main(String[ ]
args)
starts from
func main() and
should be in
package main
Syntax
C Java Go
Variable
Declaration
int a; float b;
int a,b,c;
Initialization
int a=25;
char c=ā€™aā€™;
int a; float b; a int
var c string
var a,b,c float
Initialization
var o,p int=34,65
k=45.67 (type of variable
auto judged by
compiler)
Shorthand notation
a:=30 (only inside
function)
Data Types bytes,short,int,long,
double,float,char,void
Primitive
bytes,short,int,long
,double,float,
boolean,char
uint, int,float32,...,
complex, byte,rune
C Java Go
Constant const int LEN=10 final int PI=3.14 const LEN int=10
Operators All operators like
Arithmetic,Logical,
Bitwise etc. are
same
All operators like
Arithmetic,Logical,
Bitwise etc. are
same
All operators like
Arithmetic,Logical,
Bitwise etc. are
same
Decision Making
Statements
(If else)
if(i>5){
flag=true
}
else{
flag=false
}
if(i>5){
flag=true
}
else{
flag=false
}
if i>5{
flag=true
}else{
flag=false
}
Syntax
C Java Go
Switch Case switch(i){
case 1: ā€¦ā€¦
break;
.
.
default:.....
break ;
}
switch(i){
case 1: ā€¦ā€¦
break;
.
.
default:.....
break ;
}
Expression switch
switch marks{
case 90: grade==ā€™Aā€™
case 50,60,70:grade==ā€™C .
default: fmt.Println(ā€œInvalidā€)
}
Type switch
var x interface{}
switch x.(type){
case int:
fmt.Println(ā€œx is intā€)
default:
fmt.Println(ā€œI donā€™t knowā€)
}
Syntax
C Java Go
For loop for(i=1;i<5;i++){
ā€¦ā€¦...
}
for(i=1;i<5;i++){
ā€¦ā€¦ā€¦ā€¦..
}
for i:=0;i<5;i++{
ā€¦ā€¦ā€¦..
}
for key,val:=range
numbers{
ā€¦ā€¦ā€¦ā€¦..
}
While Loop while(i<10){
i++;
}
while(i<10){
i++;
}
for sum<100{
sum+=sum
}
Syntax
C Java Go
Function Declaration
int sum(int,int)
int sum(int x,int y){
ā€¦ā€¦ā€¦ā€¦ā€¦
return
}
Calling
int add;
add=sum(10,20)
-Supports pass by
value and reference
Define method
public int sum(int
a,int b){
ā€¦ā€¦ā€¦ā€¦..
return
}
-Only pass by value
func sum(no int)
(int){
ā€¦ā€¦
return ..
}
-Both pass by value
and reference
Function
Overloading
No Yes No
Syntax
C Java Go
Variadic Functions No printMax(10,20,30)
public static void
printMax(doubleā€¦
numbers){
ā€¦ā€¦...
}
func sum(num
...int) int{
ā€¦..
ā€¦.
}
Ex. Println() is
implemented in
ā€œfmtā€
package
func Println(a
...interface{})(n
int,err error)
String char greet[6]={
ā€˜hā€™,ā€™eā€™,ā€™lā€™,ā€™lā€™,ā€™oā€™,ā€™0ā€™
}
String s=new
String(ā€œHelloā€)
var
greeting=ā€Helloā€
Syntax
C Java Go
String Functions strcpy(str1, str2)
strcat(str1,str2)
strlen(s1)............
str.length()
str.concat(str2)
str.compareTo(str2
)
String is made up
of runes. Rune is
UTF Format (A-
ā€™65ā€™,a-ā€™97ā€™)
len(str)
strings.join(str1,str
2)
Arrays Fixed size data
structure
Declaration
int array[10];
Accessing Elements
int value=array[10]
Declaration
int[ ] numbers
Creation
numbers=new
int[10]
Declaration
var number [10]int
Initialization
Var bal=[10]
int{...............}
Syntax
C Java Go
Slice There is no growable
data structure
java.util.Collection
package provides
dynamic growable
array. E.g List,Set,Map
etc
Growable data
structure
Declaration
var numbers []int
Creation
numbers=make([
]int,5,5)
5 len, 5 is capacity
append(),copy()
Default value - nil
Map There is no map data
structure in C
Key, Value pair
Map m=new
HashMap()
Map[key] value
Default value is nil
Syntax
C Java Go
Map - m.put(ā€œZeroā€,1)
put( )
get( )
ForEach to iterate
over collection and
array
var dictionary=map
[string] int
dictionary[ā€œZeroā€]=1
Create using make
var dict=make(map
[string] int)
Range -> to iterate over
slice,map
for key,val:=range values
{
ā€¦ā€¦...
}
Syntax
C Java Go
Struct / Class Collection of fields and
methods
struct book{
int id;
char name[50];
char author[50];
}book;
//Access members
struct book book1;
strcpy(book1.id,400)
Java does not have
struct but have
class
class Books{
int id;
String name;
String author;
void display(){
ā€¦ā€¦ā€¦ā€¦...
}
}
Books b=new
Book();
b.name=ā€Visionā€
Go have struct to
hold data in
variables.
type struct Book{
id int;
name string;
}
func(book3 *Book)
display() {
ā€¦ā€¦ā€¦ā€¦..
}
book1:=new(Book)
var book2 Book;
book2.name=ā€Goā€
Syntax
C Java Go
Embedding It is like inheritance
in Java
class A {
ā€¦.
}
Class B extends A
{
...
}
type Person struct{
Name string
}
func (per *Person)
speak(){
ā€¦ā€¦..
}
type Mobile struct{
Person
Model String
}
Mob:=new(Mobile)
mob.Person.speak(
)
Syntax
C Java Go
Pointer Direct address of
memory location
int *a
a=&b;
NULL pointer
Always assign null
value to pointer
variable when you
donā€™t know exact
address to assign
int *a=NULL;
Java does not
support pointer
var a *int
var fp *float32
a=&p
NIL pointer
var *p int=nil
Syntax
C Java Go
Interface C does not have
interface concept
-Collection of only abstract
methods (from java 8 it
supports static methods
also)
-Classes implements
interface
public interface Animal{
public void eat();
public void sleep();
}
public class Monkey extends
Animal{
ā€¦ā€¦ā€¦..
}
-Provides method
signatures
type Shape
interface {
area() float64
}
type square struct{
side float64
}
func(sq Square)area( )
float64 {
return sq.side*sq.side
}
Same method signature
is implemented
Syntax
C Java Go
Go has empty interface which is like
object class in java. An empty
interface can hold any type of
value.
fmt.Println(a ...interface{ })
Type Casting Convert variable from
one to another data type
(type) expression
int sum=5,count=2;
Double d=(double)
sum/count
Widening
byte->short->int->float->
long->double
float=10
Narrowing
double->float->long->int-
>short->byte
int a=(float)10.40
var i int=10
var f float64=6.44
fmt.Println(float64(i))
fmt.Println(int(f))
Syntax
C Java Go
Error Handling -No direct support for error
handling
But it returns error no.
perror() and strerror() used to
display text message associated
with error no
int dividend=20;
int divisor=0;
int quotient;
if(divisor==0){
fprintf(stderr,ā€Divide by zeroā€);
exit(-1);
}
Exception Handling
-Exception is problem
arises during program
execution.
Checked/Unchecked Ex.
try{
ā€¦ā€¦
}
catch(Exception ex){
ā€¦ā€¦..
}
finally{
ā€¦ā€¦..
}
No try/catch mechanism.
Instead it is having
defer,panic,recover
concepts.
-Provides error interface
type error interface{
Error() string
}
Normally function
returns error as last
return value. Use
errors.New() for
specifying error msg.
Syntax
C Java Go
Concurrency /
Multithreading
Doesnā€™t have
support.
Java have multithreading
concept for simultaneous
execution of different
tasks at same time.
We need to extends
Thread class or Runnable
interface and then
implement run( ) and write
your code
start(),run(),join(),sleep(),...
Here, we use
goroutines for
concurrent
execution.
To make function
as goroutine just
append go in front
of your function.
Two goroutines are
communicating
using channel
concept
Syntax
Thank You!
Drop us an email if you any doubts contact@mindbowser.com

More Related Content

What's hot

Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?
Andreas Enbohm
Ā 
Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++
Anton Kolotaev
Ā 
String in c programming
String in c programmingString in c programming
String in c programming
Devan Thakur
Ā 
Strings
StringsStrings
Strings
Nilesh Dalvi
Ā 
Computer Programming- Lecture 5
Computer Programming- Lecture 5 Computer Programming- Lecture 5
Computer Programming- Lecture 5
Dr. Md. Shohel Sayeed
Ā 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
CyberPlusIndia
Ā 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
Deepak Singh
Ā 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
Nilesh Dalvi
Ā 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its functionFrankie Jones
Ā 
C++11
C++11C++11
String in c
String in cString in c
String in c
Suneel Dogra
Ā 
Managing I/O & String function in C
Managing I/O & String function in CManaging I/O & String function in C
Managing I/O & String function in C
Abinaya B
Ā 
Generic Programming
Generic ProgrammingGeneric Programming
Generic Programming
Muhammad Alhalaby
Ā 
C++11
C++11C++11
Clojure basics
Clojure basicsClojure basics
Clojure basics
Knoldus Inc.
Ā 
C++ Presentation
C++ PresentationC++ Presentation
C++ Presentation
Carson Wilber
Ā 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
Intro C# Book
Ā 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
Jan RĆ¼egg
Ā 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++
Ilio Catallo
Ā 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
Knoldus Inc.
Ā 

What's hot (20)

Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?
Ā 
Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++
Ā 
String in c programming
String in c programmingString in c programming
String in c programming
Ā 
Strings
StringsStrings
Strings
Ā 
Computer Programming- Lecture 5
Computer Programming- Lecture 5 Computer Programming- Lecture 5
Computer Programming- Lecture 5
Ā 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
Ā 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
Ā 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
Ā 
Type header file in c++ and its function
Type header file in c++ and its functionType header file in c++ and its function
Type header file in c++ and its function
Ā 
C++11
C++11C++11
C++11
Ā 
String in c
String in cString in c
String in c
Ā 
Managing I/O & String function in C
Managing I/O & String function in CManaging I/O & String function in C
Managing I/O & String function in C
Ā 
Generic Programming
Generic ProgrammingGeneric Programming
Generic Programming
Ā 
C++11
C++11C++11
C++11
Ā 
Clojure basics
Clojure basicsClojure basics
Clojure basics
Ā 
C++ Presentation
C++ PresentationC++ Presentation
C++ Presentation
Ā 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
Ā 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
Ā 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++
Ā 
Scala categorytheory
Scala categorytheoryScala categorytheory
Scala categorytheory
Ā 

Similar to Syntax Comparison of Golang with C and Java - Mindbowser

ASP.NET
ASP.NETASP.NET
ASP.NET
chirag patil
Ā 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
Ā 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
xcoda
Ā 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
Shalabh Chaudhary
Ā 
Java Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfJava Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdf
Aditya Kumar
Ā 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
Chhom Karath
Ā 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patterns
league
Ā 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
Saifur Rahman
Ā 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
Santosh Rajan
Ā 
Lecture 2 java.pdf
Lecture 2 java.pdfLecture 2 java.pdf
Lecture 2 java.pdf
SantoshSurwade2
Ā 
Learning Java 1 ā€“Ā Introduction
Learning Java 1 ā€“Ā IntroductionLearning Java 1 ā€“Ā Introduction
Learning Java 1 ā€“Ā Introduction
caswenson
Ā 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
simenehanmut
Ā 
Charcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.pptCharcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.ppt
mulualem37
Ā 
Fantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptFantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptKamil Toman
Ā 
C language
C languageC language
C language
Priya698357
Ā 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
Ā 
Session 4
Session 4Session 4
Session 4
Shailendra Mathur
Ā 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
Baishampayan Ghose
Ā 
Python 3.pptx
Python 3.pptxPython 3.pptx
Python 3.pptx
HarishParthasarathy4
Ā 

Similar to Syntax Comparison of Golang with C and Java - Mindbowser (20)

ASP.NET
ASP.NETASP.NET
ASP.NET
Ā 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
Ā 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
Ā 
Java 5 New Feature
Java 5 New FeatureJava 5 New Feature
Java 5 New Feature
Ā 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
Ā 
Java Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfJava Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdf
Ā 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
Ā 
Scala Functional Patterns
Scala Functional PatternsScala Functional Patterns
Scala Functional Patterns
Ā 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
Ā 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
Ā 
Lecture 2 java.pdf
Lecture 2 java.pdfLecture 2 java.pdf
Lecture 2 java.pdf
Ā 
Learning Java 1 ā€“Ā Introduction
Learning Java 1 ā€“Ā IntroductionLearning Java 1 ā€“Ā Introduction
Learning Java 1 ā€“Ā Introduction
Ā 
Advanced Web Technology ass.pdf
Advanced Web Technology ass.pdfAdvanced Web Technology ass.pdf
Advanced Web Technology ass.pdf
Ā 
Charcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.pptCharcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.ppt
Ā 
Fantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptFantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and Javascript
Ā 
C language
C languageC language
C language
Ā 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Ā 
Session 4
Session 4Session 4
Session 4
Ā 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
Ā 
Python 3.pptx
Python 3.pptxPython 3.pptx
Python 3.pptx
Ā 

More from Mindbowser Inc

Healthcare Technology Survey 2023
Healthcare Technology Survey 2023Healthcare Technology Survey 2023
Healthcare Technology Survey 2023
Mindbowser Inc
Ā 
Top DevOps Trends And Statistics You Need To Know In 2023
Top DevOps Trends And Statistics You Need To Know In 2023Top DevOps Trends And Statistics You Need To Know In 2023
Top DevOps Trends And Statistics You Need To Know In 2023
Mindbowser Inc
Ā 
How To Achieve Project Success With Your Outsourced Team?
How To Achieve Project Success With Your Outsourced Team?How To Achieve Project Success With Your Outsourced Team?
How To Achieve Project Success With Your Outsourced Team?
Mindbowser Inc
Ā 
Data Science Consulting: From Idea To Deployment
Data Science Consulting: From Idea To DeploymentData Science Consulting: From Idea To Deployment
Data Science Consulting: From Idea To Deployment
Mindbowser Inc
Ā 
Understanding The Difference Between RPO And Staff Augmentation
Understanding The Difference Between RPO And Staff AugmentationUnderstanding The Difference Between RPO And Staff Augmentation
Understanding The Difference Between RPO And Staff Augmentation
Mindbowser Inc
Ā 
Top 5 Benefits Of IT Staff Augmentation For Modern Businesses
Top 5 Benefits Of IT Staff Augmentation For Modern BusinessesTop 5 Benefits Of IT Staff Augmentation For Modern Businesses
Top 5 Benefits Of IT Staff Augmentation For Modern Businesses
Mindbowser Inc
Ā 
How To Select The Right Software Architecture For Your Healthcare Product?
How To Select The Right Software Architecture For Your Healthcare Product?How To Select The Right Software Architecture For Your Healthcare Product?
How To Select The Right Software Architecture For Your Healthcare Product?
Mindbowser Inc
Ā 
Agile Scrum Mastery: Learn How To Bring Complex Projects To life!
Agile Scrum Mastery: Learn How To Bring Complex Projects To life!Agile Scrum Mastery: Learn How To Bring Complex Projects To life!
Agile Scrum Mastery: Learn How To Bring Complex Projects To life!
Mindbowser Inc
Ā 
A Guide To Minimum Viable Architecture Points For Any Startup
A Guide To Minimum Viable Architecture Points For Any StartupA Guide To Minimum Viable Architecture Points For Any Startup
A Guide To Minimum Viable Architecture Points For Any Startup
Mindbowser Inc
Ā 
Benefits and challenges of ehr
Benefits and challenges of ehrBenefits and challenges of ehr
Benefits and challenges of ehr
Mindbowser Inc
Ā 
What To Choose Between - Native App And Hybrid Mobile App
What To Choose Between - Native App And Hybrid Mobile AppWhat To Choose Between - Native App And Hybrid Mobile App
What To Choose Between - Native App And Hybrid Mobile App
Mindbowser Inc
Ā 
7 Secret Reasons To Choose An Outsourced Agency?
7 Secret Reasons To Choose An Outsourced Agency?7 Secret Reasons To Choose An Outsourced Agency?
7 Secret Reasons To Choose An Outsourced Agency?
Mindbowser Inc
Ā 
How We Thrill Customers?
How We Thrill Customers?How We Thrill Customers?
How We Thrill Customers?
Mindbowser Inc
Ā 
Benefits and Challenges of EHR
Benefits and Challenges of EHRBenefits and Challenges of EHR
Benefits and Challenges of EHR
Mindbowser Inc
Ā 
20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...
20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...
20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...
Mindbowser Inc
Ā 
Get Ready For What's New In Insurance Technology Trends For 2021
Get Ready For What's New In Insurance Technology Trends For 2021Get Ready For What's New In Insurance Technology Trends For 2021
Get Ready For What's New In Insurance Technology Trends For 2021
Mindbowser Inc
Ā 
10 top mobile app development trends to look out for in 2021
10 top mobile app development trends to look out for in 202110 top mobile app development trends to look out for in 2021
10 top mobile app development trends to look out for in 2021
Mindbowser Inc
Ā 
How To Ensure Quality With Automation
How To Ensure Quality With AutomationHow To Ensure Quality With Automation
How To Ensure Quality With Automation
Mindbowser Inc
Ā 
15 Questions To Answer Before Building Your Website
15 Questions To Answer Before Building Your Website15 Questions To Answer Before Building Your Website
15 Questions To Answer Before Building Your Website
Mindbowser Inc
Ā 
10 growth strategies for a telehealth platform
10 growth strategies for a telehealth platform10 growth strategies for a telehealth platform
10 growth strategies for a telehealth platform
Mindbowser Inc
Ā 

More from Mindbowser Inc (20)

Healthcare Technology Survey 2023
Healthcare Technology Survey 2023Healthcare Technology Survey 2023
Healthcare Technology Survey 2023
Ā 
Top DevOps Trends And Statistics You Need To Know In 2023
Top DevOps Trends And Statistics You Need To Know In 2023Top DevOps Trends And Statistics You Need To Know In 2023
Top DevOps Trends And Statistics You Need To Know In 2023
Ā 
How To Achieve Project Success With Your Outsourced Team?
How To Achieve Project Success With Your Outsourced Team?How To Achieve Project Success With Your Outsourced Team?
How To Achieve Project Success With Your Outsourced Team?
Ā 
Data Science Consulting: From Idea To Deployment
Data Science Consulting: From Idea To DeploymentData Science Consulting: From Idea To Deployment
Data Science Consulting: From Idea To Deployment
Ā 
Understanding The Difference Between RPO And Staff Augmentation
Understanding The Difference Between RPO And Staff AugmentationUnderstanding The Difference Between RPO And Staff Augmentation
Understanding The Difference Between RPO And Staff Augmentation
Ā 
Top 5 Benefits Of IT Staff Augmentation For Modern Businesses
Top 5 Benefits Of IT Staff Augmentation For Modern BusinessesTop 5 Benefits Of IT Staff Augmentation For Modern Businesses
Top 5 Benefits Of IT Staff Augmentation For Modern Businesses
Ā 
How To Select The Right Software Architecture For Your Healthcare Product?
How To Select The Right Software Architecture For Your Healthcare Product?How To Select The Right Software Architecture For Your Healthcare Product?
How To Select The Right Software Architecture For Your Healthcare Product?
Ā 
Agile Scrum Mastery: Learn How To Bring Complex Projects To life!
Agile Scrum Mastery: Learn How To Bring Complex Projects To life!Agile Scrum Mastery: Learn How To Bring Complex Projects To life!
Agile Scrum Mastery: Learn How To Bring Complex Projects To life!
Ā 
A Guide To Minimum Viable Architecture Points For Any Startup
A Guide To Minimum Viable Architecture Points For Any StartupA Guide To Minimum Viable Architecture Points For Any Startup
A Guide To Minimum Viable Architecture Points For Any Startup
Ā 
Benefits and challenges of ehr
Benefits and challenges of ehrBenefits and challenges of ehr
Benefits and challenges of ehr
Ā 
What To Choose Between - Native App And Hybrid Mobile App
What To Choose Between - Native App And Hybrid Mobile AppWhat To Choose Between - Native App And Hybrid Mobile App
What To Choose Between - Native App And Hybrid Mobile App
Ā 
7 Secret Reasons To Choose An Outsourced Agency?
7 Secret Reasons To Choose An Outsourced Agency?7 Secret Reasons To Choose An Outsourced Agency?
7 Secret Reasons To Choose An Outsourced Agency?
Ā 
How We Thrill Customers?
How We Thrill Customers?How We Thrill Customers?
How We Thrill Customers?
Ā 
Benefits and Challenges of EHR
Benefits and Challenges of EHRBenefits and Challenges of EHR
Benefits and Challenges of EHR
Ā 
20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...
20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...
20 Tools That Any Non Tech Founder Can Use To Manage Their Tech Product Devel...
Ā 
Get Ready For What's New In Insurance Technology Trends For 2021
Get Ready For What's New In Insurance Technology Trends For 2021Get Ready For What's New In Insurance Technology Trends For 2021
Get Ready For What's New In Insurance Technology Trends For 2021
Ā 
10 top mobile app development trends to look out for in 2021
10 top mobile app development trends to look out for in 202110 top mobile app development trends to look out for in 2021
10 top mobile app development trends to look out for in 2021
Ā 
How To Ensure Quality With Automation
How To Ensure Quality With AutomationHow To Ensure Quality With Automation
How To Ensure Quality With Automation
Ā 
15 Questions To Answer Before Building Your Website
15 Questions To Answer Before Building Your Website15 Questions To Answer Before Building Your Website
15 Questions To Answer Before Building Your Website
Ā 
10 growth strategies for a telehealth platform
10 growth strategies for a telehealth platform10 growth strategies for a telehealth platform
10 growth strategies for a telehealth platform
Ā 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
Ā 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
Ā 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
Ā 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
Ā 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
Ā 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
Ā 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
Ā 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
Ā 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
Ā 
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
UiPathCommunity
Ā 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
Ā 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
Ā 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
Ā 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
Ā 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
Ā 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
Ā 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
Ā 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
Ā 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
Ā 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
Ā 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Ā 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Ā 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Ā 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Ā 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Ā 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
Ā 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Ā 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Ā 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
Ā 
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder ā€“ active learning and UiPath LLMs for do...
Ā 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Ā 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Ā 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Ā 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Ā 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Ā 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Ā 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Ā 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Ā 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Ā 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
Ā 

Syntax Comparison of Golang with C and Java - Mindbowser

  • 1.
  • 2. Syntax C Java Go Extension .c .java .go VM Needed Not needed JVM is there to convert java files to class files Not needed Compiler TurboC javac gc Program Execution Starts from main() function Starts from public static void main(String[ ] args) starts from func main() and should be in package main
  • 3. Syntax C Java Go Variable Declaration int a; float b; int a,b,c; Initialization int a=25; char c=ā€™aā€™; int a; float b; a int var c string var a,b,c float Initialization var o,p int=34,65 k=45.67 (type of variable auto judged by compiler) Shorthand notation a:=30 (only inside function) Data Types bytes,short,int,long, double,float,char,void Primitive bytes,short,int,long ,double,float, boolean,char uint, int,float32,..., complex, byte,rune
  • 4. C Java Go Constant const int LEN=10 final int PI=3.14 const LEN int=10 Operators All operators like Arithmetic,Logical, Bitwise etc. are same All operators like Arithmetic,Logical, Bitwise etc. are same All operators like Arithmetic,Logical, Bitwise etc. are same Decision Making Statements (If else) if(i>5){ flag=true } else{ flag=false } if(i>5){ flag=true } else{ flag=false } if i>5{ flag=true }else{ flag=false } Syntax
  • 5. C Java Go Switch Case switch(i){ case 1: ā€¦ā€¦ break; . . default:..... break ; } switch(i){ case 1: ā€¦ā€¦ break; . . default:..... break ; } Expression switch switch marks{ case 90: grade==ā€™Aā€™ case 50,60,70:grade==ā€™C . default: fmt.Println(ā€œInvalidā€) } Type switch var x interface{} switch x.(type){ case int: fmt.Println(ā€œx is intā€) default: fmt.Println(ā€œI donā€™t knowā€) } Syntax
  • 6. C Java Go For loop for(i=1;i<5;i++){ ā€¦ā€¦... } for(i=1;i<5;i++){ ā€¦ā€¦ā€¦ā€¦.. } for i:=0;i<5;i++{ ā€¦ā€¦ā€¦.. } for key,val:=range numbers{ ā€¦ā€¦ā€¦ā€¦.. } While Loop while(i<10){ i++; } while(i<10){ i++; } for sum<100{ sum+=sum } Syntax
  • 7. C Java Go Function Declaration int sum(int,int) int sum(int x,int y){ ā€¦ā€¦ā€¦ā€¦ā€¦ return } Calling int add; add=sum(10,20) -Supports pass by value and reference Define method public int sum(int a,int b){ ā€¦ā€¦ā€¦ā€¦.. return } -Only pass by value func sum(no int) (int){ ā€¦ā€¦ return .. } -Both pass by value and reference Function Overloading No Yes No Syntax
  • 8. C Java Go Variadic Functions No printMax(10,20,30) public static void printMax(doubleā€¦ numbers){ ā€¦ā€¦... } func sum(num ...int) int{ ā€¦.. ā€¦. } Ex. Println() is implemented in ā€œfmtā€ package func Println(a ...interface{})(n int,err error) String char greet[6]={ ā€˜hā€™,ā€™eā€™,ā€™lā€™,ā€™lā€™,ā€™oā€™,ā€™0ā€™ } String s=new String(ā€œHelloā€) var greeting=ā€Helloā€ Syntax
  • 9. C Java Go String Functions strcpy(str1, str2) strcat(str1,str2) strlen(s1)............ str.length() str.concat(str2) str.compareTo(str2 ) String is made up of runes. Rune is UTF Format (A- ā€™65ā€™,a-ā€™97ā€™) len(str) strings.join(str1,str 2) Arrays Fixed size data structure Declaration int array[10]; Accessing Elements int value=array[10] Declaration int[ ] numbers Creation numbers=new int[10] Declaration var number [10]int Initialization Var bal=[10] int{...............} Syntax
  • 10. C Java Go Slice There is no growable data structure java.util.Collection package provides dynamic growable array. E.g List,Set,Map etc Growable data structure Declaration var numbers []int Creation numbers=make([ ]int,5,5) 5 len, 5 is capacity append(),copy() Default value - nil Map There is no map data structure in C Key, Value pair Map m=new HashMap() Map[key] value Default value is nil Syntax
  • 11. C Java Go Map - m.put(ā€œZeroā€,1) put( ) get( ) ForEach to iterate over collection and array var dictionary=map [string] int dictionary[ā€œZeroā€]=1 Create using make var dict=make(map [string] int) Range -> to iterate over slice,map for key,val:=range values { ā€¦ā€¦... } Syntax
  • 12. C Java Go Struct / Class Collection of fields and methods struct book{ int id; char name[50]; char author[50]; }book; //Access members struct book book1; strcpy(book1.id,400) Java does not have struct but have class class Books{ int id; String name; String author; void display(){ ā€¦ā€¦ā€¦ā€¦... } } Books b=new Book(); b.name=ā€Visionā€ Go have struct to hold data in variables. type struct Book{ id int; name string; } func(book3 *Book) display() { ā€¦ā€¦ā€¦ā€¦.. } book1:=new(Book) var book2 Book; book2.name=ā€Goā€ Syntax
  • 13. C Java Go Embedding It is like inheritance in Java class A { ā€¦. } Class B extends A { ... } type Person struct{ Name string } func (per *Person) speak(){ ā€¦ā€¦.. } type Mobile struct{ Person Model String } Mob:=new(Mobile) mob.Person.speak( ) Syntax
  • 14. C Java Go Pointer Direct address of memory location int *a a=&b; NULL pointer Always assign null value to pointer variable when you donā€™t know exact address to assign int *a=NULL; Java does not support pointer var a *int var fp *float32 a=&p NIL pointer var *p int=nil Syntax
  • 15. C Java Go Interface C does not have interface concept -Collection of only abstract methods (from java 8 it supports static methods also) -Classes implements interface public interface Animal{ public void eat(); public void sleep(); } public class Monkey extends Animal{ ā€¦ā€¦ā€¦.. } -Provides method signatures type Shape interface { area() float64 } type square struct{ side float64 } func(sq Square)area( ) float64 { return sq.side*sq.side } Same method signature is implemented Syntax
  • 16. C Java Go Go has empty interface which is like object class in java. An empty interface can hold any type of value. fmt.Println(a ...interface{ }) Type Casting Convert variable from one to another data type (type) expression int sum=5,count=2; Double d=(double) sum/count Widening byte->short->int->float-> long->double float=10 Narrowing double->float->long->int- >short->byte int a=(float)10.40 var i int=10 var f float64=6.44 fmt.Println(float64(i)) fmt.Println(int(f)) Syntax
  • 17. C Java Go Error Handling -No direct support for error handling But it returns error no. perror() and strerror() used to display text message associated with error no int dividend=20; int divisor=0; int quotient; if(divisor==0){ fprintf(stderr,ā€Divide by zeroā€); exit(-1); } Exception Handling -Exception is problem arises during program execution. Checked/Unchecked Ex. try{ ā€¦ā€¦ } catch(Exception ex){ ā€¦ā€¦.. } finally{ ā€¦ā€¦.. } No try/catch mechanism. Instead it is having defer,panic,recover concepts. -Provides error interface type error interface{ Error() string } Normally function returns error as last return value. Use errors.New() for specifying error msg. Syntax
  • 18. C Java Go Concurrency / Multithreading Doesnā€™t have support. Java have multithreading concept for simultaneous execution of different tasks at same time. We need to extends Thread class or Runnable interface and then implement run( ) and write your code start(),run(),join(),sleep(),... Here, we use goroutines for concurrent execution. To make function as goroutine just append go in front of your function. Two goroutines are communicating using channel concept Syntax
  • 19. Thank You! Drop us an email if you any doubts contact@mindbowser.com