all repos — h3rald @ 3166aaee68ce93e945d9c42d45676413d32ca80d

The sources of https://h3rald.com

Processing lexers if language is specified.
h3rald h3rald@h3rald.com
Mon, 19 Feb 2024 13:00:09 +0100
commit

3166aaee68ce93e945d9c42d45676413d32ca80d

parent

36c66a24de64febaaeaa74147a52cd6863149f4f

2 files changed, 20 insertions(+), 16 deletions(-)

jump to
M contents/articles/10-more-programming-languages.mdcontents/articles/10-more-programming-languages.md

@@ -25,7 +25,7 @@ While no 1.0 version has been released yet, the language is quite popular. It comes with a [web framework](https://amberframework.org/), it has been used to create [games](https://medium.com/@alanwillms/you-should-write-your-next-game-with-crystal-f27306b63e3d), and someone even calls it [the most promising programming language of 2018](https://medium.com/@DuroSoft/why-crystal-is-the-most-promising-programming-language-of-2018-aad669d8344f). It is not backed by a big companies like some of the languages on this list, but this could be a good thing, after all.

#### Example FizzBuzz Implementation -``` +```crystal 1.upto(100) do |v| p fizz_buzz(v) end

@@ -61,7 +61,7 @@ If you always wanted to try out Erlang but never did because its syntax scared you, then Elixir can definitely help.

#### Example FizzBuzz Implementation -``` +```elixir 1..100 |> Enum.map(fn i -> cond do rem(i,3*5) == 0 -> "FizzBuzz"

@@ -92,7 +92,7 @@ Elm offers static typing, [type inference](https://guide.elm-lang.org/types/), [pattern matching](https://guide.elm-lang.org/types/pattern_matching.html), [functors, applicative and monads](https://medium.com/@l.mugnaini/functors-applicatives-and-monads-in-pictures-784c2b5786f7). It kinda feels a bit like Haskell, but perhaps less daunting and more to-the-point: you are going to use it to build web applications after all.

#### Example FizzBuzz Implementation -``` +```elm import Graphics.Element exposing (show) import List exposing (map)

@@ -130,7 +130,7 @@ If you want a fairly stable and well-rounded programming language for your next project, Go is a safe and powerful choice.

#### Example FizzBuzz Implementation -``` +```go package main import "fmt"

@@ -171,7 +171,7 @@ Sure, it's less mature and tooling probably is not quite on-par with Python, but over the years it is slowly gaining some momentum, especially after its recent 1.0 release. Also, the fact that it has FFIs to C, Fortran, Python, R and Java could probably tempt more scientists into a more step-by-step adoption.

#### Example FizzBuzz Implementation -``` +```julia for i in 1:100 if i % 15 == 0 println("FizzBuzz")

@@ -205,7 +205,7 @@ Although I have never been a big fan of the JVM, Kotlin is definitely one of the most innovative and trending languages running on it nowadays, and perhaps more well-known than its comparable contenders, like [Ceylon](https://ceylon-lang.org/) and [Xtend](https://www.eclipse.org/xtend/) — the so-called _second generation_ JVM languages.

#### Example FizzBuzz Implementation -``` +```kotlin fun fizzBuzz() { for (i in 1..100) { when {

@@ -239,7 +239,7 @@ Want to know something else really cool written in Nim? The open source [Nim forum engine](https://github.com/nim-lang/nimforum) which is based on the [Karax](https://github.com/pragmagic/karax) SPA framework and the [Jester](https://github.com/dom96/jester) web server, both also written in Nim.

#### Example FizzBuzz Implementation -``` +```nim for i in 1..100: if i mod 15 == 0: echo("FizzBuzz")

@@ -272,7 +272,7 @@ There are quite a few articles online comparing Rust to Nim and Go. These three language are somewhat in the same space, being all born as system programming languages and addressing similar concerns. If you read these articles you'll see an almost equal percentage of wins and losses... there are pros and cons as in everything: Nim has the smallest community, Go probably the biggest; Nim syntax is practically Python, Go's is pretty easy as well, while Rust seems syntactically the closes to C/C++, and also arguably the most complex. But again, your mileage may vary.

#### Example FizzBuzz Implementation -``` +```rust use std::borrow::Cow; fn main() { for i in 1..101 {

@@ -305,7 +305,7 @@ While definitely a step up from Objective-C from a syntax and high-level features point of view, unlike most of the other languages on this list its niche is pretty much mobile apps, or better, _iOS_ apps. If I were to develop an iOS app today, I'd probably pick Swift as well.

#### Example FizzBuzz Implementation -``` +```swift for i in 1...100{ var s:String? if i%3==0{s="Fizz"}

@@ -333,7 +333,7 @@ Could this be the holy grail, the true replacement of C? Only time will tell. It's way too soon to judge, but this new kid on the block is the last on this list, but one of the most promising.

#### Example FizzBuzz Implementation -``` +```zig const std = @import("std"); pub fn main() void {
M rules.minrules.min

@@ -105,15 +105,19 @@ symbol process-code

(str :text ==> str :result) ( "temp/highlight" :tmpfile - "chroma $# --html --html-only --html-prevent-surrounding-pre" :cmd - text "<pre>\s*<code[^>]*>([\s\S]+?)</code></pre>" ( + "chroma $# $#--html --html-only --html-prevent-surrounding-pre" :cmd + text "<pre>\s*<code[^>]*?(?:class=\"([a-z0-1]+)\")?>([\s\S]+?)</code></pre>" ( :match - match 1 get :code + match 2 get :code + match 1 get :lang + "" :lexer + (lang "" !=) + ("--lexer $# " (lang) =% @lexer) + when ; Unescape HTML entities code "(&gt;|&lt;|&quot;|&amp;)" ( :match match 1 get :ntt - (ntt "&gt;" ==) (">") when

@@ -128,7 +132,7 @@ ("&")

when ) replace-apply @code code tmpfile fwrite - "$#" (cmd) =% (tmpfile) =% run /output :out + cmd (tmpfile lexer) =% run /output :out "<pre class=\"chroma\"><code>$#</code></pre>" (out) =% ) replace-apply @result )

@@ -245,7 +249,7 @@ (

content /id :id (content /content-type "project" ==) (content PROJECTS append @PROJECTS) when content - "." print! + ;"." print! process-timestamp process-content @content