charlzz
One of the earliest programming languages I’ve used was C. In C, you could simply compile two programs (say, foo.c and bar.c) and use header files, so that one file (foo.c, say) could access functions in another file. So I’m used to coding in this manner without resorting to some kind of build tool (mix for Elixir or lein for Clojure).
I’ve been able to run code using a single Elixir file. I typically type “elixir foo.ex” to run the code, and I like the simplicity of that.
I know mix is probably the way to go, but is there something like being able to use foo.ex and bar.ex without using mix to set it up which would allow me, say, to run the code in foo.ex, but refer to code in bar.ex. Or is that so non-standard, that I should be using mix?
And if so, any recommendations on which mix tutorial to look at?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #performance










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
However, in C you still had to be sure to compile things in the right order and link them in the right order, that is the purpose of a build system, like CMake in the C/C++ world.
Really meant for
exsinstead ofexfiles.exsstates it is a ‘script’ (with top level code and all) andexdesignates it is a module(s). Although the extension is mostly documentative when passed directly in though. ^.^;elixircis what actually compiles theextobeamfiles, so you can do that to link files in, then specify the path to them (defaults to the current directory), here is an example shell session without mix:But really, handling the compiling in the right order and all that mess is painful, just use mix. ^.^
The standard elixir tutorials on mix is fine, but really just start by running
mix newand reading when it tells you. Then put source code in thelibdirectory in your new projects directory.mix helpfor lots of help too, can runmix help <cmd>for any specific mix command too.charlzz
That was quick! So, basically, use mix if you want to do more than one file (and probably one file) and put the files in the lib folder. Gotcha. Guess I need to dive into mix at some point, and now is pretty good.
OvermindDL1
Mix is dead-simple, one of the easiest build systems out (certainly easier than anything in the C world for sure). ^.^
But yep yep.
hassan
“mix new” also automatically sets up a test harness for you, ready
to run out of the box.
I love writing tests.
charlzz
How do you decide what tests to write?
OvermindDL1
Same as in any other language. It’s good to write tests to test every callpath through your public functions.
hassan
Write the tests that describe the feature/functions that you want and
are about to write
IMO writing a test and making it pass in an idiomatic way is a great
learning mechanism, aside from the benefits of having well-tested
production code.