Skip to content

Instantly share code, notes, and snippets.

View jseteny's full-sized avatar
👋
PLease call. I write your parser, DSL, Converter in any language

János Setény jseteny

👋
PLease call. I write your parser, DSL, Converter in any language
View GitHub Profile
@gvolpe
gvolpe / build.sbt
Last active September 29, 2023 10:26
Minimal SBT build for pfps-examples
ThisBuild / scalaVersion := "2.13.5"
lazy val root = (project in file("."))
.settings(
name := "minimal",
libraryDependencies ++= Seq(
compilerPlugin(
"org.typelevel" %% "kind-projector" % "0.11.3"
cross CrossVersion.full
),
@fancellu
fancellu / MyIO.scala
Last active October 5, 2024 13:24
Simple example of an IO effect Monad, no Cats, no ZIO
import scala.util.Random
// Simple example of an IO effect Monad, no Cats
object MyIO extends App{
// IO encapsulates a side effecting operation
final class IO[A](val run: () => A) {
def map[B](f: A => B): IO[B] = IO(f(run()))
@amrali
amrali / hkt.cpp
Created September 17, 2018 00:14 — forked from jhaberstro/hkt.cpp
Functor, Maybe, and Higher-Kinded Types in C++
// Example program
#include <iostream>
#include <string>
#include <vector>
#include <type_traits>
//---------------------
// Maybe and MyVector, two totally unrelated classes whose only commanilty is that they are both type constructors of the same arity (e.g. 1) and order (e.g. 1).
//---------------------
template< typename T >

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@jonnyjava
jonnyjava / Tpp.md
Last active April 14, 2023 15:00
The Pragmatic Programmer: From Journeyman to Master

The Pragmatic Programmer: From Journeyman to Master

Tips collected

  1. Care About Your Craft
  • Why spend your life developing software unless you care about doing it well?
  1. Think! About Your Work
  • Turn off the autopilot and take control. Constantly critique and appraise your work.
  1. Provide Options, Don't Make Lame Excuses
  • Instead of excuses, provide options. Don't say it can't be done; explain what can be done.
@Avaq
Avaq / combinators.js
Last active May 20, 2025 01:53
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@staltz
staltz / introrx.md
Last active July 25, 2025 02:08
The introduction to Reactive Programming you've been missing
@seratch
seratch / build.sbt
Created December 1, 2011 06:07
Scala School - Testing with specs2 examples
organization := "net.seratch"
name := "sandbox"
version := "0.1"
scalaVersion := "2.9.1"
libraryDependencies ++= Seq(
"junit" % "junit" % "4.9" withSources(),