The Rise of Python for Embedded Systems - <AUTHOR> https://www.zerynth.com/blog/the-rise-of-python-for-embedded-systems/ <comment><USER2> There's nothing wrong with using Python on an embedded platform in certain circumstances, but this article is a poorly written advertisement.

> "Expert and skilled C programmers could justify this stating that "C > generates a faster, more compact, and more reliable code"… BUT … if you > replace C with "assembly" in that statement, you'd have exactly what an > extinct generation of programmers said about 20 years ago!"

Yes, the differences between C and Assembly are directly comparable to the differences between Python and C.

> "There's an enormous crowd of professionals skilled in using Python > "potentially" able to develop the software for the "next big thing" in IoT > and to ship new amazing embedded applications in a short time."

Python doesn't even appear on the IEEE rankings shown at the start of the article, It's amazing how this "enormous crowd" can stay so silent.

Are there any examples of products with an MCU running Python being manufactured at scale? Even if Python provides benefits for rapid prototyping, I'm really struggling to think of a business case where you wouldn't replace it with C or C++ before going into production.

<comment><USER3> > Yes, the differences between C and Assembly are directly comparable to the > differences between Python and C.

To unpack that for PC programmers: the best documentation, API design, and tooling for a microprocessor often happens at the memory map level. Sad, but true. Everything above that is typically cat shit wrapped in dog shit. The C ecosystem natively supports memory and addresses as abstractions, letting you directly consume those APIs, documentation, and tools. Note that this is one of those cases where "best" emphatically does not imply "good," and that it lies in stark contrast to the situation on "real" processors where you'll almost always find solid abstractions much further up the stack.

<comment><USER2> Yeah, my biggest issue with C/C++ on embedded systems is that it's cumbersome to build useful, safe abstractions of hardware. Almost every manufacturer- provided MCU driver library I've encountered is filled with void* and #define abuse that wouldn't fly in any other type of project.

I once worked on a project where some poor soul took the time to provide a zero-cost abstraction, described in a Scott Meyers presentation[1], for every register on an MCU. This resulted in thousands of lines of C++ template classes, which, while hurting compile times, resulted in a really strong, safe and performant API that drivers could be built upon. It was wonderful to use, but all that upfront work isn't realistic for most projects.

I'd definitely be interested in a language that supports this type of abstraction "natively" (i.e. doesn't require lots of boilerplate code) while providing C-like performance on bare-metal platforms. I know that some people are trying to make Rust fit this hole but I'm not sure how that's coming along.

1\. [http://www.aristeia.com/c++-in- embedded.html](http://www.aristeia.com/c++-in-embedded.html)

<comment><USER3> Agreed 100%. I don't think memory maps will ever go away as the "API" between hardware and software -- the "alternatives" always seem to involve staggering complexity or a violent neutering on either the SW or the HW side (always the opposite of the person doing the talking, of course) -- but I do think that it's profitable to contain that interface beneath application code, preferably with a language-enforced barrier. I'm cautiously optimistic about Rust's "unsafe" as well. I'm just not cautiously optimistic about python :-)

</comment></comment></comment></comment><comment><USER4> whhhhhhyyyyyyy?

i just can't understand why someone would want python for embedded applications. i primarily use labview for systems development, and there is not a single thing that would be gained by moving to python while many things would be lost. and no one can convince me that using python over labview would generate more robust code. i have used python before, and it was slower to develop in and more error prone than labview for system development.

personally, i want to see more lisps/schemes and ML-based languages on embedded systems. i know there are some, but they aren't quite there. that's the direction i think we should move. python isn't the best at any one thing other than having lots of libraries. there are far more productive dynamic languages (lisps/schemes) and far better languages for developing safe code (ML-based). i am currently learning idris, which seems like it could be amazing for embedded code development. having provable state machines would be a huge plus.

<comment><USER5> > _i have used python before, and it was slower to develop in and more error > prone than labview for system development._

Exact opposite in my experience. I've been there, tried that. Re-wrote it in python for a more than 50x productivity gain.

At my first job out of school, I inherited maintenance for a couple of projects. All were extremely expensive custom test equipment, written in Labview. One was the central project, the whole point of this group's existence. It had been in development for more than two years. It routinely destroyed thousands of dollars worth of hand-made sensors during its power-on self-test. It was a far cry from being finished. It couldn't even be considered a prototype.

In a two-week period, I taught myself python, quickly cloned the existing calibration procedures, and finished the entire thing. My boss thought I was a genius rockstar, but no, I'm not. I just had the sense to evaluate every available tool and came to the conclusion that Python (mostly due to the ctypes module and a robust Windows ecosystem), was the best option.

Personally I'll use C whenever possible for embedded work. (And later I did port the entire project to a DSP running C, because Labview & an AD DAcq board was too expensive.) But if latency doesn't matter, Python is fine.

edit: Side note, I was already conversational in Labview. Admittedly only for school projects, but at that point I knew more Labview than Python.

<comment><USER6> Agreed, at my job I'm now actively campaigning against LabView (and Matlab) for application development. These projects turn out productive at first and invariably turn into unsupportable messes.

What's the right platform for "embedded systems" is debatable. A true bare- metal app has different requirements from something running on RPi or Beagleboard.

<comment><USER7> I strongly disagree. I've used both LV and matlab for many years and they are tremendously good for specific tasks.

Labview is great for data acquisition and GUIs to visualize this data. Drop a ready made UART/TCP/VISA block, some array manipulation in a loop, connect a waveform block with zoom/cursors/etc. and you have a working real-time app in a couple of hours.

Matlab is perfect for heavy matrix operations on large datasets, fantastic for plotting your data and it's very good for prototyping algorithms.

I tried python as an alternative for both. Tons of boilerplate code, a pain for GUIs and don't get me started on matplotlib/scipy/numpy...

The biggest drawback of both LV/matlab is their proprietary nature and the expensive licenses which make them unsuitable for hobbyists (at least there's octave as a matlab alternative). But they're great tools for the appropriate tasks

<comment><USER8> The problem with both LV and MATLAB is that once you've done the basics, and now you want to turn it into something that you can maintain and sell.

With LabVIEW you can compile and redistribute, but good luck writing an efficient binary search tree when your data gets bigger than what can be searched for with brute force. Also, at least last time I used it, the version control was horrendous.

For MATLAB, just forget redistribution in general. Nobody is going to buy a MATLAB licence to run your code.

<comment><USER7> >The problem with both LV and MATLAB is that once you've done the basics, and now you want to turn it into something that you can maintain and sell.

That's true, but it's not their strong selling point. There's tons of problems to solve at the r&d stage when dealing with custom hardware, a dozen different instruments and algorithm exploration. That's where these tools shine and the reason they're ubiquitous in industrial/military/aerospace environments.

For a full product with drivers, libraries and fast, customer friendly UI sure there are better solutions, but there's no law that dictates to use the same tools at the development stage

</comment></comment></comment></comment></comment></comment><comment><USER9> I'll just drop this here: [Evaluation of MicroPython as Application Layer Programming Language on CubeSats]([http://ieeexplore.ieee.org/document/7948548/](http://ieeexplore.ieee.org/document/7948548/))

I think Python has _everything_ a language needs to be the future of Embedded Systems - except a compiler.

You start writing you program using MicroPython as interpreter. You add type hints because it's the right thing to do anyway. Once your prototype is done, you compile to get the speed (cutting execution time, increasing sleep time, increasing battery live).

My background is Aerospace Engineering and maybe that's why I can't understand why nobody does a real, AOT, Python compiler. There is Nuitka, but it's a transpiler that extensively uses libpython and isn't fit for microcontrollers (still awesome project, tough). Cython also uses libpython and a different type-annotation system.

<comment><USER10> For something as critical as aerospace, wouldn't a statically-typed language be a better choice anyway? I love Python, but I don't think it has a place where rigor and validation are concerned.

Though I suppose if you were writing a compiler, you could require and enforce type hints... but then any calls into the standard library will just have to be trusted. I dunno. It seems tricky.

<comment><USER9> That's why I'd enforce type-hints.

The whole story with these critical systems is tricky. At the one hand, they want to have formal verification. Academia really loves stuff like Haskell for that. There is Ada which was designed with critical systems in mind.

On the other hand, there is a lot of C and C++ everywhere. On microcontrollers, no matter how much you love Haskell, Ada or Rust, there might not even be a compiler and probably no HAL.

And in the end, all of those languages focus on the machine and the math. A mathematical prove of the correctness of your software is nice, but readable code is too. And the formal verification doesn't save you from making wrong design choices. It doesn't check your logic. No language or tool can do that. But what I believe a language can do for you is help you express your thoughts in such an simple, structured and readable way that the cognitive load is reduced to a minimum, freeing up thought-power to check your logic.

A lot of the failures in space that were caused by software weren't actually programming errors like the overflows that allow us to hack everything. There was a Mars Orbiter that crashed because the data was in the wrong format - still the types matched. A lander crashed because they forgot to put in logic to handle invalid sensor data: a broken sensor in the landing led triggered the 'touch-down' signal, the lander believed it landed and cut the chute. Except it really wasn't even close to ground.

Using a bit of hyperbole, there is formal verification in Academia on the one side, and people forgetting to design robust logic while trying to figure out pointers on a microcontroller that can only be programmed in C on the other.

Static Python. That's my proposal to save the next mission :)

<comment><USER4> but all that seems to be silly. why try to force feed patches to make python something it was in no way designed for? it seems like the completely wrong approach from a design point of view.

and your dismissal of the power of type checking systems seems strange. seems weird to say that it doesn't really help when python has nothing of the sort. even a "static python" wouldn't reach the power of some existing systems. even for dynamic languages, python is behind the times for things like that. for example, look at racket versus python.

and then there's languages like idris, which go well beyond what even haskell can do. something like idris would be wonderful for critical embedded systems. and if you really want flexibility and a dynamic language, python seems well below lisp/scheme. i would love to see racket and ML-based languages to move towards embedded development over something like python.

finally, both lisps/schemes and ML-based languages are very readable. many would argue they are more readable than a language like python. so your implication that type systems incur a readability penalty isn't generally accurate.

> But what I believe a language can do for you is help you express your > thoughts in such an simple, structured and readable way that the cognitive > load is reduced to a minimum, freeing up thought-power to check your logic.

basically what i am getting at is that a language like racket or idris fulfill this requirement very strongly, even moreso than python. and additionally, they come with advanced language features that no version of python will ever likely touch on.

</comment></comment></comment></comment><comment><USER11> Each has its own place. I write code in all languages including Python and C. Yet, I have to write code in assembly even today when the particular problem statement requires its usage. Such generalization can only be expected from a marketing campaign that this post really is.

<comment><USER12> What specific tasks require assembly?

<comment><USER13> Not the OP, but I've written assembly in our codebase for:

* First stage initialization

* Interrupt prologue/epilogue

* Bitbanging where you want deterministic cycle counts

* For using the FIQ for very high priority interrupts. It has it's own registers partially banked, so if you stay in r8-r13 you don't have to save and restore state at all.

So we don't use assembly for magic go faster juice, but instead when there's a coding constraint that we can't easily explain to the compiler.

<comment><USER14> I'm curious to hear more how/why you use FIQ? From googling it looks like it's an ARM feature. How can/does that work with a general purpose OS or are you using bare metal ARM?

<comment><USER13> We've got our own internal RTOS, not a general purpose OS.

We use it for different things depending on the board, but my favorite is a really sweet profiler that's integrated with our watchdog logic that'll give us ~1000 PC+SP samples in the 100msec or so before our watchdog timer resets our board. That's pretty invaluable for debugging.

</comment></comment></comment></comment></comment><comment><USER15> Couldn't something like micro python and Cython replace Zerynth? Reads like the marketing post that it is. Starts off with interesting stuff and ends with promo. It also looks very proprietary to me. Just add more FOSS and I will definitely be interested.

<comment><USER16> Something _like_ cython certainly could, but cython itself is far too integrated with the CPython C API to work well with micropython.

<comment><USER17> There's an old github issue[0] exploring this, but it seems to have died. One contributor had some basic success[1], so perhaps there could be opportunity to more closely integrate the two projects by a sufficiently skilled and motivated dev?

[0] [https://github.com/micropython/micropython/issues/658](https://github.com/micropython/micropython/issues/658)

[1] [https://github.com/micropython/micropython/issues/658#issuec...](https://github.com/micropython/micropython/issues/658#issuecomment-45096909)

</comment></comment></comment><comment><USER18> I am using MicroPython on ESP8266 right now. What are the major differences between Zerynth and MicroPython, and why do they exist?

<comment><USER19> Agree. I've been using Micropython for almost two years on several projects. This Spamvertising from Zerynth doesn't say why I should switch.

<comment><USER20> Prototyping ? Or products ? And if so please expand.

</comment></comment></comment><comment><USER21> Cached version: [https://webcache.googleusercontent.com/search?q=cache:-F31l-...](https://webcache.googleusercontent.com/search?q=cache:-F31l-w3tE4J:https://www.zerynth.com/blog/the- rise-of-python-for-embedded-systems/+&cd=1&hl=fr&ct=clnk&gl=fr)

</comment><comment><USER22> Is there a benefit on using Python in terms of performance rather than C/++ for embedded systems? Does Python work well for lower level applications (in terms of hardware access)?

<comment><USER23> > Is there a benefit on using Python in terms of performance

If you're talking about _machine_ performances, the opposite, even for a dedicated dialect like micropython. The benefits are in safety, readability and ease of development.

<comment><USER22> Both in terms of embedded systems application: What makes micropython safer and easier to develop compared to C/++? In terms of safety, is there better memory allocation and hardware control through Python? I would imagine micropython would be more inefficient and more prone to hardware error. As for the ease of development, wouldn't C/++ be better? Sure, it's harder to read but C/++ seems like the right tool for this particular job.

I'm pretty curious because I'm pretty fluent in Python and I have been learning C++ for more lower level stuff mainly for speed reasons. I still program most of uC through C++ so I'm curious if I should learn micropython if it provides substantial benefits.

<comment><USER23> > Both in terms of embedded systems application: What makes micropython safer > and easier to develop compared to C/++?

Python is a GC'd (reference-counted in CPython and probably µpython) and memory-safe language so it should be less prone to memory corruption, although it is more likely to open you up to resource exhaustion.

> In terms of safety, is there better memory allocation and hardware control > through Python?

These are not what is usually understood by "safety" in programming.

> I would imagine micropython would be more inefficient

Definitely, the overhead of micropython would be substantial (even more so as it can't leverage compiler optimisations) so it's a tradeoff between hardware requirements and ease of development/time to market. IIRC micropython also supports only a relatively small subset of all embedded systems.

See [http://docs.micropython.org/en/v1.8.6/pyboard/reference/spee...](http://docs.micropython.org/en/v1.8.6/pyboard/reference/speed_python.html), [http://docs.micropython.org/en/v1.8.6/pyboard/reference/cons...](http://docs.micropython.org/en/v1.8.6/pyboard/reference/constrained.html)

> As for the ease of development, wouldn't C/++ be better?

Generally speaking python is more expressive and more readable than C++ code, which makes it easier to write (develop) Python. C++ is more finicky, thus harder to develop.

<comment><USER14> > > In terms of safety, is there better memory allocation and hardware control > through Python? > These are not what is usually understood by "safety" in > programming.

In many embedded and RTOS contexts, safety and allocation and hardware control are very difficult to distinguish.

> > As for the ease of development, wouldn't C/++ be better? > Generally > speaking python is more expressive and more readable than C++ code, which > makes it easier to write (develop) Python. C++ is more finicky, thus harder > to develop.

C++ is a huge pain with loose type casting behavior (e.g. is this an long or does this expression convert it to an unsigned long?). But then again Python has very _loose_ descriptions of int and float types at all. For me that makes doing bit manipulation for talking to peripherals more opaque rather than less so.

<comment><USER24> If you want C-like ints and floats, you use ctypes. You have all the typical types, e.g. c_char, c_float, c_int8/16/32/64, c_size_t, etc, plus structs and arrays.

</comment></comment></comment></comment></comment></comment><comment><USER25> I am trying to read more but the website went down. My question: I have been dabbling with mbed for quite some time and I would love to use Python for uC. The main problems(at least the perception) are that: you cannot do programming for low power and for real time functions, python will not work. Are these issues addressed by zerynth?

<comment><USER26> Micropython actually has decent support for real-time operation, according to [1]. This is via proper use of timers and interrupts. I imagine it's something like programming for a real-time operating system.

[1]: [http://www.edn.com/electronics-blogs/embedded- basics/4440447...](http://www.edn.com/electronics-blogs/embedded- basics/4440447/Using-MicroPython-for-real-time-software-development)

<comment><USER13> The article doesn't really make it's case for Micropython having real-time capabilities. The author seems to be confusing 'real-time' and 'microcontroller'. At a bare minimum you'd need a proper priority scheme.

</comment></comment></comment><comment><USER27> What about memory fragmentation? I have had a lot of fun with MicroPython on an ESP8266, and, while I was thinking about my problem all wrong, I did bump up against reboots due to exhaustion of the address space (I think)...

</comment><comment><USER28> This makes me want to poke my eyes out. I like python, I've used it before and would use it again, but please stop using tools that are not made for a certain job just because they're popular for other jobs. There are languages especially made for this kind of work, such as Lua or others.

<comment><USER29> Python has a far healthier ecosystem than Lua [1] [2].

[1] [https://luarocks.org/m/root](https://luarocks.org/m/root) [2] [https://pypi.python.org/pypi](https://pypi.python.org/pypi)

<comment><USER30> The Python ecosystem is basically irrelevant to embedded programming.

What you need is things like [1] or maybe [2]. Lua has them because it's been the dynamic language of choice for this domain for years (with Lisps and Forths as its main competitors).

Now we see new challengers like micropython, mruby and jerryscript / iotjs, it will be interesting, but they're clearly not the mainstream choices for embedded.

[1] [http://www.eluaproject.net/doc/v0.8/en_refman_gen.html](http://www.eluaproject.net/doc/v0.8/en_refman_gen.html)

[2] [https://wiki.openwrt.org/doc/howto/luci.essentials](https://wiki.openwrt.org/doc/howto/luci.essentials)

</comment></comment></comment><comment><USER31> On a side note for ruby fans, it's quite popular in the embedded world in Japan via a dedicated project: [https://github.com/mruby/mruby](https://github.com/mruby/mruby)

</comment><comment><USER32> Do CS grads even get taught C any more? I get the feeling that the newest generation is all Java/Python/JS.

Given that cheap embedded systems are so powerful now it makes sense.

<comment><USER33> If they take an Operating Systems course (which, I hope, every CS grads does) then they certainly get taught C. That was the case for me and I only graduated last year. Plus, most CS grads learn C++ which means they can easily get started with C.

</comment></comment><comment><USER34> There are even companies writing drivers in Python.

[https://foxdeploy.com/2017/07/19/buildyourowniotmonitoringto...](https://foxdeploy.com/2017/07/19/buildyourowniotmonitoringtool/)

Search for "via a driver written in Python!".

<comment><USER35> this looks like someones blog, and the search returned no results related to python drivers...

<comment><USER34> It is someone's blog indeed.

The author tried to do an IoT setup for C#.

If you searched properly, you would have found the remark I've written, where the author explains that the chinese OEM of a touch screen that failed to work with his setup,told him that the respective device driver was written in Python.

</comment></comment></comment><comment><USER36> Here is a link to the zerynth docs: [https://docs.zerynth.com/latest/official/core.zerynth.docs/i...](https://docs.zerynth.com/latest/official/core.zerynth.docs/installationguide/docs/index.html)

</comment><comment><USER37> This whole article is predicated on the COMICALLY flawed IEEE review: see [https://news.ycombinator.com/item?id=14811321](https://news.ycombinator.com/item?id=14811321)

(I'm a huge python fan, but not this way...)

</comment><comment><USER38> So the developers of Zerynth say Zerynth is great. Nice try... I say, Wrong Tool for the Job. Use C.

</comment><comment><USER39> Well, "Embedded Systems" represents a continuum ranging from simple non-smart programmable thermostats to microwave ovens, televisions, engine controllers, navigation systems, high performance servo controllers and more. I have always found discussion about programming languages to completely miss the reality of what it is to deliver, support and maintain these products.

I have developed embedded systems in the context of a real business manufacturing and supporting these products using everything from assembly language, through Forth, C, C++ and, yes, Python.

There was always a good reason to make an choice at the time. For example, an embedded system running a sophisticated control panel with dozens of knobs and buttons was done entirely in assembly language eons ago. It didn't take long for that to become a very bad idea. It was very difficult to maintain, improve and evolve the system. We ultimately decided to bite the bullet and port the code to C. The difference in the ability to express ideas was massive.

The only two languages I would avoid today are assembly language and Forth. The first because it is a nightmare to support, maintain and evolve outside of trivial systems. The second because it is impossible to find good Forth programmers these days and the ecosystem (libraries, etc.) is nonexistent. That said, I still think everyone should learn both.

I have yet to see an embedded system that can't be done well (and by that I mean the entire life cycle of a product) with plain-old C. Nothing wrong with the language. No magic. It works and it can produce clean, reliable fast code.

C++. Well. If you came up through assembler and Forth you learn to despise waste. And that's what forcing an object oriented approach tends to be when there is, in the end, no real need to take this route. Sometimes I see OO as a tool lazy programmers reach for. Some of the funniest code I've seen are things like erecting a complex OO solution to implement a state machine when a simple lookup table and minimal procedural code could do exactly the same, run faster and with less resources. I also do hardware in FPGA's so that's a formula for being keenly aware of resources and not wasting them.

As for Python. Well, frankly, it's about the libraries and nothing else. If you need to do an advanced embedded system with, for example, vision, you almost can't beat the Python ecosystem. Not because of the language. No. I couldn't care less. I care about time to market and the Python ecosystem offers a cornucopia of solutions covering just about any field one might care to name. You can hire Python programmers and anyone who knows C-like languages can learn it fast. That's important.

In the end we build products and all that matters is to build said products as cost-effectively as possible and the ability to support, maintain and evolve them just as effectively.

<comment><USER40> > C++. Well. If you came up through assembler and Forth you learn to despise > waste. And that's what forcing an object oriented approach tends to be when > there is, in the end, no real need to take this route.

I like wrapping an object around a hardware resource, so that the only way it can be modified is a call that went through a public member of that object. You can enforce consistency that way.

And C++ has the philosophy that "you don't pay for what you don't use". (Of course, if you _use_ what you don't _need_ , you can still cause waste...)

<comment><USER39> You don't need C++ for that. Let's say we are talking about a serial port and a motor driver, all in the same MCU. A programmer would have to be pretty sloppy to use motor controller functions to try and talk to the serial port.

If I write a function called "set_serial_baud_rate()" and another called "set_motor_rpm()" it would be alarming if someone tried to use it to set the set_motor_rpm() to change the serial port's baud rate.

I understand encapsulation very well but it simply isn't necessary in a lot of embedded cases. I can't remember a single instance in thirty years of product development when we had an issue in development because code was NOT object oriented. Product development never slowed down due to not using OO. More bugs were not introduced due to not using OO. Code was just as maintainable and extensible using C or C++. It truly does not matter at all as far as I am concerned.

What I look for is "done for you" code. Libraries that can produce power-of- two or order-of-magnitude gains in developing a product. Show me gains of that magnitude and I'll code in COBOL if necessary. I truly don't care about languages any more. Just like I don't care about code editors (counting milliseconds in vim). Give me a decent IDE like JetBrains products and life is good.

I know this puts me at odds with most of what they teach today. Kids come out of school and automatically reach for objects for even the simplest of problems. OO has it's place, of course, but it should not be the first tool one reaches for unless it is well justified.

A CPU couldn't care less if you wrote the code in machine language or Python. The facilities provided by these languages are for the programmer, not for the CPU.

One of my favorite interview techniques: Ask someone to solve a problem. If they are on the younger side they'll immediately define a class, members, properties, maybe multiple classes. When they are done, ask them to do the same in procedural form. I've seen people get completely tangled-up by this simple request.

EDIT: To be clear, I am NOT saying OO doesn't have it's place. Of course it does. I've written a bunch of iOS apps in Objective-C with a good mix between OO and procedural when justified. For example, a genetic solver done in procedural form on iOS is miles faster than the same solver implemented in OO. A lot of it has to do with using layers of data objects rather than the raw data types typically used in C. In other words, there's a cost associated with using an object to store and manipulate what would otherwise be a simple array. You might be surprised to see just how dramatic the performance improvement can be.

<comment><USER40> Well, let's say that set_motor_rpm() didn't try to slam the RPM to the requested value, but instead tried to smoothly accelerate or decelerate to the requested value at a rate that would not damage the motor. It might use a function called set_immediate_rpm() to set the value for the next instant, but that value needs to be not very different from the current value, or damage can result. You can use an object to make sure that nobody from outside calls set_immediate_rpm() by mistake.

Now, you're still right, because in C, you just make set_immediate_rpm() static, so that nobody can call it from outside the file, and then the non- static functions become the public API.

<comment><USER39> To go further than that, embedded projects more frequently than not have one and only one software developer. It's not like building a website with a team of several developers.

In this context the "nobody" in your scenario is the only person on the project. Which, once again, brings us to the idea that it isn't the language or procedural vs. OO at the root of the problem at all if things are done wrong or misused.

I must also point out that hypothetical examples are rarely meant to cover all possible scenarios, much less corner cases. They are simplified examples to facilitate an explanation. As such it is always possible to find holes in the hypothetical.

A colleague taught me a very important lesson about twenty-five years ago. He was about ten years older than me and had far more experience. I had just finished coding an electronics component management system for our manufacturing department where we worked. It was really slick and fast at a time when text-only apps and menus reigned. I was proud that my six month effort had produced such a product.

I was showing it off. When it was his turn to be dazzled he let me do my "look at this" tour of the software and said virtually nothing. When I was done he said "looks good" and proceeded to plant his palm on the keyboard and run it back and forth about four times, pressing as many keys as he could at random. The program crashed and he walked away.

It took me about a month to make it robust enough to have it react gracefully to such an attack. Learned a lot in the process about dealing with the real world. This gave me the mindset to write code defensively.

A function such as "set_immediate_rpm()" should be bulletproof, and this has nothing to do with OO vs. procedural. A good implementation of "set_immediate_rpm()" would have a rate-of-change evaluation such that you could call it a million times and yet not violate the maximum desired rate of change (presumably set through a different function or defined as a constant somewhere).</comment></comment></comment></comment></comment>


Report: NSA bulk metadata collection has "no discernible impact" - <AUTHOR> http://arstechnica.com/tech-policy/2014/01/report-nsa-bulk-metadata-collection-has-no-discernible-impact/ <comment><USER2> Wow. OK _now_ we see why we had to spend billions of dollars and shred the Bill of Rights. Because a cab driver sent $8500 home to Somalia. It's all clear now. Carry on, patriots.

What may annoy me even more, is that even in this article, Ars needed "balance" so much that they let some executive branch lizard blow his pompous bullshit at us without putting his name on it. That has got to stop. Anonymous speech is for citizens, not tyrants.

<comment><USER3> > Anonymous speech is for citizens, not tyrants.

That's why I can't get behind the privacy movement. No one seems to be arguing that privacy is a right - it's just a privilege extended to those we like (citizens), but shouldn't necessarily be extended to those who oppose us (tyrants). Among those we don't trust, openness is necessary to avoid despotism. Among those we do trust, privacy is a fundamental freedom.

The NSA agrees with your sentiment 100%. Your only disagreement is on who is the tyrant.

<comment><USER4> Bah. This is a government worker talking about his job in a quasi-official capacity, not "those who oppose us." I should know as much about what he's doing at work as my company should know what I'm doing at my job.

<comment><USER5> > I should know as much about what he's doing at work as my company should > know what I'm doing at my job.

Is that what you tell the traffic cop too?

</comment></comment></comment></comment><comment><USER6> I believe we are watching agitprop being masterfully and skillfully applied to the positioning on this whole metadata issue, even here among the cognescenti, by the powers in charge of these meetings.

This is a setup for us to all start thinking "oh, metadata doesn't really mean anything". 'It doesn't mean anything, because its obviously not useful.'

So .. here's my delegitprop thought: If today, the line is "Feds are not achieving anything with metadata", then tomorrow .. or maybe a little later .. the line will become "metadata doesn't achieve anything".

So we'll see.

Who is asking the politicians if they actually do know what the word 'meta-' means? Because .. those who are collecting "meta-"data can facetiously use that word from multiple angles .. and these totalitarians (call them what they are, folks) are fastidious about never using words in this realm that they do not have clearly, internally at least, defined.

The NSA has its own dictionary of the English language, for internal use. It is used to promote internal doctrine, and it is used externally to position. Information positioning is a refined, pure, utter science in this realm. So this NSA dictionary should be on the table in front of any Senator, doing their job, in these meetings. I highly doubt it is relevant what I think, but the only way out of this mess is a total dox'ing of the agency, and a replacement with something else ..

<comment><USER7> If it has no impact then:

1) Why are we wasting money collecting and storing it?

2) Why are we wasting time looking at it?

This does not muddy the waters to anyone with critical-thinking skills. Why does this invasion of my privacy need to happen if it is unable to achieve its own stated goals?

Edit:

My point was that people should be asking these questions, and these aren't hard questions to ask. Even just asking "if this has no impact then why are we wasting money" should be an easy question to ask for fiscal conservatives. I really don't see many people going the route of thinking, "this is ineffective, therefore we should just keep doing it because the metadata doesn't matter."

I don't understand why people see me asking these questions and automatically assume that I'm attacking them and defending the NSA or something.

<comment><USER8> It has no impact on catching terrorists. That's the article claim.

It obviously has some impact somewhere, otherwise nobody would lose time creating it.

<comment><USER7> The impact may not be much though. People have wasted much time, money and effort on endeavors based on faulty premises just because they never took the time to evaluate their situation.

<comment><USER9> At a guess, it is a measurement tool for analysing cause and effect with the aim of not being caught out by political mass movements. If you want to model a society thermodynamically, you need a lot of data. But then I have always been a fan of Asimov's Foundation.

</comment></comment></comment></comment></comment><comment><USER10> "No discernible Impact" on preventing acts of terrorism.

But that was never the end goal of bulk metadata collection. Terrorism was the merely the excuse to invoke those powers. The end goal is and always has been, to give the U.S Govt unfettered access to all communications of it citizens for whatever purposes it desires without having to go thru the legal process (not even the ridiculously permissive FISA court).

Prediction - They will use every excuse in the book to hold onto this capability.

<comment><USER11> >> The end goal is, and always has been, to give the U.S. govt unfettered access to all communications of its citizens<< I sort of feel like this glosses over the rest of us out here in the world. We don't have anyone to complain to that can/will do anything and are far more likely to suffer from US government actions. It's worse that we suffer this crap that US citizens do, not better as we don't get any say in it.

</comment></comment><comment><USER12> _" This capability was put in place after 9/11 for a good reason," said a senior administration official who asked not to be identified discussing sensitive deliberations._

"We can't tell you exactly what those reasons are, but trust us, they're really important."

<comment><USER13> Edit: and oh, we are anonymous when we say that... you know, just for our own protection...

\- are we going to see a day where a SWAT team raid your house for unclear reason, you are being tried under secret court that you have no influence over, and decision is made by an anonymous judge or secret jury (for their own protection, of course).

Crap, I say: capital punishment for everyone, even if it was only a jaywalking!

/sarcasm.

</comment></comment><comment><USER14> Surveillence of Citizens Is ALWAYS Aimed at Crushing Dissent[0]

[0][http://www.ritholtz.com/blog/2014/01/surveillence-of- citizen...](http://www.ritholtz.com/blog/2014/01/surveillence-of-citizens-is- always-aimed-at-crushing-dissent/)

</comment><comment><AUTHOR> Quote:

"A new paper published Monday by the New America Foundation... closely examines the 225 cases... the controversial bulk collection of American telephone metadata... appears to have played an identifiable role in initiating, at most, 1.8 percent of these cases."

(That's 4 cases)

<comment><USER12> 4 cases against 4 people involved in one actual attempt by a cab driver to send $8500 home to Somalia. So allowing a figure as high as 1.8 percent is really, really generous.</comment></comment>


Ask HN: Building cheap, affordable houses in earthquake-hit Nepal? - <AUTHOR>

I am from Nepal.
Thousands of houses has been completely destroyed here. Any expert here who can suggest some technology which could help people to build houses fast and cheap.
I really need these info to help people rebuild there houses. We have many youths who are ready to provide help but we are not familiar with the process. <comment><USER2> So I did a bit of research. Here are my two approaches to hacking complex problems:

      1. Find who is doing it already.
      2. See how this problem was tackled by someone who had it worse.

For #1: See [http://www.naturalbuildingblog.com/](http://www.naturalbuildingblog.com/) They aim for simple to build earth-based houses for $10/sq ft. A good next step likely is to reach Dr. Owen Geiger.

For #2: See [http://www.rebuildhaitihomes.org/](http://www.rebuildhaitihomes.org/) Looks like they started with fundraising.

</comment><comment><USER3> You may want to try to contact Mike Reynolds, who is best known for building self-sufficient houses called Earthships by using refuse (rammed-earth tires, plastic bottles, etc.) as a structural component.

He took a team to places hard-hit by the 2004 tsunami and worked with the local people to design and build houses out of whatever was available[0]. He appears to be good at figuring out how to build homes that are suited to their environment given the materials at hand. For example, he saw that lack of clean drinking water was as big a problem for the islands hit by the tsunami as the lack of real housing, so he incorporated rainwater catchments and cisterns into the structure of the single-family structure he designed with the islanders.

I think his talents would be well-suited to a disaster situation where there is a need for fast, cheap housing, and it seems he has the heart for it as well. I bet we could crowd-fund his travel costs if he's willing to go and there's a need for that. There is a contact page with a phone number on the earthship website[1].

[0][https://www.youtube.com/watch?v=49oE6nbwz8E](https://www.youtube.com/watch?v=49oE6nbwz8E)

[1][http://earthship.com/home/contact-us](http://earthship.com/home/contact- us)

</comment><comment><USER4> The question is quite unclear here. Are we talking about temporary houses to live or the kind of houses which are supposed to be sustainable and residential. Better house construction techniques are sure to help and earthquake resistant building techniques are known and applied during current construction of houses in Nepal, I suppose. I am not the authority here though. Just clearing the confusion in the question.

P.S. I am also from Nepal.

</comment><comment><USER5> Ikea is entering production with their temporary refugee shelters:

[http://www.theverge.com/2015/3/26/8287509/ikea-refugee- shelt...](http://www.theverge.com/2015/3/26/8287509/ikea-refugee-shelter- flatpack-photos-iraq-syria)

</comment><comment><USER2> The big question is: which materials you have available for construction now - concrete, wood, glass?

</comment><comment><USER6> knowing what materials you have available would make it easier to help come up with a design.

shipping containers come to mind as something easy to acquire and redesign the interior of quickly and easily.

if wood is in abundance, there are many cheap and fast designs for small shelters/houses available online that have been made for ease of construction. Wood is probably easier/faster to build to earthquake resistant building code, then other materials.

small and efficient home design is often studied in architecture schools, there is an abundance of designs available online. if you found one suitable, ask the creator if they would be willing to provide your cause with a free set of blue prints or more detailed design materials.</comment>


Amazon EC2 F1 Instances: Run Custom FPGAs in the AWS Cloud - <AUTHOR> https://aws.amazon.com/ec2/instance-types/f1/ <comment><USER2> Discussion when they were announced: [https://news.ycombinator.com/item?id=13072432](https://news.ycombinator.com/item?id=13072432)

</comment><comment><USER3> One thing that's really missing from that landing page is any sort of meaningful FPGA specs(LUTs, DSP slices, block RAM, etc).

Still pretty cool to see FPGAs now showing up in cloud managed hardware.

<comment><USER4> They mention that the F1 instance is using Xilinx's UltraScale+ FPGAs and that they have approx. 6800 DSP slices.

You can see that they must be targeting the VU9P from the product selection guide (pdf) here:

[http://www.xilinx.com/support/documentation/selection- guides...](http://www.xilinx.com/support/documentation/selection- guides/ultrascale-plus-fpga-product-selection-guide.pdf#VUSP)

From the guide:

      VU9P:
        6840 DSP slices,
        2.3M flip-flops,
        1.1M LUTs
        36Mb distributed RAM
        76Mb block RAM
        270Mb ultra RAM

Additional documentation is linked on the last page of the selector guide.

Note that these specs are per FPGA. An F1 instance comes with up to 8 of these devices.

</comment></comment><comment><USER5> If I knew anything about VHDL, I would create a cloud Amiga!</comment>


Ask HN: Which is better for tech – London or Berlin - <AUTHOR> For a well funded startup which is a better city to open an engineering office. Which city has access to a larger pool of software engineers. <comment><USER2> From my limited, anecdotal experience, Berlin. That being said I've done no formal research on statistics, etc.

Edit: Also the industry would affect things, I imagine

</comment><comment><USER3> San Francisco or Palo Alto.</comment>


Snapchat rises: Why Poke's decline shows Facebook's inability to invent - <AUTHOR> http://www.gigaom.com/2012/12/26/snapchat-rises-why-pokes-decline-shows-facebooks-inability-to-invent/

<comment><USER2> This is a classic Receiver-end bug that can never be fixed! Even if Snapchat & FB fix this issue in future upgrade of the app, what if the receiving user does not upgrade the app? The sender may have the latest version of the app and think that it is totally secure. However as long as the recipient is using the old app (something the sender will never know), poof goes the security! Breaking support for old version of the app may solve it, but that's very inelegant and don't think Snapchat or FB will try it or Apple will allow it.</comment>


Quibi - Snackable Movies - <AUTHOR> https://qz.com/1569423/jeffrey-katzenbergs-quibi-to-offer-snackable-movies-on-phones/ <comment><AUTHOR> it seems to me like he's trying to reinvent the wheel. a 2hr movie divided into 8 minute segments isn't a movie it's a minisode of a series. Yes, there's a name for it because it's not even an original idea. By the way youtube, who he labels as competition already has a lot of web series in minisode format. This guy is following Apple's model. 1. Copy somebody else's idea. 2. put it in a shiny package & add a catchy, fancy sounding tag line without really improving the core functionality. 3. sell it at a premium under the guise of it being innovative. It only works because people attach a premium value to Apple's copies because they're either not familiar with the original product that Apple copied or they believe Apple's excuse for passing off another company's idea as their own. This is the same thing.</comment>


A Swedish farmer using oats to make milk - <AUTHOR> https://www.theguardian.com/sustainable-business/2017/aug/26/wow-no-cow-swedish-farmer-oats-milk-oatly <comment><USER2> From what it looks like reading swedish news over the years, there is no money in running a traditional farm, german milk is cheaper, danish meat is cheaper and so on. I'm sure that's the main reason a farmer would go for something like this, rather than for saving the planet or whatever.

And my personal experience with this Oatly milk, it tastes like hay. Which makes me wonder where this demand came from.

<comment><USER3> These oat-based products are popular because allergies are common. People allergic to milk and/or soy proteins can drink this milk, eat this ice-cream etc

<comment><USER4> But why would you then drink some product that tastes nothing like real milk? Just because it is white, sweetish and marketing people called it "<something> milk"?

<comment><USER5> Two broad alternatives: because it's the best substitute ("somewhat like milk in some way"), or because it's good. It's not like "milk" in "<something> milk" has to refer to the taste of, or to cow's milk at all.

<comment><USER6> Exactly. Milk means you can put it on your cereal and use it in your flat white. It doesn't mean you can turn a 50kg calf into a 500kg bull.

</comment></comment></comment></comment></comment><comment><USER7> Just got to add that Oatly is a great product. Unlike most other plant based substitute for milk, it isn't overly sweet.

<comment><USER8> How thick is it? Other plant "milks" I've tried (almond, rice, soy) seem to resemble skim milk in texture, and you have to get something labeled "creamer" to find a consistency that resembles 2%, let alone whole milk.

<comment><USER9> A non-creamer plant based milk with a thicker texture is Califia Farms Toasted Coconut Almond Milk, highlights 0 grams of sugar, 50% more calcium than milk and 45 calories/cup.

<comment><USER10> Coconut fat (milk) works well to bring up the thickness of almond milk. Makes it work significantly better in coffee.

</comment></comment></comment></comment><comment><USER11> Plant based milks have been around for ages and they work great to substitute milk that you drink or put on your cereal or something.

But they aren't going to replace milk that we use in, say, the production of butter, cheese, casein, or lactose products.

I'd be curious to see what a pie chart of the end products from our milk production looks like.

<comment><USER8> For the vast majority of uses, butter can be replaced by vegetable-based shortenings like margarine. There is non-dairy (usually soy-based) cheese, too. Not that either of those tastes remotely as good as the dairy-based versions, but I can imagine it's possible to improve on them with concerted effort.

<comment><USER12> I have never noticed a difference in taste between butter and margarine, and I have eaten both with a spoon after coming home to an otherwise empty fridge. It's just fat.

Or maybe you are just talking about "soy cheese"? I agree that pure tofu is pretty bland, but with various seasonings (I'm partial to Chili oil), it can be quite good.

<comment><USER8> To my palate, butter tends to be a little bit sweeter and less oily than margarine. It tastes lighter and richer.

It's not as obvious as, say, olive oil vs. canola oil, but it is distinguishable. I can imagine giving up butter in favor of margarine... but then I also doubt the half pound I go through per year has a major impact in the big picture.

As for cheese... I do eat tofu sometimes in place of meats, but don't see it as a good substitute for cheese, except for perhaps a very narrow selection of cheese varieties (perhaps paneer).

I've yet to find a soy substitute for a cheddar or brie. What I have had is soy ricotta, which is about 80% of the way to matching the real thing in terms of texture and about 50% there in terms of flavor. I have no doubt it will be done eventually, but we're still a _very_ long way from replacing a cheese lover's dairy consumption with alternatives.

</comment></comment></comment></comment><comment><USER13> First, it's not "milk" only because it's a white liquid. Second, if people are so grossed out by milk, why do they want to drink surrogates of it?! I understand that there are lactose intolerant people, too, but I'm not talking about them if it's unclear. I've seen lactose-free milk at stores recently.

<comment><USER14> > First, it's not "milk" only because it's a white liquid

That's exactly why it's milk actually. Just like coconut milk, which has existed forever, milk of magnesia which has existed since 1875, and soy milk which has been widely consumed since the 1800s.

Oat milk is not milk. But it's milk. English has no problem with that. Pizza pie is not pie. Boot camp is not camp. A house boat is not a boat. We understand each other just fine. You add a word to another word and you get a third word that's unique from both of its parts.

<comment><USER15> Actually the EU recently ruled that "Plant-based foods cannot be sold in the European Union using terms such as milk, butter and cheese". There are some exceptions though. See [http://www.bbc.com/news/business-40274645](http://www.bbc.com/news/business-40274645)

There's a similar push happening in Australia.

BTW, I think pizza is only called 'pizza pie' in the US? And a house boat is definitely a boat if it floats.

<comment><USER16> True about the EU ruling, but legal language is often different than more informal everyday language. Obviously the Court of Justice did not rule that you are forbidden from using the word "milk" when speaking to your friends about soy milk :-)

</comment></comment></comment></comment><comment><USER17> I grew up on a farm and we did this all the time. We just fed the oats to cows. < _ducks_ >

<comment><USER18> You won't get milk from ducks, no matter how many oats you feed them.

<comment><USER19> Now I'm wondering what platypus milk tastes like.

</comment></comment></comment><comment><USER20> My daughter had an intolerance to cow's milk. We were advised to try soya instead, which her tummy also didn't like. Next we tried oat milk (Oatly being one of the brands) and she loved it. Actually, the rest of us tried it too, and liked it so much that we no longer have any cow's milk in the house.

<comment><USER21> I like goat cheese.. never tried goat milk, now I'm curious.

</comment></comment><comment><USER22> The only problem with oat and almond milk is that they're mostly a suspension of cheap vegetable oil in water. Vegetable oils like sunflower oil aren't healthy.

<comment><USER23> Is there a way to measure healthiness of a single ingredient? I didn't find anything allowing me to label stuff as healthy or unhealthy. At least not scientific. I do not even think there's a scientific definition of healthiness of one single ingredient. I guess by your definition (vegetable oils increasing risk of some cardiovascular diseases) makes all meat, animal breast milk, eggs unhealthy.

I thought only diets and lifestyle can be healthy, regardless of what a single ingredient can do.

Also, if it is vegetable oil, how come there's protein in it? I thought oil is just fat? There's 4 grams of protein in 100mL of soy/oat milk (about the same as cow breast milk). Almonds on the other hand are a big scam with only 0.x protein, water with some flavour.

<comment><USER24> Industrially produced seed oils are thought to be unhealthy due to an over- abundance of Omega 6. But some regulatory authorities still cling to the decades-old wisdom that basically boils down to avoiding saturated fat at all costs, so they'll recommend vegetable oils over animal products.

There are definitely healthy fats and unhealthy ones, for example everyone can agree trans fats are in the latter category. The perfect fatty acid profile is a matter for debate but it's definitely possible to isolate bad ingredients by a variety of means (populational studies, etc). It's not easy though, if it were then there wouldn't be so much debate in this space.

<comment><USER5> If you're afraid of consuming too much Omega 6, choose oils with more Omega 3 such as flaxseed and rapeseed. Also:

 _" [We] have known about the harms of fatty acid imbalance, and an excess of omega-6, for a long time. So much so that sunflower oil in the US was 'upgraded' through selective breeding to produce a high-oleic-acid variety (high monounsaturated fatty acid) that now prevails, and AVOIDS the potential harms noted in this paper. The same thing is now being done to soybean oil, and the high monounsaturated fatty acid version of that will soon replace the old variety."_ [https://www.forbes.com/sites/alicegwalton/2016/04/13/the- ani...](https://www.forbes.com/sites/alicegwalton/2016/04/13/the-animal-vs- vegetable-fat-saga-continues/)

</comment></comment></comment></comment><comment><USER25> How is this different from any other oat milk?

<comment><USER16> Surprised by the hype in this thread, I was wondering the same, so I went out and bought some. I've had oat and other grain milks before, and I'm not a fan nor an expert. Also, I didn't do a direct comparison with another oat milk.

That said, I find Oatly less watery and much less sweet than the last oat milk I remember trying. It has a darker greenish-gray color than other plant milks (maybe from the added algae?). It still tastes like oats (though less than others) and not like milk. In a blind tasting, I think I would prefer it to other oat and similar milks because of the more rounded, less earthy and less sweet taste than the others I have had.

Overall, it's better than the competition, but it won't become something I will buy regularly (as opposed to cow's milk).

</comment></comment><comment><USER5> One of their competitors, Planti, uses oats to make a great alternative to vanilla yoghurt called YogOat: [http://planti.se/Vaara-produkter/YogOat- Vanilj](http://planti.se/Vaara-produkter/YogOat-Vanilj)

</comment><comment><USER26> I dont think this will be adopted broadly unless it matches the price of real milk.

Given that oat milk cuts out the middleman (middlecow?), should this not be cheaper anyway, or are there scale effects preventing it from reaching price parity?

<comment><USER27> As far as the middleman, at least cows don't typically charge money for their services.

<comment><USER28> Well, cows do cost money to keep, which is what wohlergehen must be referring to.

</comment></comment></comment><comment><USER8> Does the process use the whole oat? If not, what's done with the solids left over after processing?

<comment><USER16> The French version of their FAQ at [http://www.oatly.com/faq/](http://www.oatly.com/faq/) (but not other language versions, for whatever reason) says that they feed whatever is left to animals. Here is the whole question ran through Google Translate:

What do we do with waste from the manufacture of oat beverages?

We work as much for sustainable consumption of food as for a sustainable production of these products. Regarding the consumption of food, it is indisputable that a sustainable diet for the future contains far fewer animal products than we eat today, there is even a great unanimity on this subject in all sciences of this disciplined. In sustainable food production, we believe that the crops of the future will be much more than they are today, focusing directly on food rather than animal feed.

Any production of food products, even based on vegetable raw materials, also generates waste. It is not always possible to use the entire raw material in the final product. In the case of oat beverages, we remove some of the insoluble fiber which results in a loss of nutrients, which are extracted with the insoluble fraction. Efforts to achieve sustainable food production are largely based on sobriety in the use of resources. Regarding waste, we believe that their most sustainable management is to exploit the remaining food and energy in the form of food by making them the ingredients of animal fodder that are still high. All this to benefit from the food produced. In the next step, when all the food has been used as fodder, the final waste is biogas.

</comment></comment><comment><USER29> is café con horchata a big thing in the US? I don't remember seeing it on my travels.

It's not widely known in Australia (to us Anglos) but a Mexican friend supplied me with some and it tasted better than the almond or soy substitutes I've had!

<comment><USER30> I googled horchata and apparently it is any milk made from nuts of cereal. Including almonds.

<comment><USER31> Horchata varies by region. The one I'm familiar with, from Spain, is based on tigernuts. It's a very traditional summer drink and frankly you won't find a different kind of horchata in Spain, unless you search for it in ethnic stores (and even so I'm not sure where I would look for it). Apparently horchata in Mexico is based on rice, and I don't know if there aren't any other versions. I haven't tried rice based horchata, but it soudns very different from the Spanish one, and I'd like to try it some day.

I don't know about how has the term evolved in the English speaking word, but _no one_ in Spain will refer to horchata as milk, nor do we use it as a milk replacement (nobody would mix it with coffee, for example). Also we don't use the term as a generic word for vegetal milk at all. Milk and horchata don't really have anything in common aside from being white drinkable liquids.

</comment></comment></comment><comment> cirrus-clouds I drink milk, but we (as in "we in the Western World"), could all do with drinking less of it.

You would be surprised by how many people are unaware of how milk is produced. Only a pregnant female cow can produce milk [Edit: as BenjiWiebe correctly states below, cows lactate after they give birth). So a female dairy cow will spend most of her adult life in a pregnant state. Once she gives birth, she is separated from her calf usually within a few hours (sometimes she'll be together with her offspring for 24 hours, but never more than that).

Then she'll be artificially inseminated again (normally within 3 months of giving birth) so she can start producing milk again. And so the cycle repeats.

The reason milk is so cheap (at least in Europe) is because we aren't prepared to pay for higher welfare conditions. We say we care for farm welfare, but our behaviour shows otherwise. Maybe we care a little bit, but we care even more for cheap prices. (And yes, I confess I am as guilty as the rest of us).

In many European countries, increasing numbers of dairy cows spend their entire lives indoors ("zero grazing"). For example, Germany is the EU's largest milk producer and the majority of dairy cows spend their entire lives indoors with no access to outdoor pasture. This is perfectly legal under EU regulations.

<comment><USER27> Um, the first part of your comment is a common misunderstanding. Female cows produce milk only _after_ they've had a calf. Not _during_. And they continue producing milk generally for as long as you milk them. Their production does go down over time, but they can be milked for a year after one calf, sometimes two years. Production does go down when they are pregnant, though. :) Source: 20 years on a dairy

<comment><USER32> Also, typically, only the milk after the second calf is used. Milk obtained between first and second calf contains proteins that are unsuitable for human consumption.

</comment></comment></comment><comment><USER33> These types of drinks have _nothing_ in common with milk...

The manufacturing process involves grinding almonds, oats, etc, into a very fine particulate powder, mixing it into water.

Then adding in all things necessary to keep it in suspension, and making it drinkable (try "almond milk" without the sugar and see how long it takes you to regurgitate it back out).

Almond-milk wasn't even selling until they placed it into the refrigerated section of the store next to real milk - to confuse the buyers with what it actually was-not.

It is likely that most consumers think the manufacturers press or squeeze the almonds to get at its "milk", and have no idea they are just drinking a few grams of powdered almonds.

<comment><USER34> I don't think anyone confuses nut milk for cow milk in stores. It's usually more expensive than cow milk and clearly labeled with the specific main ingredient. I don't think these companies are trying to deceive anyone. There's a relatively small subset of consumers, who are interested in milk substitutes, so it's a niche product that serves them well. And cow milk contains sugars too, lactose, which is a disaccharide of galactose and glucose. Finally, the thought that they would squeeze almonds to get milk also never even crossed my mind. I know it's a suspension of powdered almonds in water. There's even recipes of DIY nut milk, that are essentially "grind almonds, add water, stir". So your whole argument seems just ridiculous to me.</comment></comment>


Traffic spikes - The Hacker News Effect - <AUTHOR> http://alexblom.com/blog/2010/04/the-hacker-news-effect/

<comment><USER2> It would be interesting to see the absolute numbers i.e. how many unique visitors have come to your blog entry from HN's front page.

<comment><USER3> Generally one of my articles that end up at the top of HN gets about 5000 hits, most in the first 2-3 hours.

A lesser article gets, well, less hits... 1, 2, 3k, depending.

Here's a screenshot:

[http://skitch.com/swombat/n9mrs/danieltenner.com- dashboard-c...](http://skitch.com/swombat/n9mrs/danieltenner.com-dashboard- clicky)

You can probably correlate those with article dates on my blog and find out how many votes translate to what level of traffic.

Edit: I wouldn't give so much weight to the HN RSS feed. Google Reader is by far the largest subscriber to my feed, and hits from there register as hits from google.com, not hits from news.ycombinator.com.

As you can easily see here: [http://skitch.com/swombat/n9mfb/danieltenner.com- dashboard-c...](http://skitch.com/swombat/n9mfb/danieltenner.com-dashboard- clicky) the Google reader hits are a very small minority. Most people read HN on HN, not on the RSS feed. I guess the author uses the RSS feed and so gives it a disproportionate weight.

<comment><AUTHOR> Hi. I'll try to clean my language from the site up a little. I do use the RSS feed for the stories however most hits came direct from the website.

<comment><AUTHOR> And corrected. I mis-titled the picture.

</comment></comment></comment></comment><comment><USER4> I've had a few things from my sites hit the top of HN. In fact, that's how I _found_ HN (so, big thanks to those who've submitted my stuff on helping me find this awesome community)

Still, I get an order of magnitude more traffic from a good day on StumbleUpon than from hitting the top of the page here at HN.

</comment><comment><USER5> FYI, it's "moral" not "morale."

<comment><AUTHOR> Thanks. Did not pick it up in my proof - typo corrected.

<comment><USER6> If you're using WordPress, consider using After the Deadline. It doesn't detect moral vs. morale today, but I'll make sure it does next time I deploy an update. It'll find a lot of other typos for you though.</comment></comment></comment>


Show HN: jobs board for online careers - <AUTHOR> http://digitalcareersearch.com/

<comment><USER2> nice and simple design.

but now starts the hard part that makes any online job portal make or break; listing X% out of all the jobs out there, and making prospective people aware of it

<comment><AUTHOR> Thanks, you're right that will be the hard part. Luckily there is a strong tech community where I'm from (Brighton UK) so hopefully that will be a good stepping stone!

<comment><USER2> good luck from my side then :)

<comment><AUTHOR> Thanks!</comment></comment></comment></comment>


Linux 3.4+: arbitrary write with CONFIG_X86_X32 (CVE-2014-0038) - <AUTHOR> http://seclists.org/oss-sec/2014/q1/187 <comment><USER2> This might be useful context:

[http://en.wikipedia.org/wiki/X32_ABI](http://en.wikipedia.org/wiki/X32_ABI)

 _an application binary interface project for Linux that allows programs to take advantage of the benefits of x86-64 (larger number of CPU registers, better floating-point performance, ... ) while using 32-bit pointers and thus avoiding the overhead of 64-bit pointers_

<comment><USER3> So in other words, it's a 32-bit address space in 64-bit mode? I thought that wasn't possible with x86-64... in fact the biggest mistake I think with x86-64, after some(admittedly not much) reading of the manuals is that it wasn't like the 16/32-bit where you could independently choose the default operand and address sizes, and use 32-bit addresses or registers in 16-bit mode and vice-versa.

<comment><USER4> Not sure what you were reading, but to the best of my knowledge, long mode retains almost all of the 32-bit instructions, only a relative handful were ripped out.

Code running in 32-bit protected mode can't access 64-bit instructions or registers, of course, but that's a different issue. x32 is basically just long mode code that limits itself to instructions that use 32-bit addresses.

<comment><USER5> You can jump between 32-bit and 64-bit modes in a 64-bit Windows and Linux by switching between the 0x23 and 0x33 code segments. Like so:

        BITS 32
        start:
            call far 0x33:code64
        code32:
            nop ; resume
        code64:
        BITS 64
            xor rax, rax
        BITS 32
            retf ; return to 0x23:code32

<comment><USER6> That's interesting that the CS values are the same in windows and linux, more than a coincidence... Is this part of some x86_64 ABI spec?

<comment><USER5> After checking the docs, it seems the fast syscall instructions force the GDT to be laid out in a specific order. Since the segment values (selectors) are really offsets into the GDT, it makes sense that they end up being the same.

</comment></comment></comment></comment></comment></comment><comment><USER7>
        -       if (get_compat_timespec(&ktspec, timeout))
        +       if (compat_get_timespec(&ktspec, timeout))
                        return -EFAULT;

Sigh

</comment><comment><USER8> On the plus side, hardly anybody uses x32 ABI.

<comment><AUTHOR> Unfortunately, it looks like Ubuntu just recently enabled it in their kernels:

[https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1274754](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1274754)

<comment><USER9> How do you get an x32 Ubuntu? I couldn't find it on the regular download page. I'm not surprised since it _is_ a rather obscure configuration.

<comment><AUTHOR> I don't run Ubuntu myself, but CONFIG_X86_X32 isn't a new architecture, it's an option for 64 bit kernels. Based on the state of that bug report, it looks like it's an option they've enabled in their recent 64 bit kernels (Quantal+)

<comment><USER10> You need a completely different userland, compiled for x32 instead of amd64. Just running the default amd64 installation with a x32 kernel doesn't make it x32. EDIT: It would also work for just running x32 apps on an amd64 system, but then you only get the x32 benefits for those applications.

<comment><USER11> You don't need a whole x32 userland in order to be exploited. Just a single x32 binary executable that happens to not depend on on any external libraries.

<comment><USER12> You don't even need that. This can be done within a 64bit process using the x32 syscall number for recvmmsg.

-Brad

<comment><USER11> Ouch.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER13> While we sometimes get laughed at for not running the latest and greatest, I am (once again) quite glad that I'm running RHEL 5 and 6 and their 2.6.18 and 2.6.32 kernels.

<comment><USER14> Those are patched against the myriad of bugs and vulnerabilities from _the last 8 years_... haha?

<comment><USER15> As long as he's upgrading, yes they are, Red Hat fully supports those kernels.

</comment></comment></comment><comment><USER16> At the bottom there are two lines that taken together really confuse me:

        <grsecurity> If you're running Linux 3.4 or newer and enabled CONFIG_X86_X32 , you need to disable it or update
        immediately; upstream vuln CVE-2014-0038

and

        <grsecurity> In case there's confusion, this vuln is not about 32bit userland on 64bit (CONFIG_X86_32), but the new X32
        ABI.  Ubuntu enables it recently

Does the second line affect the first? EDIT: I ask because it looks like I need to fix my kernel, but I'd rather be lazy if possible.

<comment><USER17> CONFIG_X86_X32 and CONFIG_X86_32 are different.

The first one, with the second X, enables the new X32 ABI. The second one, without the second X, is the "32bit userland on 64bit".

</comment></comment><comment><AUTHOR> Has anyone seen talk of this leading to an expedited 3.13.2/3.12.10 release? If I need to manually patch my kernels to fix this, I'll do it, but if upstream is going to release fixed versions shortly, that seems like the preferable solution.

So far though, I haven't seen anything about merging in the patch provided by PaX.

<comment><USER4> Are you actually using x32? I doubt most people are. It didn't even exist in a stable kernel until April 2012.

<comment><AUTHOR> I am not actively using it, but I am running kernels that have CONFIG_X86_X32 enabled.

<comment><USER4> Yeah, I just saw that Ubuntu at least already enabled it quite a while ago. Ouch.

<comment><AUTHOR> I don't suppose there's some way to disable x32 from within a running system that's not using it?

edit: It doesn't appear there is. Not shocking, but I was hoping for a bit of luck.

<comment><USER4> As far as I know, no. I'm about 90% sure you have to rebuild the kernel to disable it. That said, I've only read about it, not played with it, and I don't have a box with it enabled at my fingertips.

That said, this is a local exploit, so unless you have untrusted users or otherwise run untrusted native code, your risk is pretty low. Someone would have to exploit something else first to get access to run custom code on the box.

</comment></comment></comment></comment></comment></comment><comment><USER18> Am I the only one shocked by the lack of comments in the code? It's literally a wall of code.

<comment><USER2> How familiar are you with largish C codebases?

At this level, you're dealing with an API at the calling end (you should be fairly intimately familiar with the semantics without much reference to the docs if you're working on the implementation) and the functions being calling are almost readable as English.

Code should strive to be written such that it doesn't need comments unless it's being clever - and it should avoid being clever if possible.

Also, I'm not sure where you saw a "wall of code". I don't see any walls of code, not in the commit diff, nor in the smaller diff in the email. A wall of code, for me, would have to be long (say, 70+ lines - but it depends on the language) and dense (e.g. boolean expressions complex enough to need parentheses to clarify precedence).

<comment><USER19> I'm reading Clean Code (again). I dont see that code as being particularly bad. But it definitely wouldnt follow the axioms in that highly regarded book. I realize it isnt java but can someone familiar with the text comment on the number of parameters in that function and the naming of some of those variables?

Relevant quote: "The ideal number of arguments for a function is zero (niladic). Next comes one (monadic), followed closely by two (dyadic). Three arguments (triadic) should be avoided where possible. More than three (polyadic) requires very special justification—and then shouldn't be used anyway."

<comment><USER20> I find the idea that the ideal function takes no arguments to be astonishing. There are only two kinds of functions that take no arguments:

1\. Those that return the same result every time.

2\. Those that mutate some internal state (or, roughly equivalently, those that inspect internal state being mutated elsewhere).

#1 isn't all that useful in general, although there are obviously cases where it's exactly what you want. For #2, while state is useful at times and a necessary evil in many other cases, it's hardly ideal.

Even a single parameter seems decidedly un-ideal. To do useful work in general, you're typically going to want to take two parameters: something to be modified, and the modification to make. This can be done with state (modify in place) or functionally (return a new object with the modifications applied). Once again, having a single argument seems to imply either something not very useful (basically a getter or some similar derive-a-value function) or something relying on mutable state. You need two arguments to achieve the sort of combinatorial power that makes functions interesting and properly useful.

<comment><USER21> I wonder if the book, which I assume is talking about Java, is ignoring the implicit zeroth argument which is the object you're invoking the function on. Obviously in C you have to make that parameter explicit, but I've got enough experience of both languages to know that people often don't consider the object to be a parameter to one of its member functions.

So if you're converting that rule back to C, you'd need to add one to each element of the rule. The one parameter rule is saying that when special cases are common, a special function to handle it is a good thing. So writing `i++` rather than `i = i + 1` or `next(node)` rather than `skip(node,1)`.

<comment><USER20> That would make sense, except for the part where Java doesn't have functions at all, but rather methods. I imagine you could call them functions, but I haven't seen it done, and that sort of terminology sloppiness leads exactly to confusion like this.

<comment><USER19> Thanks for the responses. The text is definitely referring to Java methods as functions, and not counting the implicit object instance (this) as a parameter. The text also considers multiple parameters of the same type that are treated identically as lists counting as one parameter.

<comment><USER20> Appreciate the clarification. The advice sounds much more sane that way. It sounds like a terribly confusing way to put it, but maybe it's better in context.</comment></comment></comment></comment></comment></comment></comment></comment>