Hacker Newsnew | past | comments | ask | show | jobs | submit | korpiq's commentslogin

Hey what about someone donate a Mac to mrDIMAS? Might pay back =)


you're someone


This feels welcome to me. I tend to think a language needs multiple independent implementations that only share the same source language spec, in order to really tear a clear spec apart from the quirks of any particular implementation.

I find Rust (the spec, though also the implemenration) quite safe and practical (a balance). It deserves some independent implementations to secure a long and stable future.

On the other hand, I want to use it on non-ARM embedded platforms, where current cross-compilation through C produces unusably big binaries. I dream this might increase hope for that, too, eventually.


>> I find Rust (the spec, though also the implemenration) quite safe and practical (a balance). It deserves some independent implementations to secure a long and stable future.

Where is the Rust spec? Unless something happened really quickly that I was not aware of there is only the implementation.


https://doc.rust-lang.org/stable/reference/ is the closest thing we have. It is not yet complete.


Thank you! I look forward to the day when there is a spec, but I was surprised to see it mentioned and was wondering if I missed something big.


What programming language would cause least friction for providing discrete types for all domain primitives or even all handled data?


Ada does a great job in this regard. Using some examples in the article:

>> For example, say that you want to represent the number of books ordered. Instead of using an integer for this, define a class called Quantity. It contains an integer, but also ensures that the value is always between 1 and 240

The Ada code to implement this is:

type Quantity is new Integer range 1 .. 240;

>> instead of just using a string, define a class called UserName. It contains a string holding the user name, but also enforces all the domain rules for a valid user name. This can include minimum and maximum lengths, allowed characters etc.

The Ada code to implement this is:

with Ada.Strings.Bounded; package UserName is new Ada.Strings.Bounded.Generic_Bounded_Length (Max => UserName_Max_Length);

Dynamic predicates or even a string subtype could be used to further refine the UserName definition depending on exactly what restrictions are needed.

While it's not perfect, Ada does make it pretty easy to specify constraints on data types and will complain loudly when the constraints are violated.


As an addendum, some of those features are also possible on Pascal/Modula variants, although not as expressive as Ada.


Oh my god. I wish C# had this.


Ada is pretty much still the only language that has this.


> Ada is pretty much still the only language that has this.

Common Lisp does too:

    (deftype quantity () '(integer 0 240))
    (defun foo (x)
      (declare (type quantity x))
      (1+ x))
    (foo 1) → 2
    (foo -1) → ERROR
    (defun valid-username-p (string)
      (and (< 8 (length string) 24)
           (every (lambda (char)
      (find char "abcdefghijklmnopqrstuvwxyz0123456789-_=./" :test #'char=))
    string)))
    (typep "foo" 'username) → NIL
    (typep "foobarbaz" 'username) → T
    (typep "foobar-baz" 'username) → T
    (typep "foobar-baz " 'username) → NIL
Common Lisp is pretty awesome.


Well, except for the fact that it's Common Lisp. ;)


Pascal:

    type
        Quantity = 1 .. 240;
        Colors = (Red, Green, Blue);
        Pixels = array [1..1024, 1..768, Colors] of Byte;
Just a small example how its type system already so much better than C, although not as good as Ada.


It's really not helpful to put examples here that are basically Animal IS Dog level of argumentation. Making toy types like that may help to convince some beginners, but really these features are just unflexible. They work if you're not doing any arithmetic on these values, in which case the type safety is not really needed in the first place. Otherwise (if you're doing arithmetic) they're very much a chore, making code more verbose and in many cases raising complexity to the point where you're starting to introduce enterprisey uber-complicated systems that can easily lead to many thousand lines of boilerplate for solutions that are looking for an actual problem.

And overall, Pascal's type system is NOT so much better. Not strictly better at all, if at all any better. It's a chore to do the simplest things, starting from the mess that is the various types of strings, to a confusing memory management story, continuing with extremely verbose type declaration syntax (which requires to add many additional names), to the mess that is 0-based vs 1-based indexing, and let me not start with the messy object systems that were put on top in Delphi.

If you ask me it's definitely WORSE over all, although for example Delphi has nice aspects to it, especially in the IDE.

Oh yeah, and if Ada was ever adopted by a significant adoption of programmers, then they probably have committed suicide in the meantime.


Yeah not every developer is able to cope with programming languages that promote engineering best practices.

By the way, better check your github issues.


Check your github issue answers! Thank you for checking the project finally, as promised :-) https://github.com/jstimpfle/language/issues/2

I don't know how much effort you put into finding this, but the result feels almost like a certificate of quality to me and confirmed my opinion that this style of coding is pretty f*ing safe in practice. And that while I spent definitely less than 1% time on debugging memory issues (running valgrind twice, according to my git history, compared to working on this project during 7 months, initially 2.5 months full time, leading to an estimate of about 500h of development time).


OCaml, F#, Haskell, Elm, ... (anything with lightweight notation to define sum types [sometimes with only 1 variant], and a module system to limit who can construct them)

There's a whole well-reviewed book on exactly this: https://pragprog.com/book/swdddf/domain-modeling-made-functi...


Rust and Swift can also be added to this list.


TypeScript is surprisingly good at this. It's not popular as a backend language, but shows that your choices aren't limited to pure FP languages and low-level systems programming languages.


Typescript is explicitly bad at this; it is structurally typed, not nominally typed, meaning its effectively useless at enforcing domain guards.

See the same program in flow [1] (nominally typed) and TypeScript [2] (structurally typed).

In the case of flow the type can only be constructed with the class -thus enforcing the guards - whereas in TypeScript I can accidently (or deliberately) bypass all guards by having a class with an equivalent structure.

[1] https://flow.org/try/#0MYGwhgzhAEAKD2ECWAXJA3ApgSQHYswHNMAna...

[2] https://typescript-play.js.org/#code/MYGwhgzhAEAKD2ECWAXJA3A...


There are ways to enforce nominal typing in TS [1]

  type Brand<K, T> = K & { __brand: T }

  type USD = Brand<number, "USD">
  type EUR = Brand<number, "EUR">

  const usd = 10 as USD;
  const eur = 10 as EUR;

  function gross(net: USD, tax: USD): USD {
    return (net + tax) as USD;
  }

  gross(usd, usd); // ok
  gross(eur, usd); // Type '"EUR"' is not assignable to type '"USD"'.
[1] https://michalzalecki.com/nominal-typing-in-typescript/#appr...


Thats pretty cool, but it comes with a series of issues:

* It uses an arguably invalid construct "K & { __brand: T }", where K is not an object, is an empty intersection. The fact that typescript allows casting a number to this type is concerning.

* Typescript currently allows "{} as USD" for non-object "K"'s but this will throw up serious issues down the line (obj is not number etc.); this is a likely error after validating JSON for example.

* Similarly typescript will allow you to bypass the guards for primitive types by using the structurally invalid value "{__brand: 'USD'}", or bypass them for object types using a structurally valid form with a "__brand: 'USD'" member. Which is more concerning I don't know.

* The type system now believes you have a member "__brand" that you don't actually have.

* In summary, you cannot enforce the guards through the type system.

That said, this is an interesting hack that, assuming your developers aren't trying to hurt you and you don't use it for primitives, could help get some extra safety in there. However the absurdity of the intersection looms heavily over it, I wouldn't bet on this working in a few years...


I’ve found F# to be good in this regard. Can’t claim that it would have the least friction, however.


Not saying it's the least friction, but Golang can accomplish this pretty easily with interfaces, structs and receivers. In Haskell, you can use phantom types to accomplish this in really elegant way, as is illustrated here: https://wiki.haskell.org/Phantom_type.


And a related question: How far is too far and/or impractical?

I just recently was working on a backend application and was modeling the database entities. The project uses UUIDs as primary keys. Should each entity have its own primary key type? `Location` gets a `LocationId`, User gets a 'UserId', etc, etc, where they're really all just wrappers around UUID?

Honestly, I thought about doing that a bunch of times during the start of the project, but I was pretty sure I'd get some harsh, sideways, glances from the rest of the team.


Yes. This is exactly what we do at work.

It makes sure that you never pass a `LocationId` where a `UserId` is expected; the type system literally will not allow it.


I've always thought that a language like Idris based on Dependent Types would by far be the best language for this.

The problem is a non-trivial one even for 'simple' things like a person's name. Having a rule that takes in languages, special characters, spaces etc is hard.


> I've always thought that a language like Idris based on Dependent Types would by far be the best language for this.

As someone who loves the idea of dependent types, it seems to me that this is the best theoretical solution, but maybe not the best practical solution. If solving a simple-seeming domain problem involves modelling, not just first-order types, but the whole theory of dependent types, then I think people are going to start looking for escape hatches rather than upgrading their mental models.


Thank you, both insights help me in pondering how to ever better ensure quality.


I think most statically typed languages should be good for this.


Static typing isn't really the only thing here. Strong typing would also be good.

E.g. C has a very weak type system, which is static. There's a lot of implicit conversion going on. Also the expressiveness of the type system is very limited (in C++ also).

OCaml, F#, Haskell and other functional candidates are strongly and statically typed, with very expressive type systems.

Idris with it's dependent types would be ideal and goes even further than the above.

In embedded most likely ADA and Rust offer strong enough static type systems.


> C has a very weak type system, which is static. There's a lot of implicit conversion going on. Also the expressiveness of the type system is very limited (in C++ also).

It is true that the subset that C++ shares to C has too many implicit conversions, but you can do much better.

For example in C++ you can use enum class to define strongly typed integrals that do not implicitly convert to the basic types.


Enum classes are a good first step, but C++ is still very relaxed on integer and float conversions.

I just wish I could use rust or ADA at work.


Agree, strongly typed languages are best suited for this as it usually allows to embed business domain invariants into the type system which can be checked at compile time.

Rust does a great job in that regard and is not too slow.


Or just upper case first letter and full stop?


Because, as Mr. Obvious notes, capitalisation and stops never appear elsewhere in sentences, etc., etc.


If I understand correctly, currently anthropogenically accumulated extra CO2 takes some hundreds of thousands of years to return to geological circulation, while the faster biological circulation won't withhold it all, and seas are getting saturated (and will acidify beyond supporting current lifeforms in the process). [see eg. Hot Earth Dreams]

Also, if I understood correctly a single article I'll try to dig up a link to later, the kickback effect of stopping a temporary cooling measure and returning to the warming trend caused by the CO2 still in air will have stronger harmful effects. If these hold, it might prove tricky to keep up a moderate, safe cooling effect long enough, even if some technical measure to cause volcanic winter was found. [https://www.nature.com/articles/s41559-017-0431-0?utm_source... via https://www.rollingstone.com/politics/politics-features/devi...]

I would hope this or some other measure would prove successful. but I'm not yet able to put all my faith on any of them.


I would really appreciate if you could share some of your findings there.


Honestly I just had to switch window scaling to 2x in the Xfce appearance settings, then I run this to fix my layout on each login, giving me a consistent size and no weird rendering -

#!/bin/bash

xrandr --output HDMI-0 --mode 1920x1200 --pos 0x100 --scale 1.5x1.5 --output DP-4 --mode 3840x2160 --primary --scale 1x1 --pos 2880x-150

AFAICT this effectively renders the smaller screen as if it had a much larger resolution (2880x1800), then downscales, giving a good quality image, and then positions the 4k screen to the right of it. The key is the scale factor compensating for different DPI on the different screens.

I tried scaling the other way first, by giving a sub-1.0 scaling factor to the 4k screen, but that meant rendering a lower res and then upscaling, which looked terrible!

The only annoyance now that I have this set up is that occasionaly driver updates change which output is which and I have to update the script so it works again.


1000 days in circulation means we'll have to wait at least 4 summers to start seeing a change, I'd wager. Also, it might depend on where there are different types of insects currently, and how successful they happen to be in reproduction and spreading over time.


Since neonics have a half-life of ~30 days when exposed to sunlight (unclear if that’s continuous exposure or what), it could be that we see some statistically significant improvements sooner than the 1000 days.


I think they hang around in the soil and waterways (where insects live) much, much longer than the UV exposed half-life.

Also, I’d imagine it will take ecosystems multiple seasons (so years) to rebound and reach equilibrium.


For that, I'd be interested in Paulownia trees for their fast growing speed, and thus (I assume) faster CO2 reduction rate.

1) https://en.m.wikipedia.org/wiki/Paulownia_tomentosa is also rapid to spread, which may turn out too rad for local flora or neighborhood politics thereof, while

2) https://en.m.wikipedia.org/wiki/Paulownia_elongata seems not to spread on its own and thus may need active help for that.

You'll end up with a lot of soft wood from these relatively fast (10 years?). That should be used in some way that does not release the CO2 back.

I have no studies nor experience in biology nor gardening and all of this is only based on what I've been reading on the internet.


The most appropriate trees for an area are the local ones and with a view to Climate Change, the local species with good adaptability to climate change characteristics (need less water, can rezist temperatures variations, etc.). Pawlonia is being pushed/marketed heavily on the internet due to some superficial/mercantile characteristics (fast growth, big foliage), but besides that, in the agroforestry/agroecology academia, Paulonia is known to be just a marketing buzz, and a relatively dangerous one.


There are organisations varying from grassroots to global where you can participate in such purchases with nominal sums, and end up with small parts of land in your name, collectively owned with other participants, or probably something in between.

Here is one (that I know about because my employer currently offers an option to use some of our open source contribution rewards for that): https://www.helsinkifoundation.org/


What happens if I need my money back?


What do you mean “my” money? When you spend it, it’s no longer yours. You have land now in this line of reasoning.


Can I sell this land to someone else if I need money? Is the use of that land for the new owner restricted or can it be repurposed for agriculture or other uses?


As a serious answer for anyone reading this who might be curious, even though the the above comment is probably not asking seriously.

Most of these situations the land is placed in a thing called a 'land trust', at least that is the structure I see most often. These are generally then set out with an elected governing board, and a set of bylaws and rules about the lands. Often these rules can require a voting majority of everyone who placed in money on the land to make decisions about the land. Usually there is a minimum amount of land you personally must purchase in the larger purchase to constitutes a "share" like 1 acre.

If someone has a change of heart later down the line the trust actually is a very hard entity to get around even if you are on the board of a small 5-10 person land trust. There have been examples of such boards being flipped and sold, but more often than not what you encounter is: one of the board members is interested in selling off the land and is utterly unable to because of how the trust is structured. They can be pretty robust.

The only difference between buying land and creating your own trust and foundations like this is, the foundation ultimately controls all the board seats of land trust generally.


So, if I go bankrupt it's basically worth nothing to anybody else because nobody could sell it for money? Even if it gets taken away and somebody else owns my shares they couldn't do anything with it when the board disagrees? Even if the state takes those shares and tries to force a selloff?


The answer is there are many ways in which the trust documentation can be completed and structured. Clearly you have never heard of this type of structure since is it really common even in normal trusts. It isn't really that weird.

For example: My friend has a trust that was structured such that, he was allowed 5k for graduating high school, and 5k for graduating college, and then he was not allowed any other access to his fund. He will not be allowed any other access to his fund until he turns 40. Any other expense has to be deemed an emergency and signed off on by a board of his trust which includes only bank employees, and his trust manager, he has virtually no influence over them. There have been times that he really needed his money and they deemed that he did not, and voted against giving him access to his own funds. So in short, YES what you are being sarcastic about is how trust often work.

I suspect based on your tone you are trying to be sarcastic and snarky and don't actually care about the intricacies of trust structures. I won't answer any of your questions directly, because they are unclearly written, but will instead suggest that this information is very easy to find with a quick search.


Thanks for explaining.


You haven't understood the purpose of projects like these at all, have you?


I think what they are saying is that the land isn't really in your name if you can't sell it later.


To me this looks like an interesting attempt to holistically give some overview of mathematics to lay people and could be improved if eg. those with correction proposals here would have some way to contribute back.

I might immensely enjoy such a wikipedia of mathematics.


Honestly, I would suggest looking at Wikipedia proper. It's coverage of mathematical topics seems to be currently quite good. You can generally easily google the proofs and the details for topics presented without these. The web altogether is goldmine of mathematical knowledge today imo.

Most things aren't explained "down to the elementary level" but anyone who spends significant time on this stuff will reach a higher level and appreciate not having the same elementary explanations repeated over and over.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: