Design a site like this with WordPress.com
Get started

GSoC Report- I

Hello World!

Here is my report on GSoC Project- Openlibm.

The project’s primary purpose is to provide a consistent libm to Octave. I tested some of the Bugs listed on the wiki page and below is my observation and report.

I tested the bug on Ubuntu 20.04, UBuntu 22.04, and macOS using the Github Action. The code for Bug Testing can be found on the BugTesting repository.

The c++ programs relevant for each bug are compiled with different compilers and on the different systems using Github action. Then the programs are also compiled with openlibm to observe if the consistency of the math library is achieved.

Testing of Bug #55538: "logspace BIST tests fail when Octave built with LLVM libc++" 

“When octave is compiled with llvm’s libc++ library the output of the below command differs from the accurate output that is compiled with gcc compiler.

#when octave copiled with gcc
>>power (10, complex (inf, 1)) 
ans = -Inf + Infi 
>> power (complex (10, 0), complex (inf, 1))
 ans =  Inf - NaNi " 

This C++ program is used to test the bug octave is producing. Below is the expected output and produced output with different compilers and openlibm

Output Expected:

(-inf,inf), (inf,-nan), (-inf,inf), (inf,-nan) 
  • Ubuntu 22.04 (with GCC compiler and Libstdc++)
  • Without OpenLibm
g++ -std=c++17 bug#55538.cc -o bug#55538      //compiling
ldd bug#55538                 // to show shared libraries
./bug#55538                           //output of program
linux-vdso.so.1 (0x00007fff09dde000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fca42c41000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6(0x00007fca42b5a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fca42b3a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6(0x00007fca42912000)
/lib64/ld-linux-x86-64.so.2 (0x00007fca42e7f000)

(-inf,inf), (inf,-nan), (-inf,inf), (inf,-nan)
  • With OpenLibm
g++ -std=c++17 bug#55538.cc -o bug#55538 -lopenlibm  //compiling
ldd bug#55538                         //to show shared libraries
./bug#55538                                  //output of program
linux-vdso.so.1 (0x00007ffe1cd2b000)
libopenlibm.so.3 => /lib/x86_64-linux-gnu/libopenlibm.so.3 (0x00007fa21846e000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa218242000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa218222000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6(0x00007fa217ffa000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6(0x00007fa217f13000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa2184b0000)

(-inf,inf), (-nan,-nan), (-inf,inf), (inf,-nan)
  • macOS (with llvm/Clang and Libc++)
  • Without OpenLibm
clang++ -stdlib=libc++ bug#55538.cc  -o x       //compiling
otool -L x                       // to show shared libraries
./x                                     //output of program
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

(inf,nan), (inf,nan), (-inf,inf), (inf,nan)
  • With OpenLibm
clang++ -stdlib=libc++ bug#55538.cc -o bug#55538  -lopenlibm  
otool -L bug#55538                  // to show shared libraries
./bug#55538                         //output of program
/usr/local/opt/openlibm/lib/libopenlibm.4.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

(inf,nan), (inf,nan), (-inf,inf), (inf,nan)

Observation:

The expected output is not achieved by compiling the program with Openlibm. Also the output is not consistent with systems and different compilers. Hence, the openlibm as a proposed solution to solve this bug has failed.

Testing of Bug #62212: "Issues when casting large integers to floating point"

This C++ program is used to test the bug octave is producing. Below is the expected output and produced output with different compilers and openlibm.

Output Expected:

db_large_integer: 1.84467e+19
ui64_large_integer: 18446744073709551615
  • Ubuntu 22.04 (with GCC compiler and Libstdc++)
  • Without OpenLibm
g++ -std=c++2a bug#62212.cc -o bug#62212 
ldd bug#62212
./bug#62212        
linux-vdso.so.1 (0x00007ffd0f5e4000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff95887c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff958654000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff95856d000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff958aba000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff95854d000)

db_large_integer: 1.84467e+19
ui64_large_integer: 0
  • With OpenLibm
g++ -std=c++2a bug#62212.cc -o bug#62212 -lopenlibm
ldd bug#62212
./bug#62212
linux-vdso.so.1 (0x00007ffed5d98000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd1778b4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd17768c000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd1775a5000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd177af2000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd177585000)

db_large_integer: 1.84467e+19
ui64_large_integer: 0
  • macOS (with llvm/Clang and Libc++)
  • Without OpenLibm
clang++ -stdlib=libc++ bug#62212.cc  -o v
 otool -L v
 ./v      
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

db_large_integer: 1.84467e+19
ui64_large_integer: 0
  • With OpenLibm
clang++ -stdlib=libc++ bug#62212.cc -o bug#62212  -lopenlibm
otool -L bug#62212
./bug#62212
/usr/local/opt/openlibm/lib/libopenlibm.4.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

db_large_integer: 1.84467e+19
ui64_large_integer: 0

Observation:

On Ubuntu openlibm is failed to link when compiling. The expected output is not achieved by compiling the program with Openlibm. Even compiling with OpenLibm is not giving any difference to output. Hence, the openlibm as a proposed solution to solve this bug has failed.

Testing of Bug #62332: "[MinGW] acos(z), asin(z) and atan(z) , ( z = x + yi ) return wrong result for imaginary part lower than 1e-12"  

This C++ program is used to test the bug octave is producing. Below is the expected output and produced output with different compilers and openlibm.

Output Expected:

7.071068e-01+1.000000e-03i -> 7.853992e-01-1.414212e-03i
7.071068e-01+1.000000e-06i -> 7.853982e-01-1.414214e-06i
7.071068e-01+1.000000e-09i -> 7.853982e-01-1.414214e-09i
7.071068e-01+1.000000e-12i -> 7.853982e-01-1.414214e-12i
7.071068e-01+1.000000e-15i -> 7.853982e-01-1.414214e-15i
7.071068e-01+1.000000e-18i -> 7.853982e-01-1.414214e-18i
7.071068e-01+1.000000e-21i -> 7.853982e-01-1.414214e-21i
7.071068e-01+1.000000e-24i -> 7.853982e-01-1.414214e-24i
7.071068e-01+1.000000e-27i -> 7.853982e-01-1.414214e-27i
7.071068e-01+1.000000e-30i -> 7.853982e-01-1.414214e-30i
7.071068e-01+1.000000e-33i -> 7.853982e-01-1.414214e-33i
7.071068e-01+1.000000e-36i -> 7.853982e-01-1.414214e-36i
7.071068e-01+1.000000e-39i -> 7.853982e-01-1.414214e-39i
7.071068e-01+1.000000e-42i -> 7.853982e-01-1.414214e-42i
7.071068e-01+1.000000e-45i -> 7.853982e-01-1.414214e-45i
7.071068e-01+1.000000e-48i -> 7.853982e-01-1.414214e-48i
7.071068e-01+1.000000e-51i -> 7.853982e-01-1.414214e-51i
7.071068e-01+1.000000e-54i -> 7.853982e-01-1.414214e-54i
7.071068e-01+1.000000e-57i -> 7.853982e-01-1.414214e-57i
7.071068e-01+1.000000e-60i -> 7.853982e-01-1.414214e-60i
  • Ubuntu 22.04 (with GCC compiler and Libstdc++)
  • Without OpenLibm
g++ -std=c++17 bug#62332.cc -o bug#62332
ldd bug#62332
./bug#62332
linux-vdso.so.1 (0x00007ffe6b1f7000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff1abc78000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff1abb91000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff1ab969000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff1abeb6000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff1ab949000)

0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.41421e-12i
0.707107+1e-15i-->0.785398+-1.41421e-15i
0.707107+1e-18i-->0.785398+-1.41421e-18i
0.707107+1e-21i-->0.785398+-1.41421e-21i
0.707107+1e-24i-->0.785398+-1.41421e-24i
0.707107+1e-27i-->0.785398+-1.41421e-27i
0.707107+1e-30i-->0.785398+-1.41421e-30i
0.707107+1e-33i-->0.785398+-1.41421e-33i
0.707107+1e-36i-->0.785398+-1.41421e-36i
0.707107+1e-39i-->0.785398+-1.41421e-39i
0.707107+1e-42i-->0.785398+-1.41421e-42i
0.707107+1e-45i-->0.785398+-1.41421e-45i
0.707107+1e-48i-->0.785398+-1.41421e-48i
0.707107+1e-51i-->0.785398+-1.41421e-51i
0.707107+1e-54i-->0.785398+-1.41421e-54i
0.707107+1e-57i-->0.785398+-1.41421e-57i
0.707107+1e-60i-->0.785398+-1.41421e-60i
  • With OpenLibm
g++ -std=c++17 bug#62332.cc -o bug#62332 -lopenlibm
ldd bug#62332
./bug#62332
linux-vdso.so.1 (0x00007ffef447c000)
libopenlibm.so.3 => /lib/x86_64-linux-gnu/libopenlibm.so.3 (0x00007efff64c3000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007efff6297000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007efff606f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007efff5f88000)
/lib64/ld-linux-x86-64.so.2 (0x00007efff6505000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007efff5f68000)

0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.4142e-12i
0.707107+1e-15i-->0.785398+-1.44329e-15i
0.707107+1e-18i-->0.785398+0i
0.707107+1e-21i-->0.785398+0i
0.707107+1e-24i-->0.785398+0i
0.707107+1e-27i-->0.785398+0i
0.707107+1e-30i-->0.785398+0i
0.707107+1e-33i-->0.785398+0i
0.707107+1e-36i-->0.785398+0i
0.707107+1e-39i-->0.785398+0i
0.707107+1e-42i-->0.785398+0i
0.707107+1e-45i-->0.785398+0i
0.707107+1e-48i-->0.785398+0i
0.707107+1e-51i-->0.785398+0i
0.707107+1e-54i-->0.785398+0i
0.707107+1e-57i-->0.785398+0i
0.707107+1e-60i-->0.785398+0i
  • macOS (with llvm/Clang and Libc++)
  • Without OpenLibm
 clang++ -stdlib=libc++ bug#62332.cc  -o bug#62332
 otool -L bug#62332
 ./bug#62332
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.4142e-12i
0.707107+1e-15i-->0.785398+-1.33227e-15i
0.707107+1e-18i-->0.785398+-0i
0.707107+1e-21i-->0.785398+-0i
0.707107+1e-24i-->0.785398+-0i
0.707107+1e-27i-->0.785398+-0i
0.707107+1e-30i-->0.785398+-0i
0.707107+1e-33i-->0.785398+-0i
0.707107+1e-36i-->0.785398+-0i
0.707107+1e-39i-->0.785398+-0i
0.707107+1e-42i-->0.785398+-0i
0.707107+1e-45i-->0.785398+-0i
0.707107+1e-48i-->0.785398+-0i
0.707107+1e-51i-->0.785398+-0i
0.707107+1e-54i-->0.785398+-0i
0.707107+1e-57i-->0.785398+-0i
0.707107+1e-60i-->0.785398+-0i
  • With OpenLibm
clang++ -stdlib=libc++ bug#62332.cc  -lopenlibm -o bug#62332
otool -L bug#62332
./bug#62332
           
/usr/local/opt/openlibm/lib/libopenlibm.4.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)

0.707107+0.001i-->0.785399+-0.00141421i
0.707107+1e-06i-->0.785398+-1.41421e-06i
0.707107+1e-09i-->0.785398+-1.41421e-09i
0.707107+1e-12i-->0.785398+-1.4142e-12i
0.707107+1e-15i-->0.785398+-1.33227e-15i
0.707107+1e-18i-->0.785398+-0i
0.707107+1e-21i-->0.785398+-0i
0.707107+1e-24i-->0.785398+-0i
0.707107+1e-27i-->0.785398+-0i
0.707107+1e-30i-->0.785398+-0i
0.707107+1e-33i-->0.785398+-0i
0.707107+1e-36i-->0.785398+-0i
0.707107+1e-39i-->0.785398+-0i
0.707107+1e-42i-->0.785398+-0i
0.707107+1e-45i-->0.785398+-0i
0.707107+1e-48i-->0.785398+-0i
0.707107+1e-51i-->0.785398+-0i
0.707107+1e-54i-->0.785398+-0i
0.707107+1e-57i-->0.785398+-0i
0.707107+1e-60i-->0.785398+-0i

Observation:

Compiling with the Openlibm is providing the output that we want to avoid.The expected output is not achieved by compiling the program with Openlibm. Hence, the openlibm as a proposed solution to solve this bug has failed.

MY TAKE: The proposed solution to use Openlibm as a replacement of libm to deal with the inconsistancy in maths library caused when Octave is compiled with libc++ (default on macOS) and sometimes with libstdc++ has failed and the bug issues and can not be solved with openlibm. Hence, there is need to find an alternate solution to address this issue.

My Project at GNU Octave

Don’t comment bad code,Rewrite it.

Brian Kernighan

Hello World!

Let’s explore my project at GNU Octave- OpenLibm.

GNU Octave has been facing issues regarding inconsistency in C maths library functions on different compilers and systems. Some of the issues are listed here. The main concern is having platform-independent, reliable, and high-quality C math library functions. And here, OpenLibm comes into play.

OpenLibm is a high-quality system independent, portable, open-source libm implementation. Linking Openlibm in place of default Libm can solve the above-mentioned concerns. Since GNU Octave is a high-level programming language that is intended for scientific computing and numerical computations, the need for platform-independent and highly precise maths functions is a must and so is my project. Before diving deep into the project let’s try to know some technical terms:

  • GCC: The GNU Compiler Collection (GCC) is a set of compilers and development tools available for Linux, Windows, and various other operating systems mainly used to compile c/c++ files.
  • Libm: Libm is the standard C library of essential mathematical functions, e.g., sin(x), exp(x), etc. we can include Libm functions, by just adding -lm on the link command line. In GCC, libm is implicitly linked.
  • Clang/LLVM: Clang is a front-end compiler, used to compile programming languages such as C++, C, Objective C++, and Objective C into machine code.
  • libc++ & libstdc++: libc++ and libstc++ is implementation of c++ standatd library. while libc++ is clang/llvm based libstdc++ is gcc/linux based.

My Project in Detail:

As mentioned the main goal of the summer project is linking openlibm while building/compiling Octave. In simple words replacing the default Libm (-lm) and introducing (-lopenlibm) in the command line during the Octave build.

C++ standard library defines itself through C. So we wish to replace the inconsistent default libm with our good libm- Openlibm. In other words, we want to replace the cmath with openlibm_math. So whenever c++ functions invoke C functions implementation instead they will use openlibm implementation. Below is an example of a c++ program compiled when linked with openLibm and the default Libm. We can clearly see that c++ functions can be used with openLibm and how it’s beautifully providing us a replacement for C math libraries.

C++ PROGRAM
COMPILING FIRST WITH OpenLibm THEN WITH DEFAULT Libm

The below picture provides us a clear view of what libraries are linked during compilation and what remains unused.

NOTE: ldd -u –> provides the list of unused libraries during the compilation.

Libraries used during different operations (above: openlibm is linked, below: libm is linked)

The issues listed on the wiki page can be solved when openlibm will be linked to the octave. The problems are due to libstdc++ and libc++’s inconsistent behavior on different compilers and platforms. Since libstdc++ is the default library used by GCC/Linux-based OS and libc++ is the default for Clang-based OS such as MacOS, inconsistency in output arises. Now, with linking to openlibm the output will be consistent.

The next issue I have to deal with is the high precedence of c++ inline functions. while openLibm provides a better version of math library functions but octave still prefers c++ inline math functions because of its high precedence.

In the next step, I’ll be revisiting all the listed bugs in the wiki and dealing with BISTs that need to be visited and revised after the openLibm configuration to the Octave.

Thanks for Reading. 😉

An approach to Speed up Octave Compilations

For my OpenLibm project, I need to build Octave from the Configuration step every time for testing. As building and compiling Octave takes a lot of time, my mentor has suggested using ccache to speed up compilation. Below is the detailed explanation:

Ccache:

Ccache is a software development tool that caches the output of C/C++ compilation so that the next time, the same compilation can be avoided and the results can be taken from the cache. This can greatly speed up recompiling time. The detection is done by hashing.

Steps to Install ccache:

# Install package
sudo apt install -y ccache

# Update symlinks
sudo /usr/sbin/update-ccache-symlinks

# Prepend ccache into the PATH
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc

# Source bashrc to test the new PATH
source ~/.bashrc && echo $PATH

Now create symlinks: (in the current octave build environment):

which gcc
/usr/bin/gcc

which ccache
/usr/bin/ccache

#create sysmlinks
ln -s /usr/bin/ccache /usr/local/bin/gcc
ln -s /usr/bin/ccache /usr/local/bin/cc
ln -s /usr/bin/ccache /usr/local/bin/c++
ln -s /usr/bin/ccache /usr/local/bin/g++

#updated path
which gcc
/usr/local/bin/gcc

This method may speed up your octave compilation time remarkably. There are other tricks to speed up the compilation time. Do visit the GNU discourse discussion link and contribute if you know such tricks.

Bonus:

The command ‘ln -s’ in bash is used to create soft-link (symbolic links) in the system.

Syntax: ln -s ‘existing file’ ‘link’

This way a symlink named link will be created that will point to the existing file.

Happy Learning 🤗.

Hello GSoC!

Open Source Creates symbiotic relationships where the best ideas win.

Saradhi Giriraju, Director of PM, Intuit

Hello World!

I am ecstatic to announce that I have been selected as GSoC Student Developer for the project ‘Openlibm’ at the GNU Octave organization. This project will be mentored by fantastic mentors- Kai T. Ohlhus and Abdallah Elshamy.

About GNU Octave:

GNU Octave is a free, high-level, scientific programming language. It is used to implement numeric algorithms that solve mathematical problems e.g. differentiation, integration, matrix manipulation, algebraic equations, differential equations, optimization, System simulation and control, and many more. It is also used in statistics and data analysis and is very similar to Matlab. It can be the best alternative to MatLab if you are looking for it. To learn more about it visit GNU Octave.

My project ‘Openlibm’:

OpenLibm is an effort to have a high-quality, portable, standalone C mathematical library (libm). It can be used standalone in applications and programming language implementations and is maintained by Julia developers.

GNU Octave is facing the issues(bugs) due to inconsistency of C math library functions on different compilers and platforms. And these issues can be addressed by the implementation of OpenLibm. The main goal of this project is to link Octave against the OpenLibm library rather than the default libm for high and consistent quality math functions on different compilers and operating systems. Since the implementation of Openlibm can be a solution for the replacement of C library functions (that are inconsistent), I will be dedicatedly working on it and will coordinate with mentors to test its implementation. The other important works of this project include learning about the usage of GNU Autotools, modifying and testing configure, and accordingly rewriting BISTs.

My project timeline:

My project is a 12-week medium-sized project. You can find the complete detail of the project timeline and the proposal here. I will be covering more details about my proposal and some Octave journey in the next blog so stay tuned. Thank for reading 😉.

My Internship with OCaml: Outreachy Summary

<Hello World/>

Now that the Outreachy internship is about to end, it’s time, to sum up, the final project progress and my erudite and productive internship journey with OCaml Organisation. Before moving further, I remind you, Outreachy is a diversity initiative that provides paid, remote internships to the people who identify as underrepresented groups in the tech industry. I was selected as an Outreachy intern to work with the OCaml organization on the project ‘Improve OCaml.org website’.

OCaml is a general-purpose programming language with rich toolsets and libraries and its community comprise mainly of functional programmers.

About Project:

My project with the organization is working on the launch of the V3(version) of the main OCaml.org website to support some new features coming to OCaml such as Multicore Support.

Tech Stacks Required for the Project:

The V3 site of OCaml is built on  OCaml (for processing data) and various other modern technologies like ReScript (for frontend work), NextJs (for server-side rendering and generating static website), and Tailwind (CSS framework to build modern websites in an easy and customized way).

My Project Tasks:

My main project goals were to:

  • Implement Web designs for webpages using ReScript and Tailwind.
  • Import data from the old repo of OCaml.org to ocaml/ood repo to use in the V3 site.
  • Improve accessibility of the Website.
  • Provide data/content wherever required.
  • Writing an Outreachy Blog every fortnight during the internship about my internship progress.

 A Quick  Glance at ReScript:

One of the limitations of Javascript is that it’s a weakly typed programming language while it’s also very dynamic giving developers reason to use JS. But what if we want a programming language that has both dynamic as well strong type system features. And here, ReScript comes into play.

ReScript is a new and strongly typed programming language that combines the best parts of JS and OCaml making development much faster and smoother.

So let me tell you why the type system is very important and how ReScript is addressing this issue?

Type System in  OCaml and ReScript:

Static typing includes declaring types of variables, function returns, etc. It can be possible that a variable that is declared gets assigned with a different type. When using a Type system, the compiler will throw an error if something is called with “incorrect type”.This allows the developer to see the type error easily by just running terminal commands and hence the possibility of breaking of code during runtime gets avoided. Thus ReScript having OCaml’s type system feature helps in the maintenance of an extensive codebase where a large scale of type errors are possible, thus reducing the effort and cost of production. 

Here is how the ReScript compiler throws an error:

A helpful error (as the compiler is suggesting what type error it is having.)

ReScript-React:

The ReScript has inbuilt Reactjs bindings that enable developers to use react features. It  has two file extensions .res for implementation and .resi for interface.On compiling, .js files are produced with js output for ReScript codes. 

ReScript Code
Javascript Output

Bindings in ReScript- pros, and cons:

Bindings in ReScript is a way to use JS functions/libraries and third-party APIs in ReScript. For example, if a project needs react leaflet library, first dependencies for leaflet are installed and then one binding file with .res extension is created specifying the types of the Leaflet’s function and containers. So that the containers of the third party can be accessed in the project. Below is the binding for MapContainer:

ReScript binding for MapContainer (React-Leaflet container)
  • Pros: easy to use existing JS libraries.
  • Cons: Sometimes it takes more effort and time to do ReScript bindings for complex APIs.

Variant type and pattern matching: 

The best feature of ReScript that I came across was its variant types and pattern matching feature. It helps to deal with logic errors that occur in JS because of NULL or UNDEFINED values but ReScript doesn’t allow NULL values and   Variant type in ReScript helps in achieving this very goal. Have a look at how null value is beautifully taken care of using Option type and Variant. Notice the option, Some, None keyword.

Cons: when dealing with pattern matching one has to make ensure to take care of all cases otherwise compiler throws errors.

Modules:

Each ReScript file is a module in itself with the same name and is accessible to every other ReScript module. So,  Unlike Reactjs there is no need of importing and exporting of modules and functions.

For example a variable name myVariable in Test. res can be accessed like this Test.myVariable in other files.

Community & Documentation:

The ReScript is a new language with a growing community and with mediocre documentation. A newcomer like me had to struggle a lot as there are very few solutions and approaches available on the internet for ReScript bugs.

Compilation time:

For the first time as a ReScript user, I had to wait for more than  1 min every time to compile code, giving me an irritating feeling.

Use of React-Leaflet library and Next js Dynamic Importing :

I worked on the implementation of the world Map on the ‘Academic page’ using React-leaflet Map. As discussed earlier, in ReScript, for using JS libraries or third-party APIs in the project there is a need to create ReScript binding for that API/Library. For the leaflet library, one ReScript binding file was created. Since my project also uses Next.Js, there was an error in rendering Map(leaflet containers ) in the browser. 

Next.js uses SSR- Server Side Rendering while React-leaflet uses CSR-Client Side Rendering. Hence one conflict arose as the leaflet failed to find Windows objects in SSR. This problem was solved by the functionality of Dynamic import in NextJs. 

NextJs provides an advanced feature Dynamic Import by which JS modules can be dynamically imported in the browser when the web page loads. With the help of this functionality, the Leaflet map was successfully loaded in the browser.  Below is the code snippet of ReScript Binding for the next/dynamic functionality.

ReScript Bindings for next/dynamic function
World Map with Universities marked on it: ReScript Bindings, React-Leaflet, and NextJS Dynamic Import

My experience with OCaml syntaxes:

My very first task during the internship was to work on the OCaml/ood repo to import all required data for the academic webpage from the old repo. I got the opportunity to work with OCaml, Yaml, and markdown files. Here is a code snippet of my work:

 image of code snippet of academic_institution.mli (where acad page data is stored )

Some of My major PRs/work in ReScript:

Implemented the web design for Academic Excellence Webpage using ReScript and Tailwind and using some react hooks. Made my second major PR.

Figma design for academic_excellence page by web designing team
 webpage created by me using Rescript and Tailwind

Implemented the design of the Industrial Users page with improved readability of code. Made my third major PR.

 Figma design for Industrial Users page by web designing team
webpage created by me using Rescript and Tailwind

code snippet of the Industrial users’ web page written in ReScript and Tailwind

My open-source experiences takeaways:

The best part of Open Source is anyone can contribute. You are not required to be a pro in the field. The open-source community especially the OCaml community where I worked were very helpful and friendly. I could ask doubts to any of the OCaml members and they were always ready to help me. Open source helped me enhance my tech skills and provided me with a wonderful experience working on a real-world project. I interacted with people from different countries, communities and also got to work with the web design team. These all experiences have helped me enhance my personality development and coordination and teamwork skills.

Once I asked my mentor- what’s the inspiration behind working in the open-source? And he replied that it gives him satisfaction when people use his contributions for free. By doing this,  he is helping others and creating a positive impact on technology and as a result in people’s lives directly. And yes this is what Open Source actually is!

Tips for Upcoming Interns:

Open Source is the best platform to showcase your technical skills, where you can help people directly with the contributions, and Outreachy provides a better platform to grow and learn. You need not be pro in any technical skills all that matters is the quest for learning and improvement.

Never afraid to ask questions and seek help from the community members. Before asking any question to mentor first research on the topic, if not able to solve in 4-5 hours then ask.

My Takeaway from this internship:

I was fortunate to do my first internship in Outreachy with the very supportive and friendly members of the OCaml Organisation. I got an opportunity to work with the web design team along with the backend and frontend teams. I have learned many technical skills and gained confidence in web development and enhanced my network. I admire my mentors a lot for their leadership skills and helping nature. I never felt any pressure while working on the project under their guidance. They are the most lovable people I’ve ever met. I will miss Outreachy and its community. 🥺

Modifying Expectations

We have a strategic plan.It’s called “doing things.”

~Herb Kelleher

Hello world!🤗

In this blog, I’ll talk about project expectations,planning and timeline. As it goes by saying that “an hour of planning can save you 10 hours of doing“.Taking this into consideration, in outreachy interns have to propose a project timeline that includes work goals set to achieve during our internship.

Initially, I had proposed a project timeline on which I wanted to work during my intern period but had to change my timeline as a similar new project was announced by mentor and I was asked to work on the new one.

Since the project and its tech stacks were new to me,I was given two weeks to accomodate myself with the new codebase and learn the required tech stacks.For this my mentors provided me resources to learn and guided me every time I got stuck.We then moved on setting project on my local machine. That’s how my first three weeks of internship went.Finally, I became comfortable with codebase and learnt all required tech stacks.😎

My mentors have given me freedom to work on what I like. So, I chose a github issue by myself and got permission to work on. it was about implementing a webpage design using ReScript and react and fetching the required data for this webpage from old repository using OCaml packages.

I worked on fetching data and made my first Pull request. After that I implemented the web design and created the desired webpage.

After completion my first work I created another webpage and the moved on learning react-leaflet for implementation of a World Map on a webpage with ReScript bindings.

Currently, I am working on accessibility of website and learning Pa11y CI tool and gitHub actions to integrate accessibility tool with GitHub.

I expected to learn a lot during my internship and yes I am learning a lot. I am enjoying my new project timeline and hoping to finish my works in timeframe.

Thank you for reading!😊

My Project at OCaml

Hello world! 🤗

In this blog, I’ll answer some general questions regarding my community OCaml organization and my project.So let’s get started.😊

What is OCaml and What kind of people participate in OCaml community?

OCaml is a general purpose programming language with an emphasis on expressiveness and safety.It is principally maintained at INRIA (French Institute for Research in Computer Science and Automation), it has an advanced type system that helps catch your mistakes without getting in your way. It is supported by an active community, and has a rich set of libraries and development tools.Mostly functional programmers or people that enjoy functional programming are a part of the community.

OCaml is a strongly typed functional programming language, in the same niche as Haskell, Scala or F#. If you had been looking for an opportunity to practice a functional programming language with a powerful type system, participating to the OCaml community would be an excellent choice.

What problem is your community trying to solve?

The OCaml community is trying to find the best way to combine safety and expressiveness in a language, i.e., they are trying to find a meeting point between mathematics rigor and human creativity in programming.The community contributes to the implementation of the language, as well as the surrounding ecosystem of tools and libraries.

How does your project fit into the larger community?Why would people want to use your project?

With its strong security features and high performance, several companies rely on OCaml to keep their data operating both safely and efficiently.Companies like Jane Street, Facebook, Docker, Bloomberg, Citrix, and a lot more use Ocaml.

I am working on launch of V3(version) of main OCaml.org website in order to support some new features coming to OCaml such as Multicore Support.My main tasks are to implement web designs,work on accessibilty by integrating it with GitHub action and importing data from old repository using OCaml packages.The website uses ReScript and React for its frontend framework. Using ReScript, you can access the vast JavaScript ecosystem and tooling but without the warts, with a great type system, and with a lean build toolchain that doesn’t waste your time. It’s lot more faster than JS and has readable output .Other than this my project uses nextjs,tailwind(CSS library),OCaml etc.

What makes you most excited to work on your project?

The most exciting part of this project is I am working as a team with web designers and web developers. I have to implement the web designs made by designing team and it’s supercool task.Sometimes I undergo a lot of debugging and errors. But at last seeing the code running and getting merged to the site with positive feedback and appreciation from the mentors gives an immense pleasure and boosts confidence and excitation to complete new tasks.

What new terms or concepts have you learned in the past month?

Each day in internship, I learn new things. I learnt implementation of react leaflet using ReScript last week as a task to implement world map on a webpage. Currently, I am learning Pa11y CI accessibility tool with integration with GitHub action. I learnt many new terms in Git like rebase, cherry-pick commit, merge conflict resolving techniques etc. and others like use of makefile.

Thank you for reading.

Everybody Struggles

There is no gain without struggle.

Hello World!

It’s almost four weeks of my Outreachy Internship period and I’m having an amazing experience with my project so far. However, learning and experiencing new things invites a lot of challenges. I too struggle sometimes.

My struggle started when I had to start using Ubuntu for my project during the contribution period. I had very little knowledge of Linux commands.😅 So, making myself comfortable with Ubuntu was a new challenge for me.

My internship with Ocaml is all about improving their website. The tech stacks to build this project includes ReScript, React, Tailwind and OCaml, etc. And guess what? these all are new things to me 🤣 except React that I was familiar with before this internship was started.

So, the first two weeks went by learning and exploring these new things. But the real struggle came when I started working on my first issue. I had no idea what to do. Initially, I was hesitant to ask, since I didn’t have any particular questions, I was confused about almost everything. I began reading the documentation and exploring the codebase. Still, my efforts weren’t enough. Finally, I brought this up on a call with my mentors. They screen-shared and gave me an overall idea of the codebase and that was helpful indeed. I was able to raise my first PR.🎉

It’s ok to ask questions, never be afraid of asking for directions. Don’t be embarrassed or fake knowledge to look cool. Be brave and curious.😃

I love that my mentors gave me the freedom to work on what I like, they encourage me to ask questions whenever I got stuck in the code as every question is important. I am working on my next task and still struggling with many bugs, errors but this time I’m not afraid of asking for help from my mentors and thankfully they respond quickly.

So, here is the situation we all can relate to.😁

OpenSource Vocabulary Terms

I was introduced to many terms and concepts related to the OpenSource community when I started contributing. For instance, CI(Continuous Integration) tool, RSS feeds, and much Git-related stuff.

Let’s explore git pre-commit hooks.

Git pre-commit hooks:

Git provides hooks for events such as commit, push, receive, update, etc. The Git hook feature is built-in, no need to download or install anything. You can check these built-in hooks by running in ls .git/hooks in any git repository.

Pre-commit hook runs before typing the commit message. It’s primarily being used for linting or running tests to make sure everything is working. Pre-commit hooks are very helpful in maintaining the coding standards and productivity also as many of the suggested lint changes can be fixed automatically. It plays an essential role when multiple people are working on the same repo. The team can make sure everything goes to the repo passes the checks and balances put in place by using pre-commit hooks.

Here is the list of Git hooks: https://githooks.com/

The expert in anything was once a beginner.

So, let’s begin our journey in the OpenSource community and embrace the struggles to become an expert.😊

Thank you for reading.🤗

Hello, Outreachy!

The power of Open Source is the power of the people.The people rule.

-Philipe Kahn

Hello World!

The first week of my Outreachy internship has just started and I am really looking forward to a wonderful summer with OCaml!🎉🥳 I am woking on the project ‘Improve OCaml.org’ mentored by Patrick Ferris, Anil Madhavapeddy, Gargi Sharma and Bella.

I am Shreya Gupta from Bihar, India. I have just completed my sophomore year at Indian Institute Of technology, Patna. Here, I am pursuing Electrical and Electronics Engineering.

I am very fond of reading novels, watching political debates, and listening to music.I also like learning new language and reading culture and history of different places and countries. Currently, I am learning Spanish😊. I love chatting with my friends.😁

Core values that are important to me are Friendship, Determination and Curiosity.

Friendship is the most important core values and the one I give the highest priority.The reason is it itself comes with many important core values like love, trust, honesty, equality, peace and independence.It’s an opportunity to love, to learn about yourself, to mature as a human being, and to open up to the full experience of life. A friend is very vital for mental health.I’m blessed to have some lovely friends who always motivate and support me.😄

Determination enables us to persist in the face of difficulties.With determination, we can overcome any type of obstacle.For me being determined for something provides hope and courage not to give up until success.🙃

Curiosity is the very purpose of life. I love exploring and trying out new things. These include learning about different place’s cultures and history, learning new tech skills, etc.Being curious has made myself better and improved.✌

What motivated me for outreachy:

I came to know about contribution to Open source Software in my college.I joined some clubs of my college that motivates students to contribute to Open Source, there I got to know about Outreachy Summer Internship.

What I liked the most about Outreachy was the fact that it celebrates diversity and also it’s paid. Getting this internship would mean having a chance to meet the superheroes from all over the world who have been under-represented in their field. I was certain that this internship would provide me opportunities to connect people across the world and learn and explore tech skills required for my project.