Skip to content

Instantly share code, notes, and snippets.

View munificent's full-sized avatar

Bob Nystrom munificent

View GitHub Profile
@munificent
munificent / gist:9749671
Last active June 23, 2022 04:04
You appear to be creating a new IDE...
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs:
someAsyncThing.then((_) => itWorked())
..catchError((error) {
handleError();
});
@munificent
munificent / gist:6d65cc423fc7c5cae324
Created August 14, 2014 22:19
Pub interop with other package managers

I'm starting to think through how pub can interop with bower and other package managers. I'm calling these "foreign" packages. I have a strawman here I want to get feedback on. It's based heavily on earlier work from John Messerly and Justin Fagnani.

High level goals

  • Your application can depend on stuff from other package managers. I'm initially targeting bower, but I want this to be open-ended.

  • Your application can depend on pub packages which in turn depend on stuff from other package managers.

  • You can depend on foreign packages which in turn have their own (foreign) dependencies.

@munificent
munificent / gist:a56a70c7d5387f65cb8f
Last active August 29, 2015 14:05
How to bump the async_await compiler in the Dart repo

Scenario: Kevin and Erik or some other fine contributor to the async_await package on GitHub has committed some changes and you want to use those within the main Dart repo.

About you:

  • You already have the repo downloaded locally on your machine.
  • You are using Git, not svn. You also probably ride a horseless carriage and no longer use leeches and bloodletting to cure your ailments.

Note that you do not need a separate svn checkout. You already have one, you just don't know it.

Given that, here's the process. This likely alsos work for other third party packages that live on GitHub that we want to use in the Dart repo, but I make no promises there:

library logger;
import 'verbose.dart';
import 'plain.dart';
log(message) {
print(const String.fromEnvironment("logger.level"));
if (const String.fromEnvironment("logger.level") == "verbose") {
logVerbose(message);
} else {
@munificent
munificent / gist:b8f2785c7d1744bdd22f
Created October 29, 2014 18:03
Getters versus fields
// On my laptop, I get:
// getter run 1: 73ms
// getter run 3: 64ms
// getter run 11: 63ms
// getter run 12: 14ms
// getter run 30: 13ms
// field run 1: 68ms
// field run 7: 64ms
// field run 9: 63ms
@munificent
munificent / lexer.wren
Created January 9, 2015 15:13
Start of lexer for Wren in Wren
class Token {
new(type, text) {
_type = type
_text = text
}
type { _type }
text { _text }
toString { _text + " " + _type }
@munificent
munificent / dart2js.diff
Created June 9, 2015 22:50
This is a diff of the changes between formatting dart2js (151303 lines) using the current 0.1.8 version of the formatter and the new rules version.
diff --git a/pkg/compiler/lib/compiler.dart b/pkg/compiler/lib/compiler.dart
index cf68043..80a6c9c 100644
--- a/pkg/compiler/lib/compiler.dart
+++ b/pkg/compiler/lib/compiler.dart
@@ -96,7 +96,8 @@ class CompilationResult {
*/
Future<CompilationResult> compile(Uri script, Uri libraryRoot, Uri packageRoot,
CompilerInputProvider inputProvider, DiagnosticHandler handler,
- [List<String> options = const [], CompilerOutputProvider outputProvider,
+ [List<String> options = const [],
@munificent
munificent / dev_compiler_output.js
Created August 5, 2015 16:33
Dart->JS output on a simple program
dart_library.library('simple', null, /* Imports */[
"dart_runtime/dart",
'dart/core'
], /* Lazy imports */[
], function(exports, dart, core) {
'use strict';
let dartx = dart.dartx;
class Simple extends core.Object {
Simple(name) {
this.name = name;
@munificent
munificent / gist:12336bc4d9d1abee5bde
Created September 3, 2015 20:28
Pub test errors
~/dev/dart/sdk/third_party/pkg/pub ((1c08b84...)) → ../../../xcodebuild/ReleaseIA32/dart-sdk/bin/dart --package-root=../../../xcodebuild/ReleaseIA32/packages/ ../test/bin/test.dart --package-root=../../../xcodebuild/ReleaseIA32/packages/
00:22 +39 -1: test/build/copies_browser_js_next_to_entrypoints_test.dart: compiles dart.js and interop.js next to entrypoints
The schedule had 2 errors:
ScheduleError:
| Expected: match 'Got dependencies!|Changed \d+ dependenc(y|ies)!'
| Actual: 'Resolving dependencies...'
Stack chain:
| package:test/src/frontend/expect.dart 63:30 fail
| package:test/src/frontend/expect.dart 58:3 expect