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 Comment 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.
  • (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.
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2  
  • (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.