Stories
Slash Boxes
Comments

SoylentNews is people

The Fine print: The following are owned by whoever posted them. We are not responsible for them in any way.

Journal by turgid

Which LISP should I learn? Years ago I read about Scheme and wrote some hello world level code. I learned about lambda functions and currying. I also looked at racket. A few years ago, much of my day job involved the JVM and I was getting sick of Java so I got a book on Clojure, which is a very nice language, but I never wrote any.

A few days ago I downloaded and built the latest version of DrRacket.

Should I go straight to Haskell? Or what about other functional languages? Is Erlang worth a look?

I need something stimulating to distract my brain from the mundane nature of everyday life, and mediocre programming languages.

Display Options Threshold/Breakthrough Reply to Article Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
(1)
  • (Score: 3, Informative) by Anonymous Coward on Saturday November 27 2021, @10:45AM (12 children)

    by Anonymous Coward on Saturday November 27 2021, @10:45AM (#1199934)

    A big advantage of Clojure is runs within your existing JVM playpen or, it's Clojurescript variant, in the browser.

    I found Haskell too esoteric with its everything is a monad.

    But there are plenty of tutorials for ML online and F# is a dialect of OCAML that runs on .net runtime for Linux, so...

    But if it's for "work" then mainstream languages are gradually introducing functional concepts. Kotlin looks a lot more functional with its Scala-inspired type inference.

    • (Score: 2) by turgid on Saturday November 27 2021, @10:46AM (10 children)

      by turgid (4318) Subscriber Badge on Saturday November 27 2021, @10:46AM (#1199935) Journal

      It's purely for personal interest now. I need something detached from the work environment.

      • (Score: 0) by Anonymous Coward on Saturday November 27 2021, @02:32PM (9 children)

        by Anonymous Coward on Saturday November 27 2021, @02:32PM (#1199984)
        Sounds like you've gone a bit bored with coding, but are thinking that a different language will "spice things up a bit" with its novelty.

        Instead, you could look further afield. Find something completely unrelated to programming, or even computers. There's a crapton of stuff that needs to be done in the real world that isn't getting done because the pandemic is causing a shortage of volunteers and an increase in demand. Animal shelters, food banks, delivery to shut-ns, daily phone wellness checks, suicide prevention hotlines, walk a dog, get a dog, etc.

        Getting away from the keyboard and reconnecting with humans will probably be sufficient to make your current languages interesting again because they won't be boring any more due to over-exposure. Plus you'll feel better about yourself and your place in the world.

        That's in contrast to the usual suspects who spend all day fucking around arguing on this and other sites because they literally have nothing better to do.

    • (Score: 1, Interesting) by Anonymous Coward on Sunday November 28 2021, @05:46AM

      by Anonymous Coward on Sunday November 28 2021, @05:46AM (#1200166)

      F# is a good compromise on functional languages. They are also making it easier to incorporate F# libraries with other CLR languages, so it may even come in handy later.

  • (Score: 1, Interesting) by Anonymous Coward on Saturday November 27 2021, @04:32PM (2 children)

    by Anonymous Coward on Saturday November 27 2021, @04:32PM (#1200000)

    Erlang is very nice. Its native distribution and error-handling primitives are great. Its syntax is terse but legible. Its alternative to OOP is breath-taking in both simplicity and flexibility. Its realtime capabilities are lovely and practical. Its library is deep and well-maintained.

    At first erlang will seem like a bit of a slog, but then you will get about three a-HA! moments, and then it turns everything around.

    Other languages keep copying its features (badly) and missing the point. Golang springs to mind.

    • (Score: 1, Informative) by Anonymous Coward on Sunday November 28 2021, @05:43AM (1 child)

      by Anonymous Coward on Sunday November 28 2021, @05:43AM (#1200165)

      Erlang is an good choice if you are into those sorts of things. It was definitely engineered with a purpose in mind by people who knew what they were doing. It also has an equally wonderful reference implementation and some major alternate implementations. An additional benefit is that if you want to learn Lisp, you can run LFE directly in the Erlang environment.

      • (Score: 1, Informative) by Anonymous Coward on Sunday November 28 2021, @08:38PM

        by Anonymous Coward on Sunday November 28 2021, @08:38PM (#1200302)

        This is kind of why I recommend erlang. It is well engineered, it's not a toy language, it has a mature library set, and within its domain it still sets the standard. It can be a glue language for distributed management of tight code written in C, or you can do everything in there directly.

        IF I'd wanted to suggest an obscure functional language, I might have proposed APL ...

  • (Score: 3, Interesting) by Subsentient on Saturday November 27 2021, @06:05PM (2 children)

    by Subsentient (1111) on Saturday November 27 2021, @06:05PM (#1200013) Homepage Journal

    I don't know any Lisp (seems to parenthesis-ey to me), but I can suggest a few languages worth checking out.

    • If you want a real challenge, learn Rust [rust-lang.org]. Not just enough to do hello world, enough where you understand its memory model and can do lifetime annotations effectively. Ignore the political bullshit, it looks like that part of the organization will implode soon anyways, and we'll end up with more decentralization.
    • If you want something interesting that you might not have seen before, check out Crystal [crystal-lang.org]. It's basically statically compiled Ruby with native performance.
    • If you want something whimsical but potentially useful, check out Fish shell [fishshell.com]. I'm currently having fun with Fish. It's really such a better shell than bash. The syntax is much nicer too. Reminds me heavily of Lua, and oh dear god do I love my Lua.
    • If you want a fascinating, tiny, fast compiling systems language that I've even considered contributing to, check out the V programming language [vlang.io].

    There's good stuff out there if you know where to look. ^^

    --
    "It is no measure of health to be well adjusted to a profoundly sick society." -Jiddu Krishnamurti
    • (Score: 2) by Subsentient on Saturday November 27 2021, @06:18PM

      by Subsentient (1111) on Saturday November 27 2021, @06:18PM (#1200018) Homepage Journal

      I would also advise to pursue your interest in computing. If you have other interests, great, but if you're pining for a new language, my advice is to lean fully into it. It's good for the soul of a programmer. It's important to keep interesting new tools and innovations available to you to keep the fire alive. Don't let yourself get drowned in Java. :^)

      --
      "It is no measure of health to be well adjusted to a profoundly sick society." -Jiddu Krishnamurti
    • (Score: 1, Interesting) by Anonymous Coward on Sunday December 05 2021, @08:54AM

      by Anonymous Coward on Sunday December 05 2021, @08:54AM (#1202316)

      Oh man, an interesting language is J, another interesting language is Haskell, then there is, for instance, Factor.

  • (Score: 4, Funny) by krishnoid on Sunday November 28 2021, @07:15AM (3 children)

    by krishnoid (1156) on Sunday November 28 2021, @07:15AM (#1200180)

    Emacs-Lisp? Ow, tomatoes are ok but no dragonfruit and pineapples! Fine, I'll see myself out.

    • (Score: 2) by krishnoid on Sunday November 28 2021, @09:00PM (2 children)

      by krishnoid (1156) on Sunday November 28 2021, @09:00PM (#1200313)

      Seriously, though, if you have a utility that uses a LISP dialect as an extension language, that's an easy way to get mentally familiar with, er, "list processing" syntax. Emacs and make (ugh) v4 [gnu.org] come to mind, but if there are other utilities you're currently using, it's a much smoother on-ramp to start coding to implement your own tweaks, then small functions, then larger ones.

      • (Score: 0) by Anonymous Coward on Monday November 29 2021, @02:24AM (1 child)

        by Anonymous Coward on Monday November 29 2021, @02:24AM (#1200372)

        Except that emacs-lisp has been flagged as shit by GNU themselves and have had multiple attempts at replacing the interpreter with something nicer, including Guile.

        • (Score: 3, Insightful) by hendrikboom on Monday November 29 2021, @07:36PM

          by hendrikboom (1125) on Monday November 29 2021, @07:36PM (#1200645) Homepage Journal

          The problem with emacs-lisp is, apparently, that it doesn't do proper binding of variables. (the FUNARG problem of the 60's) There's been work about dealing with that, but there's such an enormous base of emacs lisp programs that making this change is ... difficult.

          Racket has an editor written in a dialect of Scheme (i.e. Racket) which does handle bound variables properly. I'm not sure how language-independent it is, but the hallmark of Racket is its ability to handle multiple languages.

          If GNU ever does manage to produce an editor based on any Scheme, I'd like to see it.

  • (Score: 3, Insightful) by quietus on Sunday November 28 2021, @01:34PM

    by quietus (6328) on Sunday November 28 2021, @01:34PM (#1200211) Journal

    I support the advice of another comment, of going out in real life and do something there; on the other hand, it seems like you'd like to still do some (interesting) hands-on programming, as your day to day job currently makes this impossible.

    So my advice: why not phone one of your local schools, make contact with whoever teaches informatics there, and ask them what they need/want for course notes [in programming, obviously]. You'll find that most of them, if not all, have written their own: which takes a lot of time (and really learns you the language too).

    Where I live, and as a former teacher, I can tell you that the official teaching handbooks insist on only examples out of accounting. So, no programming of robots, space flight, games or anything which might cause the slightest whiff of coolness & excitement with pupils.

    I suggest you try to change that a little.

    If you want to continue along the Lisp road -- learning some new programming paradigms -- I suggest you start with Learn You a Haskell for Great Good! first, then follow up with Land of Lisp, both from No Starch Press; after that, and on a more serious note, you can tackle Structure and Interpretation of Computer Programs (Abelson, Sussman, Sussman).

  • (Score: 1, Interesting) by Anonymous Coward on Monday November 29 2021, @03:04AM

    by Anonymous Coward on Monday November 29 2021, @03:04AM (#1200400)

    If you want to really stretch yourself into new paradigms, try Prolog into Datalog. A datalog database can make your application code much simpler as well. It is all about making the logic of your program explicit. Another benefit of doing so at that level is that it can make functional languages like F#, Erlang, and Lisp much easier to grasp as they are fundamentally a super-set and next level of the same logical thinking.

  • (Score: 1, Interesting) by Anonymous Coward on Monday November 29 2021, @01:33PM (2 children)

    by Anonymous Coward on Monday November 29 2021, @01:33PM (#1200501)

    Nils M Holm has some books on writing LISP compilers, and I am a fan of his concise writing style. Building a language from the gound up is a lot of fun!

    • (Score: 3, Interesting) by hendrikboom on Monday November 29 2021, @07:41PM (1 child)

      by hendrikboom (1125) on Monday November 29 2021, @07:41PM (#1200650) Homepage Journal

      Racket has mechanisms for implementing new languages on top of the built-in Racket base. It's been used for implementing Algol 60, for example.
      But most of the Racket-built languages are similar in syntax to Racket, such as typed Racket.

      • (Score: 1, Funny) by Anonymous Coward on Monday November 29 2021, @09:56PM

        by Anonymous Coward on Monday November 29 2021, @09:56PM (#1200709)

        There is something nice about the fact that a statically-typed Racket could be called "Tracket." It sounds like "Track it" and lets you and the compiler keep track of what type each variable is.

  • (Score: 3, Funny) by hendrikboom on Monday November 29 2021, @07:54PM

    by hendrikboom (1125) on Monday November 29 2021, @07:54PM (#1200654) Homepage Journal

    Or have a crack at some silliness. Have a crack at nanogenmo, which is the challenge to write a computer program that writes a novel.
    I don't think anyone has produced anything along this line that's readable for more than a few paragraphs, but there's lots of open exploration space there.

    I've done a few of those. One starts "The mathematician started counting" ... and you can guess what happens then ... lots of numbers until the document is long enough for a novel. There's a catch, though -- at the end he discovers he's off by one, so one of the numbers is missing. Up to you to find it.

    It has a sequel [pooq.com] in which the main character counts past infinity into the ordinals. I use elippses ("...") a lot.

    Source code for both novels(??) is at https://github.com/hendrikboom3/Text-generation/tree/master/counting [github.com]

    -- hendrik

  • (Score: 3, Insightful) by DannyB on Monday November 29 2021, @08:42PM

    by DannyB (5839) Subscriber Badge on Monday November 29 2021, @08:42PM (#1200684) Journal

    There is a lot more than I can write here. I hope some of these ideas will fire your imagination.

    From late 1986 to early 1993 I got into Common Lisp. Wrote lots of fun code. Not to do anything practical. But to stretch my abilities. Solve puzzles. Dabble with natural language processing (remember early 90's now so don't be judgemental). Pattern matching. Pattern rewriting systems. Toy compilers. Toy text "adventure" type games. (Yes, Lisp is good for this)

    I started looking at Clojure because it was interesting, and it happened to run on JVM. In 2014 I started seriously playing with Clojure. Like my Common Lisp adventures, I wrote lots of code, but not to do anything really practical. Just to scratch my own itch. Solve interesting problems. Learn things. Project Euler problems. [projecteuler.net]

    I've dabbled with DrRacket.

    Some things that are outstanding about Clojure:

    • "Persistent" data structures. eg, everything is immutable. No surgical splicing operations on data structures like Common Lisp can do. Now this has a profound effect on solving many types of tree search or graph search algorithms. Game play. Puzzle solution. Etc. If I make a mutation to, say, a game board, I still have the original board. And the new mutated board. Even if all I did was change one element of a large array -- I now have two versions of that large array. And it is efficient. This means you never have to develop operations that copy an entire data structure. This automatically happens when you change anything. You have the original still, and the modified version. And it is not a giant copy. (Internal implementation: they still share immutable structure of much of the non changed parts. You don't have to worry about how it works. It's all explained.)
    • List operations are lazy. This has another profound effect. You can simply implement infinite lists of things via recursion and not worry about getting stuck in an infinite loop. As you pull more and more elements off the infinite list, more and more of the list gets created. Such as a list of all prime numbers, or Fibonacci numbers, or Pythagorean right triangle integer triplets. Try creating a list combinations or permutations function that works on an infinite list. "Give me every possible 6 element group of prime numbers."
    • side diversion: if you develop a lot of functions to do with prime numbers, you start to find there are a lot of interesting problems that are now easily solved

    In a nutshell, in Clojure more so than Common Lisp, I could think about my problem and not end up with weird bugs because I ended up mutating data structures for "efficiency" but that efficiency ruined some abstraction. In other words, Clojure let me think at a higher level and not get bogged down in machine details -- even in Common Lisp.

    I will always fondly remember Common Lisp. But I had loads of fun with Clojure.

    Think about: how would you build an infinite list of Pythagorean triples? A2+B2=C2. Iterate through all of the possible A's. For each A, iterate through all of the possible B's. But how far? When do you stop searching for a higher B because you can prove there will never be another, and you should now move on to the next A? When you are iterating over the A's and B's should you iterate only over your infinite list of prime numbers, or all possible integers? Obviously, each search for B values should begin with the current A value, but why?

    This is but one of many examples of experimentation, learning and diversion that you can do a lot of thinking about. Some of the thinking is about math and proving things. Some thinking is about efficiency of algorithms. (And I don't mean saving a cpu cycle or a byte here or there like in C.)

    I know it's a solved problem, but write: A sudoku solver. A rubick's cube solver. An "unblock me" solver. (Google it) Write a Minimax game engine that supports plug in board scoring functions for TicTacToe, Connect 4, Checkers and Reversi all using the same generic Minimax engine.

    If you're using Clojure in Java instead of Javascript, you can also access MIDI.

    If you're in to Scheme, get a book called The Reasoned Schemer which introduces you to a logic system called Mini-Kanren. Clojure has a similar system as a package called Core.Logic.

    In fact, the library/packages available for Clojure are fertile ground for experimentation. Try InstaParse. You just feed it grammar. No need to worry about LALR or LL(1), or right or left recursive. Just mix them all up together in your grammar and InstaParse will parse your input from your grammar and build a tree for you.

    I truly hope your muse will distract you from the ordinary, mundane, mediocre of every day programming and languages. Best of luck!

    --
    Young people won't believe you if you say you used to get Netflix by US Postal Mail.
  • (Score: 2) by DannyB on Tuesday November 30 2021, @03:07PM (2 children)

    by DannyB (5839) Subscriber Badge on Tuesday November 30 2021, @03:07PM (#1200867) Journal

    Another fun programming diversion.

    Processing.org

    They have both a Java (JVM) version and a JavaScript version. Both are batteries included. Easy to download and get started without a lot of setup.

    You write either Java or JavaScript depending on which version you download. The environment provides a huge number of graphics and other functions that you can call.

    Look at the gallery of examples. Let your imagination run wild. You can draw anything. You start out with a blank canvas.

    In the spirit of Logo (which someone mentioned above) I created my own Turtle Graphics class in Java which I used in Processing.org. You can trivially create a turtle (or as many different turtles as you like). Each turtle has commands like Pen Up, Pen Down, MoveForward(x), TurnBy(degrees), MoveTo(x,y), etc. I'm sure you can google all kinds of fun things to do with turtle graphics.

    As an example, to help inspire you, I created a Spirographtm work alike in Processing.org. You specify the large ring inner number of teeth, and the number of teeth of the wheel which moves along the inner ring. It draws the figure on screen. It does this by advancing a fraction of one "tooth" and doing a LineTo(x,y) type operation to move the pen a little bit.

    Also don't mention Project Euler which I mentioned in my Common Lisp / Clojure post above. There are tons of fun problems there to work on using any language of your choosing. Mine was Clojure and sometimes Java.

    --
    Young people won't believe you if you say you used to get Netflix by US Postal Mail.
  • (Score: 2) by DannyB on Tuesday November 30 2021, @03:28PM (13 children)

    by DannyB (5839) Subscriber Badge on Tuesday November 30 2021, @03:28PM (#1200874) Journal

    Write your own Mandelbrot explorer program. The first step is to simply generate the Mandelbrot set on a complex plane from +/-2.0 real axis and +/-2.0 imaginary axis. Then work on user interface to use the mouse to select a rectangular area and then pick a menu command to Zoom In causing the selected area to expand to fill the area previously occupied by the original graphic. It's not that you're solving a new problem. It's the fun and stretching your ability. Try to do something new and original.

    Here is what I've worked on, put on hold, and hope to pick up on again. A Mandelbrot explorer in Java. You never have to set any iteration limit. Calculating the pixels to display any part of the Mandelbrot set is what is called an "embarrassingly parallel" problem. So do it multi threaded. Divide and conquer. Split the rectangle into two smaller rectangles, and keep recursing. Once you get down to a rectangle that is, say, 7x7 or smaller in either dimension, then brute force calculate each pixel in that small area. But . . . gigantic optimization . . . on every rectangle during the recursion, no matter the size of rectangle, do a quick check of the border to see if all pixels on the border of that rectangle are all the same "color" (or iteration count). If they are, then simply block fill that entire rectangle with that iteration count (eg, color). The observation about the Mandelbrot set is that there are large blocks of uniform color and also large areas of "fiddly bits" with chaotic colors.

    Use separate cpu threads to brute calculate every 7x7 grid. (Or adjust the 7x7 threshold to achieve best cpu utilization.)

    Do all your calculations as integers. BigIntegers. You have a variable that you call ONE, and set it to, say ten billion. In your calculations, simply tread that big integer ONE as the value 1.0. So if ONE is 10_000_000_000, then your axis is from +/-20_000_000_000. There is a method to my madness of using integers instead of some kind of gigantic floating point.

    Make your program also offer a web server. Any arbitrary browser can connect to this port on your computer while the program is running. It displays a page that has JavaScript. The computer running a browser connected to your program is contributing its compute power. This makes it extremely easy to set up and tear down quick ad-hoc networks of several computers. JavaScript also has Big Integers (or packages for such). Thus you still get EXACT same results in a different language. When you program needs to calculate all of the "fiddly bits" of some rectangle, it farms that out to another cpu thread, or a connected slave computer connected via a browser contributing its cpu. Don't farm out 7x7 (or smaller) rectangles to a separate computer. Maybe not even to a thread. Farm out, say 100x100 (or smaller) rectangles to a separate computer. Measurement and tuning will achieve optimal results.

    A next step would be to develop a program that runs as a background service (on Linux, Windows, etc) and can contribute its cpu, and is locally controlled by a separate user interface program to configure it. (Or an XML or JSON config file if you don't want to build a UI.)

    Back in the 1990's I built a very fun Macintosh (classic) Mandelbrot explorer in C++. I had a couple friends looking over my shoulder on Sunday afternoons and we would then go out to eat lunch and discuss all sorts of various ideas which I would then implement. But we never got as far as multi threading let alone using multiple computers. But that 1990s project fired my imagination.

    Oh, I mentioned that the user doesn't have to set an iteration limit, which I consider a major failing of most Mandelbrot explorer programs. How to do that? In your inner calculation loop, take all of the local variables and make them members of an object. Now that object preserves the entire state of where in the "loop" that calculation is. Have a large matrix of these objects, one object per pixel. Now calculate about 100 iterations on every pixel. Then do another 100 iterations on every pixel. You are doing the same calculation, but you're "advancing" each pixel a little bit, all of the pixels advancing together. Some pixels will "escape" and are now done. Others will iterate to infinity. For the entire imagine (not just the local rectangle you are calculating) keep track of some statistics of what the maximum iterations are for pixels that have been completed. Use a threshold of several times that as your "dwell limit". Now the dwell limit will be dynamic. As some "fiddly bits" take more and more iterations to complete, the dynamic "dwell limit" will increase. Thus the end user never has to manually guess what the maximum iterations should be before a pixel is considered to iterate to infinity.

    In Java (or JavaScript, or C#, Python, etc) where GC is involved: always pre-allocate all data structures. Then do your calculations. In your inner loop you never allocate anything, thus no GC happens. Note how well this idea fits with having a large matrix of "saved inner loop variables" so you can advance all the pixels in a rectangle together in marching steps in small numbers of iterations per step.

    --
    Young people won't believe you if you say you used to get Netflix by US Postal Mail.
    • (Score: 2) by hendrikboom on Wednesday December 01 2021, @09:21PM

      by hendrikboom (1125) on Wednesday December 01 2021, @09:21PM (#1201267) Homepage Journal

      Write a screen-saver that travels along the boundary of the Mandelbrot set on a schedule that repeats every year. Zoom in enough that the image is somewhat stable.

    • (Score: 3, Interesting) by turgid on Wednesday December 01 2021, @10:33PM (11 children)

      by turgid (4318) Subscriber Badge on Wednesday December 01 2021, @10:33PM (#1201294) Journal

      About a million years ago I had several ideas for stuff and then over the years whenever I've had time I've tried to do bits and pieces of them. Some years ago I set about writing my own graphics primitives (in C) to be rendered using SDL (well, it's simple and cheap). I wrote pixels, lines, circles, ellipses, boxes, colour gradients and all sorts. I even implemented display lists so that I could have objects to render and move the mouse about and it would know which object it was over, click to drag and so on. On my travels I wrote some code to do the Mandelbrot set. I thought it would be a fun thing for Turgid jr. to see being written. He was about 8 at the time. I planned to make it zoomable with the mouse but never got around to it. And did I tell you about my home-made 3D graphics? Oh boy... with multi-threading?

      • (Score: 2) by DannyB on Thursday December 02 2021, @03:22PM (2 children)

        by DannyB (5839) Subscriber Badge on Thursday December 02 2021, @03:22PM (#1201517) Journal

        I've mentioned this on SN before.

        Back in ancient times long past, there were these things called "flip phones" or "candy bar phones". (Paleontologists label this as the "pre smart phone era")

        https://soylentnews.org/comments.pl?cid=1134316&sid=42871 [soylentnews.org]

        I remember J2ME. (Java "lite" on all of the billions of mobile phones in the pre smartphone daze.)

        It didn't have any floating point. I was building my own "asteroids" clone. (And did successfully build it. Gave it to a few friends. Once that accomplishment achieved, I moved on.)

        I needed trig functions. I wanted to draw the ship and rocks as sprites sub classed from a common super class. Each line vector figure (ship or rock) had a series of points relative to a "center" point. It was the center point of the sprite that moved on each frame update. In my game, the rocks rotated, unlike original asteroids. These points around the center point were expressed in polar (r-theta) form. Just draw a line from the first point to the last, and then back to the first, thus drawing a closed figure. (Ship or rock)

        I need to convert from polar form to x-y coords, and then offset to the x-y center of the sprite before drawing on screen.

        But J2ME only had long integers and no trig functions (or log, power, etc)

        There was some library that had the name "bear" in it. This used a 64-bit long, dividing it into 32-bit mantissa and fraction. Trig functions did a few taylor series terms, and that was more than good enough.

        Wow, those were ye olden daze. And it was after the year 2000. Wow, I'm getting old.

        Be sure to see some replies after that posting.

        See also:
        https://soylentnews.org/comments.pl?noupdate=1&sid=40718&page=1&cid=1080994#commentwrap [soylentnews.org]
        about drawing vector graphics on a scope, which in subsequent replies brings up the J2ME asteroids game again. It also shows a way to write a Factorial function without iteration. And how to do Trig functions when you have only integers but no floating point.

        --
        Young people won't believe you if you say you used to get Netflix by US Postal Mail.
        • (Score: 2) by turgid on Thursday December 02 2021, @05:11PM (1 child)

          by turgid (4318) Subscriber Badge on Thursday December 02 2021, @05:11PM (#1201553) Journal

          I wrote fixed-point trig functions once and used them to calculate pi.

          • (Score: 3, Interesting) by DannyB on Thursday December 02 2021, @05:45PM

            by DannyB (5839) Subscriber Badge on Thursday December 02 2021, @05:45PM (#1201561) Journal

            I wrote a Java function to calculate PI to arbitrary precision, using only BigInteger, no trig, only add, subtract, multiply and divide. It was an efficient algorithm based on some efficient formula. I think I saw it years ago on Hacker News.

            I tried to post that function here, but alas SN just won't allow it.

            Then I built a very similar function that used Java's BigDecimal.

            Someone, not myself, wrote a set of Trig and other functions for the BigDecimal class. BigDecimal is excellent for business numeric values such as money, but not quite like floating point. With BigDecimal you must specify precision limits, rounding modes, etc. There are no defaults. You must specify them.

            --
            Young people won't believe you if you say you used to get Netflix by US Postal Mail.
      • (Score: 2) by DannyB on Thursday December 02 2021, @08:14PM (7 children)

        by DannyB (5839) Subscriber Badge on Thursday December 02 2021, @08:14PM (#1201616) Journal

        <no-sarcasm>
        There is some programming you do for fun. There is other programming that pays the bills.
        </no-sarcasm>

        Another fun project (annually, which I just had lots of fun doing) is writing code to do electronic filing as per specification IRS Pub. 1220 (Rev. 10-2021) to communicate with mainframes in an archaic fixed record format designed in the days when dinosaurs roamed the earth.

        --
        Young people won't believe you if you say you used to get Netflix by US Postal Mail.
        • (Score: 3, Funny) by DannyB on Thursday December 02 2021, @10:33PM (4 children)

          by DannyB (5839) Subscriber Badge on Thursday December 02 2021, @10:33PM (#1201661) Journal

          Well here is a first, for me anyway.

          IRS Pub 1220 (Rev. 10-2021). Available here:

          https://www.irs.gov/pub/irs-pdf/p1220.pdf [irs.gov]

          There is an error!

          ERROR on IRS Pub 1220 (Rev. 10-2021)
                  Page 113 of PDF
                          Record B, Form 1099-NEC
                                  Positions 548-722 Blank 173 length
                                          WRONG: the length is 175 not 173!

          It pays to be a geek and pay attention to detail.

          --
          Young people won't believe you if you say you used to get Netflix by US Postal Mail.
          • (Score: 0) by Anonymous Coward on Friday December 03 2021, @05:18AM (3 children)

            by Anonymous Coward on Friday December 03 2021, @05:18AM (#1201745)

            They make errors in the length calculation all the time. The specification says, or at least used to say, that the "length" column is "advisory" and that you should only rely on the position. However looking at this year's with my experience in the past, I vaguely remember there being a different layout in that same area with more length 1 records. Perhaps they changed them all to blanks this year or in the past and just copy-pasted the 173 instead of adding the two 1s as well. Perhaps you could check the IRS's test files to see what they do.

            • (Score: 3, Insightful) by DannyB on Monday December 06 2021, @03:40PM (2 children)

              by DannyB (5839) Subscriber Badge on Monday December 06 2021, @03:40PM (#1202513) Journal

              If you go with 173 instead of 175 then your total record length is 748 instead of 750, and all your other field positions are wrong. If you assume that it is length which is wrong, then all other field positions line up, record length if 750 and everything else fits correctly. So the preponderance of the evidence is that there is a single small mistake, instead of all other field positions and the record length being wrong for the "B" record.

              --
              Young people won't believe you if you say you used to get Netflix by US Postal Mail.
              • (Score: 0) by Anonymous Coward on Monday December 06 2021, @10:22PM (1 child)

                by Anonymous Coward on Monday December 06 2021, @10:22PM (#1202600)

                Maybe I am misreading you, but where did I suggest the alternative?

                • (Score: 0) by Anonymous Coward on Monday December 06 2021, @11:36PM

                  by Anonymous Coward on Monday December 06 2021, @11:36PM (#1202612)

                  I think I got it. That last sentence is missing its introductory phrase of "if you really cared" that I could have sworn I added.

        • (Score: 1, Funny) by Anonymous Coward on Sunday December 05 2021, @10:39AM (1 child)

          by Anonymous Coward on Sunday December 05 2021, @10:39AM (#1202326)

          You know, you're on to something. That format is just screaming out in the hope that you implement it in COBOL. Two birds with one stone, that is. You can add COBOL experience (I hear it is in high demand /s) and IRS/financial software experience to your resume. What better way to make yourself seem too old and too expensive to hire at the same time?

          • (Score: 1, Funny) by Anonymous Coward on Saturday December 18 2021, @05:13PM

            by Anonymous Coward on Saturday December 18 2021, @05:13PM (#1206170)

            Cobol is a form of Ransomware?

(1)