This document compares and contrasts various features of C++ and Go, including:
- Error handling approaches like exceptions in C++ vs explicit error checking in Go.
- Class/struct definitions and how they compare between the languages.
- Common data structures like vectors, maps, and how they are implemented in each language.
- Benchmark results that show Go outperforming C++ in some cases but C++ performing better in others, depending on optimizations and data structure choices.
- Interfacing Go with C via Cgo and the performance overhead of marshalling between the languages.
- Concurrency primitives available in each language like mutexes, channels, atomics.
An introduction to functional programming with goEleanor McHugh
A crash course in functional programming concepts using Go. Heavy on code, light on theory.
You can find the examples at https://github.com/feyeleanor/intro_to_fp_in_go
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
An updated version of my talk on virtual machine cores comparing techniques in C and Go for implementing dispatch loops, stacks & hash maps.
Lots of tested and debugged code is provided as well as references to some useful/interesting books.
A reworking of my 2010 RubyConf lightning talk introducing Go via a concurrent implementation of MapReduce. This code is probably buggy as hell and the design awful but it's also a reasonably good intro to the full breadth of Go.
An introduction to functional programming with goEleanor McHugh
A crash course in functional programming concepts using Go. Heavy on code, light on theory.
You can find the examples at https://github.com/feyeleanor/intro_to_fp_in_go
Implementing virtual machines in go & c 2018 reduxEleanor McHugh
An updated version of my talk on virtual machine cores comparing techniques in C and Go for implementing dispatch loops, stacks & hash maps.
Lots of tested and debugged code is provided as well as references to some useful/interesting books.
A reworking of my 2010 RubyConf lightning talk introducing Go via a concurrent implementation of MapReduce. This code is probably buggy as hell and the design awful but it's also a reasonably good intro to the full breadth of Go.
Implementing Software Machines in C and GoEleanor McHugh
The next iteration of the talk I gave at Progscon, this introduces examples of Map implementation (useful for caches etc.) and outlines for addition of processor core code in a later talk.
Implementing Software Machines in Go and CEleanor McHugh
Early draft of a tutorial on techniques for implementing virtual machines and language interpreters. Contains example programs for functional stacks and despatch loops.
Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
Why we are submitting this talk? Because Go is cool and we would like to hear more about this language ;-). In this talk we would like to tell you about our experience with development of microservices with Go. Go enables devs to create readable, fast and concise code, this - beyond any doubt is important. Apart from this we would like to leverage our test driven habbits to create bulletproof software. We will also explore other aspects important for adoption of a new language.
This talk will explore inference from the perspective of protocols and generics and is based off a series of blog posts I've written(foxinswift.com) on the topic. In the first part of my talk casting number types through inference. I'll then show you struct serialization example demonstrating inferring a type through a mapping function. My last example will take you through inferring an associatedtype on a barebones promise implementation and we'll use it to in the context of making a network request. To finish things off I'll briefly speak on what's new in swift generics and some limitations of those features.
program to convert decimal number into roman number
program of prime number
program to print total number of times a given number exist from 1 to 100
program to compare two given matrices
Implementing Software Machines in C and GoEleanor McHugh
The next iteration of the talk I gave at Progscon, this introduces examples of Map implementation (useful for caches etc.) and outlines for addition of processor core code in a later talk.
Implementing Software Machines in Go and CEleanor McHugh
Early draft of a tutorial on techniques for implementing virtual machines and language interpreters. Contains example programs for functional stacks and despatch loops.
Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
Why we are submitting this talk? Because Go is cool and we would like to hear more about this language ;-). In this talk we would like to tell you about our experience with development of microservices with Go. Go enables devs to create readable, fast and concise code, this - beyond any doubt is important. Apart from this we would like to leverage our test driven habbits to create bulletproof software. We will also explore other aspects important for adoption of a new language.
This talk will explore inference from the perspective of protocols and generics and is based off a series of blog posts I've written(foxinswift.com) on the topic. In the first part of my talk casting number types through inference. I'll then show you struct serialization example demonstrating inferring a type through a mapping function. My last example will take you through inferring an associatedtype on a barebones promise implementation and we'll use it to in the context of making a network request. To finish things off I'll briefly speak on what's new in swift generics and some limitations of those features.
program to convert decimal number into roman number
program of prime number
program to print total number of times a given number exist from 1 to 100
program to compare two given matrices
Go is a language developed by Google with multi-core in mind. Differ from other languages, concurrency is a first-class primitive in Go. This talk covers some useful patterns for dealing with concurrency.
I wrote the following change it to having a header, main and cpp fi.pdfrishteygallery
I wrote the following: change it to having a header, main and cpp file.. THERE ARE ERRORS
PLEASE FIX.. Picture of output is given below
The internal representation of a Polynomial is an array of terms. Each term contains a coefficient
and an exponent, e.g., the term
2x4
has the coefficient 2 and the exponent 4.
Develop a complete class containing proper constructor and destructor functions as well as set,
get, and print functions. The class should also provide the following overloaded operator
capabilities:
a) Overload the addition operator (+) to add two Polynomials.
b) Overload the subtraction operator (-) to subtract two Polynomials.
c) Overload the assignment operator to assign one Polynomial to another.
d) Overload the multiplication operator (*) to multiply two Polynomials.
e) Overload the addition assignment operator (+=), subtraction assignment operator (-=), and
multiplication assignment operator (*=).
Write an application that tests all the functionality provided by class Polynomial:
• create three Polynomials
• add two Polynomials, using + and += operators
• subtract two Polynomials, using – and -= operators
• assign one Polynomial to another Polynomial
• multiply two Polynomials, using * and *= operators.
---------------------------------------------------------------------------------------------
#include
#include
using namespace std;
using std::setiosflags;
using std::resetiosflags;
class Polynomial
{
public:
Polynomial();
Polynomial operator+( const Polynomial& ) const;
Polynomial operator-( const Polynomial& ) const;
Polynomial operator*( const Polynomial& );
const Polynomial operator=( const Polynomial&);
Polynomial& operator+=( const Polynomial& );
Polynomial& operator-=( const Polynomial& );
void enterTerms( void );
void printPolynomial( void ) const;
private:
int exponents[ 100 ];
int coefficients[ 100 ];
};
Polynomial::Polynomial()
{
for ( int t = 0; t < 100; ++t ) {
coefficients[ t ] = 0;
exponents[ t ] = 0;
}
}
void Polynomial::printPolynomial( void ) const
{
int start;
bool zero = false;
if ( coefficients[ 0 ] ) { // output constants
cout << coefficients[ 0 ];
start = 1;
zero = true; // at least one term exists
}
else {
if ( coefficients[ 1 ] ) {
cout << coefficients[ 1 ] << \'x\'; // constant does not exist
// so output first term
// without a sign
if ( ( exponents[ 1 ] != 0 ) && ( exponents[ 1 ] != 1 ) )
cout << \'^\' << exponents[ 1 ];
zero = true; // at least one term exists
}
start = 2;
}
// output remaining polynomial terms
for ( int x = start; x < 100; ++x ) {
if ( coefficients[ x ] != 0 ) {
cout << setiosflags( ios::showpos ) << coefficients[ x ]
<< resetiosflags( ios::showpos ) << \'x\';
if ( ( exponents[ x ] != 0 ) && ( exponents[ x ] != 1 ) )
cout << \'^\' << exponents[ x ];
zero = true; // at least one term exists
}
}
if ( !zero ) // no terms exist in the polynomial
cout << \'0\';
cout << endl;
}
const Polynomial Polynomial::operator=( const Polynomial& r )
{
exponents[ 0 ] = r.exponents[ 0 ];
coefficients[.
Developer Experience i TypeScript. Najbardziej ikoniczne duoThe Software House
Wiktor Toporek: TypeScript bez wątpienia jest obecnie pewnym standardem wśród obecnych rozwiązań powstałych w JavaScripcie. Ale czy poza byciem dodatkiem który uzupełnia odrobinę dokumentacje i deklaruje kontrakt jakiego typu parametry przyjmują i zwracają np. funkcje jakiejś biblioteki, można wycisnąć z niego coś więcej? Podczas prezentacji wykorzystamy TypeScript do granic możliwości, używając zaawansowanych technik które sprawiają że interfejs naszego API będzie sam kierował używających go developerów na drogę poprawnego użycia, które jest zgodne z naszymi (twórców) założeniami, poprawiając tym samym ich doświadczenia.
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶ отладки в TarantoolTimur Safin
Презентация для выступления на Владивостокском митапе https://moscowdjango.timepad.ru/event/1884275/
"Основной режим разработки приложений в Тарантуле — это написание скриптов и манипуляции данными на Lua (оставим пока за скобками режим SQL). Часто внедрению Тарантула в некую систему становится блокером использование Lua.
В экосистеме Lua мало тулинга, это касается как встроенного интерпретатора, так и JIT-транслятора LuaJIT.
Давайте оглядимся, как обстоят дела с тестированием, профилированием, статическим анализом и дебагом в Lua. И как это все может быть использовано при разработке сервисов, в архитектуре которых есть Tarantool."
Новый InterSystems: open-source, митапы, хакатоныTimur Safin
Presentation for the 1st InterSystems Meetup in the Minsk:
- New and better InterSystems changes their practice.
- open-source repositories, meetups, and hackathon;
- CPM (package manager) as a good example of open-source project
Implementation of community package managerTimur Safin
Implementation update for "Community Package Manager" project which is being created for Cache' ObjectScript developers.
Presentation created by TimurSafin and @DmitryMaslennikov
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfJay Das
With the advent of artificial intelligence or AI tools, project management processes are undergoing a transformative shift. By using tools like ChatGPT, and Bard organizations can empower their leaders and managers to plan, execute, and monitor projects more effectively.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
5. • There is no way to centralize error handling, and you
doing it the “old good way” (check after each step):
No exceptions
defer ts.Close()
conf := newConf(ts.URL)
_, err := conf.Exchange(context.Background(), "exchange-
code")
if err == nil {
t.Fatalf("got no error, expected one")
}
_, ok := err.(*RetrieveError)
if !ok {
t.Fatalf("got %T error, expected *RetrieveError; error
was: %v", err, err)
6. •So observations are that average Go
function length might be up to 3x
longer if to correctly handle all
errors (than comparable C*/C++
code)
No exceptions
* C at least has a preprocessor
7. •"If it walks like a duck and it quacks like a
duck, then it must be a duck”
•In duck typing, an object's suitability is
determined by the presence of
certain methods and properties, rather than
the type of the object itself.
Duck Typing vs True
https://en.wikipedia.org/wiki/Duck_typing
10. MODULE Lists;
TYPE
List* = POINTER TO ListNode;
ListNode = RECORD
value : Integer;
next : List;
END;
PROCEDURE (l : List) Add* (v : Integer);
BEGIN
IF l = NIL THEN
NEW(l); (* create record instance *)
l.value := v
ELSE
l.next.Add(v) (* recursive call to .add(n) *)
END
END Add;
Oberon-2
UglyClasses
11. LL(1) grammar with C-like keywords
var prohibitionaryDialArgTests =
[]struct {
network string
address string
}{
{"tcp4", "127.0.0.1"},
{"tcp6", "::ffff:127.0.0.1"},
}
func DoProhibitionaryDialArg(t
*testing.T) (error) {
Go
const
prohibitionaryDialArgTests : array [1..2]
of record
network : string;
address : string;
end = (
(network: ‘tcp4’, address:
‘127.0.0.1’),
(network: ‘tcp6’, address: ‘::ffff:
127.0.0.1’)
);
function DoProhibitionaryDialArg(var t:
Testing.T) : TError;
Pascal
Pascal/Oberon syntax which mimics C
12. •Order of keywords in declaration
•No name overloads
• No generics
• No pointer arithmetic
• Fast compiler
• Weak optimizer
• Source modules-based build
• blahblahthousandsmoreweakanalogues
More Pascal/Oberon like…
23. C++ Go
#include <iostream>
#include <vector>
int main() {
int64_t sum = 0;
for (int e = 0; e < 200; e++) {
sum = 0;
std::vector<int64_t> x;
for (int i = 0; i < 1000000; i++) {
x.push_back(i);
}
std::vector<int64_t> y;
for (int i = 0; i < 1000000 - 1; i++) {
y.push_back(x[i] + x[i + 1]);
}
for (int i = 0; i < 1000000; i += 100) {
sum += y[i];
}
}
std::cout << sum << std::endl;
}
package main
import "fmt"
func main() {
var sum int64 = 0
for e := 0; e < 200; e++ {
sum = 0
var x []int64
for i := 0; i < 1000000; i++ {
x = append(x, int64(i))
}
var y []int64
for i := 0; i < 1000000-1; i++ {
y = append(y, x[i]+x[i+1])
}
for i := 0; i < 1000000; i += 100 {
sum += y[i]
}
}
fmt.Println(sum)
}
24. Go C++
go build bench-go.go clang++ -m64 -o bench-cpp -O3 bench-
cpp.cpp
✔ ~/go_vs_cpp
02:29 $ time ./bench-go
9999010000
real 0m1,785s
user 0m2,417s
sys 0m0,246s
✔ ~/go_vs_cpp
02:29 $ time ./bench-go
9999010000
real 0m1,809s
user 0m2,441s
sys 0m0,253s
✔ ~/go_vs_cpp
02:29 $ time ./bench-cpp
9999010000
real 0m0,868s
user 0m0,729s
sys 0m0,128s
✔ ~/go_vs_cpp
02:29 $ time ./bench-cpp
9999010000
real 0m0,875s
user 0m0,735s
sys 0m0,130s
25. Go C++
go build -gcflags=-B bench-go.go clang++ -m64 -o bench-cpp -O3 bench-
cpp.cpp
✔ ~/go_vs_cpp/I_vlxy_I
01:37 $ time ./bench-go
1999802000000
real 0m0,350s
user 0m0,504s
sys 0m0,055s
✔ ~/go_vs_cpp/I_vlxy_I
01:37 $ time ./bench-go
1999802000000
real 0m0,352s
user 0m0,510s
sys 0m0,058s
✔ ~/go_vs_cpp/I_vlxy_I
01:37 $ time ./bench-cpp
1999802000000
real 0m0,511s
user 0m0,447s
sys 0m0,014s
✔ ~/go_vs_cpp/I_vlxy_I
01:39 $ time ./bench-cpp
1999802000000
real 0m0,488s
user 0m0,425s
sys 0m0,012s
26. C++* Go*
#include <iostream>
#include <vector>
int main() {
int64_t sum = 0;
std::vector<int64_t> x;
x.reserve(1000000);
std::vector<int64_t> y;
y.reserve(1000000);
for (int e = 0; e < 200; e++) {
x.clear();
y.clear();
for (int i = 0; i < 1000000; i++) {
x.push_back(i);
}
for (int i = 0; i < 1000000 - 1; i++) {
y.push_back(x[i] + x[i + 1]);
}
for (int i = 0; i < 1000000; i += 100) {
sum += y[i];
}
}
std::cout << sum << std::endl;
return 0;
}
package main
import "fmt"
func main() {
var sum int64 = 0
var x []int64
x = make([]int64,0,1000000)
var y []int64
y = make([]int64,0,1000000)
for e :=0; e<200; e++ {
x = x[:0]
y = y[:0]
for i :=0; i < 1000000; i++ {
x = append(x, int64(i))
}
for i :=0; i< 1000000-1; i++ {
y = append(y, x[i]+x[i+1])
}
for i:=0; i<1000000; i+=100 {
sum += y[i]
}
}
fmt.Println(sum)
}
27. C++* Go*
#include <iostream>
#include <vector>
int main() {
int64_t sum = 0;
std::vector<int64_t> x;
x.reserve(1000000);
std::vector<int64_t> y;
y.reserve(1000000);
for (int e = 0; e < 200; e++) {
x.clear();
y.clear();
for (int i = 0; i < 1000000; i++) {
x.push_back(i);
}
for (int i = 0; i < 1000000 - 1; i++) {
y.push_back(x[i] + x[i + 1]);
}
for (int i = 0; i < 1000000; i += 100) {
sum += y[i];
}
}
std::cout << sum << std::endl;
return 0;
}
package main
import "fmt"
func main() {
var sum int64 = 0
var x []int64
x = make([]int64,0,1000000)
var y []int64
y = make([]int64,0,1000000)
for e :=0; e<200; e++ {
x = x[:0]
y = y[:0]
for i :=0; i < 1000000; i++ {
x = append(x, int64(i))
}
for i :=0; i< 1000000-1; i++ {
y = append(y, x[i]+x[i+1])
}
for i:=0; i<1000000; i+=100 {
sum += y[i]
}
}
fmt.Println(sum)
}
28. C++** Go*
#include <iostream>
#include <array>
std::array<int64_t, 1000000> x;
std::array<int64_t, 1000000> y;
int main()
{
int64_t sum = 0;
for (int e = 0; e < 200; e++)
{
for (int i = 0; i < 1000000; i++)
{
x[i] = i;
}
for (int i = 0; i < 1000000 - 1; i++)
{
y[i] = x[i] + x[i + 1];
}
for (int i = 0; i < 1000000; i += 100)
{
sum += y[i];
}
}
std::cout << sum << std::endl;
return 0;
}
package main
import "fmt"
func main() {
var sum int64 = 0
var x []int64
x = make([]int64,0,1000000)
var y []int64
y = make([]int64,0,1000000)
for e :=0; e<200; e++ {
x = x[:0]
y = y[:0]
for i :=0; i < 1000000; i++ {
x = append(x, int64(i))
}
for i :=0; i< 1000000-1; i++ {
y = append(y, x[i]+x[i+1])
}
for i:=0; i<1000000; i+=100 {
sum += y[i]
}
}
fmt.Println(sum)
}
29. Go C++
go build -gcflags=-B bench-go.go clang++ -m64 -o bench-cpp-array -
O3 bench-cpp-array.cpp
✔ ~/go_vs_cpp/I_vlxy_I
01:37 $ time ./bench-go
1999802000000
real 0m0,350s
user 0m0,504s
sys 0m0,055s
✔ ~/go_vs_cpp/I_vlxy_I
01:37 $ time ./bench-go
1999802000000
real 0m0,352s
user 0m0,510s
sys 0m0,058s
✔ ~/go_vs_cpp/I_vlxy_I
01:39 $ time ./bench-cpp-arrays
1999802000000
real 0m0,275s
user 0m0,256s
sys 0m0,009s
✔ ~/go_vs_cpp/I_vlxy_I
01:53 $ time ./bench-cpp-arrays
1999802000000
real 0m0,281s
user 0m0,255s
sys 0m0,012s
31. •Very convenient way to generate Cgo
binding
•But they both use orthogonal run-time
environments
•And marshalling Go arguments to C stack is
slow as a hell
Cgo interface
39. “Go is safe”
Ross Cox
“Go is defined to be a safe language. Indices into
array or string references must be in bounds; there
is no way to reinterpret the bits of one type as
another, no way to conjure a pointer out of thin air;
and there is no way to release memory, so no
chance of “dangling pointer” errors and the
associated memory corruption and instability.”
Russ Cox,"Off to the Races"
46. •And marshalling Go arguments to C stack is
slow as a hell
•goroutines not transferred between processes
•Api: Posix, windows, …
•Low-cost ipc :
• fork
• ....
Multiprocessing & NUMA in Go
49. • Only short and simple functions are inlined – less than 40
expressions. No function calls, loops, closures…
• Multiple cases when escape analysis gives up, e.g. any kind of
indirection (*p = …)
• Function calls, package boundaries, slice literals, subslicing and
indexing – all inhibits escape analysis
• Range assignment converted to memchr
Go optimizer limitations
https://github.com/golang/go/wiki/CompilerOptimizations
51. • Which uses fully-featured GCC backend…
• And could proceed proper optimizations even
LTO…
• Looks like it’s out of sync with main Go
compiler
And nobody* uses it…
What about gccgo?
53. •Govendor was a pain. Looks irrelevant at the
moment
•But even then it was much better than lack
of wide-spread C++ PM.
•Vcpkg or Conan will help eventually here
•All eyes on WG21/SG15 (tooling)
Past experience with PM
54. Go package managers usage
https://www.jetbrains.com/lp/devecosystem-2019/go/
55. Package Managers in C++?
https://www.jetbrains.com/lp/devecosystem-2019/cpp/
59. Go
1.0
2009 2010 2011 2012 2013 2014 2015 2015 2017 2018
1.1 1.2 1.10
May 2013 Version 1.1 unicode code points in strings literals. 32 and 64 bit int, uint. 64-bit heap of tens of gigabytes.
December 2013 Version 1.2 10K threads. 4K > 8K stacks
June 2014 Version 1.3 no language changes
December 2014 Version 1.4 Much of runtime is in Go.
August 2015 Version 1.5 Self-hosted (in Go and assembler, without C). GC < 10millisecs.
February 2016 Version 1.6 no language changes
August 2016 Version 1.7 sse for x64. SSA-based x64 code generation.
February 2017 Version 1.8 More sse/avx instructions. GC 10..100 microsecs. Overhead deferred improved.. Overhead from Go to C improved
August 2017 Version 1.9 Type aliases in Go. Compilation of functions in parallel
February 2018 Version 1.10 359 x64 instructions supported.
August 2018 Version 1.11 no language changes.WASM. Preliminary support for modules.AVX512 in assembler.
February 2019 Version 1.12 no language changes.TLS 1.3. Improved modules.
60. Go
1.0
2009 2010 2011 2012 2013 2014 2015 2015 2017 2018
1.1 1.2 1.10
May 2013 Version 1.1 unicode code points in strings literals. 32 and 64 bit int, uint. 64-bit heap of tens of gigabytes.
December 2013 Version 1.2 10K threads. 4K > 8K stacks
August 2016 Version 1.7 sse for x64. SSA-based x64 code generation.
August 2017 Version 1.9 Type aliases in Go. Compilation of functions in parallel