code-cookbook icon indicating copy to clipboard operation
code-cookbook copied to clipboard

Wanted articles

Open markknol opened this issue 7 years ago • 5 comments

If you are in the mood for writing but don't know what, then you can use this list:

  • [x] Beginner - Lists and Arrays
  • [x] Beginner - Using Regular Expressions
  • [ ] Beginner - Using Math
  • [ ] Beginner - Using abstract
  • [x] Beginner - Using enum / ADT
  • [x] Beginner - Using strings
  • [x] Beginner - Using numbers
  • [ ] Beginner - Type parameters and generics
  • [x] Beginner - Using FileSystem - add section about Path
  • [ ] Using Sys stuff to write command line tools
  • [ ] Using sys.io.Process
  • [x] Pattern Matching examples
  • [x] How to use Array Access
  • [ ] How to type Json using typedefs
  • [ ] Examples of expression reification
  • [ ] Examples of type reification
  • [ ] Examples of class reification
  • [x] Using HXML (https://blog.onthewings.net/2013/03/04/hxml-tricks-every-haxe-user-should-know/) this is in manual now
  • [ ] Mainloop / Timing / Delays / Intervals
  • [ ] Using Haxe to make backend API
  • [ ] Using Haxe to make command line tool
  • [ ] Using Haxe to make static websites (like code.haxe.org 😉)
  • [ ] onAfterGenerate
  • [ ] JavaScript: macro --include to bundle external js files
  • [ ] JavaScript: Use promises
  • [ ] JavaScript: How to use/manipulate DOM
  • [ ] JavaScript: Use canvas
  • [ ] JavaScript: Use webGL
  • [ ] JavaScript: Use camera
  • [ ] JavaScript: Get location
  • [ ] JavaScript: Send notifications
  • [ ] JavaScript: Use virtual dom
  • [ ] JavaScript: Output ES6
  • [ ] JavaScript: Split output https://github.com/elsassph/haxe-modular
  • [ ] JavaScript: Use local storage
  • [ ] JavaScript: Minify / get smallest output / make project production ready https://github.com/back2dos/closure or uglify
  • [ ] Make simple game

Btw, these titles are suggestions. This list will get updated over time.

markknol avatar Aug 12 '16 12:08 markknol

How to type Json using typedefs

This one is quite "funny". We even have such example in the manual, but in fact, it's not really safe when it comes to arrays on static targets, e.g.:

var a:Array<Int> = haxe.Json.parse("[1,2,3]")

This compiles (because of Dynamic) but might either fail at runtime or introduce hidden copy-casting, because haxe.Json.parse parses arrays to Array<Dynamic> which isn't really the same as Array<Int> on targets like C# and C++ which try to implement arrays in an efficient way for basic types.

So nowadays I'm doubting that this is something we should promote. At least we should note that particular issue so people are aware of it.

I think @hughsando dealt with this somehow for the newer hxcpp, but this is still an issue in C# (without -D erase-generics).

nadako avatar Aug 12 '16 13:08 nadako

Alright, seems doable.

But I'm still waiting on someone to approve or review the Stack Overflow documentation changes I proposed! ;)

dstrekelj avatar Aug 12 '16 14:08 dstrekelj

A couple more things (that I think are highly needed):

  • handling of utf8/unicode strings
  • advanced regexes (and how they differ from other languages)

azrafe7 avatar Apr 04 '17 22:04 azrafe7

I have another request: more macro-related stuff. :+1:

As of writing I'm in the process of trying to learn them, and have found myself with tens of tabs open from various sources (manual (new and old)/blog posts/articles/libs). All of them helpful! But infos are scattered around, and I find myself jumping back and forth trying to collect the missing pieces.

The code cookbook has been particularly helpful so far, I just really wish it had more examples. Please! :stuck_out_tongue:

So... here's a little list of some of the difficulties/confusing-moments I've faced so far (hoping it can serve as hint for more enlightening snippets):

  • in many examples (around the web) variables are not type-hinted, and that makes hard to grasp what the inferred type is
  • related to the previous point: using the various macro.*Tools without mentioning them in comments makes it harder to understand the code
  • Type vs ComplexType
  • confusion about TAnonymous (same name, but present in different modules)
  • macro keyword vs macro define (what's the relation, when it's NEEDED to use the keyword, etc.?) (I currently use a trial&error approach: run the compiler until it works, and then analyse the output)

As I said, I've just recently started to make sense of the powerful macro system, and I think that learning from useful examples is the best way.

PS: Someone may object that my points are material for StackOverflow or the MailingList. I agree, but having them explained clearly in the official cookbook is a plus (SO and ML could still link to them).

azrafe7 avatar Jun 17 '17 22:06 azrafe7

Those are helpful ideas, thanks! If you want to contribute to one of those topics,feel free to add it.

markknol avatar Jun 18 '17 10:06 markknol