CyberSpy

Rantings from a guy with way too much free time

Pathocaml - Getting Wacky with Functions And Polymorphism

2018-03-19 Programming Rob Baruch

OCaml on the Fringes - You can do that??

So, I got bored this afternoon and was contemplating why I was enjoying diving into OCaml more than say Elixir/Erlang for functional programming. The quality of the language that’s most captured my attention is the type system.

When you start playing around with the type system in OCaml you can go from some basic definitions of user-defined types to some pretty cool looking constructs. Let’s start of with something pretty transparent and move into something that might actually melt your brain.

Continue reading

OCaml OpenGL - Get into Gear!

2018-03-13 Programming Rob Baruch

OCaml and OpenGL - Getting our Functional Programming into Gear!

In my blog post for this day, I thought I’d take a look at the OCaml OpenGL library, lablgl. If you’re not already familair with openGL, I strongly suggest that you take a look at one of the tutorials available online. One that I found to be very informative; although written in c++, is opengl-tutorial. Nonetheless, in this post, we’ll look at some simple, and not so simple examples written in OCaml. But before we can do that, we need to install the requisite opam dependencies. To install lablgl, simply:

Continue reading

Exercism - Get your Code Deamons Out! Heal Your Body!

2018-02-28 Programming Rob Baruch

Exercis(m)

The best way to keep the mind, body, and soul sharp is to exercise! No better way to learn new programming paradigms than following this same precept when learning new concepts in an unfamiliar programming language. There are several sites online that afford noobs practice problems - Hackerrank, kaggle to name a few. But one that I recently came across, exercism.io, aims to provide not just programming exercises, but a community of folks committed to commenting and sharing both code and criticism on implementations to problem sets across many languages.

Continue reading

Riding the Camel Deeper into the Desert of Code: Records and Variants

2018-02-11 Programming Rob Baruch

Extending and Encapsulating Data - Records and Variants

Up next on our tour of OCaml are records and variants. If you are familiar with typedef, struct, and union in c/c++, you’ll quickly come to understand how to use records and variants in OCaml. We’ll start off looking at records, how to define them, use them in functions, and automatically generate common functions from our type definitions. There’s more to the eye than what you get in a language like c, so pay close attention as we move through the descriptions below. We’ll break it down one at a time so you’ll have no problems!

Continue reading

Let's Get Funky with the Camel

2018-02-09 Programming Rob Baruch

How many ways can we get Fun(ky)

In any programming paradigm, it’s critical to understand how we write functions - be they traditional imperative , anonymous , recursive, or functional. In this post, I will break down the different types of functions that you can write in OCaml.

Let’s start by examining the imperative function. Here’s a simple function that prints out the phrase Hello World! $n$ times, once on each line, and returns the value $n$ as its result.

Continue reading

OCaml Hello World and more

2018-02-06 Programming Rob Baruch

Well Hello There!

As tradition has it, every new programming language experience must begin with the basic Hello World. Let’s walk the the basics of how to set up our development environment specifically for OCaml and demonstrate how to compile our basic program.

Warming up our Environment

Of course we could just use our vanilla editor to enter our OCaml programs, but a more efficient work environment leverages an extensible editor that is aware of our programming language. Editors like sublime, Atom, and Visual Studio Code are some of the more popular selections. Vim and Emacs are also options, but the new tools tend to support vi/emacs style editing while offering more extensive and expansive features.

Continue reading

OCaml Intro: You can have it all: Object-Oriented, Imperative, and Functional

2018-02-01 Programming Rob Baruch

YAPL

So why take the time to delve into yet another programming language? I find at worst, one can expands one’s knowledge of existing programming paradigms by studying the language design choices of other languages not used on a daily-basis. Best case, one discovers a new language that is rich in expression and productivity; thereby refining the productivity of the user.

OCaml

So, I tripped over this programming language in a rather random and circuitous path. I was watching a super-cool video visualizing how the Fourier Transform integral is constructed (by 3Blue1Brown). At the end of the video, the sponsor was a well-known, prestigious wall-street boutique, Jane Street, famous for hiring the best of the best in mathematics and computer science. So, naturally, I thought I’d take a closer peek at their website and discovered that they were big sponsors in OCaml as it underlies their trading and production environments. And down the rabbit hole I went.

Continue reading
Older posts Newer posts