News for hackers. Stuff that matters.
Re:The power of Result types in Swift by drb91 on Sunday June 17, 2018 @07:47PM (#17335029)
What would a typeless language look like?
Re:The power of Result types in Swift by igouy on Sunday June 17, 2018 @10:16PM (#17335532)
"In BCPL,flexibility is retained by eliminating the concept of data types and representing all quantities by bit patterns of the same length. A single vector may, for example, hold bit patterns representing numbers, booleans and pointers to other vectors. Variables are declared before use, but simply as variables, not as variables of any particular type."

See chapter 13 example BCPL programs:

http://www.cl.cam.ac.uk/~mr10/bcplman.pdf

See chapter 13 example MCPL programs:

http://www.cl.cam.ac.uk/~mr10/mcplman.pdf

Re:The power of Result types in Swift by orbifold on Monday June 18, 2018 @06:23AM (#17337049)
Sounds like a nightmare, this is basically the type system of vanilla verilog: Everything is just a bitvector of a certain length, each bit can have four states X,Z,0,1, so that it allows you to assign to a 32bit vector a 16bit vector resulting in the upper 16bit to be undefined. System verilog added structs, but if you declare them packed they allow unstructured assignment. Overall it is a complete nightmare given the fact that at the end you will tape out a chip that might cost >1 million to produce.
Re:The power of Result types in Swift by pjmlp on Monday June 18, 2018 @06:47AM (#17337163)
BCPL main goal was to Bootstrap CPL, but then some people decided to use it on its own, and the rest is history.
Re:The power of Result types in Swift by khitchdee on Sunday June 17, 2018 @08:46PM (#17335201)
C. Just basic data types.
Re:The power of Result types in Swift by drb91 on Sunday June 17, 2018 @09:03PM (#17335260)
C is in no way typeless.

Furthermore, i would expect a well behaved dev to avoid c at all cost.

Re:The power of Result types in Swift by khitchdee on Sunday June 17, 2018 @09:46PM (#17335389)
Well, this article is about Result types in Swift, and my point is, I think this kind of thing is overkill. It tends to make the learning curve for a new programmer steeper because there's all these extra bells and whistles provided by the language that have to be learnt before you can get going, and then you have sample code and tutorials and so on. Learning and using C was and is a lot simpler than say Swift.
Re:The power of Result types in Swift by pjmlp on Monday June 18, 2018 @02:31AM (#17336327)
I keep hearing for about 30 years now, how writing correct code in C is just a matter of being good.
Re:The power of Result types in Swift by khitchdee on Monday June 18, 2018 @09:14AM (#17337961)
It's a matter of getting good at it and that takes time and effort, but the end result is far better than not getting good at it and using a more automated, higher level lanuggae to take the easy way out
Re:The power of Result types in Swift by pjmlp on Monday June 18, 2018 @09:52AM (#17338226)
If not even Linux kernel developers with their merge review process and stress tooling are good at it, what to say of the more mundane developer...

https://www.cvedetails.com/product/47/Linux-Linux-Kernel.htm...

http://openwall.com/lists/oss-security/

Re:The power of Result types in Swift by khitchdee on Monday June 18, 2018 @12:10PM (#17339342)
Some people develop good coding techniques, like Donald Knuth. If you're new, you set out on your own or read up on what they've done or get lucky and work with a good programmer. That's how you pick it up. But, it's all pedal to the metal. Knuth's entire work is for C.

Nowadays, everything is done at a high level using some kind of pre-existing framework and the type of code being written is cookie-cutter so none of this applies. Swift belongs to this new age trend in coding,

Re:The power of Result types in Swift by pjmlp on Monday June 18, 2018 @01:17PM (#17339908)
So you are stating no one on Linux kernel development is a match to Donald Knuth, and given the CVE track record they should improve themselves to Donald Knuth level.

If there is anything new about Swift, it is a return to the past of proper programming languages.

"Oh, it was quite a while ago. I kind of stopped when C came out. That was a big blow. We were making so much good progress on optimizations and transformations. We were getting rid of just one nice problem after another. When C came out, at one of the SIGPLAN compiler conferences, there was a debate between Steve Johnson from Bell Labs, who was supporting C, and one of our people, Bill Harrison, who was working on a project that I had at that time supporting automatic optimization...The nubbin of the debate was Steve's defense of not having to build optimizers anymore because the programmer would take care of it. That it was really a programmer's issue....

Seibel: Do you think C is a reasonable language if they had restricted its use to operating-system kernels?

Allen: Oh, yeah. That would have been fine. And, in fact, you need to have something like that, something where experts can really fine-tune without big bottlenecks because those are key problems to solve. By 1960, we had a long list of amazing languages: Lisp, APL, Fortran, COBOL, Algol 60. These are higher-level than C. We have seriously regressed, since C developed. C has destroyed our ability to advance the state of the art in automatic optimization, automatic parallelization, automatic mapping of a high-level language to the machine. This is one of the reasons compilers are ... basically not taught much anymore in the colleges and universities."

-- Fran Allen interview, Excerpted from: Peter Seibel. Coders at Work: Reflections on the Craft of Programming

Re:The power of Result types in Swift by khitchdee on Monday June 18, 2018 @03:13PM (#17340857)
I'm not trying to glorify Knuth or downgrade Linux kernel developers. I'm only saying that you can leanr a lot from a good programmer, and an apprentice type arrangement is probably the best way to learn programming and we need more of that than new languages
Re:The power of Result types in Swift by TimJYoung on Monday June 18, 2018 @10:19AM (#17338421)
I understand what you're saying, and I agree to some extent. I'm not sure if these kinds of types are actually making things easier or more difficult for learning the underlying language. There's something to be said for stopping at a certain point, or taking more caution with "kitchen sinking" the language design. For example, I think that promises in JS are a mess, and Go has it right with coroutines. The underlying problem was callback hell, and promises just replaced one set of problems with another and are, IMO, not nearly as easy to reason about.
Re:The power of Result types in Swift by drb91 on Monday June 18, 2018 @12:58AM (#17336091)
This is completely true. However, after having learned both sides, I certainly appreciate the compiler’s help. I think it’s the classic tradeoff between specialization and accessability at play here.
Re:The power of Result types in Swift by khitchdee on Monday June 18, 2018 @02:24AM (#17336294)
I think the designers (Apple) have targeted a certain class of apps with Swift, XCode and the underlying libraries (Cocoa). A majority of their existing developer base will likely benefit from what they've done. But from the point of view of new developers and someone who's just trying to use the hardware in an effective way, this is not a step forward.