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

this is wrong! ocaml is a functional programming language with side effects.


To be fair, OCaml is multi-paradigm.


i mean, then we get into defining multi-paradigm :P does it have objects that could, theoretically, be used in a java-like object oriented system? yes! does anybody do that? not really! it's far more functional than any other paradigm, and that's what counts.


annoyingly go can't have proper sum types, as the requirement for a default value for everything doesn't make any sense for sum types


Couldn't the zero value be nil? I get that some types like int are not nil-able, but the language allows you to assign both nil and int to a value of type any (interface{}), so I wonder why it couldn't work the same for sum types. i.e. they would be a subset of the `any` type.


You can just default to the first variant, no?


Said "requirement" is only a human construct. The computer doesn't care.

If the humans choose to make an exception for that, it can be done. Granted, the planning that has taken place thus far has rejected such an exception, but there is nothing about Go that fundamentally prevents carving out an exception.


that's not how compile time works buddy


What are your other options? A type-based proof system implies dependent types, implies universe levels if you want it to be consistent.


Why do dependent types require universe levels to be consistent? I mostly see that in the context of the type of all types and similar, which doesn't seem especially necessary to express. A variable that denotes a type could have type 'any' or 'unspecified', as opposed to a type T^1 or similar.


I believe the parent was referring to Girard's paradox [1], but it's been a while and I'm not a specialist in this area.

[1] https://en.wikipedia.org/wiki/System_U#Girard's_paradox


You lose a very large amount of expressive power if you don't. Any formalisation of the reals requires at least 3 levels, if I remember correctly.


They do not really require it but note my other answer in this subthread.


You would have to not use a type-based proof system. I think those are not going to be the "as simple as possible" ones. Consider metamath for example.


Trying to compare a switch statement to proper pattern matching is like comparing a rock to a rocket.


If you're thinking of C/C++ switch statements and everyone that blindly copied them (looking at you Java, JS and PHP), you're right, but Go's switch is much more flexible (https://gobyexample.com/switch).

PHP tried to correct the mistake of not giving some more thought to the switch statement at the beginning by including a new "match" expression in PHP 8 - fun times for everyone who used classes called "Match"...


Nowadays Java and C# switch are almost as powerful as Standard ML match.


It's still a rock. Play with a language with proper pattern matching, Rust, Haskell, Ocaml, Scala, and you will also see it's just a rock.


A switch or case statement is a restricted form of pattern matching for simple values. It fits those use cases, which are frequent.

I use a language that has both pattern matching and case constructs. I use both.

If you're doing complex pattern matching all over the place (especially matching the same sets of cases repeatedly in multiple locations in the code), maybe your design sucks. It's not making effective use of OOP or some other applicable organizational principle.


> Trying to compare a switch statement to proper pattern matching is like comparing a rock to a rocket.

Yeah, but when you need to bash someone over the head, the rocket suddenly isn't any use anymore.

IOW, sometimes the simpler thing is better.

In fact, in practice, the simpler thing is usually better... Like, rocks are usually more useful to the average person than rockets are.


Go's switch statement is closer to lisp's cond expression, except it doesn't evaluate to a value.


I am unashamedly stealing this one, it is both apt and making me smile. Kudos



What's your workflow for adding a new feature to something? In OCaml, with it's "high-tech language features like algebraic data types and ultra-strict typing", my entire workflow is: - Modify the types to add the new thing. - Fill in all the pattern matching cases that the compiler tells me I need to fill in. - Maybe write a little bit extra logic. And then i'm done, with a solution I know is type safe, will never crash unless i've explicitly let it, etc. How does this help with moving data? Well, wouldn't it be handy if the compiler could stop your program from crashing when something goes wrong, or you could have the compiler track where you've safely and unsafely done operations, or a million other things. Maybe this is too strong a statement, but if you can't see the advantage of that, I don't want to work with code you've written, because you're not doing everything you can to make it as safe as possible.


Yeah, in any modern language with pattern matching stuff like this is absolutely the compiler's job, and can be done pretty well[1] - of course, there are plenty of legacy languages that don't have pattern matching, but seeing as it can be compiled straight to switches and whatnot, even the lowest level languages don't have /that/ much of an excuse.

refs: [1]: http://moscova.inria.fr/~maranget/papers/ml05e-maranget.pdf https://julesjacobs.com/notes/patternmatching/patternmatchin...


+1 for "Brady_story".


what score change +/- should there be for bragging about having "... 55 US patents"?


"Bragging" seems unnecessarily pejorative. Reading the information about his patents didn't sway me one way or the other the first time I visited his site, but I can see it being relevant data for some of his audience. The (superior) content of his books did sway me, as did Mark's willingness to make many of them available for free. I've since had occasion to interact personally with Mark, and I've unfailingly found him to be gracious and personable; "braggart" does not apply, in my experience.


And also a fairly active HN user as well!

https://news.ycombinator.com/threads?id=mark_l_watson


It's just a basic resume credentials, the same as job experience. There is another HN thread talking having personal projects online. Whatever increases your changes to put the leg in the door, do it.


The point of this website isn't to mock software that has bugs - it's to show pitfalls that have been fallen into before, and could be fallen into again. If popular languages have encountered them in the past, and fixed them, why not document it? Helps people in the future. Sure, actual examples of pure unsoundness are more interesting, but creating unsoundness in what should be a sound system is also useful to implementers of these sorts of systems.


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

Search: