How we made compiler warnings fatal in Firefox - <AUTHOR> https://blog.mozilla.org/nnethercote/2017/07/05/how-we-made-compiler-warnings-fatal-in-firefox/ <comment><USER2> I remember my first programming job straight out of school, where a full clean build of our project emitted 10K+ warnings, and I thought to myself, "Is this really how professional programming is?" Asked a co-worker why on Earth we don't fix them, as there may be serious bugs hiding in there, and the response was "We're too busy fixing bugs!"

<comment><USER3> Related:

"We're going to rush through implementation so that we have lots of time left at the end to fix all the bugs caused by rushing through implementation."

<comment><USER4> Also we will never actually do that last part.

<comment><USER5> But I get to look high-minded by participating in the hand-wringing about the problem without actually moving a muscle to improve the situation.

<comment><USER4> The last refuge of the scoundrel!

</comment></comment></comment></comment></comment><comment><USER6> > Congratulations! You now have fatal warnings on everywhere that is > practical.

I think that last bit is the most important one. You need to be practical about stuff like this.

Putting a ban-hammer down like a CI-nazi is most likely not going to get you the results you were hoping for.

Edit: Looking at the linked issue [1], this has taken _quite_ some time. First comment on that issue is 15 years old :D

[1] [https://bugzilla.mozilla.org/show_bug.cgi?id=187528](https://bugzilla.mozilla.org/show_bug.cgi?id=187528))

<comment><USER7> I think that linked bugzilla issue is amazing, slow patient work over years to fix issues. We should really celebrate this sort of effort more in our industry.

<comment><USER8> Move slow and fix things?

<comment><USER9> Pun intended? ;-)

</comment></comment></comment></comment><comment><USER10> One big reason to make compiler warnings fatal (not mentioned here, as far as I can see) is the fact that otherwise, unless you do a full rebuild, you won't see warnings for any source files that don't need to be rebuilt.

<comment><USER11> That's always something where I think current build systems are failing.

<comment><USER12> Perhaps not build systems, but I think editors that help you keep track of warnings should probably have a list of them per-file and only clear that list when the file actually gets rebuilt

<comment><USER11> I don't know, I'd rather have that functionality in the build system. The editor should just parse the build system's output and keep the stuff it does to a minimum.

</comment></comment></comment></comment><comment><USER13> How do you deal with thirdparty includes, particularly with big header-only libraries? You basically have to change compiler flags on the fly, and AFAIK it isn't well supported. My colleagues have dealt with this by defining some ugly macros which enable/disable hardcoded warnings, and there are lots of them.

<comment><USER14> I've had good success including not-my-code with the appropriate compiler flag. This tells the compiler that I'm not interested in warnings in those files since I'm not going to change them.

[https://gcc.gnu.org/onlinedocs/cpp/System- Headers.html](https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html)

<comment><USER15> How does this work with templates? If a type you pass into such a library causes a warning in that library, is that your fault or the library's? How could the compiler possibly tell? It seems like this can't even work in principle if there are templates involved.

<comment><USER14> The warnings I've had issues with were warnings regardless of whether the code was templates: ignored return values, unused parameters, etc.

There may be cases where the potential false negatives are unacceptable. Be judicious, but in my case the benefits far outweighed the risks.

Of course, it's a great idea to provide upstream patches and issues whenever possible.

</comment></comment></comment></comment><comment><USER16> The hardest part about where you are and where you want to be is the getting there from here.

This is some good practical advice (and a welcome improvement) from Mozilla.

I'm also reminded of an email I sent out to a technical mailing list some time back, in response to a user's question about suppressing warning messages when running his program (this for a runtime-based interpreter).

Various suggestions came for how to limit, suppress, or remove warnings from the log.

My response, which apparently earned some favourable consideration at the vendor:

"Fix the bugs in your code."

</comment><comment><USER17> I'm surprised it took them this long. I've used ``-Wall -Werror`` on all my code for decades. If you use it from the start it's easy to maintain and catches a lot of potential bugs. There are the occasional false positives and warnings coming from 3rd party headers. For these I add warning specific suppressions.

<comment><USER18> Did you build on many different platforms using multiple compilers with various degrees of standards support, just as Mozilla does? That makes it harder (for starters: how do you suppress warnings in a portable way?)

<comment><USER19> It would be nifty to supress warnings on a per include directory level by passing flags directly to the compiler. This is how static analysis tools like PVS avoid flooding us with errors.

<comment><USER18> That's what Mozilla does, too, reading the article.

However, that's not what the grandparent wrote: _" For these I add warning specific suppressions"_. I read that as disabling single warnings, not a compilation unit at a time.

For example, in Visual Studio, you can do ([https://msdn.microsoft.com/en- us/library/2c8f766e.aspx](https://msdn.microsoft.com/en- us/library/2c8f766e.aspx)):

       #pragma warning(push)
       #pragma warning(disable: 1234)
       ...
       #pragma warning(pop)

Intel's compiler is compatible with this ([https://software.intel.com/en- us/cpp-compiler-18.0-developer...](https://software.intel.com/en-us/cpp- compiler-18.0-developer-guide-and-reference-pragmas)), but it would surprise me if it used the same warning numbers.

GCC and clang, on the other hand, need ([https://gcc.gnu.org/onlinedocs/gcc/Diagnostic- Pragmas.html#D...](https://gcc.gnu.org/onlinedocs/gcc/Diagnostic- Pragmas.html#Diagnostic-Pragmas), [https://clang.llvm.org/docs/UsersManual.html#controlling- dia...](https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics- via-pragmas)):

       #pragma GCC diagnostic push
       #pragma GCC diagnostic ignored "-W..."
       ...
       #pragma GCC diagnostic pop

Because you ideally only want to target the exact place that triggers a warning, either is fairly wordy, and it gets worse if you want to cater for all three compilers.

It also wouldn't surprise me if Mozilla supported multiple versions of gcc (for instance because they want to build for an OS with long-term support, or for an obscure OS for which the latest gcc is not (yet) available).

(_If_ you use C99, at least with gcc and clang, you can simplify that by using __Pragma_ , which has the big advantage that you can use it in preprocessor macros, so that you may be able to simplify what things look like in the source)

<comment><USER19> >> ideally only want to target the exact place that triggers a warning

On the other hand, its typically some library that is messing up the static analysis tool.

While the #pragama options are good for disabling warnings in typical projects, from personal experience they are broken in NVCC.

</comment></comment></comment></comment></comment><comment><USER20> We did the same for the linter in our JavaScript project. Of course, the linter config is focused mostly on pitfalls and "good parts", not on code style (except for the most annoying code style issues).

<comment><USER21> Can't most of these code-style issues be auto-formatted on save these days?

Years ago when I still programmed in Go I made use of that all the time: if it didn't format on save I knew I had a compiler error somewhere.

<comment><USER22> kozak is specifically saying their linter is mostly focused on any _non- codestyle_ issue.

And compiler errors are not worth linting given you can just do a syntax check, linting is useful to avoid or require disambiguation of error-prone constructs.

Examples in JS would be `with`, `==`, assignments inside a conditional check, parseInt without a base (mostly in older browser), parseFloat, non-prefixed octal literals (073 rather than the explicit hex-style 0o73), string expression statements (outside of the "use strict" pseudo-pragma), and several scoping errors (which strict mode will mostly only check at runtime). All of these are syntactically perfectly valid, but more often than not they're also mistakes or sources of errors.

<comment><USER23> _assignments inside a conditional check_

I see this in C code often. Why do people seem to like doing this?

<comment><USER22> As demonstrated by other commenters, makes for a terse iterator-ish pattern in languages without iterators (like C, or until recently Javascript) e.g.

        while ((c = getchar()) != EOF) {
         //
        }

in a language with iterators would be

        for (c in chars()) {
         //
        }

<comment><USER22> And note that this C pattern only works when you can pass the "end of iteration" signal in-band, if you can't you will need to use more complex pseudo-iteration protocols e.g.

        while(generator(&c)) {
            //
        }

</comment></comment></comment></comment></comment></comment><comment><USER24> I remember compiling and working with Firefox code many years ago, one thing that surprised me were non-fatal assertion errors continuously printing errors to console in debug build. It looked like Netscape legacy, I wonder if they managed to clean this.

<comment><USER25> Firefox ESR 52.2.0 on Debian still prints a whole bunch of assertion errors if you run it in a terminal:

        (firefox-esr:345): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed

<comment><USER26> I've never seen any Gtk application that does not spew messages like this at least occasionally.

<comment><USER27> I've noticed this as well in all the Gtk apps that I've run through the terminal.

Never having programmed in Gtk, what is the cause of this? Is Gtk broken or are all the programmers using it incorrectly? I've programmed a great deal in WinAPI and stuff like that never happens.

<comment><USER28> No one knows how to use GTK correctly, not even the GTK developers. At least that was the situation in 2014 when subsurface moved from GTK to Qt, [https://www.youtube.com/watch?v=ON0A1dsQOV0](https://www.youtube.com/watch?v=ON0A1dsQOV0).

<comment><USER29> I think this is very common.

There's a bunch of boilerplate code that just gets carried from project to project.

My favourite was when KDE decided to move to cmake. People realized that most m4/autoconf macros were there for no reason and no one actually knew what they checked for let alone how.

<comment><USER30> You might like this essay:

[http://queue.acm.org/detail.cfm?id=2349257](http://queue.acm.org/detail.cfm?id=2349257)

<comment><USER29> > Sam Leffler's graphics/libtiff is one of the 122 packages on the road to > www/firefox, yet the resulting Firefox browser does not render TIFF images

Don't even get me started on the circular dependencies that need to be broken by installing packages with some options disabled. Kind of an awkward bootstrap.

<comment><USER31> I added CMake support to libtiff last year. Haven't checked if the ports tree uses it yet.

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER32> Have done something similar, and it works, but ...

... the downside is that every time someone uses a different version of your normal compiler, or a different compiler, you have an unfortunately large chance of having the build fail because a new bit of code that previously was warning free is now determined to be warning-worthy.

Not a huge problem (and better than cultivating the habit of ignoring warnings), but it is a time cost that has to be paid now and again for committing to halting the build on a static analysis failure.

<comment><USER33> From the blog post:

"Set things up so that fatal warnings are off by default, but enabled on continuous integration (CI). This means the primary coverage is via CI. You don't want fatal warnings on by default because it causes problems for developers who use non-standard compilers (e.g. pre-release versions with new warning classes). Developers using the same compilers as CI can turn it on locally if they want without problem."

</comment></comment><comment><USER34> The problem with my work project is that most of the warnings are from third party libraries (Cocoapods since it's an iOS project). Most of them from Jainrain, which has publicly said they don't care.

<comment><USER35> If you're copy-and-pasting source code into your project, you can ignore all warnings on a per-file basis (See [https://stackoverflow.com/a/6921972/1176156](https://stackoverflow.com/a/6921972/1176156)).

And if you're using a package manager like Cocoapods, it shouldn't be a problem.

Edit: Wait I just re-read your post again and you are using Cocoapods. Can you not just turn on "treat warnings as errors" to YES for your main project, but leave it off for your main project? Or just add `inhibit_all_warnings!` to the top of your Podfile, like on this example file: [https://guides.cocoapods.org/syntax/podfile.html](https://guides.cocoapods.org/syntax/podfile.html)

<comment><USER2> Yea, I've had success with the following procedure:

1\. Determine the set of warnings you're going to enable for you project, and apply them to your own code and all third-party libraries.

2\. For each third party dependency, find the minimal set of warnings that, when suppressed, make them compile cleanly, and disable just those (only for that specific third party project).

3\. If any of those suppressions makes you uncomfortable, submit a patch to the third party maintainer if possible :)

As for #3 with open source libraries, I've seen the spectrum of attitudes from "thank you very much for the patch!" to "we don't care about compiler warnings, just turn them off"

EDIT: One thing this doesn't address is third party dependencies where #including their headers from your project results in warnings. If you're a developer who writes header files that produce warnings, please take a moment to hang your head in shame.

<comment><USER34> Thanks.

</comment></comment></comment></comment><comment><USER36> I wonder how much harder this approach will make compiler updates for them.

<comment><USER37> They specifically chose warnings one by one(e.g -Wunused-but-set-variable) instead of by groups (-Wall) to avoid that being an issue.

<comment><USER38> That helps, but is not bullet proof. Changes to optimization passes can cause warnings to be emitted in cases where they weren't previously. For example, detection of an unused result of an expression.

<comment><USER39> I can't really think of any case where this is possible. Warnings are produced (only?) before the serious optimisation passes. Have you got an example where unused result warning changes between optimisation levels?

<comment><USER40> These are, or used to be, quite common with gcc. Unused-result warnings require dataflow analysis to run to determine whether the values are used, and on no-optimisation compiles gcc didn't bother to do dataflow analysis.

Conversely, here's one where a warning is produced only without -O2:

      orth$ cat z.c
      int foo (int a) {
         int x;
         if (a == 5) { x = 3; return 42; }
         return x;
      }
      orth$ gcc -O2 -Wall -o z.o -c z.c
      orth$ gcc  -Wall -o z.o -c z.c
      z.c: In function 'foo':
      z.c:4:4: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
          return x;
          ^
      orth$ gcc --version
      gcc (Debian 4.9.2-10) 4.9.2

</comment></comment></comment></comment></comment><comment><USER41> Since I've been programming in the Go language for a few months now I've really often compared the compiler's strictness with the C/C++ compiler's default laxity. The Go compiler won't even let you leave in an unused import, and there are a number of other things that in C would maybe generate a warning that won't compile in Go.

<comment><USER42> I absolutely hate that you can't have unused variables in Go, or that you can't have unreachable code in Go or Java. It makes the already tiresome work of debugging significantly more frustrating.

<comment><USER41> Why? What's useful about unused variables or unreachable code?

<comment><USER42> It's not useful in shipped code, and absolutely should be a warning, but it's incredibly useful while creating the program or debugging.

</comment></comment></comment></comment><comment> Ono-Sendai How is ALLOW_COMPILER_WARNINGS implemented?

<comment><USER33> Firefox has a custom build system, and it's implemented within that. So it's not something that will translate to another project, alas.

</comment></comment><comment><USER43> #pragma warning( disable : xxxxx )

</comment><comment><USER44> > _Also, before upgrading the compilers on CI you need to fix any new > warnings. But this isn't a bad thing._

It's, in fact, downright stupid and means you're writing in a different programming language with each compiler upgrade and at the mercy of some poorly-considered third-party opinions.

Many compiler warnings are just stylistic. They can even contradict each other. Compiler A says, "suggest parentheses here". Oops, compiler B doesn't like it: "superfluous parentheses in line 42".

As a rule of thumb, warnings that aren't finding bugs aren't worth a damn.

The proper engineering approach is to evaluate newly available warnings and try them. Keep any that are uncovering real problems, or could prevent future ones; enable those and not any others.

Warnings are just tools. You pick the tools and control them, not the other way around.

Every code change carries risk!

<comment><USER45> I don't know what languages you are thinking but firefox is mostly C and C++.

There are no superfluous parenthesis warnings in GCC and MSVC.

<comment><USER46> Uhh, perhaps I'm not parsing your claim correctly, but that warning most certainly does exist in gcc.

      $ gcc -Wall test.c
      test.c: In function 'main':
      test.c:6:5: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
          if (a = b) {
          ^

Parentheses here would be superfluous, but would perhaps confirm you really intended to assign (i.e. used = instead of ==).

<comment><USER45> You realize that you have an assignment instead of a comparison?

The warning here couldn't be more justified. In a decent language, this should be a hard error.</comment></comment></comment></comment>


Henry Ford, Innovation, and That "Faster Horse" Quote - <AUTHOR> http://blogs.hbr.org/cs/2011/08/henry_ford_never_said_the_fast.html <comment><USER2> The article goes on to point out how Ford successfully disrupted the market but then lost a lot of market share later by sticking too closely to his original plan.</comment>


Writing a Compiler by Proving It Correct - <AUTHOR> http://liamoc.net/posts/2015-08-23-verified-compiler.html <comment><USER2> Interesting work. I don't remember who said that "formal verification is the way of the future... and it's going to stay that way!"

Quite strange that the article doesn't mention CompCert though, which has an extensive bibliography:

[http://compcert.inria.fr/publi.html](http://compcert.inria.fr/publi.html)

Edit: The person I quote is a researcher in formal verification, I think it's Gérard Huet from Inria.

<comment><USER3>
       CompCert

There's now a lot of work in this space, e.g. [http://sf.snu.ac.kr/sepcompcert](http://sf.snu.ac.kr/sepcompcert)

       and it's going to stay that way!

Whoever said this has been proven wrong. This stuff works, it's just expensive. The only real question is: when will formal verification be convenient enough to be widely used in industry. I reckon that's 15-20 years away. Right now organisations like Facebook ([http://fbinfer.com](http://fbinfer.com)) and Microsoft ([https://www.fstar- lang.org](https://www.fstar-lang.org)) use it, but sparingly.

<comment><USER4> Facebook's Infer is just an ordinary static analysis tool, albeit one inspired by separation logic. It is unsound and does not prove that code is correct.

<comment><USER3> I agree, FB Infer is not a certifying compiler, but it's based on program logic.

</comment></comment></comment></comment><comment><USER5> It looks like this compiler never actually reports any errors. (It uses the Maybe type, so you just get nothing.)

I appreciate that it's a toy compiler, but I really wish people wouldn't leave that out. The quality of a compiler's user interface almost entirely depends on its error messages, so it's important to demonstrate how that's done.

<comment><USER6> Replace `find [] s = nothing` with `find [] s = left ("variable " ++ s ++ " not defined")`

(assuming types/functions similar to Haskell, I don't actually know Agda)

</comment></comment><comment> nv-vn This got me thinking, how feasible would an implementation of APL be as a DSL embedded inside of Agda (or some other similar language)?

</comment><comment><USER7> And there's not one mention of the word 'optimization'.</comment>


Ask HN: Tips for creating good questions in surveys for market research - <AUTHOR> <comment><USER2> You may benefit from reading [https://medium.com/mule-design/on- surveys-5a73dda5e9a0](https://medium.com/mule-design/on-surveys-5a73dda5e9a0) (she also wrote a book: [https://abookapart.com/products/just-enough- research](https://abookapart.com/products/just-enough-research))</comment>


Scaler Academy Review by Swapnil Mahajan - <AUTHOR> https://dev.to/scaleracademy/scaler-academy-review-how-scaler-academy-helped-me-grab-my-dream-job-at-google-2d0j <comment><AUTHOR> Read our Scaler Swapnil Mahajan's complete journey in his own words, where he shares how he began his preparation from scratch, motivation amongst failures during the journey, secrets to his not-giving up attitude, the contribution of Scaler Academy to grab his dream job at Google and most importantly, his advice for individuals who want to aim higher in life.</comment>


Ask HN: How do I go about PHP? - <AUTHOR> Hey hackers,
I've a background in C#, Java and JavaScript but don't know a thing about PHP. Couple of questions
a) How do you recommend I should go about learning PHP? b) Any recommended Editors (I've to use Windows)? c) I spent sometime looking for frameworks and CodeIgniter seems promising. Your thoughts?
Any other tips, books, libraries, frameworks and goodies you would recommend? Any help is highly appreciated. <comment><USER2> As a long-time PHP veteran still in the practice:

\- Recommend Editor: "Eclipse PDT" [1] probably has the best tools relating to PHP development, although I just use Vim for all of my PHP work.

\- Bookmark the PHP online manual [2], and add their search plugin to Firefox, so you can look up standard library functions just by typing it into the search bar.

\- The Zend Framework [3], more of a great library than a traditional framework, is probably the best resource for any projects your may be starting from scratch, although CodeIgniter is definitely a top contender.

Probably the best way to learn PHP itself is to read the (rather well-done) PHP manual, which includes everything from an introduction to the language, it's parsing and syntax trees, all the way up to how its object model works, and complete references for the entire function library, and all standard modules.

Read some source code from the wild. I suggest Mediawiki and Drupal.

Key points to make sure you understand:

\- Arrays are the archetypal datatype in PHP, and can be used as lists, dictionaries, or a mix of the two.

\- You can do just about anything just by using the standard function library. _Frameworks are not necessary, contrary to popular belief._

\- Objects are a mishmash of arrays, structures, and standard C++/Java objects. You can add class variables, functions, and such at runtime.

\- You can do a lot of "fancy" meta-programming in PHP; you just have to know how to accomplish what you want. The PHP library helps out a lot with this.

\- Everything is a template. It may be a bit more verbose than compiled templating dialects, but PHP itself is a really handy templating system in it's own right, just using <?php and ?> tags.

[1] <http://www.eclipse.org/pdt/>

[2] <http://www.php.net/manual/en/>

[3] <http://framework.zend.com/>

<comment><USER3> "- You can do just about anything just by using the standard function library. Frameworks are not necessary, contrary to popular belief."

Up vote for that bullet, specifically for PHP.

</comment></comment><comment><USER4> I worked with Java for four years, slowly moving to PHP as version 4 came about. Why? Rising demand.

As with any programming language, the best way to get started (in my opinion) is just to build something. A blog, a guestbook: something functional and useful. In the process you'll become familiar with the language fundamentals. I recommend that you at first build something using no framework (to get an idea of what sort of security measures you need to take, handling DB transactions, etc) and then followup with the framework of your choice.

I used vim/Eclipse for Java, and still use the same for PHP. There is an Eclipse build specifically for PHP, called "Eclipse PDT." There are several others out there (Komodo, Zend Studio) but PDT is free and therefore easier to try out.

I use CakePHP as a framework and find it to meet most of my needs. I have also tried symphony and the Zend framework, but neither of them were flexible enough for me. I have not tried CodeIgniter, but I have heard good things about it. There are some articles on IBM DeveloperWorks that are a good introduction to CakePHP.

<comment><USER5> I've been told that JavaServer Pages is greater than any framework out there that PHP has mustered up, I'm wondering if you've ever given this a whirl and how it compares? I don't have a enough experience in Java, which is why I wonder.

<comment><USER6> I've used both, and while I'm no fan of PHP I think it's absurd to even compare the two. Quite simply, JSP is an exercise in masochism. These days JSPs are only used for the view layer and most of the work is done in a servlet or a controller in whatever framework you're using so they really serve as little more than a templating tool.

Even when used that way they are a royal PITA because of the bean conventions and the fact that many of the classes in the Java API (Collections _cough_ ) don't adhere to them. Unless you use a scriptlet you can't directly call a method on an object. You reference properties like myObject.prop1 and in the background it would call the method getProp1(). This convention only works with get _, set_ and is* methods. If you want to get the size of a list (List.size()) you're SOL since lists don't adhere to the bean naming conventions. You either have to write a wrapper class or use a scriptlet. It's some kind of cruel joke.

PHP isn't pretty, but it's got a huge library of functions, it's easy to get it running and it doesn't enforce a bunch of questionable rules in order to protect you from yourself.

</comment></comment></comment><comment><USER7> I recommend Kohana as a framework to work with (kohanaphp.com). It started as a branch of CI so is similar to that - but was totally rewritten with PHP5 support and lots of new stuff :)

Worth a look.

I always recommend Notepad++ plus a XAMPP installation over any form of IDE. It's simpler in the long run.

As to learning: that is a hugely personal thing. I picked it up over 4 or 5 years (still learning even now though!). If you already have a good grouding in general programming you wont have a problem :)

But with PHP learnign by doing is a good approach :) there are lots of snippet sites out there as well for you to peek through for ideas :D

<comment><USER8> I would also like to show my support for Kohana, Notepad++, and XAMPP.

</comment></comment><comment><USER9> i've been developing in PHP for 6 years now....and i have tried many frameworks. the one i like the most in my opinion is CodeIgniter.

CodeIgniter is very flexible and not as strict when it comes to implementing your own code and (libraries/classes/plugins). It's very simple, implements great separation (in regard of its MVC archt.) which makes it easy to understand and use. The framework has great, easy to follow documentation with great forum support and a growing community.

i say just watch one of their video tutorials of their website and you'll see how easy it is to get started on a project.

As for an IDE editor:

if you're using windows....i HIGHLY RECOMMEND PhpED (by nusphere)

I have tested every possible editor out there and this one by far is the BEST. It's fully featured in every aspect, easily customized and runs fast!.

they have definitely taken programmers needs and dumped it into this application.

it's definitely worth a try at least.

just checkout the features here.

<http://www.nusphere.com/products/phped.htm>

<comment><USER10> I second playing with CodeIgniter first. It's very "liberal" in the way it allows you to set things up, which means you'll be learning PHP and not fighting the framework designer.

You aren't constrained by the framework. If you want to do queries in the controller, go for it.

</comment></comment><comment><USER11> I didn't set out to learn PHP. I set out to learn Drupal and picked up PHP along the way.

I think that's a pretty good way to go, actually. You want to learn PHP by tinkering with a bunch of (a) working code that (b) has been reviewed by a community of people, at least some of whom are (c) trying to exhibit some taste. The problem with the language is that various sectors of it are poorly thought out, or have been implemented several times, and the best way to avoid stumbling over them is to follow in the footsteps of some expert guides.

Joining the userbase of one or another framework will probably give you much of the same effect.

The language itself is not hard to learn at all, except for the bits that are maddeningly silly. Watch out for the array() and the way it handles keys. Find the handy online table that compares empty() and isset() and is_null() and helps you to figure out that, in many cases, none of them is the thing you really want. ;) Watch out for accidental typecasts and their effect on your logic.

</comment><comment><USER12> I'm just popping in because you mentioned codeigniter. Code igniter is great, if you are forced in PhP 4. However, there is <http://kohanaphp.org> Kohana started out as a fork of codeigniter, and is very similar, except that it uses php5's object-oriented features to create a much more elegant MVC framework.

</comment><comment><USER13> CakePHP is a technical disaster. if you want a proper PHP framework, try Symfony

<comment><USER14> Details? Why?

<comment><USER15> I'm not the poster but the last time I looked into Cake it's internal code was just an utter mess. A lot of the mess is from it's continued support of PHP4 and PHP5 which have a lot of incompatibilities in their object models.

I haven't used Symphony in ages, but it was originally a fork of a project called Mojavi (which I used to work on). It was designed as a pure PHP5 MVC framework with a heavy emphasis on being easy to override or modify any of the components. I don't know how true it's held to that these days, but the original code base was pretty slick.

That said. I don't use either, I've got a little 300 line OOP MVC wrapper I wrote that serves my purposes. But if I were going to look at a framework today it would be Zend or Symphony.

<comment><USER16> CakePHP has changed ALOT, and for the better to boot! As a 6 year php coder and a 2 year cakephp developper, I HIGHLY recommend it.

Yes, everyone thinks the docs aren't good. They're currently pretty decent actually. Also, the community is amazing and all of it (core code, docs and community) is just getting better.

It's a really good, VERY flexible framework and most important; incredibly portable, which I think is the reason why I love it.. I haven't had a hiccup with it since the latest versions have come out (1.2 RC3?). I've also done ALOT of client work using it, rarely on my on web host. It is the Madlib to rails' Timbaland.

That being said, cakephp 1.1 was REALLY bad. I can't stress that enough. This is probably why it gets so much bad press. There's still ALOT of information written on 1.1, alot of technical articles, howtos, etc.. and an upsetting amount of reviews and performance tests based on 1.1 or early beta 1.2 releases.

I capitalize ALOT. I'm REALLY sorry. I just really like cake...

</comment></comment></comment></comment><comment><USER17> a) i recommend learning by doing. imo, start at the bottom and learn how to hand-code from scratch a single table CRUD app. then go through and clean it up. then build the same thing with a framework (i suggest CakePHP or CodeIgniter). then go through and clean it up. then build something more meaningful.

b) a quality text editor will work just fine. when doing php stuffs, i use jedit, and have used eclipse and netbeans in the past.

c) see a

</comment><comment><USER18> The way I've transitioned between languages was to first do a syntax comparison: [http://merd.sourceforge.net/pixel/language-study/syntax- acro...](http://merd.sourceforge.net/pixel/language-study/syntax-across- languages.html)

Then take a crash course: [http://cs.metrostate.edu/~fitzgesu/courses/ics325/summer04/C...](http://cs.metrostate.edu/~fitzgesu/courses/ics325/summer04/Ch01Notes.htm)

Then learn about database interfaces: <http://www.kitebird.com/articles/php- pdo.html>

Then learn about programming patterns: [http://www.rosettacode.org/wiki/Category:Solutions_by_Progra...](http://www.rosettacode.org/wiki/Category:Solutions_by_Programming_Task)

Then learn about security: <http://www.owasp.org/index.php/PHP_Top_5>

Then learn about error handling: <http://www.w3schools.com/php/php_error.asp>

Then learn about debugging: <http://www.onlamp.com/pub/a/php/2004/08/12/DebuggingPHP.html>

Then learn about idioms: <http://www.cybersprocket.com/wiki/index.php/Eric's_PHP_Guide>

Then read a comprehensive book: <http://www.ubookcase.com/book/Sams/PHP%205%20Unleashed/>

Then learn about optimization: <http://progtuts.info/55/php-optimization- tips/>

I've used PSPad, Komodo Edit, and Aptana Studio Community Edition for PHP editing, and recommend them all.

I've tried CakePHP and Drupal, but had trouble with the documentation and syntax of both compared to pure PHP. Wordpress has great documentation, community support, and readable sourcecode.

</comment><comment><USER19> a) With your background you should not have any problems to learn PHP. If you start, don't begin with a big complex system, like a blog or a forum. Try small scripts and learn about web secruity and PHP pitfalls. Then you are ready to begin something bigger.

b) If have experiences with Java, try one of the PHP Plugins for Eclipse.

c) CodeIgniter is mostly based on PHP 4. This results in same outdated patterns, especially regarding PHP 5.3. If you want real extensibility (and highly object orientated code) try the Zend Framework. If this is a bit too much, i recommend the Yii Framework, it's lightweight and brings lots of ideas from rails to PHP without copying the rails specific approach.

</comment><comment><USER5> Well, how familiar are you with HTML, MySQL, (or any other db lang), and CSS? In the end, a PHP file is really just parsed HTML, so anything not between <?php and ?> is just good ole markup. It also depends on what you want to get out of it, since PHP covers so much ground, but given that PHP is more attractive from the back than the front, I'll assume you wanna build some server-side applications. So for starters, in order to familiarize yourself with $_POST and $_GET (the two variables you'll be molesting the most) and the basic syntax try doing some simple HTML pages that evaluates some browser/platform condition and slowly work your way into HTML forms and attempt a feedback form. After that you'll work your way into MySQL functions and how to evaluate their output (this is back-back-end stuff [your typical db commands; creates, queries, inserts, etc]), user authentication comes next along with the global variable $_SESSION, which also considers how to handle cookies and different types of users, and lastly, after you've completed all of the following, you could attempt some sort of CMS (keep in my mind the scale since you're still learning), but by creating a basic CMS you'll slowly start seeing what an MVC pattern is in PHP. It's hardly abstract and quite hideous since you're only using MySQL and PHP, but by participating in this process you should uncover the gist of PHP and why it's so easy. After that if you're still sane, install PEAR and reiterate the process using their libraries else if unsatisfied or overwhelmed move onto something in Java and try JavaServer Pages.

</comment><comment><USER20> I generally recommend PHP newbies start with a framework and I generally recommend they start with CakePHP over CodeIgniter, because CI is much more flexible and therefore forgiving of bad practices which can turn into bad habits. CakePHP is more strict, which probably teaches better design patterns early on.

In your case, though, you sound like an experienced programmer in other languages, so you should be fine starting with a simple CRUD app and then progressing to frameworks; any of the popular ones will do fine.

</comment><comment><USER21> Great question.

For editors I highly recommend Eclipse DPT: <http://www.eclipse.org/pdt/>

With a Java background I would think you'll feel right at home there.

Framework wise stay tuned to (shameless plug) <http://www.recessframework.org> \- it's a framework I've been working on that makes greater use of the OO facilities in PHP5, is RESTful, and has a straightforward ORM. Public preview release soon.

CodeIgniter is written to run in either PHP4 or 5 which means it makes less interesting use of the PHP5 object model. If you're an OO nut I suggest staying in 5 and perhaps looking at Kohana.

</comment><comment><USER22> I see lots of complex answers, but not the answer to actually learning a bit about PHP. My favorite book is "PHP in Easy Steps" by McGrath, published by Barnes and Noble. Very inexpensive.

A good intro to the basics, which will allow you to make use of the online docs, which is the best documentation of a programming language I've ever seen.

After that, the other resources come in to play. For an editor, I use notepad++ on the pc and textwrangler on the mac. With apache, mysql, and php running locally, your development platform is free.

</comment><comment><USER23> a) i haven't used any php related books, but this is invaluable:

<http://www.php.net/docs.php>

i would suggest downloading a version of it for quick reference. it's worth learning the commonly used functions, but a big chunk of php's value (and the main criticism against it) is a namespace filled with goodies (with varying degrees of good). This means there is probably a lot of useful functionality that's used sporadically enough that it's not worth committing permanent headspace to. Rather, learn to be quick about finding the right function to use. It's usually worth checking to see if there's some strange function/module that does exactly what you're trying to do. and if there's not, you can usually find example code in the comments - though i wouldn't recommend copying that code into production. rather, use it as a starting point for exploring the problem at hand.

i'd suggest learning php by giving yourself a well defined, if simple, project to start with and attacking it the same way you've learned languages in the past. probably with some reading, a lot of doing, occasional breaking, then more reading.

b) notepad++ or homesite are my preferred IDE's

c) codeigniter, cakephp ( <http://cakephp.org/> ) and the zend framework ( <http://framework.zend.com/> ) are the big frameworks i'm aware of, but i'm sure there are more out there.

enjoy!

<comment><AUTHOR> Thanks. Still confused about the framework. Not sure why CodeIgniter doesn't support PHP 5 :(

<comment><USER24> From here: <http://codeigniter.com/user_guide/overview/at_a_glance.html>

"CodeIgniter is written to be compatible with PHP 4. Although we would have loved to take advantage of the better object handling in PHP 5 since it would have simplified some things we had to find creative solutions for (looking your way, multiple inheritance), at the time of this writing PHP 5 is not in widespread use, which means we would be alienating most of our potential audience. Major OS vendors like RedHat are moving slowly to support PHP 5, and they are unlikely to do so in the short term, so we felt that it did not serve the best interests of the PHP community to write CodeIgniter in PHP 5.

Note: CodeIgniter will run on PHP 5. It simply does not take advantage of any native features that are only available in that version."

<comment><AUTHOR> Hmmm, interesting. I didn't read that. Thank you, thorax.

</comment></comment></comment></comment><comment><USER25> Take advantage of the object oriented features (classes, inheritence, etc) Write unit tests early and often. Re-read the docs; some of the PHP functions are inconsistently parameterized -- meaning one function expects params in one order and a simliar function expects the params in the opposite order! (Can't think of those functions off the top of my head but there I swear...) Just be careful. PHP is forgiving (almost?) to a fault

</comment><comment><USER26> The worst thing about PHP is how easy it is to leave SQL and HTML all over your code.

Install Doctrine (ORM) and Smarty (Templating engine) or friends and use it religiously. If you do, you can use PHP for what it's best at: Cranking out business logic at high speed.

<http://www.doctrine-project.org/>

<http://www.smarty.net/>

</comment><comment><USER27> When I was learning PHP (way back in version 3) I started by building a simple addressbook backed by mysql, I would also recommend as kungfooey did to start by building something and learn as you go.

As far as editors go, I use emacs, but for about 5 years I used UltraEdit and was very pleased with it.

I personally use a framework i wrote a while back, but if I were starting over I think codeignitor would be my pick

</comment><comment><USER28> The other advice here is excellent, I'd just like to throw out a vote for the editor Textpad (<http://www.textpad.com/>).

It's much lighter than eclipse, but still has tons of features (regular expression search & replace is a favorite).

Small download, so it's at least worth checking out.

</comment><comment><USER29> Late to the game here, but I have to recommend Komodo Edit for your IDE - I've been using it for about a year now and it's just so solid. I've tried others (most recently Netbeans PHP, which is a CLOSE contender), but they just don't do things that Komodo does that I've grown very accustomed to.

</comment><comment><USER24> a) Probably start trying to write a site you want and learning from there-- with a background in other languages it's more about "I know the language can do X-- let me search for something like it". When using PHP you can often just google "PHP equivalent of " whatever function you know in C#/Java/JS and there will be some corresponding example to use.

b) I like NuSphere PhpEd even though it isn't free. Some people like Netbeans IDE for PHP.

c) I love CodeIgniter. Very fast, MVC, some of the best user guides for any framework, just very solid all around. Go with it initially-- I know many PHP developers who got started there and have grown to be some of the most productive web coders I've ever seen.

</comment><comment><USER30> Personally I would forget the framework - you don't need it. Any sufficiently advanced framework is indistinguishable from php.

OK, maybe not exactly, but many of them suffer from second system syndrome where they try to re-implement everything php offers.

Just use php directly.

<comment><USER31> Yeah, I think this is bad advice. One of PHP's drawbacks is that it is such a loose language. If you don't use a framework, you will most likely fall into the trap that many PHP coders fall into, which is being quite lax with your code and consistency.

Using a framework really helps you maintain some consistency throughout your code. If you don't like what other people have made, build your own.

</comment></comment><comment><USER32> CakePHP. The documentation is great. Performance is great. The learning curve isn't too bad. It's a framework that will take care of you.

Every negative criticism about CakePHP is about two years old and no longer relevant.

</comment><comment><USER33> Though you may find some sections rudimentary, this is actually a great primer/refresher: <http://devzone.zend.com/node/view/id/627>

</comment><comment><USER31> You can jump into PHP quite quickly. The syntax is not very different from other languages such as C++ or Java. What takes a little while is learning the built-in functions.

</comment><comment><USER34> After 7 years of exp I found that

1\. Zend Framework - best framework, CodeIgniter is next. 2\. Zend Studio - best IDE 3\. Smarty - don't reinvent the wheel

</comment><comment><USER35> I worked with cakephp, but because of the lack of documentation i'm turning to codeigniter. It just works.

Welcome to php! :)

</comment><comment><USER36> a)Depends on what you consider learning PHP. Depending on the framework you choose, you may or may not actually need to know much PHP, aside from basic syntax. More on this in point c.

b)Until yesterday I've been using eclipse PDT, but you'll soon have a love/hate relationship with it, and start looking for alternatives from time to time. That said, I started to use Netbeans PHP yesterday, so far so good.

c)With your background I recommend you check out NOLOH (Not One Line of HTML) <http://www.noloh.com>, it's currently in public Beta, and is slated for general release in January. One of things you'll notice from the NOLOH website and it's tutorials is that you really don't need to know PHP, other than the syntax, check out the Hello World and Threaded Comments videos to see what I mean.

Full Disclosure: I'm one of the co-founders of NOLOH.

</comment><comment><USER37> Anyone here care to give some opinions about Zend PHP Certificate?

<comment><USER38> I'm not sure how much value certificates have. I just see them as another revenue stream for Zend Corp. I think a quality portfolio (commercial, side- projects, open source) has much more value.

</comment></comment><comment><USER9> but to point out the from the first comment left by kungfooey

you're best way to start in any language is to develop a small app without a framework.....great advice by him/her.

</comment><comment><AUTHOR> EDITED TO ADD:

Most web hosts support PHP4 or PHP5? Any ideas on this one?

<comment><USER39> I run a little web hosting business myself and from what I know about the industry most hosts should offer both at this point (with PHP5 as the default). If PHP4 is the default on your host, you can try adding this to an .htaccess file in the root directory of your site:

       AddHandler application/x-httpd-php5 .php

If your host is running the latest version of CPanel, you should be able to access your control panel and change the default version yourself: Software Services -> PHP Configuration.

If that doesn't work, complain to your host and demand PHP5!

</comment></comment><comment><USER40> a) Starting with tutorials is a logical first step, however they may be some bad advice in there. Writing some simple applications or pages to accomplish stuff is good to get a handle on the breadth of built-in functionality.

Please also note that PHP 5 has much better OO functionality than PHP 4. PHP 4 is end-of-lifed, however CodeIgniter is still compatible with PHP 4, thus limiting it in some respects.

I wouldn't focus on too much open source PHP apps, much of them are kind of sloppy-the frameworks will probably be a better code base to look at. Just like any other language you can write sloppy code, but you can also exert some effort and make a well-organized codebase.

The last thing I would recommend is to read about PHP security issues. (Disclaimer, this is my own site) <http://flourishlib.com/docs/Security> has an overview of security issues, however some of it is focused on using Flourish to fix issues.

b) I would recommend looking at:

      - PHPEd (commercial, http://nusphere.com) <- I use this
      - Netbeans 6.5 (open source, http://netbeans.org)
      - Aptana with the PHP 1.0 plugin (open source/commercial, http://aptana.com/php)

Komodo (commercial, <http://www.activestate.com/Products/komodo_ide/>) was alright but I haven't tried the new 5.0 release. Eclipse PDT 1.x (<http://eclipse.org/pdt/>) was ok, but very much a pain to configure-I hear 2.0 is coming out soon.

c) In terms of frameworks, here are a few of the big ones in addition to CodeIgniter, however if performance is a concern, please do check out <http://paul-m-jones.com/?p=315>.

      - http://cakephp.org
      - http://framework.zend.com
      - http://symfony-project.org

<http://kohanaphp.com> may be of interest since it was originally based on CodeIgniter, but has been rewritten to use PHP 5 functionality.

Definitely learn to use <http://php.net> for lots of reference. The comments on function pages can often include a good amount of insight. All functions are accessible via <http://php.net/function_name>.

If you are looking for less of a framework, but more of a library, I've been working on Flourish (<http://flourishlib.com>) for a while. I've focused a good amount on security, documentation and usability.

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


Ask HN: What are you using for Log Management? - <AUTHOR> Some of the cloud solutions like sumo logic, splunk cloud seem expensive while the open source alternatives seems like a lot of investment to keep it up and running. Any recommendations? <comment><USER2> Right now I am evaluating Clickhouse as a warm/cold storage for logs.

Looked first at elastic; but since most (>80%) log searches will be on the time dimension and not in free form queries, it makes sense to use a columnar SQL DB

Also, my company has a lot of Oracle Hexadata DBAs on payroll and we can just train them on Clickhouse which shares a lot of concepts with Oracle.</comment>


Alfred for your Chrome - <AUTHOR>

I got fed up wasting my time trying to navigate my way through bunch of bookmarks folder to arrange them. So if you are:

  - Obsessed with organization
  - Have a couple hundreds (or thousands) of folders in your bookmarks
  - You like to keep things tidy and every page has to be in its "perfect" place
  - You like easy and fast access to your bookmarks
 then you booklight is for you. Booklight is a clean Chrome Extension to ease the way of adding a bookmark.
To Launch press (ctrl/Control + b) and thats it
Features

  - Filter bookmarks based on manual entry
  - Show the path of the current selected folder
  - Navigate easily through the folders tree using keyboard [if the folder is highlighted in blue this means that it contains sub-folders as well. The right arrow (->) keyboard key will go inside that folder. You can go back one step to the back using the left keyboard arrow (<-)]
  - Bookmark directly when you find your target
  - The ability to switch to urls search [NEW]
  - Launching urls in current or new tab [NEW]
  - Fuzzy search enabled for filtering on both folders and urls [NEW]
  - Clean current URL before bookmarking (sometimes the url is polluted with query strings e.g ?source= ... for various tracking information). To clean the url from those, hit ctrl+alt+x and this will solve this issue.
 https://github.com/ahmadassaf/booklight <comment><USER2> Very interesting.

Here is an idea: for saving space on my bookmarks bar, I often empty out the whole name of the bookmark and leave the favicon only: [http://i.imgur.com/Na63dCS.png](http://i.imgur.com/Na63dCS.png)

Would be nice if search will count those (based on URL?) as well.

Also, when I hit ctrl+B then press enter to add it to a folder, if I press enter again it will add it again. I'd expect a toogle (add/remove) or at least one single add.

<comment><AUTHOR> great feedback :) thanks a lot for that. I will fix the double add part. I will also implement fuzzy search on URL, hopefully by next weekend</comment></comment>


GitHub banned all Iranian users. Our accounts are restricted. Please support us - <AUTHOR> https://github.com/1995parham/github-do-not-ban-us <comment><USER2> Recent discussion "GitHub and Trade Controls" [https://news.ycombinator.com/item?id=20526039](https://news.ycombinator.com/item?id=20526039) and "My GitHub account has been restricted due to US sanctions as I live in Crimea" [https://news.ycombinator.com/item?id=20531039](https://news.ycombinator.com/item?id=20531039) And related "How is it like to be a dev in Iran" [https://news.ycombinator.com/item?id=20493699](https://news.ycombinator.com/item?id=20493699)

> let us download our private repositories and also make them public (setting > control).

Seems reasonable.

> change their restriction policies to not limiting users based on their > Nationality.

I don't see this happening. It's US law and github (Microsoft) is bound by it. Maybe a competitor will use it to their advantage and offer

> announce their decision publicly and apologize for making this situation > (like what slack did before in the same situation: [https://slackhq.com/an- > apology-and-an-update](https://slackhq.com/an-apology-and-an-update)).

I can see how the PR team will issue a careful worded letter or blog post. It will say "we regret the situation" but I doubt be an apology.

<comment><USER3> >It's US law and GitHub (Microsoft) is bound by it.

That seems like a terrible situation. What if tomorrow there's a US law that <insert ridiculous thing which "everybody" says won't happen until the day it happens>

Maybe they should fork into GitHub US, GitHub EU and so on.

<comment><USER4> If the law is believed to be unconstitutional, a US company can fight it in court. Otherwise, the company is required to comply with all laws applicable in the jurisdictions they operate. If there is a conflict, the US law has highest authority.

In this case, if GitHub EU is owned by Microsoft, a US company, GitHub EU still must follow US rules. On the flip side, while GitHub EU must follow GDPR, GitHub US would not be required to do so.

<comment><USER5> Are you sure? Isn't the point of Azure in Ireland that the US government won't be able to request data under the patriot act?

<comment><USER4> Nope, the point of Azure in Ireland is to increase availability and decrease latency for EU clients. Microsoft challenged a warrant in 2013 to hand over emails stored in Ireland, but the SCOTUS vacated the rulings since it was moot by the CLOUD act of 2018, which allows the government to get data from US companies, no matter where the data physically is.

[https://en.m.wikipedia.org/wiki/Microsoft_Corp._v._United_St...](https://en.m.wikipedia.org/wiki/Microsoft_Corp._v._United_States)

[https://en.m.wikipedia.org/wiki/CLOUD_Act](https://en.m.wikipedia.org/wiki/CLOUD_Act)

<comment><USER6> Huh. Azure used to have a special region in Germany (joint operation with Deutsche Telekom) but it seems they've killed it last year.

</comment></comment></comment></comment></comment></comment><comment><USER7> Microsoft banned all Iranian users. And crimea if I recall correctly.

Financial support of open source is a nice thing, but folding open source into the world of US political choas seems so wrong.

I for one will be moving my projects elsewhere. Not sure where yet, probably a bitbucket server.

<comment><USER8> Gitlab, IMHO, is the gold-standard for self-hosted Git data, CI/CD, Issue- tracking, etc (IMHO, at least). You can use their (US-based, IIRC) hosted solution, or download their Omnibus package and get a self-hosted instance running in less than an afternoon.

</comment></comment><comment><USER9> This is well within GitHub's Account ToS in Section B 3.6. [0] so all GitHub users who are part of the US sanctioned countries list [1] are banned from having an account. Since Microsoft/GitHub are all US based companies, they must comply with US export laws and I'm afraid not even GH/Microsoft staff can intervene in this.

I don't know what to think about this 'message to GitHub' since they can't do anything about this, but I think that migrating off of GitHub and lessening or completely removing our dependence on the service is probably better for those developers and for open-source in general.

[0] [https://help.github.com/en/articles/github-terms-of- service#...](https://help.github.com/en/articles/github-terms-of- service#3-account-requirements)

[1] [https://help.github.com/en/articles/github-and-trade- control...](https://help.github.com/en/articles/github-and-trade-controls#on- which-countries-and-territories-are-us-government-sanctions-applied)

</comment><comment><USER10> Looks like it's time to migrate the rest of my stuff off US-based hosts.

Today Iran, tomorrow who knows?

Far easier to take a couple days to move my stuff now than having to do it under duress in a year or two.

<comment><USER11> They only block really antagonistic regimes which don't comply with UN and other international sanctions. It has to be a really rogue regime that threatens regional or world peace.

<comment><USER12> For now. There is absolutely no reason to suspect that won't change in the future.

<comment><USER13> Well if the future is just a big black box, why is it reasonable to move to hosts outside the US?

If current conditions are not a good predictor for future conditions, isn't it equally likely that other countries (same as the US), could change in the future to sanction other countries and restrict online services operated there?

</comment></comment></comment></comment><comment><USER14> The Fifth Amendment of the U.S. Constitution:

"No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offence to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, _nor be deprived of life, liberty, or property, without due process of law; nor shall private property be taken for public use, without just compensation._ "

(Property includes intellectual property, such as computer code.)

(Due Process includes (but is not limited to) _Trial by a Jury of one 's peers_...)

<comment><USER15> I love the US constitution as much as the next guy, but isn't it a bit of a stretch to apply this section to a non-citizen not even located in the States?

<comment><USER16> It does say "no person". But "due process" can mean anything.

<comment><USER15> Would you contend the US constitution applies to someone living in Finland, who is a citizen of Greece born in Norway?

<comment><USER14> I would submit that someone living in Finland, who is a citizen of Greece, born in Norway, is not contractually obligated by the U.S. Constitution, unless they accept it in some way or other, and if so, that acceptance may be in conflict with other contracts (such as other citizenships) that they may have accepted prior.

So no, probably not.

On the other hand, I would presume that anyone who works for the U.S. Government has accepted the U.S. Constitution, either explicitly (by Oath) and/or implicitly (by the act of working for the U.S. Government).

Why is this important?

Well, see, if those people are in charge of creating/enforcing sanctions, they are also contractually obligated to do so while _NOT BREAKING THEIR CONTRACTUAL OBLIGATION TO UPHOLD EACH AND EVERY ASPECT OF THE CONSTITUTION_.

One of the things that The Constitution says (above) is that people (all people by the way, not just some of a specific nationality, and not just those that have accepted the Constitution) are _NOT_ to be deprived of their property _without Due Process_ (which includes but is not limited to a Trial By a Jury of one's peers).

So... you do the math.

</comment></comment></comment></comment></comment><comment><USER17> Why are these people assuming GitHub is some sort of an open source authority. Is it so difficult to understand it's a company that hosts free and open source projects like any other service? The ignorance is just baffling.

<comment><USER18> Why would you call it either ignorant or baffling? Do you expect Iranian users to have a deep understanding of American export laws and the political intricacies that might follow from Microsoft's acquisition?

This is an completely understandable reaction regarding Github's block against Iranian accounts. Github as been around for over 10 years, and this never happened before.

<comment><USER19> Github owned by Github. But this is something different. It is Github owned by Microsoft. Acquisitions, in general, do not end well for the established user- base.

Suggestion: move you repositories! Host your own repositories! Use something different, like Gerrit, to spice up your development! Take matters in your own hand! Own your data, own your compute!

<comment><USER20> Is there something about this that I've missed that has something to do with the Microsoft acquisition? The same laws would have governed GitHub if they hadn't been acquired.

<comment><USER17> From an Open Source developer point of view, yes, of course. Open Source projects should not be hosted with them. Period. It completely betrays the spirit of the licenses the code is released under, which guarantees access to anyone, regardless of political, religious, etc.

</comment></comment></comment></comment></comment><comment><USER21> Did GitHub try to fight this in courts? As with Slack, why does it just happen out of the blue? Sanctions on Iran have been there for at least a year, sanctions on Crimea since 2014 - so why now?

</comment><comment><USER22> So where is GitLab hosted? Would they be under the same restriction?

<comment><USER12> GitLab.com is hosted in the US. The GitLab on prem software can be hosted wherever the hell you want

<comment><USER23> Can you get GitLab on-prem if you're in a sanctioned country though, or is GitLab also not allowed to let you download it if that's where you're located?

<comment><USER24> Since at its core it's free software, you can download it from wherever you want.

<comment><USER25> But since US companies are forced to geo-restrict, how can you verify that the (free) software you've downloaded, is actually the free software offered by those companies?

<comment><USER24> With their signatures, commit hashes and distribution networks you trust (such as distro maintainers, for instance).

You most likely already do that without any sanctions that affect you.

</comment></comment></comment></comment></comment></comment><comment><USER26> Iran is under US sanctions, I wouldn't expect Iranians to have access to services from any US company.

It sucks, but that's the whole point of sanctions.

<comment><USER27> So there should be no protest then ? Of course it is the point of sanctions. But this is also why sanctions are wrong. As Ron Paul repeatedly said, sanctions are akin to war. Shouldn't one protest the bombing of cities because "that's the whole point of war"

<comment><USER26> There's no way to punish a government without punishing the country. The sanctions are not on the people themselves, for instance Iranians can and do visit the US.

Iranians and US citizens should protest against their governments causing this political situation. From my limited research, neither party is innocent. Bothering GitHub doesn't have a purpose, they are only blocking Iranians to comply with laws.

</comment></comment></comment><comment><USER28> This is the point of sanctions. If you can still provide goods and services to sanctioned countries, they're not really sanctions.

</comment><comment><USER29> I don't understand why this was done suddenly. Warning Iranians that there account will be blocked next month and offering read-only access in the meantime would be much more reasonable. I'd expect legal action to impose the ban would likely take at least this long. I'm glad git is a distributed system, and hope no one lost any information.

</comment><comment><USER30> I think the only solution is to move open source communities to a more neutral country. Unfortunately, the US as it stands right now, is getting a less suitable place for international organizations day by day

</comment><comment><USER31> They can alway use this [https://coding.net/](https://coding.net/) yes, I know there is a minor problem of the language.

</comment><comment><USER32> Git was meant to be distributed, however convenience usually wins thus centralization case again. Hints: git-issues, git-remote-ipfs, gitea and some mirroring via VPNs.

</comment><comment><USER33> Are all U.S. based companies required to prevent Iranian users by IP address? Would this be true for social media apps like Twitter as well?

</comment><comment><USER27> As someone of Iranian Heritage, even though I've never been to Iran, because my Father fled the country after beeing sentenced to death twice, for fighting the Mullah Regime, the Ignorance and total lack of emphaty for Iranian Devs and Open-Source contributors displayed in this thread is shocking to me. People who have nothing to do with politics and are already suffering under crippling economic sanctions as well under their own government are apparently not considered to be part of the "community". Giving them the "helpful" advise to "fight" their government even though there is currently no active opposition in Iran and every increase in tensions is making the majority of the population stand more firmly behind their government is just insane.

Can't you see that the people asking for support are not "enemies of america" but instead people who consider the Trump administrations policies to be an abberation, non-representative of the will of the american people, who they consider to be their friends and Open-Source-Community Brothers ?

</comment><comment><USER34> This is incredibly dumb. Hopefully some GitHub exec intervenes.

Edit: Happy to take the karma hit. Stupid is stupid, regardless of jurisdiction and consequences.

<comment><USER35> Why would an exec intentionally violate US law for this?

<comment><USER36> Because it's the right thing to do and MS has the power to do it.

<comment><USER20> In what way do they have that power? Do you just mean in the way that anyone has the power to break laws and face the consequences, or something else?

<comment><USER36> Microsoft is not untouchable by any means, but, probably more than any company in the world right now, they have the power to gain clarity on these sanctions (and possibly also the EAR issue).

Microsoft has obviously turned a corner recently into dramatic support for open source collaboration. They're pushing VSCode. They bought github. They support linux. None of us will be surprised to hear that they're seeking to buy StackExchange or Discord soon.

I'm saying: if these are their true colors, then they mount a full-throated resistance to this nonsense. They have the legal team, the technical talent, and the political connections to do so.

Start by refusing to take down Github Pages of nationals of sanctioned countries and refusing to disappear repositories maintained by the same, absent a specific court order. Then, challenge it in court.

Will the US Government have the gall to go to Seattle and cuff somebody over this? If they do, it will be a major international incident and rallying cry, and that person (and Microsoft) will look internationally heroic.

</comment></comment></comment></comment></comment><comment><USER37> These sanctions are immoral.

</comment><comment><USER38> Russia invades and takes over Crimea (again). This has repercussions for the people living there, many of whom are displacing those who lived there before.

Iran threatens to nuke other countries as soon as they can develop the nukes. They are in the process of trying to take over the whole middle ease, fighting in Yemen, Syria, Iraq, Lebanon, etc. This has repercussions for the people living there.

</comment><comment><USER39> The US is not going to lift these restrictions. Why would they? If you live in these terrible places, I'm sorry, but you need to start fighting at home. I don't know enough about your specific situations or what level of action you should take, but everything from peaceful protest to armed rebellion are options. Yes, you might have to die. You might be killed just for peaceful protest or if you're government suspects you might be "trouble." This is your burden, but liberty is worth it.

<comment><USER40> And by what logic exactly does the US have the right to "push for freedom" in foreign countries?

Why do people from such countries have to doubly suffer, because not one but two governments are fucking them up?

<comment><USER39> Yes, it sucks, but they do have to doubly suffer. Do you think that giving them access to GitHub is going to make them suffer less?

BTW you're literally advocating against freedom.</comment></comment></comment>


Acheron: A Common Lisp to JavaScript compiler written in 100% Java - <AUTHOR> http://sourceforge.net/projects/acheron/

<comment><USER2> Who would write a Lisp compiler in 100% Java. Why??? There are a few things that are easier to write in Lisp, high on that list is a Lisp compiler.

<comment><USER3> Deployment, accessibility.

Consider adjusting your tone and the quality of your response, it just makes you sound partisan rather than informed.

<comment><USER2> Deployment of what? How would a compiler written in ABCL and delivered as Jar be more difficult to deploy???

Accessibility? For who? The people who actually can maintain a Common Lisp compiler are using mostly Lisp and share parts of their code. There is almost no Common Lisp compiler written not in Lisp. Part of the runtime system may be written in C, but much of the rest is Lisp and especially the compiler.

For example the compiler for ABCL running on top of the JVM is written in Lisp:

[http://trac.common- lisp.net/armedbear/browser/trunk/abcl/src...](http://trac.common- lisp.net/armedbear/browser/trunk/abcl/src/org/armedbear/lisp/compiler- pass1.lisp)

Please stop your patronizing tone. You can also increase the quality of your own response, which was near zero.

<comment><USER3> Lispers have a decidedly notorious reputation for wailing about the lack of respect their family of languages tends to get.

I say this as someone who is incredibly fond of hacking in Clojure and has spent a fair amount of time with a couple Scheme implementations.

Railing against someone else's work without providing cogent reasons for why their approach is inferior to what you have in mind doesn't do much for the community.

Not this community nor the Lisp community.

It's a lot easier to make a case from a business point of view for a lisp that can be deployed anywhere JVM is, rather than potentially have to get into the rigamarole of standardizing another piece of technology.

Programming languages that never help programmers get their jobs done don't help the world much beyond being proof-of-concepts.

That's my point and it's the point you need to refute before you start flailing around like a wanton child in retaliation.

When your language/toy of choice is unproven and not otherwise well accepted in the business/technology world the onus is upon you to prove your points.

No one owes you or your preferred tools any free credibility.

<comment><USER2> So much drivel, so little content. Stop writing bullshit.

ABCL is written in Lisp AND RUNS ON THE JVM. What's so difficult to understand? You can deploy it everywhere where the JVM runs. Totally painless.

All of Common Lisp has already been written in Lisp and is available both in GPL and Public Domain versions. A Lisp compiler could just reuse all of that or parts of it and just needs to compile to JVM byte codes. There is no need to rewrite all of that in Java - it exists already. There is no need to rewrite the library functions in Java. There is no need to rewrite the REPL in Java.

All you need is the code generator and some runtime parts. The rest, and that's a lot, exists already and can be taken.

The only thing you get by writing 100% Java is some Lisp dialect that will have tons of bugs and problems.

A compiler written in 100% Java is DOA.

</comment></comment></comment></comment></comment><comment><AUTHOR> There's also a blog: <http://lispnyc.org/blog/acheron></comment>


Blogger is back - <AUTHOR> http://googleblog.blogspot.com/2011/05/blogger-is-back.html <comment><USER2> I didn't hear any noise about this compared to, say, when Tumblr was down for a similar amount of time. Does that speak accurately to their relative popularity?

<comment><USER3> They don't really compare because the majority of Blogger blogs were still readable. Editors just couldn't create new posts. Often when Tumblr goes down you can't even read it.</comment></comment>


QCL - A Programming Language for Quantum Computers - <AUTHOR> http://tph.tuwien.ac.at/~oemer/qcl.html <comment><USER2> I've been watching this series for a general introduction into the math behind quantum computing, and would recommend it: "Quantum computing for the determined" by Michael Nielsen

[http://www.youtube.com/playlist?list=PL1826E60FD05B44E4](http://www.youtube.com/playlist?list=PL1826E60FD05B44E4)

</comment><comment><USER3> See also Quipper language, which is a DSL on top of Haskell for quantum programming. [1]

[1] [http://www.mscs.dal.ca/~selinger/quipper/](http://www.mscs.dal.ca/~selinger/quipper/)

</comment><comment><USER4> How long do we realistically have to wait before John Carmack rewrites Wolfenstein 3D in this?

</comment><comment><USER5> > The current version of QCL is 0.6.3 (Dec 14 2006):

In reality, programming quantum computers is still complicated by the changing hardware. Think about it, if your goal is to do something cool with 1 or 2 bits, it doesn't make sense to build a grand architecture which will let you factor 2^25-1. In fact, when I see grad students / postdocs / professors talking about this, it's a big warning sign.

If you're interested in what could be done in the field, I would start by taking a look at QuTIP ([https://code.google.com/p/qutip/](https://code.google.com/p/qutip/)), learning LabVIEW (It's effective, useful, and everywhere), or maybe becoming a topnotch Verilog coder. FPGA's are the future of QC.

</comment><comment><AUTHOR> I think the main question is what other _systems_ there are out there besides D-Wave which (afaik) is mainly Python-based. [http://www.dwavesys.com/en/dev- tutorial-tsp.html](http://www.dwavesys.com/en/dev-tutorial-tsp.html) ie: would the larger picture be a D-Wave based "AWS-like" system that accepts to run these different languages?

<comment><USER6> DWave's Adiabatic Quantum Annealer does not run python. It is not Turing Complete. The python component is used to manually generate a matrix that corresponds to a travelling salesman problem. QCL (and Quibble) are languages designed to describe quantum programs that would actually run on a qunatum computer. What DWaves python module does is more akin to writing OpenCL code in a string and passing that to the OpenCL runtime to be compiled.

</comment></comment><comment><USER7> Is Java/C++/etc the punch cards of our generation? Should we start learning this to keep up?

<comment><USER8> Quantom computers aren't replacing classical ones in the foreseeable future. At best, they will be simmilar to GPUs (and even that is a stretch).

<comment><USER9> At least this is true right now but the above could easily turn out to be one of those "None will ever use more than X bytes of ram" quotes.

</comment></comment></comment><comment><USER10> If Heroku don't got it, I don't learn it.

<comment><USER11> I hope that you did not flip this around and force yourself to learn PHP and JS based on this philosophy.

<comment><USER12> Hey, come on. PHP and JS fit a niche. Just like the platypus. Remarkably stupid animal, but it exists because it fit a niche that no other animal did.

<comment><USER13> Can't we like something just because it's awesome? For both cases.

<comment><USER12> Yes we can. I respect and admire all three.</comment></comment></comment></comment></comment>


Ask HN: Beginner non-trivial transpiler projects to learn from? - <AUTHOR> I have some compilers background and would like to study beginner non-trivial transpiler source code. Any recommendations? <comment><USER2> These might be too far off the beaten track for you, being non-standard languages with full game library systems, but Mark Sibly's Monkey2 (discontinued for lack of support) is a complex transpiler project written in a very read-friendly language:

[https://github.com/blitz- research/monkey2/tree/develop/src/m...](https://github.com/blitz- research/monkey2/tree/develop/src/mx2cc)

... and one of his previous languages, BlitzMax, is continued by others today as BlitzMaxNG, and it uses a frequently-updated transpiler based off the former/similar Monkey language:

[https://github.com/bmx-ng/bcc](https://github.com/bmx-ng/bcc)

Again, easy to read, and the principles are the same for almost any language.

Downloadable distros:

[https://blitzresearch.itch.io/monkey2](https://blitzresearch.itch.io/monkey2) [https://blitzmax.org/](https://blitzmax.org/)

Targets include Windows x86/64, Mac, Linux, Android and HTML5... among others!

</comment><comment> Const-me Take a look there: [https://github.com/Const- me/vis_avs_dx/tree/master/avs_dx/Dx...](https://github.com/Const- me/vis_avs_dx/tree/master/avs_dx/DxVisuals/Expressions) Couple test cases: [https://github.com/Const- me/vis_avs_dx/blob/master/avs_dx/Co...](https://github.com/Const- me/vis_avs_dx/blob/master/avs_dx/CompilerTest/CompilerTest.cpp)

The transpiler is in C++/17\. The source language is something called NSEEL, implemented in Winamp couple decades ago. The original runtime was a JIT into old-school x87 code. The target language is Microsoft HLSL, specifically it's for shader model 5 for Direct3D 11.0.

I have little to no background with compiler development, but IMO my transpiler ain't too bad, and it's very efficient.

</comment><comment><USER3> I knocked something up. It might be a bit too trivial but I'll let you judge: [https://github.com/mcapodici/badlanguage](https://github.com/mcapodici/badlanguage)

<comment><AUTHOR> thank you! Having scheme/lisp on either end of transpilation seems like a good beginner project to learn from.

<comment><USER3> He he when looking at it, be critical because I knocked this up. A pro haskeller could probably find a few flaws in it and the JS generated code will not be performant!

</comment></comment></comment><comment><USER4> You may want to have a look at an "MVP" compiler one of such projects is The Super Tiny Compiler[0]

[0][https://github.com/jamiebuilds/the-super-tiny- compiler](https://github.com/jamiebuilds/the-super-tiny-compiler)</comment>


Show HN: Ultra-fast cross platform actors coming to JVM - <AUTHOR> https://www.reddit.com/r/java/comments/6q2fwi/ultrafast_cross_platform_actors_coming_to_jvm/ <comment><USER2> Why on earth are you linking to a reddit discussion that links to a github repository, instead of simply submitting a link to your github repo and/or submitting a text post describing the project?</comment>


Average business has 7 social media campaigns, no way to measure its success - <AUTHOR> http://www.threeshipsmedia.com/page/few-businesses-have-a-clue-when-it-comes-to-social-media

<comment><USER2> This is why the company (or individual) who figures out how to properly measure social media and provide metrics will be an agency conglomerate or be purchased for ridiculous amount of money.

I know there are a few out there trying to figure this out, and it is a behind the scenes rat race that isn't publicly discussed because each firm fears the other will get there first.

Exciting times.</comment>


Gambling Dispute With a Tiny Country Puts U.S. in a Bind - <AUTHOR> http://www.nytimes.com/2007/08/23/business/worldbusiness/23gamble.html?ex=1345521600&en=06f9d1c84a864017&ei=5090&partner=rssuserland&emc=rss <comment><USER2> Guess I have to upvote that, since I've been following the story for years and now have a vested interest in the outcome.

>>Complying with the W.T.O. ruling, Professor Jackson said, would require Congress and the Bush administration either to reverse course and permit Americans to place bets online legally with offshore casinos or, equally unlikely, impose an across-the-board ban on all forms of Internet gambling -- including the online purchase of lottery tickets, participation in Web-based pro sports fantasy leagues and off-track wagering on horse racing.<<

The rest could go to hell in a handbasket as far as the government is concerned, but off-track wagering is a massive industry. The lobbying there is just too strong.

Also Americans can place bets legally with off-shore casinos (in most states there is no law against it). It's just illegal for banks to process the payments.

<comment><USER3> So how do you think this will be settled? The easiest and most logical thing to do is to allow the banks to process the off-shore casino transactions but I'm afraid that Bush would rather take down the WTO as one of his last major actions.

</comment></comment><comment><USER4> This reminds me of when Shawn Fanning of Napster visited my university in 2000. He came along with some corporate guys that seemed like his body guards and filters for anything he said. The discussion revolved around the whole Napster debate of course and the main business guy said they wanted to start charging a couple of dollars per song to make it legal. When time came for questions, I asked why they didn't just move their operations to a country where they would be within the legal limits to continue Napster as it was. His answer was basically "we just don't want to", which wasn't very satisfying. Now after allofmp3.com made their millions, I wonder if they regret not doing something like that. Of course, I'm sure there were compelling factors that would prevent well-known american businessmen from circumventing the system in that manner. Looks like Mendel doesn't suffer from the same limitations.

</comment><comment> daniel-cussen Imagine the WTO lets Antigua disregard (it's not a violation if it's legal) intellectual property rights. That might be a nail in the coffin for the movie industry.</comment>


How Long Companies Can Survive (spoiler: 27 days) - <AUTHOR> https://www.businessinsider.com/how-long-companies-can-survive-without-bringing-in-money-2020-3 <comment><USER2> 2nd wave of recession incoming?</comment>


Git Cheatsheet - <AUTHOR> http://www.ndpsoftware.com/git-cheatsheet.html <comment><USER2> Is anyone else getting tired of seeing all these "git tips", "cheatsheets", and "helpers" on here? While these all may look cool and be flashy, I've never used a single one that's showed up on the front page. Personally, I find the man pages + Google to be good enough. Then again, maybe I'm a curmudgeon.

<comment><USER3> You're not a curmudgeon, but I'll wager you've been using git for a while now. Here's the problem I have with git -- it has one of the worst CLIs I've ever seen. Many command names are counter-intuitive, i.e. they don't do anything that you would assume from the name alone. To make things worse, most commands can do rather different things depending on the command line switches.

This is all something that people can get used to, but the problem spills over from CLI into GUIs, because GUI authors try to make their programs more newbie-friendly and use more sane command names and lingo. As a result, no two GUIs will use exactly the same names for the same actions.

So imagine a newcomer to git, who starts using a GUI and gets used to its lingo. Unfortunately, that newcomer can't easily communicate with other people who use other GUIs or CLIs. Worse, sooner or later the newcomer will have to resort to using the CLI or a combination of different GUIs, because there's always some useful git feature that you either can't do in the GUI or is an order of magnitude easier to do from the command line.

That, in my not-so-humble opinion, is the _worst_ problem with git. To me, this is sort of tragicomic, because git is absolutely the best VCS I've ever used.

<comment><USER4> As an author of a Git GUI, I've thought about this problem a lot. git-cola is quite user friendly, but its target audience is specifically power users (I wrote it for myself). I don't like dumbing things down for new users.

If you think about it -- targeting new users is not the ideal for a maker- centric tool. A master chef uses the sharpest knife around. The new chef is only new for so long before he graduates up.

<comment><USER5> I found Bzr much easier to learn than Git, and I'm not aware of architectural powers that Git has which bzr doesn't.

</comment></comment></comment></comment><comment><USER6> Wow, this is actually good use of visualization. I clicked through expecting a one pager. Instead, I got an interactive cheatsheet showing how the commands interact across different repos, indices, and workspaces.

<comment><USER7> I'm actually of an opposing viewpoint about the visualization. It gets in the way of the information, why does this even need to be visualized and stylized? I know git is anything but stylish but this feels like visualization for the purpose of visualizing something.

<comment><USER8> I disagree. When I explained git (as best I could) to a friend I drew something similar, though less detailed, on the whiteboard. It helps to see the different spaces an the commands that push files between those spaces. I found the visualisation useful in this case.

</comment></comment></comment><comment><USER9> A plug to my cheatsheet, it is just a repo in github: [https://github.com/trufa/git-cheatsheet](https://github.com/trufa/git- cheatsheet)

I try to link to the relevant StackOverflow explanation-

I'm adding new stuff every now and then. This weekend I'll organize it and add some obvious stuff that is missing and publish it to HN.

I honestly find it more useful that most of the cheat sheets, specially those images with a couple of commands written on it.

Please feel free to collaborate pull requests and or issues are greatly appreciated.

</comment><comment><USER10> I just gave up and use SourceTree. I don't like git's syntax at all, but have to work with it, so a nice GUI works best for me. Maybe I'm getting old, or maybe I just prefer a better designed command line interface (for my personal projects I'm using Fossil and am quite happy with the command line there.)

<comment><USER11> I used to use SourceTree. I moved to using GitX: [http://rowanj.github.io/gitx/](http://rowanj.github.io/gitx/) and seem to prefer it much more. SourceTree feels too cluttered. Gitx has better UX and appeals to me as someone that prefers to view more relevant content on the screen.

<comment><USER12> > Gitx has better UX and appeals to me as someone that prefers to view more > relevant content on the screen.

... and has a Mac, of course, which rules it out for many of us (though I can't speak for the sdfjkl).

</comment></comment></comment><comment><USER13> Please don't break my back button.

<comment><USER14> The site is built using internal links, it no more breaks the back button than wikipedia's contents section does.

<comment><USER15> It's not listening for changes to the URL so going back through the URL does not change the pages state.

This is breaking the point of the back button and URL. If you click through a long Wiki page you'll see presing back does indeed move you back.

Back is broken it just isn't hijacked.

<comment><USER16> Yep, it should redraw the page when you hit the back button. I'll fix it. -- nd

</comment></comment></comment></comment><comment><USER17> My awkward git use case: while working on a branch, I frequently want to merge changes from the (upstream, remote) master into my branch. Is there a faster way to do this than switch to master, pull, switch back, merge master?

<comment><USER18> Strictly speaking, you can pull from any remote branch directly:

        git fetch remotename
        git merge remotename/master

But you usually just want to rebase your changes onto the latest HEAD:

        git fetch remotename
        git rebase remotename/master

Merging will place the remote branch's changes after yours, which will make your history a nightmare, especially if you're going to continue working on your branch. Rebasing will place your local branch changes after the latest changes to the main branch.

<comment><USER19> You can even collapse the first one into a single command: "git pull remotename master"

<comment><USER20> And the second one too: "git pull --rebase remotename master"

</comment></comment></comment></comment><comment><USER21> [https://github.com/ndp/git-cheatsheet](https://github.com/ndp/git-cheatsheet)

Site seems down. Just clone this repo and open git-cheatsheet.html in your browser.

<comment><USER22> <strike>

If the author has not labelled it opensource, should you be cloning it's source code (unless of course, you're the author)?

</strike>

Edit: Sorry, just researched it, you're linking the repo from the author's git account.

</comment></comment><comment><USER23> I once again want to remind people of tig[1]. While there are plugins like gitv that do similar things, i prefer tig.

You can set custom hotkeys in your tigrc (which are context sensitive). For example:

        bind generic F !git fetch
        bind main ! !git revert %(commit)
        bind main c !git checkout %(commit)

[1][http://jonas.nitro.dk/tig/](http://jonas.nitro.dk/tig/)

<comment><USER24> tig is so handy that I'm almost incredulous when people tell me they've never used it or heard of it.

<comment><USER25> I've heard of it! Looks great though I am hooked on sublime-git...

</comment></comment></comment><comment><USER26> I really like this because it shows the different 'places' things happen in Git arranged spatially, and groups commands into those spaces. This really helps with building mental model of how things work.

The visualization is great and a lot of fun but I would also like to have a non-interactive version for quick paper-based reference.

</comment><comment><USER27> Very good work here, it is interesting to think of it in a visual way.

</comment><comment><USER28> Great visualization. It actually shows how messy is git command line interface. Just looking at a cmd syntax it is hard to guess if the cmd refers to workspace, index or local repository.

<comment><USER29> Well that's because the command may refer to any of these

In case you don't know this humorous tale, read and enjoy the part about `git checkout` [http://stevelosh.com/blog/2013/04/git- koans/](http://stevelosh.com/blog/2013/04/git-koans/)

</comment></comment><comment><USER30> I wish I didn't have to click on each topic to see it, but as someone just learning to program this is extremely valuable.

</comment><comment><USER31> This is pretty neat, but I find it pretty annoying that my eyes have to keep shifting up and down to read the explanation for each command. It would be nice if the explanation text popped up closer to where my eyes are already focused.

</comment><comment><USER32> It's missing the staging area, but it looks good and well done.

<comment><USER33> They're using the term "index".

</comment></comment><comment><USER34> Nice visualization idea but the color is burning my eyes... and to be honest the best cheatsheet is a table format. Easier to search and navigate.

</comment><comment><USER35> [http://3d247fe.5minfork.com/git- cheatsheet.html](http://3d247fe.5minfork.com/git-cheatsheet.html)

</comment><comment><USER36> Small fun bug: if you click twice on an item, the description at the bottom shows 'git null' :)

</comment><comment><USER37> Awesome, thanks!</comment>