V8 is the JavaScript engine used in Google Chrome. It is open source and written in C++ with some parts implemented in embedded JavaScript. V8 uses just-in-time compilation, precise garbage collection, inline caching, and hidden classes to optimize performance. It supports 64-bit versions and has advantages like C-like syntax and bit operations. While documentation is limited, it allows embedding JavaScript in C++ applications and extending it with user libraries.
A journey through the wonderful world of Node.js C++ addons. This talk was given at the September 8, 2015 NodeMN meetup.
Code: https://github.com/cb1kenobi/nodemn
Despite being a slow interpreter, Python is a key component in high-performance computing (HPC). Python is easy to use. C++ is fast. Together they are a beautiful blend. A new tool, pybind11, makes this approach even more attractive to HPC code. It focuses on the niceties C++11 brings in. Beyond the syntactic sugar around the Python C API, it is interesting to see how pybind11 handles the vast difference between the two languages, and what matters to HPC.
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemSages
Introduction to Hadoop Map Reduce, Pig, Hive and Ambari technologies.
Workshop deck prepared and presented on September 5th 2015 by Radosław Stankiewicz.
During that the day participants had also the possibility to go through prepared tutorials and test their analysis on real cluster.
A journey through the wonderful world of Node.js C++ addons. This talk was given at the September 8, 2015 NodeMN meetup.
Code: https://github.com/cb1kenobi/nodemn
Despite being a slow interpreter, Python is a key component in high-performance computing (HPC). Python is easy to use. C++ is fast. Together they are a beautiful blend. A new tool, pybind11, makes this approach even more attractive to HPC code. It focuses on the niceties C++11 brings in. Beyond the syntactic sugar around the Python C API, it is interesting to see how pybind11 handles the vast difference between the two languages, and what matters to HPC.
Wprowadzenie do technologii Big Data / Intro to Big Data EcosystemSages
Introduction to Hadoop Map Reduce, Pig, Hive and Ambari technologies.
Workshop deck prepared and presented on September 5th 2015 by Radosław Stankiewicz.
During that the day participants had also the possibility to go through prepared tutorials and test their analysis on real cluster.
Presentation to the MIT IAP HTML5 Game Development Class on Debugging and Optimizing Javascript, Local storage, Offline Storage and Server side Javascript with Node.js
Presentation I gave at a Rust Austin meetup in November 2018 about exploring different approaches for interpreting custom DSLs in Rust with varying speed characteristics and associated safety issues.
Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/254wkpw.
Aaron Bedra focuses on describing a system as a series of models that can be used to systematically and automatically generate input data and ensure that a code is behaving as expected. Bedra discusses property based testing and how it can help one build more resilient systems and even reduce the time needed to maintain a test suite. Filmed at qconlondon.com.
Aaron Bedra is Chief Security Officer at eligible.com. He is the creator of Repsheet, an open source threat intelligence framework. Bedra is the co-author of Programming Clojure, 2nd Edition and a frequent contributor to open source software.
Не так давно Гор Нишанов представил свой доклад: C++ Coroutines a negative overhead abstraction. В этом докладе Гор упомянул, что предложенный дизайн корутин позволяет их использовать практически в любых окружениях, в том числе и с "бедным" C++ рантаймом.
Я решил попробовать запустить корутины в следующих окружениях: обычное приложение, драйвер ОС Windows, EFI приложение. Только в одном из этих окружений есть полноценный C++ рантайм и поддержка исключений, в остальных ничего этого нет. Более того, EFI приложение вообще выполняется до старта ОС.
Я хочу рассказать о том, как мне удалось запустить корутины в этих окружениях, поговорим о том, какие проблемы существуют в асинхронном системном программировании и как их можно обойти.
Presentation to the MIT IAP HTML5 Game Development Class on Debugging and Optimizing Javascript, Local storage, Offline Storage and Server side Javascript with Node.js
Presentation I gave at a Rust Austin meetup in November 2018 about exploring different approaches for interpreting custom DSLs in Rust with varying speed characteristics and associated safety issues.
Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/254wkpw.
Aaron Bedra focuses on describing a system as a series of models that can be used to systematically and automatically generate input data and ensure that a code is behaving as expected. Bedra discusses property based testing and how it can help one build more resilient systems and even reduce the time needed to maintain a test suite. Filmed at qconlondon.com.
Aaron Bedra is Chief Security Officer at eligible.com. He is the creator of Repsheet, an open source threat intelligence framework. Bedra is the co-author of Programming Clojure, 2nd Edition and a frequent contributor to open source software.
Не так давно Гор Нишанов представил свой доклад: C++ Coroutines a negative overhead abstraction. В этом докладе Гор упомянул, что предложенный дизайн корутин позволяет их использовать практически в любых окружениях, в том числе и с "бедным" C++ рантаймом.
Я решил попробовать запустить корутины в следующих окружениях: обычное приложение, драйвер ОС Windows, EFI приложение. Только в одном из этих окружений есть полноценный C++ рантайм и поддержка исключений, в остальных ничего этого нет. Более того, EFI приложение вообще выполняется до старта ОС.
Я хочу рассказать о том, как мне удалось запустить корутины в этих окружениях, поговорим о том, какие проблемы существуют в асинхронном системном программировании и как их можно обойти.
Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
JavaScript Multithread or Single Thread.pptxRAHITNATH
The most functional yet intricately constructed programming language is JavaScript. Understanding how the syntax is used in engines, such as V8 engines for chromium, is challenging. We are successfully completing tasks in Chrome at the same time. This PPT will assist you in learning about the most crucial aspects and use of JavaScript, which will help you comprehend when and where the language is required. Java provides a superior platform by using multi-threading ways to optimize the process, but how can JavaScript manage to achieve the same thing even in a better way to compile and provide us a real-time user interface on webpages even after a significant amount of time has passed.
JavaScript's non-blocking approaches offer a better method of process resolution and execution with regard to load and priority to improve user experience. Even better are the non-blocking approaches and some browser architecture. The topic focuses on JavaScript's end-to-end workflow in Chrome's V8 engine and how it distributes its load and processes with the aid of queues made available by Chrome's architectural design.
Better Open Source Enterprise C++ Web ServicesWSO2
In this webinar/presentation presented on November 10, 2009, Nandika Jayawardana explores the capabilities of the WSO2 Web Services Framework for C++ (WSO2 WSF/C++) to develop and deploy Web services in C++.
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)PROIDEA
Since the beginnings of C++, classes are the basic building block of any self-respecting application. The combination of data and its relevant functionality heavily impacts the way we modularize the program, design APIs, construct and reuse the code - think of software in general.
In the previous era, C++ was a hammer for every nail, providing secure high-level abstractions without sacrifice of the superior performance. Yet during the past decades, competing technologies dethroned it out of many domains. As the language evolved to prevail its principal advantages, so did the way classes are programmed.
I am pleased to invite you to a speech about code construction and programming techniques used in programs and libraries now and then. Expect a lot of code samples!
Sample JavaScript Code Laurence Svekis
JavaScript Closure
A closure in JavaScript is a function that has access to the variables in its parent scope, even after the parent function has completed execution. This allows for data to be “closed over” or remembered by the inner function, even after the outer function has returned.
Here, the makeCounter function returns an inner function that has access to the count variable declared in its parent scope, and can “remember” the current count value even after the makeCounter function has completed execution. Each time the inner function is called, it returns the current value of count and increments it by 1.
JavaScript Closure Advanced
In this example, the makeAdder function takes in a single argument x and returns an inner function that takes in a second argument y. The inner function has access to the x variable declared in the parent scope and uses it to add x and y together and return the result.
We can see here that the outer function makeAdder has been executed twice and it returns two different inner functions which are assigned to different variables add5 and add10 and these inner functions are able to remember their respective parent scope values of x.
You may all know that JSON is a subset of JavaScript, but… Did you know that HTML5 implements NoSQL databases? Did you know that JavaScript was recommended for REST by HTTP co-creator Roy T. Fielding himself? Did you know that map & reduce are part of the native JavaScript API? Did you know that most NoSQL solutions integrate a JavaScript engine? CouchDB, MongoDB, WakandaDB, ArangoDB, OrientDB, Riak…. And when they don’t, they have a shell client which does. The story of NoSQL and JavaScript goes beyond your expectations and opens more opportunities than you might imagine… What better match could you find than a flexible and dynamic language for schemaless databases? Isn’t an event-driven language what you’ve been waiting for to manage consistency? When NoSQL doesn’t come to JavaScript, JavaScript comes to NoSQL. And does it very well.
3. 소개
• 구글 크롬에 사용된 자바스크립트 엔진
• open source( New BSD License )
• c++ 구현됨 ( 일부는 내장 javascript 로 구
현 )
• windows / *nix / mac os X
• x86 / ARM
4. 장점
• 속도 : lua < v8 < lua-jit
• 64bit version 지원
• javascript 의 언어적 장점
– C 와 비슷
– Bit operation( <<, >> )
– 당연하게도 switch 가 있다 .
• google 에서 작성
– 안전성 , 업데이트 주기
• 인력 구하기
– 게임업계 외에서는 javascript 인력이 많다
5. 단점
• 문서 ( 예제 )
• 유저 라이브러리 확장
• corutine 같은 기능이 없음
• binder
6. 빌드
• 컴파일된 버젼이 없으니 받아서 빌드해야 함
• 선행 조건
– python 과 scon(make 같은 것 )
– python 부터 설치 하는게 편함
• 빌드 ( vc2008 기준 )
– Vcvarsall.bat
– scons env="PATH:%PATH%,INCLUDE:%INCLUDE
%,LIB:%LIB%" msvcrt=shared mode=debug
library=shared snapshot=off
7. dll 버전 사용하기
• USING_V8_SHARED
– dll 을 사용하는 응용프로그램에서 전역적으로
define 해야 함
– debug 버전
v8_g.lib, v8_g.dll
– release 버전
v8.lib, v8.dll
13. javascript 에서 c++ 함수를 호출
static Handle<Value> LogCallback(const Arguments& args)
{
HandleScope scope;
printf("LogCallback calledn");
return v8::Undefined();
}
void Function()
{
HandleScope handle_scope;
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::New("log"), FunctionTemplate::New(LogCallback));
Persistent<Context> context = Context::New( NULL, global );
Context::Scope context_scope(context);
Handle<String> source = String::New("log();");
Handle<Script> script = Script::Compile(source);
script->Run();
context.Dispose();
}
14. javascript 에서 c++ 함수를 호출
static Handle<Value> LogCallback(const Arguments& args)
{
HandleScope scope;
printf("LogCallback calledn");
return v8::Undefined();
}
void Function()
{
HandleScope handle_scope;
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::New("log"), FunctionTemplate::New(LogCallback));
Persistent<Context> context = Context::New( NULL, global );
Context::Scope context_scope(context);
Handle<String> source = String::New("log();");
Handle<Script> script = Script::Compile(source);
script->Run();
context.Dispose();
}
15. javascript 에서 c++ 함수를 호출
static Handle<Value> LogCallback(const Arguments& args)
{
HandleScope scope;
printf("LogCallback calledn");
return v8::Undefined();
}
void Function()
{
HandleScope handle_scope;
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::New("log"), FunctionTemplate::New(LogCallback));
Persistent<Context> context = Context::New( NULL, global );
Context::Scope context_scope(context);
Handle<String> source = String::New("log();");
Handle<Script> script = Script::Compile(source);
script->Run();
context.Dispose();
}
16. javascript 에서 c++ 함수를 호출
static Handle<Value> LogCallback(const Arguments& args)
{
HandleScope scope;
printf("LogCallback calledn");
return v8::Undefined();
}
void Function()
{
HandleScope handle_scope;
Handle<ObjectTemplate> global = ObjectTemplate::New();
global->Set(String::New("log"), FunctionTemplate::New(LogCallback));
Persistent<Context> context = Context::New( NULL, global );
Context::Scope context_scope(context);
Handle<String> source = String::New("log();");
Handle<Script> script = Script::Compile(source);
script->Run();
context.Dispose();
}
17. javascript 에서 c++ 전역 변수 읽고 / 쓰기
int x, y;
Handle<Value> XGetter(Local<String> property, const AccessorInfo& info)
{
return Integer::New(x);
}
void XSetter(Local<String> property, Local<Value> value, const AccessorInfo& info
{
x = value->Int32Value();
}
18. javascript 에서 c++ 전역 변수 읽고 / 쓰기
void GlobalVar()
{
HandleScope handle_scope;
Handle<ObjectTemplate> global_templ = ObjectTemplate::New();
global_templ->SetAccessor(String::New("x"), XGetter, XSetter);
global_templ->SetAccessor(String::New("y"), YGetter, YSetter);
Persistent<Context> context = Context::New(NULL, global_templ);
Context::Scope context_scope(context);
Handle<String> source = String::New("x = 10; y = 10; x = y + 20;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
String::AsciiValue ascii(result);
printf("%sn", *ascii);
}
19. javascript 에서 c++ 전역 변수 읽고 / 쓰기
void GlobalVar()
{
HandleScope handle_scope;
Handle<ObjectTemplate> global_templ = ObjectTemplate::New();
global_templ->SetAccessor(String::New("x"), XGetter, XSetter);
global_templ->SetAccessor(String::New("y"), YGetter, YSetter);
Persistent<Context> context = Context::New(NULL, global_templ);
Context::Scope context_scope(context);
Handle<String> source = String::New("x = 10; y = 10; x = y + 20;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
String::AsciiValue ascii(result);
printf("%sn", *ascii);
}
20. javascript 에서 c++ class 접근
lass Point
ublic:
Point(int x, int y) : x_(x), y_(y) { }
int x_, y_;
;
21. javascript 에서 c++ class 접근
HandleScope handle_scope;
Handle<FunctionTemplate> point_templ = FunctionTemplate::New();
Handle<ObjectTemplate> point_inst = point_templ->InstanceTemplate();
point_inst->SetInternalFieldCount(1);
point_inst->SetAccessor(String::New("x"), GetPointX, SetPointX);
point_inst->SetAccessor(String::New("y"), GetPointY, SetPointY);
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Point* p = new Point(0, 0);
Handle<Function> point_ctor = point_templ->GetFunction();
Local<Object> obj = point_ctor->NewInstance();
obj->SetInternalField(0, External::New(p));
context->Global()->Set(String::New("point"), obj);
Handle<String> source = String::New("point.x = 200;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
22. javascript 에서 c++ class 접근
HandleScope handle_scope;
Handle<FunctionTemplate> point_templ = FunctionTemplate::New();
Handle<ObjectTemplate> point_inst = point_templ->InstanceTemplate();
point_inst->SetInternalFieldCount(1);
point_inst->SetAccessor(String::New("x"), GetPointX, SetPointX);
point_inst->SetAccessor(String::New("y"), GetPointY, SetPointY);
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Point* p = new Point(0, 0);
Handle<Function> point_ctor = point_templ->GetFunction();
Local<Object> obj = point_ctor->NewInstance();
obj->SetInternalField(0, External::New(p));
context->Global()->Set(String::New("point"), obj);
Handle<String> source = String::New("point.x = 200;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
23. javascript 에서 c++ class 접근
HandleScope handle_scope;
Handle<FunctionTemplate> point_templ = FunctionTemplate::New();
Handle<ObjectTemplate> point_inst = point_templ->InstanceTemplate();
point_inst->SetInternalFieldCount(1);
point_inst->SetAccessor(String::New("x"), GetPointX, SetPointX);
point_inst->SetAccessor(String::New("y"), GetPointY, SetPointY);
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Point* p = new Point(0, 0);
Handle<Function> point_ctor = point_templ->GetFunction();
Local<Object> obj = point_ctor->NewInstance();
obj->SetInternalField(0, External::New(p));
context->Global()->Set(String::New("point"), obj);
Handle<String> source = String::New("point.x = 200;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
24. javascript 에서 c++ class 접근
HandleScope handle_scope;
Handle<FunctionTemplate> point_templ = FunctionTemplate::New();
Handle<ObjectTemplate> point_inst = point_templ->InstanceTemplate();
point_inst->SetInternalFieldCount(1);
point_inst->SetAccessor(String::New("x"), GetPointX, SetPointX);
point_inst->SetAccessor(String::New("y"), GetPointY, SetPointY);
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Point* p = new Point(0, 0);
Handle<Function> point_ctor = point_templ->GetFunction();
Local<Object> obj = point_ctor->NewInstance();
obj->SetInternalField(0, External::New(p));
context->Global()->Set(String::New("point"), obj);
Handle<String> source = String::New("point.x = 200;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
25. javascript 에서 c++ class 접근
HandleScope handle_scope;
Handle<FunctionTemplate> point_templ = FunctionTemplate::New();
Handle<ObjectTemplate> point_inst = point_templ->InstanceTemplate();
point_inst->SetInternalFieldCount(1);
point_inst->SetAccessor(String::New("x"), GetPointX, SetPointX);
point_inst->SetAccessor(String::New("y"), GetPointY, SetPointY);
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Point* p = new Point(0, 0);
Handle<Function> point_ctor = point_templ->GetFunction();
Local<Object> obj = point_ctor->NewInstance();
obj->SetInternalField(0, External::New(p));
context->Global()->Set(String::New("point"), obj);
Handle<String> source = String::New("point.x = 200;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
26. javascript 에서 c++ class 접근
HandleScope handle_scope;
Handle<FunctionTemplate> point_templ = FunctionTemplate::New();
Handle<ObjectTemplate> point_inst = point_templ->InstanceTemplate();
point_inst->SetInternalFieldCount(1);
point_inst->SetAccessor(String::New("x"), GetPointX, SetPointX);
point_inst->SetAccessor(String::New("y"), GetPointY, SetPointY);
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
Point* p = new Point(0, 0);
Handle<Function> point_ctor = point_templ->GetFunction();
Local<Object> obj = point_ctor->NewInstance();
obj->SetInternalField(0, External::New(p));
context->Global()->Set(String::New("point"), obj);
Handle<String> source = String::New("point.x = 200;");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
context.Dispose();
27. javascript 에서 c++ class 접근
Handle<Value> GetPointX(Local<String> property, const AccessorInfo &info)
{
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
void* ptr = wrap->Value();
int value = static_cast<Point*>(ptr)->x_;
return Integer::New(value);
}
void SetPointX(Local<String> property, Local<Value> value, const AccessorInfo& in
{
Local<Object> self = info.Holder();
Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
void* ptr = wrap->Value();
static_cast<Point*>(ptr)->x_ = value->Int32Value();
}
28. 한글 처리 ( 1 )
• class String
– 3 가지 nested class 를 가짐
class String {
class AsciiValue { … }; // ASCII
class Value { … }; // UTF-16
class Utf8Value { … }; // UTF-8
};
29. 한글처리 ( 2 )
• String 클래스 내부 클래스 중에서 Value 를 사
용
– input: unicode
– output: unicode
Handle<String> source = String::New(L"' 한 ' + ' 글 '");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
String::Value str(result);
wchar_t* p = *str;
30. v8 이 빠른 이유 ?
• Just-In-Time Compile
• Garbage Collection
– precise GC ( 자바가 사용한 gc 방식 )
– 더 진보됨
• Inline Cache
– property 찾은 결과 보관하여 cache
• Hidden Classes